Index: j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java,v retrieving revision 1.40.2.4 retrieving revision 1.40.2.4.4.4 diff -c -r1.40.2.4 -r1.40.2.4.4.4 *** j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java 18 Jan 2006 19:32:46 -0000 1.40.2.4 --- j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java 19 Feb 2006 16:57:52 -0000 1.40.2.4.4.4 *************** *** 23,28 **** --- 23,30 ---- import java.util.HashMap; import java.util.Iterator; import java.util.Map; + import java.util.Set; + import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException; import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; import org.netbeans.modules.j2ee.deployment.impl.Server; *************** *** 291,296 **** --- 293,344 ---- ConfigurationSupport serverConfig = server.getConfigurationSupport(); serverConfig.ensureResourceDefined(config, ejbBean); } + + public Set getDatasources() { + + Set projectDS = null; + + if (server != null) { + ConfigurationSupport configSupport = server.getConfigurationSupport(); + if (configSupport != null) { + DeploymentConfiguration config = getDeploymentConfiguration(); + if (config != null) { + projectDS = configSupport.getDatasources(config); + } + } + } + + return projectDS; + } + + public boolean isDatasourceCreationSupported() { + ConfigurationSupport configSupport = server.getConfigurationSupport(); + + if (configSupport == null) + return false; + + return configSupport.isDatasourceCreationSupported(); + } + + public void createDatasource(String jndiName, String url, String username, String password, String driver) + throws OperationUnsupportedException + { + + if (server != null) { + ConfigurationSupport configSupport = server.getConfigurationSupport(); + if (configSupport != null) { + DeploymentConfiguration config = getDeploymentConfiguration(); + if (config != null) { + try { + configSupport.createDatasource(config, jndiName, url, username, password, driver); + } catch (ConfigurationException ce) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ce); + } + } + } + } + + } // DeploymentConfigurationProvider implementation ------------------------- Index: j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java,v retrieving revision 1.47.30.3 retrieving revision 1.47.30.3.4.4 diff -c -r1.47.30.3 -r1.47.30.3.4.4 *** j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java 2 Nov 2005 03:09:08 -0000 1.47.30.3 --- j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java 19 Feb 2006 16:57:53 -0000 1.47.30.3.4.4 *************** *** 15,22 **** --- 15,28 ---- import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; + import java.io.IOException; import java.io.OutputStream; + import java.util.Iterator; + import java.util.Map; + import java.util.Set; import javax.enterprise.deploy.spi.Target; + import javax.enterprise.deploy.spi.exceptions.ConfigurationException; + import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException; import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping; import org.netbeans.modules.j2ee.deployment.common.api.ValidationException; import org.netbeans.modules.j2ee.deployment.config.*; *************** *** 27,38 **** --- 33,47 ---- import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; import org.netbeans.modules.j2ee.deployment.impl.ServerString; import org.netbeans.modules.j2ee.deployment.impl.ServerTarget; + import org.netbeans.modules.j2ee.deployment.plugins.api.Datasource; import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo; import org.netbeans.modules.j2ee.deployment.common.api.SourceFileMap; import org.netbeans.modules.j2ee.deployment.plugins.api.StartServer; import org.netbeans.modules.j2ee.deployment.plugins.api.VerifierSupport; + import org.openide.ErrorManager; import org.openide.filesystems.FileObject; + import org.openide.filesystems.FileUtil; import org.openide.util.WeakListeners; import java.io.File; import java.util.ArrayList; *************** *** 116,121 **** --- 125,166 ---- return null; } + + public Set getServerDatasources() { + ServerInstance si = ServerRegistry.getInstance ().getServerInstance (getServerInstanceID ()); + Set deployedDS = si.getDatasources(); + return deployedDS; + } + + public Set getModuleDatasources() { + Set projectDS = getConfigSupport().getDatasources(); + return projectDS; + } + + public boolean isDatasourceCreationSupported() { + return getConfigSupport().isDatasourceCreationSupported(); + } + + public final void createDatasource(String jndiName, String url, String username, String password, String driver) { + + //check whether the ds is not already on the server + Set deployedDS = getServerDatasources(); + if (deployedDS != null) { + for (Iterator it = deployedDS.iterator(); it.hasNext();) { + Datasource ds = (Datasource) it.next(); + if (jndiName.equals(ds.getJndiName())) + return; // ds with the same JNDI name already exists on the server, do not create new one + } + } + + try { + //btw, ds existence in a project is verified directly in the deployment configuration + getConfigSupport().createDatasource(jndiName, url, username, password, driver); + } catch (OperationUnsupportedException oue) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, oue); + } + } + /** * Register a listener which will be notified when some of the properties * change. *************** *** 206,211 **** --- 251,263 ---- * @param ejbtype dtd name for type of ejb: 'message-drive', 'entity', 'session'. */ public void ensureResourceDefinedForEjb(String ejbname, String ejbtype); + + public boolean isDatasourceCreationSupported(); + + public Set getDatasources(); + + public void createDatasource(String jndiName, String url, String username, String password, String driver) + throws OperationUnsupportedException; } /** Index: j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java,v retrieving revision 1.61.2.4 retrieving revision 1.61.2.4.4.3 diff -c -r1.61.2.4 -r1.61.2.4.4.3 *** j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java 18 Jan 2006 19:32:46 -0000 1.61.2.4 --- j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java 19 Feb 2006 16:57:49 -0000 1.61.2.4.4.3 *************** *** 21,33 **** import javax.enterprise.deploy.spi.status.*; import javax.swing.JButton; import javax.swing.SwingUtilities; - import org.netbeans.api.debugger.Breakpoint; - import org.netbeans.api.debugger.DebuggerEngine; import org.netbeans.api.debugger.DebuggerManager; import org.netbeans.api.debugger.DebuggerManagerAdapter; - import org.netbeans.api.debugger.DebuggerManagerListener; import org.netbeans.api.debugger.Session; - import org.netbeans.api.debugger.Watch; import org.netbeans.api.debugger.jpda.AttachingDICookie; import org.netbeans.api.debugger.jpda.JPDADebugger; import org.netbeans.modules.j2ee.deployment.plugins.api.*; --- 21,29 ---- *************** *** 86,91 **** --- 82,88 ---- private J2eePlatformImpl j2eePlatformImpl; private StartServer startServer; private FindJSPServlet findJSPServlet; + private DatasourceManager dsMgr; private final Set targetsStartedByIde = new HashSet(); // valued by target name private Map targets; // keyed by target name, valued by ServerTarget private boolean managerStartedByIde = false; *************** *** 417,422 **** --- 414,433 ---- } } return findJSPServlet; + } + + public Set getDatasources() { + + if (dsMgr == null) { + DeploymentManager dm = getDeploymentManager(); + dsMgr = server.getOptionalFactory().getDatasourceManager(dm); + } + + Set deployedDS = null; + if (dsMgr != null) + deployedDS = dsMgr.getDatasources(); + + return deployedDS; } //---------- State API's: running, debuggable, startedByIDE ----------- Index: j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ConfigurationSupport.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ConfigurationSupport.java,v retrieving revision 1.2.42.2 retrieving revision 1.2.42.2.4.4 diff -c -r1.2.42.2 -r1.2.42.2.4.4 *** j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ConfigurationSupport.java 2 Nov 2005 03:09:10 -0000 1.2.42.2 --- j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ConfigurationSupport.java 19 Feb 2006 16:57:46 -0000 1.2.42.2.4.4 *************** *** 14,23 **** --- 14,25 ---- package org.netbeans.modules.j2ee.deployment.plugins.api; import java.io.File; + import java.util.Set; import javax.enterprise.deploy.model.DDBean; import javax.enterprise.deploy.model.DeployableObject; import javax.enterprise.deploy.spi.DeploymentConfiguration; import javax.enterprise.deploy.spi.exceptions.ConfigurationException; + import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping; *************** *** 236,239 **** --- 238,255 ---- * @since 1.12 */ public abstract void updateResourceDir(DeploymentConfiguration config, File resourceDir); + + public Set getDatasources(DeploymentConfiguration config) { + return null; + } + + public boolean isDatasourceCreationSupported() { + return false; + } + + public void createDatasource(DeploymentConfiguration config, String jndiName, String url, String username, String password, String driver) + throws OperationUnsupportedException, ConfigurationException + { + throw new OperationUnsupportedException(""); + } } Index: j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/OptionalDeploymentManagerFactory.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/OptionalDeploymentManagerFactory.java,v retrieving revision 1.4 retrieving revision 1.4.36.1 diff -c -r1.4 -r1.4.36.1 *** j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/OptionalDeploymentManagerFactory.java 30 May 2005 09:16:01 -0000 1.4 --- j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/OptionalDeploymentManagerFactory.java 9 Feb 2006 16:31:54 -0000 1.4.36.1 *************** *** 58,61 **** --- 58,66 ---- public WizardDescriptor.InstantiatingIterator getAddInstanceIterator() { return null; } + + public DatasourceManager getDatasourceManager(DeploymentManager dm) { + return null; + } + }