Index: src/org/netbeans/modules/j2ee/deployment/common/api/MessageDestination.java =================================================================== RCS file: src/org/netbeans/modules/j2ee/deployment/common/api/MessageDestination.java diff -N src/org/netbeans/modules/j2ee/deployment/common/api/MessageDestination.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/netbeans/modules/j2ee/deployment/common/api/MessageDestination.java 26 Mar 2007 09:51:49 -0000 1.1.2.1 @@ -0,0 +1,59 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.modules.j2ee.deployment.common.api; + +/** + * Represents a message destination + * + * @author Libor Kotouc + * + * @since 1.25 + */ +public interface MessageDestination { + + /** + * Message destination type + */ + public enum Type { + /** + * Queue + */ + QUEUE, + + /** + * Topic + */ + TOPIC + }; + + /** + * Returns the JNDI name + * + * @return the JNDI name + */ + public String getJndiName(); + + /** + * Returns the type + * + * @return the type + */ + public Type getType(); +} Index: 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.47.6.3 retrieving revision 1.47.6.3.2.1 diff -u -r1.47.6.3 -r1.47.6.3.2.1 --- src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java 23 Mar 2007 20:29:51 -0000 1.47.6.3 +++ src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java 26 Mar 2007 09:32:39 -0000 1.47.6.3.2.1 @@ -13,14 +13,12 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.j2ee.deployment.config; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -31,13 +29,10 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; -import javax.enterprise.deploy.model.DDBean; -import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException; import org.netbeans.modules.j2ee.dd.api.common.ComponentInterface; import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping; import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeApplication; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; -import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider; import org.netbeans.modules.j2ee.deployment.impl.Server; import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException; import javax.enterprise.deploy.shared.ModuleType; @@ -60,7 +55,10 @@ import org.openide.util.NbBundle; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; +import org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans; +import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination; import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider; +import org.netbeans.modules.j2ee.deployment.plugins.spi.config.MessageDestinationConfiguration; /** * Each J2eeModuleProvider hold a reference to an instance of this config support. @@ -376,7 +374,7 @@ } public Datasource createDatasource(String jndiName, String url, String username, String password, String driver) - throws OperationUnsupportedException, DatasourceAlreadyExistsException { + throws UnsupportedOperationException, DatasourceAlreadyExistsException { Datasource ds = null; if (server != null) { ModuleConfiguration config = getModuleConfiguration(); @@ -393,6 +391,172 @@ } return ds; } + + public void bindDatasourceReference(String dsReferenceName, String dsJNDIName) throws ConfigurationException { + if (server != null) { + ModuleConfiguration config = getModuleConfiguration(); + if (config != null) { + DatasourceConfiguration datasourceConfiguration = config.getLookup().lookup(DatasourceConfiguration.class); + if (datasourceConfiguration != null) { + datasourceConfiguration.bindDatasourceReference(dsReferenceName, dsJNDIName); + } + } + } + } + + public void bindDatasourceReferenceEjb(String dsReferenceName, String dsJNDIName, + String ejbName, String ejbType) throws ConfigurationException { + if (!EnterpriseBeans.SESSION.equals(ejbType) && + !EnterpriseBeans.ENTITY.equals(ejbType) && + !EnterpriseBeans.MESSAGE_DRIVEN.equals(ejbType)) { + throw new IllegalArgumentException("ejbType parameter doesn't have an allowed value."); + } + + if (server != null) { + ModuleConfiguration config = getModuleConfiguration(); + if (config != null) { + DatasourceConfiguration datasourceConfiguration = config.getLookup().lookup(DatasourceConfiguration.class); + if (datasourceConfiguration != null) { + datasourceConfiguration.bindDatasourceReferenceEjb(dsReferenceName, dsJNDIName, ejbName, ejbType); + } + } + } + } + + public Datasource findDatasourceForReference(String referenceName) throws ConfigurationException { + String jndiName = findDatasourceBinding(referenceName); + if (jndiName == null) { + return null; + } + Set datasources = getDatasources(); + for (Datasource ds : datasources) { + if (jndiName.equals(ds.getJndiName())) { + return ds; + } + } + datasources = provider.getServerDatasources(); + for (Datasource ds : datasources) { + if (jndiName.equals(ds.getJndiName())) { + return ds; + } + } + + return null; + } + + private String findDatasourceBinding(String dsReferenceName) throws ConfigurationException { + String jndiName = null; + if (server != null) { + ModuleConfiguration config = getModuleConfiguration(); + if (config != null) { + DatasourceConfiguration datasourceConfiguration = config.getLookup().lookup(DatasourceConfiguration.class); + if (datasourceConfiguration != null) { + jndiName = datasourceConfiguration.findDatasourceBinding(dsReferenceName); + } + } + } + + return jndiName; + } + + public Datasource findDatasourceForReferenceEjb(String referenceName, String ejbName) throws ConfigurationException { + String jndiName = findDatasourceBindingEjb(referenceName, ejbName); + if (jndiName == null) { + return null; + } + Set datasources = getDatasources(); + for (Datasource ds : datasources) { + if (jndiName.equals(ds.getJndiName())) { + return ds; + } + } + datasources = provider.getServerDatasources(); + for (Datasource ds : datasources) { + if (jndiName.equals(ds.getJndiName())) { + return ds; + } + } + + return null; + } + + private String findDatasourceBindingEjb(String dsReferenceName, String ejbName) throws ConfigurationException { + String jndiName = null; + if (server != null) { + ModuleConfiguration config = getModuleConfiguration(); + if (config != null) { + DatasourceConfiguration datasourceConfiguration = config.getLookup().lookup(DatasourceConfiguration.class); + if (datasourceConfiguration != null) { + jndiName = datasourceConfiguration.findDatasourceBindingEjb(dsReferenceName, ejbName); + } + } + } + + return jndiName; + } + + public Set getMessageDestinations() throws ConfigurationException { + + Set destinations = Collections.emptySet(); + + if (server != null) { + ModuleConfiguration config = getModuleConfiguration(); + if (config != null) { + MessageDestinationConfiguration msgConfig = config.getLookup().lookup(MessageDestinationConfiguration.class); + if (msgConfig != null) { + destinations = msgConfig.getMessageDestinations(); + } + } + } + + return destinations; + } + + public Set getServerMessageDestinations() throws ConfigurationException { + ServerInstance si = ServerRegistry.getInstance().getServerInstance(provider.getServerInstanceID()); + if (si == null) { + ErrorManager.getDefault().log(ErrorManager.WARNING, + "The server data sources cannot be retrieved because the server instance cannot be found."); + return Collections.emptySet(); + } + + return si.getMessageDestinations(); + } + + public boolean supportsCreateMessageDestination() { + if (server == null) { + // the module has no target server + return false; + } + ModuleConfiguration config = getModuleConfiguration(); + if (config != null) { + MessageDestinationConfiguration msgConfig = config.getLookup().lookup(MessageDestinationConfiguration.class); + if (msgConfig != null) { + return msgConfig.supportsCreateMessageDestination(); + } + } + return false; + } + + public MessageDestination createMessageDestination(String jndiName, MessageDestination.Type type) + throws UnsupportedOperationException, ConfigurationException { + + if (server == null) { + return null; + } + + ModuleConfiguration config = getModuleConfiguration(); + if (config == null) { + return null; + } + + MessageDestinationConfiguration msgConfig = config.getLookup().lookup(MessageDestinationConfiguration.class); + if (msgConfig != null) { + return msgConfig.createMessageDestination(jndiName, type); + } + + return null; + } // DeploymentConfigurationProvider implementation ------------------------- Index: src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java,v retrieving revision 1.24.6.4 retrieving revision 1.24.6.4.2.1 diff -u -r1.24.6.4 -r1.24.6.4.2.1 --- src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java 23 Mar 2007 20:29:52 -0000 1.24.6.4 +++ src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java 26 Mar 2007 09:32:40 -0000 1.24.6.4.2.1 @@ -13,21 +13,18 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.j2ee.deployment.devmodules.api; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.WeakHashMap; +import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException; import org.netbeans.modules.j2ee.deployment.devmodules.spi.InstanceListener; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; import org.netbeans.modules.j2ee.deployment.impl.*; @@ -106,6 +103,10 @@ } jmp.deployDatasources(); + +if (System.getProperties().getProperty("resource-api-redesign") != null) { + deployMessageDestinations(jmp); +} modules = targetserver.deploy(progress, forceRedeploy); // inform the plugin about the deploy action, even if there was @@ -127,6 +128,17 @@ if (progress != null) { progress.finish(); } + } + } + + public void deployMessageDestinations(J2eeModuleProvider jmp) throws ConfigurationException { + ServerInstance si = ServerRegistry.getInstance ().getServerInstance (jmp.getServerInstanceID ()); + if (si != null) { + si.deployMessageDestinations(jmp.getConfigSupport().getMessageDestinations()); + } + else { + ErrorManager.getDefault().log(ErrorManager.WARNING, + "The message destinations cannot be deployed because the server instance cannot be found."); } } Index: 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.54.6.4 retrieving revision 1.54.6.4.2.1 diff -u -r1.54.6.4 -r1.54.6.4.2.1 --- src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java 23 Mar 2007 20:29:55 -0000 1.54.6.4 +++ src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java 26 Mar 2007 09:32:40 -0000 1.54.6.4.2.1 @@ -13,23 +13,18 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.j2ee.deployment.devmodules.spi; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.IOException; import java.io.OutputStream; import java.util.Collections; import java.util.Iterator; -import java.util.Map; import java.util.Set; import javax.enterprise.deploy.spi.Target; import org.netbeans.modules.j2ee.deployment.common.api.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.*; @@ -38,7 +33,6 @@ import org.netbeans.modules.j2ee.deployment.impl.Server; import org.netbeans.modules.j2ee.deployment.impl.ServerInstance; 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.common.api.Datasource; import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException; @@ -49,11 +43,9 @@ import org.netbeans.modules.j2ee.deployment.plugins.spi.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; import java.util.List; +import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination; /** This object must be implemented by J2EE module support and an instance * added into project lookup. @@ -207,7 +199,7 @@ try { //btw, ds existence in a project is verified directly in the deployment configuration ds = getConfigSupport().createDatasource(jndiName, url, username, password, driver); - } catch (OperationUnsupportedException oue) { + } catch (UnsupportedOperationException oue) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, oue); } @@ -325,13 +317,118 @@ * @param password user's password * @param driver fully qualified name of database driver class * @return created data source - * @exception OperationUnsupportedException if operation is not supported + * @exception UnsupportedOperationException if operation is not supported * @exception DatasourceAlreadyExistsException if conflicting data source is found * * @since 1.15 */ public Datasource createDatasource(String jndiName, String url, String username, String password, String driver) - throws OperationUnsupportedException, DatasourceAlreadyExistsException, ConfigurationException; + throws UnsupportedOperationException, DatasourceAlreadyExistsException, ConfigurationException; + + /** + * Binds the data source name used in the sources with the corresponding data source which is + * identified the given JNDI name. + * + * @param referenceName name used to identify the data source + * @param jndiName JNDI name of the data source + * @throws ConfigurationException if there is some problem with data source configuration + * + * @since 1.25 + */ + public void bindDatasourceReference(String dsReferenceName, String dsJNDIName) throws ConfigurationException; + + /** + * Binds the data source name used in the sources with the corresponding data source which is + * identified the given JNDI name. The reference is used within the scope of the EJB. + * + * @param referenceName name used to identify the data source + * @param jndiName JNDI name of the data source + * @param ejbName EJB name + * @param ejbType EJB type - the possible values are + * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.SESSION, + * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.ENTITY and + * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.MESSAGE_DRIVEN + + * @throws ConfigurationException if there is some problem with data source configuration + * @throws IllegalArgumentException if ejbType doesn't have one of allowed values + * + * @since 1.25 + */ + public void bindDatasourceReferenceEjb(String dsReferenceName, String dsJNDIName, + String ejbName, String ejbType) throws ConfigurationException; + + /** + * Finds data source which is mapped to the given reference name. + * + * @referenceName reference name + * @return data source if it exists, null otherwise + * + * @throws ConfigurationException if there is some problem with data source configuration + * + * @since 1.25 + */ + public Datasource findDatasourceForReference(String referenceName) throws ConfigurationException; + + /** + * Finds data source which is mapped to the given reference name in the scope the EJB. + * + * @param referenceName reference name + * @param ejbName EJB name + * @return data source if it exists, null otherwise + * + * @throws ConfigurationException if there is some problem with data source configuration + * + * @since 1.25 + */ + public Datasource findDatasourceForReferenceEjb(String referenceName, String ejbName) throws ConfigurationException; + + /** + * Retrieves message destinations stored in the module. + * + * @return set of message destinations + * + * @throws ConfigurationException if there is some problem with message destination configuration + * + * @since 1.25 + */ + public Set getMessageDestinations() throws ConfigurationException; + + /** + * Retrieves message destinations configured on the target server instance. + * + * @return set of message destinations + * + * @throws ConfigurationException if there is some problem with message destination configuration + * + * @since 1.25 + */ + public Set getServerMessageDestinations() throws ConfigurationException; + + /** + * Tests whether a message destination creation is supported. + * + * @return true if message destination creation is supported, false otherwise. + * + * @since 1.25 + */ + public boolean supportsCreateMessageDestination(); + + /** + * Creates and saves a message destination in the module if it does not exist in the module yet. + * Message destinations are considered to be equal if their JNDI names are equal. + * + * @param jndiName JNDI name of the message destination + * @param type message destination type; the value is of + * org.netbeans.modules.j2ee.deployment.common.api.MessageDestination.Type type + * @return created message destination + * + * @throws UnsupportedOperationException if this opearation is not supported + * @throws ConfigurationException if there is some problem with message destination configuration + * + * @since 1.25 + */ + public MessageDestination createMessageDestination(String jndiName, MessageDestination.Type type) + throws UnsupportedOperationException, ConfigurationException; } /** Index: 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.75.6.4 retrieving revision 1.75.6.4.2.1 diff -u -r1.75.6.4 -r1.75.6.4.2.1 --- src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java 21 Mar 2007 23:38:17 -0000 1.75.6.4 +++ src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java 26 Mar 2007 09:32:40 -0000 1.75.6.4.2.1 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -38,6 +38,7 @@ import org.openide.filesystems.*; import java.util.*; import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException; +import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination; import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI; @@ -52,6 +53,7 @@ import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet; import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment; import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory; +import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment; import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings; import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport; import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler; @@ -103,6 +105,8 @@ private FindJSPServlet findJSPServlet; private DatasourceManager dsMgr; private DatasourceManager ddsMgr; + private MessageDestinationDeployment msgDestDeploymentConnected; + private MessageDestinationDeployment msgDestDeploymentDisconnected; private final Set targetsStartedByIde = new HashSet(); // valued by target name private Map targets; // keyed by target name, valued by ServerTarget private boolean managerStartedByIde = false; @@ -555,6 +559,62 @@ if (dsMgr != null) dsMgr.deployDatasources(datasources); + } + + private synchronized MessageDestinationDeployment getMessageDestinationDeploymentConnected() { + if (msgDestDeploymentConnected == null) { + msgDestDeploymentConnected = server.getOptionalFactory(). + getMessageDestinationDeployment(getDeploymentManager()); + } + + return msgDestDeploymentConnected; + } + + private MessageDestinationDeployment getMessageDestinationDeploymentDisconnected() { + DeploymentManager dm = null; + try { + dm = getDisconnectedDeploymentManager(); + } catch (DeploymentManagerCreationException dmce) { + throw new RuntimeException(dmce); + } + synchronized (this) { + if (msgDestDeploymentDisconnected == null) { + msgDestDeploymentDisconnected = server.getOptionalFactory().getMessageDestinationDeployment(dm); + } + return msgDestDeploymentDisconnected; + } + } + + /** + * Retrieves message destinations configured on the target server instance. + * + * @return set of message destinations + * + * @throws ConfigurationException if there is some problem with message destination configuration + */ + public Set getMessageDestinations() throws ConfigurationException { + + MessageDestinationDeployment destDepl = getMessageDestinationDeploymentDisconnected(); + if (destDepl != null) { + return destDepl.getMessageDestinations(); + } + + return Collections.emptySet(); + } + + /** + * Deploys message destinations saved in the module. + * + * @param destinations set of message destinations + * + * @throws ConfigurationException if there is some problem with message destination configuration + */ + public void deployMessageDestinations(Set destinations) throws ConfigurationException { + + MessageDestinationDeployment destDepl = getMessageDestinationDeploymentConnected(); + if (destDepl != null) { + destDepl.deployMessageDestinations(destinations); + } } //---------- State API's: running, debuggable, startedByIDE ----------- Index: src/org/netbeans/modules/j2ee/deployment/plugins/spi/MessageDestinationDeployment.java =================================================================== RCS file: src/org/netbeans/modules/j2ee/deployment/plugins/spi/MessageDestinationDeployment.java diff -N src/org/netbeans/modules/j2ee/deployment/plugins/spi/MessageDestinationDeployment.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/netbeans/modules/j2ee/deployment/plugins/spi/MessageDestinationDeployment.java 26 Mar 2007 09:51:49 -0000 1.1.2.1 @@ -0,0 +1,53 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi; + +import java.util.Set; +import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException; +import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination; + +/** + * MessageDestinationDeployment is responsible for retrieving message destinations + * configured on the server and for message destination deployment. + * + * @author Libor Kotouc + * + * @since 1.25 + */ +public interface MessageDestinationDeployment { + + /** + * Retrieves message destinations configured on the target server instance. + * + * @return set of message destinations + * + * @throws ConfigurationException if there is some problem with message destination configuration + */ + Set getMessageDestinations() throws ConfigurationException; + + /** + * Deploys message destinations saved in the module. + * + * @param destinations set of message destinations + * + * @exception ConfigurationException if there is some problem with message destination configuration + */ + void deployMessageDestinations(Set destinations) throws ConfigurationException; +} Index: src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/Attic/OptionalDeploymentManagerFactory.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.3.2.1 diff -u -r1.1.2.3 -r1.1.2.3.2.1 --- src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java 21 Mar 2007 23:38:17 -0000 1.1.2.3 +++ src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java 26 Mar 2007 09:32:41 -0000 1.1.2.3.2.1 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -21,8 +21,6 @@ package org.netbeans.modules.j2ee.deployment.plugins.spi; import javax.enterprise.deploy.spi.DeploymentManager; -import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer; -import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver; import org.openide.WizardDescriptor; /** @@ -93,4 +91,20 @@ public DatasourceManager getDatasourceManager(DeploymentManager dm) { return null; } + + /** + * Creates a MessageDestinationDeployment for the given deployment manager + * or null if message destination deployment is not supported + * + * @param dm the deployment manager + * + * @return a message destination deployment or null + * if message destination deployment is not supported + * + * @since 1.25 + */ + public MessageDestinationDeployment getMessageDestinationDeployment(DeploymentManager dm) { + return null; + } + } Index: src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/DatasourceConfiguration.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/Attic/DatasourceConfiguration.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.1.2.1 diff -u -r1.1.2.1 -r1.1.2.1.2.1 --- src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/DatasourceConfiguration.java 23 Mar 2007 20:29:56 -0000 1.1.2.1 +++ src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/DatasourceConfiguration.java 26 Mar 2007 09:32:41 -0000 1.1.2.1.2.1 @@ -71,4 +71,60 @@ */ Datasource createDatasource(String jndiName, String url, String username, String password, String driver) throws UnsupportedOperationException, ConfigurationException, DatasourceAlreadyExistsException; + + /** + * Binds the data source name used in the sources with the corresponding data source which is + * identified the given JNDI name. + * + * @param referenceName name used to identify the data source + * @param jndiName JNDI name of the data source + * @throws ConfigurationException if there is some problem with data source configuration + * + * @since 1.25 + */ + public void bindDatasourceReference(String dsReferenceName, String dsJNDIName) throws ConfigurationException; + + /** + * Binds the data source name used in the sources with the corresponding data source which is + * identified the given JNDI name. The reference is used within the scope of the EJB. + * + * @param referenceName name used to identify the data source + * @param jndiName JNDI name of the data source + * @param ejbName EJB name + * @param ejbType EJB type - the possible values are + * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.SESSION, + * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.ENTITY and + * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.MESSAGE_DRIVEN + + * @throws ConfigurationException if there is some problem with data source configuration + * + * @since 1.25 + */ + public void bindDatasourceReferenceEjb(String dsReferenceName, String dsJNDIName, + String ejbName, String ejbType) throws ConfigurationException; + + /** + * Finds JNDI name of the data source which is mapped to the given reference name. + * + * @referenceName reference name + * @return JNDI name of the data source if the mapping exists, null otherwise + * + * @throws ConfigurationException if there is some problem with data source configuration + * + * @since 1.25 + */ + public String findDatasourceBinding(String dsReferenceName) throws ConfigurationException; + + /** + * Finds JNDI name of the data source which is mapped to the given reference name in the scope the EJB. + * + * @param referenceName reference name + * @param ejbName EJB name + * @return JNDI name of the data source if the mapping exists, null otherwise + * + * @throws ConfigurationException if there is some problem with data source configuration + * + * @since 1.25 + */ + public String findDatasourceBindingEjb(String dsReferenceName, String ejbName) throws ConfigurationException; } Index: src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/MessageDestinationConfiguration.java =================================================================== RCS file: src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/MessageDestinationConfiguration.java diff -N src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/MessageDestinationConfiguration.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/MessageDestinationConfiguration.java 26 Mar 2007 09:51:50 -0000 1.1.2.1 @@ -0,0 +1,73 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi.config; + +import java.util.Set; +import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException; +import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination; + +/** + * Configuration useful for managing module message destinations. + *

