diff -r 5eda48228ef2 j2eeserver/apichanges.xml --- a/j2eeserver/apichanges.xml Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/apichanges.xml Wed Jun 02 17:20:30 2010 +0200 @@ -116,6 +116,34 @@ + + + Implemented support for handling the server libraries. + + + + + + +

+ Implemented both SPI and API to provide support for server + libraries management. +

+
+ + + + + + + + + + + + +
+ diff -r 5eda48228ef2 j2eeserver/nbproject/project.properties --- a/j2eeserver/nbproject/project.properties Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/nbproject/project.properties Wed Jun 02 17:20:30 2010 +0200 @@ -42,7 +42,7 @@ is.autoload=true javac.source=1.6 -spec.version.base=1.67.0 +spec.version.base=1.68.0 javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/common/api/Version.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/common/api/Version.java Wed Jun 02 17:20:30 2010 +0200 @@ -0,0 +1,299 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.common.api; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.openide.util.Parameters; + +/** + * Represents the generic version. Useful for libraries, products etc. + *

+ * This class is Immutable. + * + * @author Petr Hejl + * @since 1.68 + */ +// TODO add JBoss notation parsing MAJOR.MINOR.MICRO.QUALIFIER +public final class Version { + + private static final Pattern JSR277_PATTERN = Pattern.compile( + "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.(\\d+))?)?)?(-((\\w|-)+))?"); + + private final String version; + + private final Integer majorNumber; + + private final Integer minorNumber; + + private final Integer microNumber; + + private final Integer updateNumber; + + private final String qualifier; + + private Version(String version, Integer majorNumber, Integer minorNumber, + Integer microNumber, Integer updateNumber, String qualifier) { + this.version = version; + this.majorNumber = majorNumber; + this.minorNumber = minorNumber; + this.microNumber = microNumber; + this.updateNumber = updateNumber; + this.qualifier = qualifier; + } + + /** + * Creates the version from the spec version string. + * Expected format is MAJOR_NUMBER[.MINOR_NUMBER[.MICRO_NUMBER[.UPDATE_NUMBER]]][-QUALIFIER] + * or GENERIC_VERSION_STRING. + * + * @param version spec version string with the following format: + * MAJOR_NUMBER[.MINOR_NUMBER[.MICRO_NUMBER[.UPDATE_NUMBER]]][-QUALIFIER] + * or GENERIC_VERSION_STRING + */ + public static @NonNull Version fromJsr277NotationWithFallback(@NonNull String version) { + Parameters.notNull("version", version); + + Matcher matcher = JSR277_PATTERN.matcher(version); + if (matcher.matches()) { + String fragment = matcher.group(1); + Integer majorNumber = fragment != null ? Integer.valueOf(fragment) : null; + fragment = matcher.group(3); + Integer minorNumber = fragment != null ? Integer.valueOf(fragment) : null; + fragment = matcher.group(5); + Integer microNumber = fragment != null ? Integer.valueOf(fragment) : null; + fragment = matcher.group(7); + Integer updateNumber = fragment != null ? Integer.valueOf(fragment) : null; + String qualifier = matcher.group(9); + + return new Version(version, majorNumber, minorNumber, + microNumber, updateNumber, qualifier); + } else { + return new Version(version, null, null, null, null, null); + } + } + + /** + * Returns the major number. May return null. + * + * @return the major number; may return null + */ + @CheckForNull + public Integer getMajor() { + return majorNumber; + } + + /** + * Returns the minor number. May return null. + * + * @return the minor number; may return null + */ + @CheckForNull + public Integer getMinor() { + return minorNumber; + } + + /** + * Returns the micro number. May return null. + * + * @return the micro number; may return null + */ + @CheckForNull + public Integer getMicro() { + return microNumber; + } + + /** + * Returns the update. May return null. + * + * @return the update; may return null + */ + @CheckForNull + public Integer getUpdate() { + return updateNumber; + } + + /** + * Returns the qualifier. May return null. + * + * @return the qualifier; may return null + */ + @CheckForNull + public String getQualifier() { + return qualifier; + } + + /** + * {@inheritDoc} + *

