- * Immutable
- *
- * @author Petr Hejl
- */
- public static final class Version implements Comparable
- * Two versions are equal if and only if they have same major, minor,
- * micro number and update.
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Version other = (Version) obj;
- 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.update != other.update
- && (this.update == null || !this.update.equals(other.update))) {
- return false;
- }
- return true;
- }
-
- /**
- * {@inheritDoc}
- * The implementation consistent with {@link #equals(Object)}.
- */
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 17 * hash + (this.majorNumber != null ? this.majorNumber.hashCode() : 0);
- hash = 17 * hash + (this.minorNumber != null ? this.minorNumber.hashCode() : 0);
- hash = 17 * hash + (this.microNumber != null ? this.microNumber.hashCode() : 0);
- hash = 17 * hash + (this.update != null ? this.update.hashCode() : 0);
- return hash;
- }
-
- /**
- * {@inheritDoc}
- * Compares the versions based on its major, minor, micro and update.
- * Major number is the most significant. Implementation is consistent
- * with {@link #equals(Object)}.
- */
- public int compareTo(Version o) {
- int comparison = compareToIgnoreUpdate(o);
- if (comparison != 0) {
- return comparison;
- }
- return update.compareTo(o.update);
- }
-
- /**
- * Compares the versions based on its major, minor, micro. Update field
- * is ignored. Major number is the most significant.
- *
- * @param o version to compare with
- */
- public int compareToIgnoreUpdate(Version o) {
- int comparison = majorNumber.compareTo(o.majorNumber);
- if (comparison != 0) {
- return comparison;
- }
- comparison = minorNumber.compareTo(o.minorNumber);
- if (comparison != 0) {
- return comparison;
- }
- return microNumber.compareTo(o.microNumber);
- }
-
- }
}
--- a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/Bundle.properties Fri May 28 12:20:35 2010 +0200
+++ a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/Bundle.properties Fri Jun 11 10:20:14 2010 +0200
@@ -68,4 +68,8 @@
have write access to this file.
MSG_FailedToCreateConfigFolder=The {0} folder could not be created.
-MSG_FailedToDeployDatasource=One or more datasources could not be deployed. Check project configuration.
+MSG_FailedToDeployDatasource=One or more datasources could not be deployed. Check project configuration.
+MSG_FailedToDeployLibrary=One or more libraries could not be deployed. Check project configuration.
+
+MSG_CannotReaderServerLibraries=Cannot read the server libraries value since the {0} file is not parseable.
+MSG_DidNotFindServerLibraries=Some server libraries could not be find on server or deployed.
--- a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/WLDatasourceManager.java Fri May 28 12:20:35 2010 +0200
+++ a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/WLDatasourceManager.java Fri Jun 11 10:20:14 2010 +0200
@@ -49,17 +49,14 @@
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.enterprise.deploy.spi.status.ProgressEvent;
-import javax.enterprise.deploy.spi.status.ProgressListener;
import javax.enterprise.deploy.spi.status.ProgressObject;
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
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.spi.DatasourceManager;
+import org.netbeans.modules.j2ee.weblogic9.ProgressObjectSupport;
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
import org.netbeans.modules.j2ee.weblogic9.deploy.WLCommandDeployer;
@@ -131,7 +128,7 @@
WLCommandDeployer deployer = new WLCommandDeployer(WLDeploymentFactory.getInstance(),
manager.getInstanceProperties());
ProgressObject po = deployer.deployDatasource(toDeploy.values());
- waitFor(po);
+ ProgressObjectSupport.waitFor(po);
if (po.getDeploymentStatus().isFailed()) {
String msg = NbBundle.getMessage(WLDatasourceManager.class, "MSG_FailedToDeployDatasource");
throw new ConfigurationException(msg);
@@ -162,22 +159,4 @@
}
return map;
}
-
- private void waitFor(ProgressObject obj) {
- final CountDownLatch latch = new CountDownLatch(1);
- obj.addProgressListener(new ProgressListener() {
-
- @Override
- public void handleProgressEvent(ProgressEvent pe) {
- if (pe.getDeploymentStatus().isCompleted() || pe.getDeploymentStatus().isFailed()) {
- latch.countDown();
- }
- }
- });
- try {
- latch.await(WLDeploymentManager.MANAGER_TIMEOUT, TimeUnit.MILLISECONDS);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ 5eda48228ef2 Fri Jun 11 10:20:14 2010 +0200
@@ -0,0 +1,141 @@
+/*
+ * 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.weblogic9.config;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+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.ServerLibraryDependency;
+import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryFactory;
+import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
+import org.netbeans.modules.j2ee.weblogic9.ProgressObjectSupport;
+import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
+import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
+import org.netbeans.modules.j2ee.weblogic9.deploy.WLCommandDeployer;
+import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Petr Hejl
+ */
+public class WLServerLibraryManager implements ServerLibraryManager {
+
+ private static final Logger LOGGER = Logger.getLogger(WLServerLibraryManager.class.getName());
+
+ private final WLDeploymentManager manager;
+
+ private final WLServerLibrarySupport support;
+
+ public WLServerLibraryManager(WLDeploymentManager manager) {
+ this.manager = manager;
+ String domainDir = manager.getInstanceProperties().getProperty(WLPluginProperties.DOMAIN_ROOT_ATTR);
+ assert domainDir != null;
+ String serverDir = manager.getInstanceProperties().getProperty(WLPluginProperties.SERVER_ROOT_ATTR);
+ assert serverDir != null;
+ this.support = new WLServerLibrarySupport(new File(serverDir), new File(domainDir));
+ }
+
+ @Override
+ public void deployLibraries(Set
+ Implemented both SPI and API to provide support for server
+ libraries management.
+
+ * 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
+ * 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);
+ }
+
+}
--- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java Fri May 28 12:20:35 2010 +0200
+++ a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java Fri Jun 11 10:20:14 2010 +0200
@@ -56,6 +56,9 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.annotations.common.CheckForNull;
+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 +69,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.ServerLibraryDependency;
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 +88,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 +339,42 @@
mappingConfiguration.setCMPResource(ejbName, jndiName);
}
}
-
+
+ @Override
+ public void configureLibrary(@NonNull ServerLibraryDependency library) throws ConfigurationException {
+ ServerLibraryConfiguration libraryConfiguration = getServerLibraryConfiguration();
+ if (libraryConfiguration != null) {
+ libraryConfiguration.configureLibrary(library);
+ }
+ }
+
+ @Override
+ public Set
+ * 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 configureLibrary(@NonNull ServerLibraryDependency library) throws ConfigurationException;
+
+ /**
+ * Returns the server library dependencies the enterprise module needs
+ * to work properly.
+ *
+ * @return the server library dependencies
+ * @throws ConfigurationException if there was a problem reading
+ * configuration
+ * @since 1.68
+ */
+ @NonNull
+ public Set
+ *
+ *
+ * When both specification and implementation version is
+ * The library matches the dependency if the dependency specify the minimal
+ * versions (specification and/or implementation) and corresponding versions
+ * of the library are equal or greater. If the dependency specify the exact
+ * version the corresponding versions of library must be the same as those
+ * specified for dependency.
+ *
+ * @param library the library to check
+ * @return
+ * 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;
+ }
+
+}
--- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/J2eePlatformImpl.java Fri May 28 12:20:35 2010 +0200
+++ a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/J2eePlatformImpl.java Fri Jun 11 10:20:14 2010 +0200
@@ -56,6 +56,7 @@
import org.netbeans.modules.j2ee.deployment.config.J2eeModuleAccessor;
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.api.j2ee.core.Profile;
+import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
import org.netbeans.spi.project.libraries.LibraryImplementation;
import org.openide.util.Lookup;
@@ -84,7 +85,11 @@
* @return platform's libraries.
*/
public abstract LibraryImplementation[] getLibraries();
-
+
+ public File[] getClasspathEntries(Set
+ *
+ *
+ * This interface is typically looked up in {@link ModuleConfiguration}'s
+ * lookup.
+ *
+ * @since 1.68
+ * @author Petr Hejl
+ */
+public interface ServerLibraryConfiguration {
+
+ /**
+ * Configure the library (dependency) 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 configureLibrary(@NonNull ServerLibraryDependency library) throws ConfigurationException;
+
+ /**
+ * Returns the server library dependencies the enterprise module needs
+ * to work properly.
+ *
+ * @return the server library dependencies
+ * @throws ConfigurationException if there was a problem reading
+ * configuration
+ */
+ @NonNull
+ SetMAJOR_NUMBER[.MINOR_NUMBER[.MICRO_NUMBER[.UPDATE]]]
.
- *
- * @param version spec version string with the following format:
- * MAJOR_NUMBER[.MINOR_NUMBER[.MICRO_NUMBER[.UPDATE]]]
- */
- public Version(String version) {
- assert version != null : "Version can't be null"; // NOI18N
-
- String[] tokens = version.split("\\.");
-
- if (tokens.length >= 4) {
- update = tokens[3];
- }
- if (tokens.length >= 3) {
- microNumber = tokens[2];
- }
- if (tokens.length >= 2) {
- minorNumber = tokens[1];
- }
- majorNumber = tokens[0];
- }
-
- /**
- * Returns the major number.
- *
- * @return the major number. Never returns null
.
- */
- public String getMajorNumber() {
- return majorNumber;
- }
-
- /**
- * Returns the minor number.
- *
- * @return the minor number. Never returns null
.
- */
- public String getMinorNumber() {
- return minorNumber;
- }
-
- /**
- * Returns the micro number.
- *
- * @return the micro number. Never returns null
.
- */
- public String getMicroNumber() {
- return microNumber;
- }
-
- /**
- * Returns the update.
- *
- * @return the update. Never returns null
.
- */
- public String getUpdate() {
- return update;
- }
-
- /**
- * {@inheritDoc}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}
+ * 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 Setnull
.
+ * 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
.
+ * 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 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 ?
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ 5eda48228ef2 Fri Jun 11 10:20:14 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 dependency. For example library version required by
+ * the enterprise module.
+ *
+ * @since 1.68
+ * @author Petr Hejl
+ */
+public final class ServerLibraryDependency {
+
+ private final String name;
+
+ private final Version specificationVersion;
+
+ private final Version implementationVersion;
+
+ private boolean exactMatch;
+
+ private ServerLibraryDependency(String name, Version specificationVersion,
+ Version implementationVersion, boolean exactMatch) {
+ this.name = name;
+ this.specificationVersion = specificationVersion;
+ this.implementationVersion = implementationVersion;
+ this.exactMatch = exactMatch;
+ }
+
+ /**
+ * Creates the library dependency which specifies the minimal specification
+ * and implementation version.
+ * 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 dependency which specifies the minimal specification
+ * and implementation version
+ */
+ public static ServerLibraryDependency minimalVersion(@NonNull String name,
+ @NullAllowed Version specificationVersion, @NullAllowed Version implementationVersion) {
+
+ Parameters.notNull("name", name);
+
+ return new ServerLibraryDependency(name, specificationVersion, implementationVersion, false);
+ }
+
+ /**
+ * Creates the library dependency 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 dependency which specifies the exact specification
+ * and implementation version
+ */
+ public static ServerLibraryDependency exactVersion(@NonNull String name,
+ @NullAllowed Version specificationVersion, @NullAllowed Version implementationVersion) {
+
+ Parameters.notNull("name", name);
+ Parameters.notNull("specificationVersion", name);
+
+ return new ServerLibraryDependency(name, specificationVersion, implementationVersion, true);
+ }
+
+ /**
+ * Returns true
if the given library matches the dependency.
+ * true
if the given library matches the dependency
+ * @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 dependency to match the library.
+ *
+ * @return true
if the exactly the same version are required
+ * by the dependency to match the library
+ */
+ public boolean isExactMatch() {
+ return exactMatch;
+ }
+
+ /**
+ * @{@inheritDoc}
+ *
+ * Dependencies 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 ServerLibraryDependency other = (ServerLibraryDependency) 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}
+ * 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;
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ 5eda48228ef2 Fri Jun 11 10:20:14 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);
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ 5eda48228ef2 Fri Jun 11 10:20:14 2010 +0200
@@ -0,0 +1,107 @@
+/*
+ * 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
.
+ * null
+ */
+ @CheckForNull
+ String getSpecificationTitle();
+
+ /**
+ * Returns the implementation title of the library. May return
+ * null
.
+ * 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 library name. May return null
.
+ *
+ * @return the library name; may return null
+ */
+ @CheckForNull
+ String getName();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ 5eda48228ef2 Fri Jun 11 10:20:14 2010 +0200
@@ -0,0 +1,87 @@
+/*
+ * 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 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.ServerLibraryDependency;
+
+/**
+ * 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