+ * Implementation of this interface should be registered in the {@link ModuleConfiguration} + * lookup. + * + * @author Libor Kotouc + */ +public interface MessageDestinationConfiguration { + + /** + * Retrieves message destinations stored in the module. + * + * @return set of message destinations + * + * @throws ConfigurationException if there is some problem with message destination configuration + * + * @since 1.25 + */ + public Set getMessageDestinations() throws ConfigurationException; + + /** + * Tests whether a message destination creation is supported. + * + * @return true if message destination creation is supported, false otherwise. + * + * @since 1.25 + */ + public boolean supportsCreateMessageDestination(); + + /** + * Creates and saves a message destination in the module if it does not exist in the module yet. + * Message destinations are considered to be equal if their JNDI names are equal. + * + * @param jndiName JNDI name of the message destination + * @param type message destination type; the value is of + * org.netbeans.modules.j2ee.deployment.common.api.MessageDestination.Type type + * @return created message destination + * + * @throws UnsupportedOperationException if this opearation is not supported + * @throws ConfigurationException if there is some problem with message destination configuration + * + * @since 1.25 + */ + public MessageDestination createMessageDestination(String jndiName, MessageDestination.Type type) + throws UnsupportedOperationException, ConfigurationException; + +} Index: src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/ModuleConfiguration.java =================================================================== RCS file: /cvs/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/Attic/ModuleConfiguration.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.3.2.1 diff -u -r1.1.2.3 -r1.1.2.3.2.1 --- src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/ModuleConfiguration.java 23 Mar 2007 20:29:58 -0000 1.1.2.3 +++ src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/ModuleConfiguration.java 26 Mar 2007 09:32:41 -0000 1.1.2.3.2.1 @@ -39,7 +39,8 @@ * implementations of all the supported configurations. *

* The configuration are: {@link ContextRootConfiguration}, {@link DatasourceConfiguration}, - * {@link MappingConfiguration}, {@link EjbResourceConfiguration}, {@link DeploymentPlanConfiguration} + * {@link MappingConfiguration}, {@link EjbResourceConfiguration}, {@link DeploymentPlanConfiguration}, + * {@link MessageDestinationConfiguration} *

* Implementators are advised to use {@link org.openide.util.lookup.Lookups#fixed} * to implement this method.