+ * Two versions are equal if and only if they have same major, minor, + * micro, update number and qualifier. If the version does not conform to + * notation the versions are equal only if the version strings exactly + * matches. + */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Version other = (Version) obj; + + // non conform + if ((this.majorNumber == null && other.majorNumber != null) + || (this.majorNumber != null && other.majorNumber == null)) { + return false; + } else if (this.majorNumber == null && other.majorNumber == null) { + return this.version.equals(other.version); + } + + // standard + if (this.majorNumber != other.majorNumber && (this.majorNumber == null || !this.majorNumber.equals(other.majorNumber))) { + return false; + } + if (this.minorNumber != other.minorNumber && (this.minorNumber == null || !this.minorNumber.equals(other.minorNumber))) { + return false; + } + if (this.microNumber != other.microNumber && (this.microNumber == null || !this.microNumber.equals(other.microNumber))) { + return false; + } + if (this.updateNumber != other.updateNumber && (this.updateNumber == null || !this.updateNumber.equals(other.updateNumber))) { + return false; + } + if ((this.qualifier == null) ? (other.qualifier != null) : !this.qualifier.equals(other.qualifier)) { + return false; + } + return true; + } + + /** + * {@inheritDoc} + *

+ * The implementation consistent with {@link #equals(Object)}. + */ + @Override + public int hashCode() { + // non conform + if (this.majorNumber == null) { + return this.version.hashCode(); + } + + // standard + int hash = 7; + hash = 97 * hash + (this.majorNumber != null ? this.majorNumber.hashCode() : 0); + hash = 97 * hash + (this.minorNumber != null ? this.minorNumber.hashCode() : 0); + hash = 97 * hash + (this.microNumber != null ? this.microNumber.hashCode() : 0); + hash = 97 * hash + (this.updateNumber != null ? this.updateNumber.hashCode() : 0); + hash = 97 * hash + (this.qualifier != null ? this.qualifier.hashCode() : 0); + return hash; + } + + public boolean isAboveOrEqual(Version other) { + if (this.majorNumber == null || other.majorNumber == null) { + return this.equals(other); + } + + return compareTo(other) >= 0; + } + + public boolean isBelowOrEqual(Version other) { + if (this.majorNumber == null || other.majorNumber == null) { + return this.equals(other); + } + + return compareTo(other) <= 0; + } + + @Override + public String toString() { + return version; + } + + private int compareTo(Version o) { + int comparison = compare(majorNumber, o.majorNumber); + if (comparison != 0) { + return comparison; + } + comparison = compare(minorNumber, o.minorNumber); + if (comparison != 0) { + return comparison; + } + comparison = compare(microNumber, o.microNumber); + if (comparison != 0) { + return comparison; + } + comparison = compare(updateNumber, o.updateNumber); + if (comparison != 0) { + return comparison; + } + return compare(qualifier, o.qualifier); + } + + private static int compare(Integer o1, Integer o2) { + if (o1 == null && o2 == null) { + return 0; + } + if (o1 == null) { + return Integer.valueOf(0).compareTo(o2); + } + if (o2 == null) { + return o1.compareTo(Integer.valueOf(0)); + } + return o1.compareTo(o2); + } + + private static int compare(String o1, String o2) { + if (o1 == null && o2 == null) { + return 0; + } + if (o1 == null) { + return "".compareTo(o2); + } + if (o2 == null) { + return o1.compareTo(""); + } + return o1.compareTo(o2); + } + +} diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java Wed Jun 02 17:20:30 2010 +0200 @@ -56,6 +56,7 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import org.netbeans.api.annotations.common.NonNull; 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; @@ -66,6 +67,7 @@ import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; import org.netbeans.modules.j2ee.deployment.common.api.Datasource; import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange; import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration; import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DatasourceConfiguration; import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration; @@ -84,6 +86,7 @@ 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; +import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ServerLibraryConfiguration; import org.openide.util.Mutex.Action; import org.openide.util.Parameters; @@ -334,7 +337,36 @@ mappingConfiguration.setCMPResource(ejbName, jndiName); } } - + + @Override + public void configureRequiredLibrary(@NonNull ServerLibraryRange library) throws ConfigurationException { + if (server != null) { + ModuleConfiguration config = getModuleConfiguration(); + if (config != null) { + ServerLibraryConfiguration libraryConfiguration = config.getLookup().lookup(ServerLibraryConfiguration.class); + if (libraryConfiguration != null) { + libraryConfiguration.configureRequiredLibrary(library); + } + } + } + } + + @Override + public Set getRequiredServerLibraries() throws ConfigurationException { + Set libs = Collections.emptySet(); + + if (server != null) { + ModuleConfiguration config = getModuleConfiguration(); + if (config != null) { + ServerLibraryConfiguration libraryConfiguration = config.getLookup().lookup(ServerLibraryConfiguration.class); + if (libraryConfiguration != null) { + libs = libraryConfiguration.getRequiredLibraries(); + } + } + } + return libs; + } + public Set getDatasources() throws ConfigurationException { Set projectDS = Collections.emptySet(); diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java Wed Jun 02 17:20:30 2010 +0200 @@ -166,6 +166,7 @@ server.getServerInstance().start(progress); } + DeploymentHelper.deployServerLibraries(jmp); DeploymentHelper.deployDatasources(jmp); DeploymentHelper.deployMessageDestinations(jmp); diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/ServerInstance.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/ServerInstance.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/ServerInstance.java Wed Jun 02 17:20:30 2010 +0200 @@ -42,9 +42,10 @@ package org.netbeans.modules.j2ee.deployment.devmodules.api; -import java.io.IOException; +import java.util.Set; +import org.netbeans.api.annotations.common.NonNull; import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; -import org.netbeans.modules.j2ee.deployment.impl.TargetServer; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary; import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment; /** @@ -200,6 +201,26 @@ return null; } + /** + * Returns manager providing the access to server libraries. May + * return null if the server does not support this. + * + * @return manager providing the access to server libraries or null + * @throws InstanceRemovedException if the instance is not available anymore + * @since 1.68 + */ + public LibraryManager getLibraryManager() throws InstanceRemovedException { + final ServerRegistry registry = ServerRegistry.getInstance(); + // see comment at the beginning of the class + synchronized (registry) { + org.netbeans.modules.j2ee.deployment.impl.ServerInstance inst = getInstanceFromRegistry(registry); + if (inst.isServerLibraryManagementSupported()) { + return new LibraryManager(); + } + } + return null; + } + private org.netbeans.modules.j2ee.deployment.impl.ServerInstance getInstanceFromRegistry(ServerRegistry registry) throws InstanceRemovedException { @@ -251,4 +272,33 @@ return getInstanceFromRegistry(ServerRegistry.getInstance()).getServerInstanceDescriptor().isLocal(); } } + + /** + * The manager providing the access to server libraries. + * + * @since 1.68 + */ + public final class LibraryManager { + + /** + * Returns the set of libraries the server has access to and can be deployed + * on request (by call to {@link #deployRequiredLibraries(java.util.Set)}. + * + * @return the set of libraries which can be deployed on server + */ + @NonNull + public Set getDeployableLibraries() throws InstanceRemovedException { + return getInstanceFromRegistry(ServerRegistry.getInstance()).getDeployableLibraries(); + } + + /** + * Returns the set of libraries already deployed to the server. + * + * @return the set of libraries already deployed to the server + */ + @NonNull + public Set getDeployedLibraries() throws InstanceRemovedException { + return getInstanceFromRegistry(ServerRegistry.getInstance()).getDeployedLibraries(); + } + } } diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java Wed Jun 02 17:20:30 2010 +0200 @@ -76,8 +76,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination; import org.netbeans.modules.j2ee.deployment.impl.projects.J2eeModuleProviderAccessor; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange; /** This object must be implemented by J2EE module support and an instance * added into project lookup. @@ -181,7 +184,7 @@ } return si.getStartServer().getDebugInfo(target); } - + /** * Gets the data sources deployed on the target server instance. * @@ -300,6 +303,7 @@ * The setters and getters work with server specific data on the server returned by * {@link #getServerID} method. */ + // FIXME replace this with final class - this is not deigned to be implemented by anybody public static interface ConfigSupport { /** * Create an initial fresh configuration for the current module. Do nothing if configuration already exists. @@ -485,6 +489,33 @@ public Datasource findDatasource(String jndiName) throws ConfigurationException; /** + * Configure the library (range) the enterprise module needs in order + * to work properly. + *

+ * Once library is configured it should be present in the result + * of the {@link #getRequiredLibraries()} call. + * + * @param library the library the enterprise module needs in order to work + * properly + * @throws ConfigurationException if there was a problem writing + * configuration + * @since 1.68 + */ + public void configureRequiredLibrary(@NonNull ServerLibraryRange library) throws ConfigurationException; + + /** + * Returns the server library ranges the enterprise module needs + * to work properly. + * + * @return the server library ranges + * @throws ConfigurationException if there was a problem reading + * configuration + * @since 1.68 + */ + @NonNull + public Set getRequiredServerLibraries() throws ConfigurationException; + + /** * Retrieves message destinations stored in the module. * * @return set of message destinations diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java Wed Jun 02 17:20:30 2010 +0200 @@ -392,6 +392,7 @@ "MSG_DeployOnSave", provider.getDeploymentName()), false); ui.start(Integer.valueOf(PROGRESS_DELAY)); try { + DeploymentHelper.deployServerLibraries(provider); DeploymentHelper.deployDatasources(provider); DeploymentHelper.deployMessageDestinations(provider); diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeploymentHelper.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeploymentHelper.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeploymentHelper.java Wed Jun 02 17:20:30 2010 +0200 @@ -52,6 +52,7 @@ import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange; import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer; /** @@ -114,4 +115,15 @@ "The data sources cannot be deployed because the server instance cannot be found."); } } + + public static void deployServerLibraries(J2eeModuleProvider jmp) throws ConfigurationException { + ServerInstance si = ServerRegistry.getInstance ().getServerInstance (jmp.getServerInstanceID ()); + if (si != null) { + Set libraries = jmp.getConfigSupport().getRequiredServerLibraries(); + si.deployRequiredLibraries(libraries); + } else { + LOGGER.log(Level.WARNING, + "The libraries cannot be deployed because the server instance cannot be found."); + } + } } diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java Wed Jun 02 17:20:30 2010 +0200 @@ -78,6 +78,8 @@ import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl; import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange; import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer; import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver; import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport; @@ -88,6 +90,7 @@ import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory; import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment; import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor; +import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager; 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; @@ -145,6 +148,8 @@ private J2eePlatformImpl j2eePlatformImpl; private StartServer startServer; private FindJSPServlet findJSPServlet; + private ServerLibraryManager libraryManager; + private ServerLibraryManager disconnectedLibraryManager; private DatasourceManager dsMgr; private DatasourceManager ddsMgr; private MessageDestinationDeployment msgDestDeploymentConnected; @@ -685,7 +690,32 @@ return ddsMgr; } } - + + private ServerLibraryManager getServerLibraryManager() { + DeploymentManager dm = getDeploymentManager(); + synchronized (this) { + if (libraryManager == null) { + libraryManager = server.getOptionalFactory().getServerLibraryManager(dm); + } + return libraryManager; + } + } + + private ServerLibraryManager getDisconnectedServerLibraryManager() { + DeploymentManager dm = null; + try { + dm = getDisconnectedDeploymentManager(); + } catch (DeploymentManagerCreationException dmce) { + throw new RuntimeException(dmce); + } + synchronized (this) { + if (disconnectedLibraryManager == null) { + disconnectedLibraryManager = server.getOptionalFactory().getServerLibraryManager(dm); + } + return disconnectedLibraryManager; + } + } + /** * Gets the data sources deployed on the this server instance. * @@ -716,7 +746,41 @@ if (dsMgr != null) dsMgr.deployDatasources(datasources); } - + + public boolean isServerLibraryManagementSupported() { + return getDisconnectedServerLibraryManager() != null; + } + + public Set getDeployableLibraries() { + ServerLibraryManager libraryManager = getDisconnectedServerLibraryManager(); + + Set libraries = Collections.emptySet(); + if (libraryManager != null) { + libraries = libraryManager.getDeployableLibraries(); + } + + return libraries; + } + + public Set getDeployedLibraries() { + ServerLibraryManager libraryManager = getDisconnectedServerLibraryManager(); + + Set libraries = Collections.emptySet(); + if (libraryManager != null) { + libraries = libraryManager.getDeployedLibraries(); + } + + return libraries; + } + + public void deployRequiredLibraries(Set libraries) throws ConfigurationException { + ServerLibraryManager libraryManager = getServerLibraryManager(); + + if (libraryManager != null) { + libraryManager.deployRequiredLibraries(libraries); + } + } + private synchronized MessageDestinationDeployment getMessageDestinationDeploymentConnected() { if (msgDestDeploymentConnected == null) { msgDestDeploymentConnected = server.getOptionalFactory(). diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java Wed Jun 02 17:20:30 2010 +0200 @@ -784,7 +784,10 @@ } try { + // FIXME libraries stored in server specific descriptor + // do not match server resources if (serverResources) { + DeploymentHelper.deployServerLibraries(provider); DeploymentHelper.deployDatasources(provider); DeploymentHelper.deployMessageDestinations(provider); } diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ServerLibrary.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ServerLibrary.java Wed Jun 02 17:20:30 2010 +0200 @@ -0,0 +1,150 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.api; + +import java.io.File; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.modules.j2ee.deployment.common.api.Version; +import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryFactory; +import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryImplementation; + +/** + * The representation of the server library. This means the library server + * manages not the jars deployed along with the application. + * + * @since 1.68 + * @author Petr Hejl + */ +public final class ServerLibrary { + + static { + ServerLibraryFactory.Accessor.DEFAULT = new ServerLibraryFactory.Accessor() { + + @Override + public ServerLibrary createServerLibrary(ServerLibraryImplementation impl) { + return new ServerLibrary(impl); + } + }; + } + + private final ServerLibraryImplementation impl; + + private ServerLibrary(@NonNull ServerLibraryImplementation impl) { + this.impl = impl; + } + + /** + * Returns the specification title of the library. May return + * null. + *

+ *

+ * For example specification title for JSF would be JavaServer Faces. + *
+ * + * @return the specification title of the library; may return null + */ + @CheckForNull + public String getSpecificationTitle() { + return impl.getSpecificationTitle(); + } + + /** + * Returns the specification version of the library. May return + * null. + * + * @return the specification version of the library; may return null + */ + @CheckForNull + public Version getSpecificationVersion() { + return impl.getSpecificationVersion(); + } + + /** + * Returns the implementation title of the library. May return + * null. + *

+ *

+ * For example specification title for MyFaces implementation of JSF + * this would be something like MyFaces. + *
+ * + * @return the implementation title of the library; may return null + */ + @CheckForNull + public String getImplementationTitle() { + return impl.getImplementationTitle(); + } + + /** + * Returns the implementation version of the library. May return + * null. + * + * @return the implementation version of the library; may return null + */ + @CheckForNull + public Version getImplementationVersion() { + return impl.getImplementationVersion(); + } + + /** + * Returns the file from which the library should be deployed or the from + * which the library was deployed. May return null. + * + * @return the file from which the library should be deployed or the from + * which the library was deployed; may return null + */ + @CheckForNull + public File getLibraryFile() { + return impl.getLibraryFile(); + } + + /** + * Returns the library name. May return null. + * + * @return the library name; may return null + */ + @CheckForNull + public String getName() { + return impl.getName(); + } + + // TODO should we implement equals and hashCode ? +} diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ServerLibraryRange.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ServerLibraryRange.java Wed Jun 02 17:20:30 2010 +0200 @@ -0,0 +1,232 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.api; + +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.annotations.common.NullAllowed; +import org.netbeans.modules.j2ee.deployment.common.api.Version; +import org.openide.util.Parameters; + +/** + * Represents the library version. For example library version required by + * the enterprise module. + * + * @since 1.68 + * @author Petr Hejl + */ +public final class ServerLibraryRange { + + private final String name; + + private final Version specificationVersion; + + private final Version implementationVersion; + + private boolean exactMatch; + + private ServerLibraryRange(String name, Version specificationVersion, + Version implementationVersion, boolean exactMatch) { + this.name = name; + this.specificationVersion = specificationVersion; + this.implementationVersion = implementationVersion; + this.exactMatch = exactMatch; + } + + /** + * Creates the library range which specifies the minimal specification and + * implementation version. + *

+ * When both specification and implementation version is null + * it has the meaning of any version. + * + * @param name name of the library + * @param specificationVersion the minimal specification version, may be null + * @param implementationVersion the minimal implementation version, may be null + * @return the library range which specifies the minimal specification and + * implementation version + */ + public static ServerLibraryRange minimalVersion(@NonNull String name, + @NullAllowed Version specificationVersion, @NullAllowed Version implementationVersion) { + + Parameters.notNull("name", name); + + return new ServerLibraryRange(name, specificationVersion, implementationVersion, false); + } + + /** + * Creates the library range which specifies the exact specification and + * implementation version. + * + * @param name name of the library + * @param specificationVersion the minimal specification version, may be null + * @param implementationVersion the minimal implementation version, may be null + * @return the library range which specifies the exact specification and + * implementation version + */ + public static ServerLibraryRange exactVersion(@NonNull String name, + @NullAllowed Version specificationVersion, @NullAllowed Version implementationVersion) { + + Parameters.notNull("name", name); + Parameters.notNull("specificationVersion", name); + + return new ServerLibraryRange(name, specificationVersion, implementationVersion, true); + } + + /** + * Returns true if the given library matches the range. + *

+ * The library matches the range if the range specify the minimal versions + * (specification and/or implementation) and corresponding versions + * of the library are equal or greater. If the range specify the exact + * version the corresponding versions of library must be the same as those + * specified for range. + * + * @param library the library to check + * @return true if the given library matches the range + * @see Version#isAboveOrEqual(org.netbeans.modules.j2ee.deployment.common.api.Version) + * @see Version#isBelowOrEqual(org.netbeans.modules.j2ee.deployment.common.api.Version) + */ + public boolean versionMatches(@NonNull ServerLibrary library) { + Parameters.notNull("library", library); + + if (exactMatch) { + return (library.getName() != null && library.getName().equals(name)) + && (specificationVersion == null + || specificationVersion.equals(library.getSpecificationVersion())) + && (implementationVersion == null + || implementationVersion.equals(library.getImplementationVersion())); + } + + return (library.getName() != null && library.getName().equals(name)) + && (specificationVersion == null + || (library.getSpecificationVersion() != null && specificationVersion.isBelowOrEqual(library.getSpecificationVersion()))) + && (implementationVersion == null + || (library.getImplementationVersion() != null && implementationVersion.isBelowOrEqual(library.getImplementationVersion()))); + } + + /** + * Returns the name of the required library. + * + * @return the name of the required library + */ + @NonNull + public String getName() { + return name; + } + + /** + * Returns the specification version. May be null. + * + * @return the specification version; may be null + */ + @CheckForNull + public Version getSpecificationVersion() { + return specificationVersion; + } + + /** + * Returns the implementation version. May be null. + * + * @return the implementation version; may be null + */ + @CheckForNull + public Version getImplementationVersion() { + return implementationVersion; + } + + /** + * Returns true if the exactly the same version are required + * by the range to match the library. + * + * @return true if the exactly the same version are required + * by the range to match the library + */ + public boolean isExactMatch() { + return exactMatch; + } + + /** + * @{@inheritDoc} + * + * Ranges are equal if they have the same name, specification version, + * implementation version and exact match flag. + */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ServerLibraryRange other = (ServerLibraryRange) obj; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if (this.specificationVersion != other.specificationVersion && (this.specificationVersion == null || !this.specificationVersion.equals(other.specificationVersion))) { + return false; + } + if (this.implementationVersion != other.implementationVersion && (this.implementationVersion == null || !this.implementationVersion.equals(other.implementationVersion))) { + return false; + } + if (this.exactMatch != other.exactMatch) { + return false; + } + return true; + } + + /** + * @{@inheritDoc} + *

+ * Implementation consistent with {@link #equals(java.lang.Object)}. + * @see #equals(java.lang.Object) + */ + @Override + public int hashCode() { + int hash = 5; + hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 53 * hash + (this.specificationVersion != null ? this.specificationVersion.hashCode() : 0); + hash = 53 * hash + (this.implementationVersion != null ? this.implementationVersion.hashCode() : 0); + hash = 53 * hash + (this.exactMatch ? 1 : 0); + return hash; + } + +} diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java Wed Jun 02 17:20:30 2010 +0200 @@ -46,6 +46,7 @@ package org.netbeans.modules.j2ee.deployment.plugins.spi; import javax.enterprise.deploy.spi.DeploymentManager; +import org.netbeans.api.annotations.common.CheckForNull; import org.openide.WizardDescriptor; /** @@ -179,4 +180,17 @@ public void finishServerInitialization() throws ServerInitializationException { } + /** + * Return the manager handling the server libraries. May return + * null if the functionality is not supported by the plugin. + * + * @param dm the deployment manager + * @return the manager handling the server libraries + * @since 1.68 + * @see ServerLibraryManager + */ + @CheckForNull + public ServerLibraryManager getServerLibraryManager(DeploymentManager dm) { + return null; + } } diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/ServerLibraryFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/ServerLibraryFactory.java Wed Jun 02 17:20:30 2010 +0200 @@ -0,0 +1,97 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi; + +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary; + +/** + * Factory creating the API representation of the library provided in SPI. + * + * @since 1.68 + * @author Petr Hejl + */ +public final class ServerLibraryFactory { + + private ServerLibraryFactory() { + super(); + } + + /** + * Creates the API representation of the provided SPI instance. + * + * @param impl the SPI instance + * @return the API server instance representation + */ + public static ServerLibrary createServerLibrary(ServerLibraryImplementation impl) { + return Accessor.DEFAULT.createServerLibrary(impl); + } + + /** + * The accessor pattern class. + */ + public abstract static class Accessor { + + /** The default accessor. */ + public static Accessor DEFAULT; + + static { + // invokes static initializer of ServerLibrary.class + // that will assign value to the DEFAULT field above + Class c = ServerLibrary.class; + try { + Class.forName(c.getName(), true, c.getClassLoader()); + } catch (ClassNotFoundException ex) { + assert false : ex; + } + } + + /** + * Creates the API instance. + * + * @param impl the SPI instance + * @return the API instance + */ + public abstract ServerLibrary createServerLibrary(ServerLibraryImplementation impl); + + } +} diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/ServerLibraryImplementation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/ServerLibraryImplementation.java Wed Jun 02 17:20:30 2010 +0200 @@ -0,0 +1,117 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi; + +import java.io.File; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.modules.j2ee.deployment.common.api.Version; + +/** + * The representation of the server library. This means the library server + * manages not the jars deployed along with the application. + * + * @since 1.68 + * @author Petr Hejl + */ +public interface ServerLibraryImplementation { + + /** + * Returns the specification title of the library. May return + * null. + *

+ *

+ * For example specification title for JSF would be JavaServer Faces. + *
+ * + * @return the specification title of the library; may return null + */ + @CheckForNull + String getSpecificationTitle(); + + /** + * Returns the implementation title of the library. May return + * null. + *

+ *

+ * For example specification title for MyFaces implementation of JSF + * this would be something like MyFaces. + *
+ * + * @return the implementation title of the library; may return null + */ + @CheckForNull + String getImplementationTitle(); + + /** + * Returns the specification version of the library. May return + * null. + * + * @return the specification version of the library; may return null + */ + @CheckForNull + Version getSpecificationVersion(); + + /** + * Returns the implementation version of the library. May return + * null. + * + * @return the implementation version of the library; may return null + */ + @CheckForNull + Version getImplementationVersion(); + + /** + * Returns the file from which the library should be deployed or the from + * which the library was deployed. May return null. + * + * @return the file from which the library should be deployed or the from + * which the library was deployed; may return null + */ + @CheckForNull + File getLibraryFile(); + + /** + * Returns the library name. May return null. + * + * @return the library name; may return null + */ + @CheckForNull + String getName(); +} diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/ServerLibraryManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/ServerLibraryManager.java Wed Jun 02 17:20:30 2010 +0200 @@ -0,0 +1,86 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi; + +import java.util.Set; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange; + +/** + * The interface that should serverplugin should implement in order to + * support the server library management. + * + * @since 1.68 + * @author Petr Hejl + * @see org.netbeans.modules.j2ee.deployment.plugins.spi.config.ServerLibraryConfiguration + */ +public interface ServerLibraryManager { + + /** + * Returns the set of libraries the server has access to and can be deployed + * on request (by call to {@link #deployRequiredLibraries(java.util.Set)}. + * + * @return the set of libraries which can be deployed on server + */ + @NonNull + Set getDeployableLibraries(); + + /** + * Returns the set of libraries already deployed to the server. + * + * @return the set of libraries already deployed to the server + */ + @NonNull + Set getDeployedLibraries(); + + /** + * Deploys all the required libraries passed to the method. The libraries + * passed to the method may be already deployed and it is up to implementor + * to handle such case. + * + * @param libraries the libraries to deploy + * @throws ConfigurationException if there was a problem during + * the deployment + */ + void deployRequiredLibraries(@NonNull Set libraries) throws ConfigurationException; + +} diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/ServerLibraryConfiguration.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/ServerLibraryConfiguration.java Wed Jun 02 17:20:30 2010 +0200 @@ -0,0 +1,84 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi.config; + +import java.util.Set; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException; +import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange; + +/** + * The interface defining the methods that can handle the server libraries in + * scope of enterprise module. + *

+ * This interface is typically looked up in {@link ModuleConfiguration}'s + * lookup. + * + * @since 1.68 + * @author Petr Hejl + */ +public interface ServerLibraryConfiguration { + + /** + * Configure the library (range) the enterprise module needs in order + * to work properly. + *

+ * Once library is configured it should be present in the result + * of the {@link #getRequiredLibraries()} call. + * + * @param library the library the enterprise module needs in order to work + * properly + * @throws ConfigurationException if there was a problem writing + * configuration + */ + void configureRequiredLibrary(@NonNull ServerLibraryRange library) throws ConfigurationException; + + /** + * Returns the server library ranges the enterprise module needs + * to work properly. + * + * @return the server library ranges + * @throws ConfigurationException if there was a problem reading + * configuration + */ + @NonNull + Set getRequiredLibraries() throws ConfigurationException; + +} diff -r 5eda48228ef2 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/support/ProxyOptionalFactory.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/support/ProxyOptionalFactory.java Fri May 28 12:20:35 2010 +0200 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/support/ProxyOptionalFactory.java Wed Jun 02 17:20:30 2010 +0200 @@ -53,6 +53,7 @@ import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory; import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInitializationException; import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor; +import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager; import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer; import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver; import org.openide.WizardDescriptor.InstantiatingIterator; @@ -151,6 +152,11 @@ } } + @Override + public ServerLibraryManager getServerLibraryManager(DeploymentManager dm) { + return getDelegate().getServerLibraryManager(dm); + } + private OptionalDeploymentManagerFactory getDelegate() { synchronized (this) { if (delegate != null) {