diff -r 3a3c32bf146f -r d075b556b189 glassfish.common/src/org/netbeans/modules/glassfish/spi/Utils.java
--- a/glassfish.common/src/org/netbeans/modules/glassfish/spi/Utils.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.common/src/org/netbeans/modules/glassfish/spi/Utils.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 2009-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2009-2015 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.
@@ -61,8 +61,9 @@
import org.openide.filesystems.FileUtil;
/**
- *
- * @author vbk
+ * Utilities.
+ *
+ * @author Vince Kraemer
*/
public class Utils {
@@ -416,7 +417,7 @@
/**
* Use the server instance id for a project to decide whether the server specific DD/resource
- * file should use the glassfish- prefix.
+ * file should use the {@code glassfish-} prefix.
*
* @param serverInstanceID
* @return
diff -r 3a3c32bf146f -r d075b556b189 glassfish.eecommon/nbproject/project.xml
--- a/glassfish.eecommon/nbproject/project.xml Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.eecommon/nbproject/project.xml Tue Mar 17 16:39:16 2015 +0100
@@ -219,6 +219,13 @@
org.netbeans.modules.projectapi.nb
+
+ org.netbeans.modules.nbjunit
+
+
+
+ org.netbeans.insane
+
diff -r 3a3c32bf146f -r d075b556b189 glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/GlassfishConfiguration.java
--- a/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/GlassfishConfiguration.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/GlassfishConfiguration.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 2008-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2008-2015 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.
@@ -42,7 +42,6 @@
package org.netbeans.modules.glassfish.eecommon.api.config;
-import org.netbeans.modules.glassfish.eecommon.api.*;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -54,6 +53,10 @@
import java.util.logging.Logger;
import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
+import org.netbeans.modules.glassfish.eecommon.api.Utils;
+import org.netbeans.modules.glassfish.eecommon.api.XmlFileCreator;
+import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
+import org.netbeans.modules.glassfish.tooling.utils.OsUtils;
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;
@@ -89,37 +92,217 @@
import org.openide.util.RequestProcessor;
/**
- * Basic j2eeserver configuration api support for V2 and V3 plugins
- *
- * @author Peter Williams
+ * Basic Java EE server configuration API support for V2, V3 and V4 plugins.
+ *
+ * @author Peter Williams, Tomas Kraus
*/
public abstract class GlassfishConfiguration implements
ContextRootConfiguration,
EjbResourceConfiguration,
MessageDestinationConfiguration,
- DatasourceConfiguration
- {
+ DatasourceConfiguration {
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Class attributes //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /** GlassFish Java EE common module Logger. */
+ private static final Logger LOGGER = Logger.getLogger("glassfish-eecommon");
+
+ /** GlassFish resource file suffix is {@code .xml}. */
+ private static final String RESOURCE_FILES_SUFFIX = ".xml";
+
+ /** List of base file names containing server resources:
+ * [0] points to current name used since GlassFich v3.
+ * [1] points to old name used before GlassFich v3.
+ * */
+ static final String[] RESOURCE_FILES = {
+ "glassfish-resources" + RESOURCE_FILES_SUFFIX,
+ "sun-resources" + RESOURCE_FILES_SUFFIX
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Static methods //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Create resource file path fragment for given Java EE module.
+ * Internal helper method.
+ *
+ * @param module Java EE module (project).
+ * @param fileName Resources file name.
+ * @return Resource file path fragment for given Java EE module.
+ */
+ private static String resourceFilePath(final J2eeModule module,final String fileName) {
+ String configDir = JavaEEModule.getConfigDir(module.getType());
+ if (configDir == null) {
+ throw new IllegalArgumentException("Unknown Java EE module type.");
+ }
+ return OsUtils.joinPaths(configDir, fileName);
+ }
+
+ /**
+ * Get existing {@code RESOURCE_FILES} array indexes for provided GlassFish
+ * server version.
+ *
+ * Internal {@link #getExistingResourceFile(J2eeModule, GlassFishVersion)
+ * helper method.
+ *
+ * @param version GlassFish server version.
+ * @return An array of {@code RESOURCE_FILES} array indexes pointing
+ * to resource files to search for.
+ */
+ private static int[] versionToResourceFilesIndexes(
+ final GlassFishVersion version) {
+ // All files for unknown version.
+ if (version == null) {
+ return new int[]{0,1};
+ }
+ // glassfish-resources.xml for v4
+ if (GlassFishVersion.ge(version, GlassFishVersion.GF_4)) {
+ return new int[]{0};
+ }
+ // glassfish-resources.xml and sun-resources.xml for v3
+ if (GlassFishVersion.ge(version, GlassFishVersion.GF_3_1)) {
+ return new int[]{0,1};
+ // sun-resources.xml for older
+ } else {
+ return new int[]{1};
+ }
+ }
+
+ /**
+ * Get new {@code RESOURCE_FILES} array index for provided GlassFish
+ * server version.
+ *
+ * @param version GlassFish server version.
+ * @return An {@code RESOURCE_FILES} array index pointing
+ * to resource file to be created.
+ */
+ private static int versionToNewResourceFilesIndex(
+ final GlassFishVersion version) {
+ // glassfish-resources.xml is returned for versions 3.1 and higher
+ // or as default for unknown version.
+ if (version == null
+ || GlassFishVersion.ge(version, GlassFishVersion.GF_3_1)) {
+ return 0;
+ // sun-resources.xml is returned for versions before 3.1
+ } else {
+ return 1;
+ }
+ }
+
+ /**
+ * Get existing GlassFish resources file name.
+ * GlassFish resources file depends on server version and used storage.
+ * GlassFish v3 supports old {@code sun-resources.xml} together with new
+ * {@code glassfish-resources.xml}. GlassFish v4 supports only
+ * new {@code glassfish-resources.xml} file.
+ * Those files can be found in server configuration directory (to be included
+ * into target project archive) or in server resources directory (won't be
+ * included into target project archive).
+ * Search works with following priorities:
+ * GlassFish v2: Only {@code sun-resources.xml} is checked.
+ * GlassFish v3: {@code glassfish-resources.xml} is checked first,
+ * {@code sun-resources.xml} as fallback.
+ * GlassFish v4: Only {@code glassfish-resources.xml} is checked.
+ * Configuration directory is checked first, resources directory
+ * as fallback.
+ *
+ *
+ * @param module Java EE module (project).
+ * @param version Resources file names depend on GlassFish server version.
+ * @return Existing GlassFish resources file or {@code null} when no resources
+ * file was found.
+ */
+ public static final File getExistingResourceFile(
+ final J2eeModule module, final GlassFishVersion version) {
+ // RESOURCE_FILES indexes to search for.
+ final int[] indexes = versionToResourceFilesIndexes(version);
+ for (int index : indexes) {
+ // Check configuration directory first.
+ final String name = resourceFilePath(module, RESOURCE_FILES[index]);
+ File file = module.getDeploymentConfigurationFile(name);
+ if (file != null && file.isFile() && file.canRead()) {
+ return file;
+ }
+ // Check resiources directory as a fallback.
+ file = new File(module.getResourceDirectory(), RESOURCE_FILES[index]);
+ if (file.isFile() && file.canRead()) {
+ return file;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get new GlassFish resources file name for creation.
+ *
+ * @param module Java EE module (project).
+ * @param version Resources file names depend on GlassFish server version.
+ * @return GlassFish resources file to be created.
+ */
+ public static final File getNewResourceFile(
+ final J2eeModule module, final GlassFishVersion version) {
+ final int index = versionToNewResourceFilesIndex(version);
+ final String name = resourceFilePath(module, RESOURCE_FILES[index]);
+ return module.getDeploymentConfigurationFile(name);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Instance attributes //
+ ////////////////////////////////////////////////////////////////////////////
protected final J2eeModule module;
protected final J2eeModuleHelper moduleHelper;
protected final File primarySunDD;
protected final File secondarySunDD;
protected DescriptorListener descriptorListener;
-
+ /** GlassFish server version. */
+ protected GlassFishVersion version;
private ASDDVersion appServerVersion;
private ASDDVersion minASVersion;
private ASDDVersion maxASVersion;
private boolean deferredAppServerChange;
private final String defaultcr;
+ ////////////////////////////////////////////////////////////////////////////
+ // Constructors //
+ ////////////////////////////////////////////////////////////////////////////
- protected GlassfishConfiguration(J2eeModule module) throws ConfigurationException {
- this(module, J2eeModuleHelper.getSunDDModuleHelper(module.getType()));
+ /**
+ * Creates an instance of Java EE server configuration API support.
+ * {@link J2eeModuleHelper} instance is added depending on Java EE module type.
+ *
+ * @param module Java EE module (project).
+ * @param version GlassFish server version.
+ * @throws ConfigurationException when there is a problem with Java EE server
+ * configuration initialization.
+ */
+ protected GlassfishConfiguration(
+ final J2eeModule module, final GlassFishVersion version
+ ) throws ConfigurationException {
+ this(module, J2eeModuleHelper.getSunDDModuleHelper(module.getType()), version);
}
- protected GlassfishConfiguration(J2eeModule module, J2eeModuleHelper moduleHelper) throws ConfigurationException {
+ /**
+ * Creates an instance of Java EE server configuration API support with existing
+ * {@link J2eeModuleHelper} instance.
+ *
+ * @param module Java EE module (project).
+ * @param moduleHelper Already existing {@link J2eeModuleHelper} instance.
+ * @param version GlassFish server version.
+ * @throws ConfigurationException when there is a problem with Java EE server
+ * configuration initialization.
+ */
+ @SuppressWarnings("LeakingThisInConstructor")
+ protected GlassfishConfiguration(
+ final J2eeModule module, final J2eeModuleHelper moduleHelper,
+ final GlassFishVersion version
+ ) throws ConfigurationException {
this.module = module;
this.moduleHelper = moduleHelper;
+ this.version = version;
if(moduleHelper != null) {
this.primarySunDD = moduleHelper.getPrimarySunDDFile(module);
this.secondarySunDD = moduleHelper.getSecondarySunDDFile(module);
@@ -210,6 +393,10 @@
throw new UnsupportedOperationException("JSR-88 configuration not supported.");
}
+ ////////////////////////////////////////////////////////////////////////////
+ // Methods //
+ ////////////////////////////////////////////////////////////////////////////
+
public void dispose() {
if(descriptorListener != null) {
descriptorListener.removeListeners();
@@ -218,7 +405,7 @@
GlassfishConfiguration storedCfg = getConfiguration(primarySunDD);
if (storedCfg != this) {
- Logger.getLogger("glassfish-eecommon").log(Level.INFO,
+ LOGGER.log(Level.INFO,
"Stored DeploymentConfiguration ({0}) instance not the one being disposed of ({1}).",
new Object[]{storedCfg, this});
}
@@ -232,7 +419,8 @@
// Appserver version support
// ------------------------------------------------------------------------
private ASDDVersion computeMinASVersion(String j2eeModuleVersion) {
- return moduleHelper.getMinASVersion(j2eeModuleVersion, ASDDVersion.SUN_APPSERVER_7_0);
+ return moduleHelper.getMinASVersion(
+ j2eeModuleVersion, ASDDVersion.SUN_APPSERVER_7_0);
}
private ASDDVersion computeMaxASVersion() {
@@ -244,8 +432,9 @@
result = ASDDVersion.SUN_APPSERVER_10_1;
else
result = ASDDVersion.SUN_APPSERVER_10_0;
- Logger.getLogger("glassfish-eecommon").log(Level.WARNING, NbBundle.getMessage(
- GlassfishConfiguration.class, "ERR_UnidentifiedTargetServer", result.toString())); // NOI18N
+ LOGGER.log(Level.WARNING,
+ NbBundle.getMessage(GlassfishConfiguration.class,
+ "ERR_UnidentifiedTargetServer", result.toString())); // NOI18N
}
return result;
}
@@ -353,10 +542,10 @@
}
} catch (IndexOutOfBoundsException ex) {
// Can't identify server install folder.
- Logger.getLogger("glassfish-eecommon").log(Level.WARNING, NbBundle.getMessage(
+ LOGGER.log(Level.WARNING, NbBundle.getMessage(
GlassfishConfiguration.class, "ERR_NoServerInstallLocation", instance)); // NOI18N
} catch (NullPointerException ex) {
- Logger.getLogger("glassfish-eecommon").log(Level.INFO, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.INFO, ex.getLocalizedMessage(), ex);
}
}
} else if ("SUNWebserver7".equals(serverType)) {
@@ -634,12 +823,12 @@
}
}
} catch (IOException ex) {
- Logger.getLogger("glassfish-eecommon").log(Level.WARNING, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.WARNING, ex.getLocalizedMessage(), ex);
String defaultMessage = " retrieving context-root from sun-web.xml";
displayError(ex, defaultMessage);
}
} else {
- Logger.getLogger("glassfish-eecommon").log(Level.WARNING,
+ LOGGER.log(Level.WARNING,
"GlassfishConfiguration.getContextRoot() invoked on incorrect module type: {0}",
module.getType());
}
@@ -671,11 +860,11 @@
}
}
} catch (IOException ex) {
- Logger.getLogger("glassfish-eecommon").log(Level.INFO, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.INFO, ex.getLocalizedMessage(), ex);
String defaultMessage = " trying set context-root in sun-web.xml";
displayError(ex, defaultMessage);
} catch (Exception ex) {
- Logger.getLogger("glassfish-eecommon").log(Level.INFO, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.INFO, ex.getLocalizedMessage(), ex);
String defaultMessage = " trying set context-root in sun-web.xml";
displayError(ex, defaultMessage);
}
@@ -703,11 +892,11 @@
}
}
} catch (IOException ex) {
- Logger.getLogger("glassfish-eecommon").log(Level.INFO, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.INFO, ex.getLocalizedMessage(), ex);
String defaultMessage = " trying set context-root in sun-web.xml";
displayError(ex, defaultMessage);
} catch (Exception ex) {
- Logger.getLogger("glassfish-eecommon").log(Level.INFO, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.INFO, ex.getLocalizedMessage(), ex);
String defaultMessage = " trying set context-root in sun-web.xml";
displayError(ex, defaultMessage);
}
@@ -715,7 +904,7 @@
});
}
} else {
- Logger.getLogger("glassfish-eecommon").log(Level.WARNING, // NOI18N
+ LOGGER.log(Level.WARNING, // NOI18N
"GlassfishConfiguration.setContextRoot() invoked on incorrect module type: {0}", // NOI18N
module.getType());
}
@@ -988,7 +1177,7 @@
return;
}
} catch(NumberFormatException ex) {
- Logger.getLogger("glassfish-eecommon").log(Level.WARNING, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.WARNING, ex.getLocalizedMessage(), ex);
}
try {
@@ -1049,7 +1238,7 @@
return;
}
} catch(NumberFormatException ex) {
- Logger.getLogger("glassfish-eecommon").log(Level.WARNING, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.WARNING, ex.getLocalizedMessage(), ex);
}
try {
@@ -1384,7 +1573,7 @@
rootDD.write(outputStream);
}
} else {
- Logger.getLogger("glassfish-eecommon").log(Level.WARNING,
+ LOGGER.log(Level.WARNING,
"Deployment plan not supported in GlassfishConfiguration.save()");
}
} catch(Exception ex) {
@@ -1480,7 +1669,7 @@
// writing the changed descriptor to disk.
// !PW FIXME notify user
// RR = could do handleEventRelatedException(ex) instead
- Logger.getLogger("glassfish-eecommon").log(Level.INFO, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.INFO, ex.getLocalizedMessage(), ex);
}
protected void handleEventRelatedException(Exception ex) {
@@ -1488,7 +1677,7 @@
// must trap it here so it doesn't cause trouble upstream.
// We handle it the same as above for now.
// !PW FIXME should we notify here, or just log?
- Logger.getLogger("glassfish-eecommon").log(Level.INFO, ex.getLocalizedMessage(), ex);
+ LOGGER.log(Level.INFO, ex.getLocalizedMessage(), ex);
}
// ------------------------------------------------------------------------
diff -r 3a3c32bf146f -r d075b556b189 glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/J2eeModuleHelper.java
--- a/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/J2eeModuleHelper.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/J2eeModuleHelper.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 2010-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2010-2015 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.
@@ -57,21 +57,23 @@
import org.openide.filesystems.FileUtil;
/**
- *
- * @author Peter Williams
+ * Java EE module helper.
+ *
+ * @author Peter Williams, Tomas Kraus
*/
public abstract class J2eeModuleHelper {
/** Web application meta data directory. */
- public static final String WEB_INF = "WEB-INF";
+ public static final String WEB_INF = JavaEEModule.WEB_INF;
- /** GlassFish specific meta data file for version 1 and 2. */
+ /** GlassFish specific meta data file for version since version 3.1. */
+ public static final String GF_WEB_XML_V2
+ = WEB_INF + File.separatorChar + GlassfishConfiguration.RESOURCE_FILES[0];
+
+ /** GlassFish specific meta data file for version 1, 2 and 3.0. */
public static final String GF_WEB_XML_V1
- = WEB_INF + File.separatorChar + "sun-web.xml";
+ = WEB_INF + File.separatorChar + GlassfishConfiguration.RESOURCE_FILES[1];
- /** GlassFish specific meta data file for version 3 and 4. */
- public static final String GF_WEB_XML_V2
- = WEB_INF + File.separatorChar + "glassfish-web.xml";
private static final Map helperMap;
private static final Map gfhelperMap;
diff -r 3a3c32bf146f -r d075b556b189 glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/JavaEEModule.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/JavaEEModule.java Tue Mar 17 16:39:16 2015 +0100
@@ -0,0 +1,185 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2015 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 2015 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.glassfish.eecommon.api.config;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+import javax.enterprise.deploy.shared.ModuleType;
+import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
+
+// This is J2eeModule.Type rewritten as Enum. I could not modify original class
+// because it's API.
+/**
+ * Java EE module types.
+ *
+ * @author Tomas Kraus
+ */
+public enum JavaEEModule {
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Enum values //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /** Client application archive. */
+ CAR(ModuleType.CAR),
+ /** Enterprise application archive */
+ EAR(ModuleType.EAR),
+ /** Enterprise Java bean archive. */
+ EJB(ModuleType.EJB),
+ /** Connector archive. */
+ RAR(ModuleType.RAR),
+ /** Web application archive. */
+ WAR(ModuleType.WAR);
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Class attributes //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /** GlassFish Java EE common module Logger. */
+ private static final Logger LOGGER = Logger.getLogger("glassfish-eecommon");
+
+ /** JavaEEModule version enumeration length. */
+ public static final int length = JavaEEModule.values().length;
+
+ /** Name of web application configuration directory. */
+ public static final String WEB_INF = "WEB-INF";
+
+ /** Name of java archive manifest directory. */
+ public static final String META_INF = "META-INF";
+
+ /** {@link J2eeModule.Type} to {@link JavaEEModule} conversion map. */
+ private static final Map j2eeModuleTypeToValue
+ = new HashMap(2*length);
+
+ // Initialize J2eeModule.Type to JavaEEModule conversion map.
+ static {
+ j2eeModuleTypeToValue.put(J2eeModule.Type.CAR, CAR);
+ j2eeModuleTypeToValue.put(J2eeModule.Type.EAR, EAR);
+ j2eeModuleTypeToValue.put(J2eeModule.Type.EJB, EJB);
+ j2eeModuleTypeToValue.put(J2eeModule.Type.RAR, RAR);
+ j2eeModuleTypeToValue.put(J2eeModule.Type.WAR, WAR);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Static methods //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Get Java EE module configuration directory (e.g. {@code "META-INF"}).
+ * This is just {@link J2eeModule.Type} shortcut.
+ *
+ * @param type {@link J2eeModule.Type} instance of Java EE module type.
+ * @return Java EE module configuration directory for known Java EE
+ * module type or {@code null} when provided Java EE module type
+ * is not known.
+ */
+ public static final String getConfigDir(J2eeModule.Type type) {
+ JavaEEModule configDir = JavaEEModule.toValue(type);
+ return type != null ? configDir.getConfigDir() : null;
+ }
+
+ /**
+ * Convert {@link J2eeModule.Type} to {@link JavaEEModule}.
+ *
+ * @param type {@link ModuleType} value to be converted.
+ * @return {@link J2eeModule.Type} value corresponding to provided
+ * {@link ModuleType} value.
+ */
+ @SuppressWarnings("deprecation")
+ public static JavaEEModule toValue(final J2eeModule.Type type) {
+ return j2eeModuleTypeToValue.get(type);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Instance attributes //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /** Java EE module type. */
+ private final ModuleType moduleType;
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Constructors //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Creates an instance of Java EE module type.
+ *
+ * @param moduleType Java EE module type.
+ */
+ private JavaEEModule(final ModuleType moduleType) {
+ this.moduleType = moduleType;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Methods //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Get stored {@link ModuleType} value.
+ *
+ * @return Stored {@link ModuleType} value.
+ */
+ private ModuleType getModuleType() {
+ return moduleType;
+ }
+
+ /**
+ * Get Java EE module configuration directory (e.g. {@code "META-INF"}).
+ *
+ * @return Java EE module configuration directory.
+ */
+ public String getConfigDir() {
+ switch (this) {
+ case CAR:
+ case EAR:
+ case EJB:
+ case RAR:
+ return META_INF;
+ case WAR:
+ return WEB_INF;
+ default:
+ throw new IllegalArgumentException("Unknown Java EE module type.");
+ }
+ }
+
+}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.eecommon/test/unit/src/org/netbeans/modules/glassfish/eecommon/api/config/GFTestEEModuleImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/glassfish.eecommon/test/unit/src/org/netbeans/modules/glassfish/eecommon/api/config/GFTestEEModuleImpl.java Tue Mar 17 16:39:16 2015 +0100
@@ -0,0 +1,138 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2015 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 2015 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.glassfish.eecommon.api.config;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collections;
+import java.util.Iterator;
+import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
+import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleImplementation2;
+import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+/**
+ * Java EE module for GlassFish features tests.
+ *
+ * @author Tomas Kraus
+ */
+public class GFTestEEModuleImpl implements J2eeModuleImplementation2 {
+
+ private final FileObject appRoot;
+ private final File srcDir;
+ private final File configDir;
+ private final J2eeModule.Type moduleType;
+ private final String moduleVersion;
+
+ /** Creates a new instance of TestJ2eeModule
+ * @param appRoot Application root directory.
+ * @param moduleType Java EE module type.
+ * @param moduleVersion Java EE version.
+ */
+ public GFTestEEModuleImpl(
+ final FileObject appRoot, final J2eeModule.Type moduleType,
+ final String moduleVersion
+ ) {
+ this.appRoot = appRoot;
+ this.srcDir = new File(FileUtil.toFile(appRoot), "src");
+ this.configDir = new File(srcDir, "conf");
+ this.moduleType = moduleType;
+ this.moduleVersion = moduleVersion;
+ }
+
+ @Override
+ public FileObject getArchive() {
+ return null;
+ }
+
+ @Override
+ public Iterator getArchiveContents() {
+ return Collections.emptySet().iterator();
+ }
+
+ @Override
+ public FileObject getContentDirectory() {
+ return appRoot;
+ }
+
+ @Override
+ public J2eeModule.Type getModuleType() {
+ return moduleType;
+ }
+
+ @Override
+ public String getModuleVersion() {
+ return moduleVersion;
+ }
+
+ @Override
+ public String getUrl() {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ @Override
+ public File getResourceDirectory() {
+ return new File(FileUtil.toFile(appRoot), "setup");
+ }
+
+ @Override
+ public File getDeploymentConfigurationFile(String name) {
+ return new File(configDir, name);
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ @Override
+ public MetadataModel getMetadataModel(Class type) {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.eecommon/test/unit/src/org/netbeans/modules/glassfish/eecommon/api/config/GlassfishConfigurationTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/glassfish.eecommon/test/unit/src/org/netbeans/modules/glassfish/eecommon/api/config/GlassfishConfigurationTest.java Tue Mar 17 16:39:16 2015 +0100
@@ -0,0 +1,304 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2015 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 2015 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.glassfish.eecommon.api.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.netbeans.api.j2ee.core.Profile;
+import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
+import org.netbeans.modules.glassfish.tooling.utils.OsUtils;
+import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
+import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleFactory;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+/**
+ * GlassFish Java EE server configuration API support tests.
+ *
+ * @author Tomas Kraus
+ */
+public class GlassfishConfigurationTest extends NbTestCase {
+
+ private GFTestEEModuleImpl moduleImplCar;
+ private J2eeModule moduleCar;
+ private GFTestEEModuleImpl moduleImplEjb;
+ private J2eeModule moduleEjb;
+ private GFTestEEModuleImpl moduleImplEar;
+ private J2eeModule moduleEar;
+ private GFTestEEModuleImpl moduleImplWar;
+ private J2eeModule moduleWar;
+ private GFTestEEModuleImpl moduleImplRar;
+ private J2eeModule moduleRar;
+
+ public GlassfishConfigurationTest(final String testName) {
+ super(testName);
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ final File dataDir = getDataDir();
+ final File rootFolder = new File(dataDir, "gfsample");
+ rootFolder.mkdirs();
+ final FileObject rootFolderFO = FileUtil.toFileObject(rootFolder);
+ moduleImplCar = new GFTestEEModuleImpl(
+ rootFolderFO, J2eeModule.Type.CAR, Profile.JAVA_EE_7_FULL.toPropertiesString());
+ moduleCar = J2eeModuleFactory.createJ2eeModule(moduleImplCar);
+ moduleImplEjb = new GFTestEEModuleImpl(
+ rootFolderFO, J2eeModule.Type.EJB, Profile.JAVA_EE_7_FULL.toPropertiesString());
+ moduleEjb = J2eeModuleFactory.createJ2eeModule(moduleImplEjb);
+ moduleImplEar = new GFTestEEModuleImpl(
+ rootFolderFO, J2eeModule.Type.EAR, Profile.JAVA_EE_7_FULL.toPropertiesString());
+ moduleEar = J2eeModuleFactory.createJ2eeModule(moduleImplEar);
+ moduleImplRar = new GFTestEEModuleImpl(
+ rootFolderFO, J2eeModule.Type.RAR, Profile.JAVA_EE_7_FULL.toPropertiesString());
+ moduleRar = J2eeModuleFactory.createJ2eeModule(moduleImplRar);
+ moduleImplWar = new GFTestEEModuleImpl(
+ rootFolderFO, J2eeModule.Type.WAR, Profile.JAVA_EE_7_WEB.toPropertiesString());
+ moduleWar = J2eeModuleFactory.createJ2eeModule(moduleImplWar);
+ }
+
+ @After
+ @Override
+ public void tearDown() {
+ // Pass everything to GC.
+ moduleImplCar = null;
+ moduleCar = null;
+ moduleImplEjb = null;
+ moduleEjb = null;
+ moduleImplEar = null;
+ moduleEar = null;
+ moduleImplRar = null;
+ moduleRar = null;
+ moduleImplWar = null;
+ moduleWar = null;
+ }
+
+ /**
+ * Test Java EE module directory structure for resource file.
+ * @throws NoSuchMethodException when there is a problem with reflection.
+ * @throws IllegalAccessException when there is a problem with reflection.
+ * @throws IllegalArgumentException when there is a problem with reflection.
+ * @throws InvocationTargetException when there is a problem with reflection.
+ */
+ @Test
+ public void testResourceFilePath()
+ throws NoSuchMethodException, IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException {
+ final Method resourceFilePath = GlassfishConfiguration.class.getDeclaredMethod(
+ "resourceFilePath", J2eeModule.class, String.class);
+ resourceFilePath.setAccessible(true);
+
+ final String pathFragment = "myDirectory";
+ final String verifyConfigDirCar = OsUtils.joinPaths(JavaEEModule.META_INF, pathFragment);
+ final String verifyConfigDirEjb = OsUtils.joinPaths(JavaEEModule.META_INF, pathFragment);
+ final String verifyConfigDirEar = OsUtils.joinPaths(JavaEEModule.META_INF, pathFragment);
+ final String verifyConfigDirRar = OsUtils.joinPaths(JavaEEModule.META_INF, pathFragment);
+ final String verifyConfigDirWar = OsUtils.joinPaths(JavaEEModule.WEB_INF, pathFragment);
+ final String configDirCar = (String)resourceFilePath.invoke(null, moduleCar, pathFragment);
+ final String configDirEjb = (String)resourceFilePath.invoke(null, moduleEjb, pathFragment);
+ final String configDirEar = (String)resourceFilePath.invoke(null, moduleEar, pathFragment);
+ final String configDirRar = (String)resourceFilePath.invoke(null, moduleRar, pathFragment);
+ final String configDirWar = (String)resourceFilePath.invoke(null, moduleWar, pathFragment);
+ assertEquals("Expected resource file path for CAR is: " + verifyConfigDirCar,
+ verifyConfigDirCar, configDirCar);
+ assertEquals("Expected resource file path for EJB is: " + verifyConfigDirEjb,
+ verifyConfigDirEjb, configDirEjb);
+ assertEquals("Expected resource file path for EAR is: " + verifyConfigDirEar,
+ verifyConfigDirEar, configDirEar);
+ assertEquals("Expected resource file path for RAR is: " + verifyConfigDirRar,
+ verifyConfigDirRar, configDirRar);
+ assertEquals("Expected resource file path for WAR is: " + verifyConfigDirWar,
+ verifyConfigDirWar, configDirWar);
+ }
+
+ /**
+ * Test new GlassFish resources file name generation depending on passed {@link GlassFishVersion}.
+ * Expected values are:
+ * PREFIX/src/conf/META_INF/sun-resources.xml for CAR, EAR, EJB and RAR
+ * on GlassFish older than 3.1
+ * PREFIX/src/conf/META_INF/sun-resources.xml for CAR, EAR, EJB and RAR
+ * on GlassFish 3.1 and later
+ * PREFIX/src/conf/WEB_INF/sun-resources.xml for WAR on GlassFish older than 3.1
+ * PREFIX/src/conf/WEB_INF/sun-resources.xml for WAR on GlassFish 3.1 and later
+ */
+ @Test
+ public void testGetNewResourceFile() {
+ for (GlassFishVersion version : GlassFishVersion.values()) {
+ final File resourceFileCar = GlassfishConfiguration.getNewResourceFile(moduleCar, version);
+ final File resourceFileEar = GlassfishConfiguration.getNewResourceFile(moduleEar, version);
+ final File resourceFileEjb = GlassfishConfiguration.getNewResourceFile(moduleEjb, version);
+ final File resourceFileRar = GlassfishConfiguration.getNewResourceFile(moduleRar, version);
+ final File resourceFileWar = GlassfishConfiguration.getNewResourceFile(moduleWar, version);
+ final File verifyPrefixCar = moduleCar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleCar.getType()));
+ final File verifyPrefixEar = moduleEar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleEar.getType()));
+ final File verifyPrefixEjb = moduleEjb.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleEjb.getType()));
+ final File verifyPrefixRar = moduleRar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleRar.getType()));
+ final File verifyPrefixWar = moduleWar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleWar.getType()));
+ final String fileName = GlassFishVersion.lt(version, GlassFishVersion.GF_3_1)
+ ? "sun-resources.xml"
+ : "glassfish-resources.xml";
+ final File verifyFileCar = new File(verifyPrefixCar, fileName);
+ final File verifyFileEar = new File(verifyPrefixEar, fileName);
+ final File verifyFileEjb = new File(verifyPrefixEjb, fileName);
+ final File verifyFileRar = new File(verifyPrefixRar, fileName);
+ final File verifyFileWar = new File(verifyPrefixWar, fileName);
+ assertTrue("New resource file for " + version.toString() + " CAR: " + verifyFileCar.toString(),
+ verifyFileCar.equals(resourceFileCar));
+ assertTrue("New resource file for " + version.toString() + " EAR: " + verifyFileEar.toString(),
+ verifyFileEar.equals(resourceFileEar));
+ assertTrue("New resource file for " + version.toString() + " EJB: " + verifyFileEjb.toString(),
+ verifyFileEjb.equals(resourceFileEjb));
+ assertTrue("New resource file for " + version.toString() + " RAR: " + verifyFileRar.toString(),
+ verifyFileRar.equals(resourceFileRar));
+ assertTrue("New resource file for " + version.toString() + " WAR: " + verifyFileWar.toString(),
+ verifyFileWar.equals(resourceFileWar));
+ }
+ }
+
+
+ /**
+ * Verify that proper resource file from Java EE module is returned.
+ * Both {@code sun-resources.xml} and {@code glassfish-resources.xml} are available
+ * in Java EE module configuration directory on the disk.
+ * Expected values are:
+ * PREFIX/src/conf/META_INF/sun-resources.xml for CAR, EAR, EJB and RAR
+ * on GlassFish older than 3.1
+ * PREFIX/src/conf/META_INF/sun-resources.xml for CAR, EAR, EJB and RAR
+ * on GlassFish 3.1 and later
+ * PREFIX/src/conf/WEB_INF/sun-resources.xml for WAR on GlassFish older than 3.1
+ * PREFIX/src/conf/WEB_INF/sun-resources.xml for WAR on GlassFish 3.1 and later
+ */
+ @Test
+ public void testGetExistingResourceFile() throws IOException {
+ final File prefixCar = moduleCar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleCar.getType()));
+ final File prefixEar = moduleEar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleEar.getType()));
+ final File prefixEjb = moduleEjb.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleEjb.getType()));
+ final File prefixRar = moduleRar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleRar.getType()));
+ final File prefixWar = moduleWar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleWar.getType()));
+ final Set prefixes = new HashSet(5);
+ prefixes.add(prefixCar);
+ prefixes.add(prefixEar);
+ prefixes.add(prefixEjb);
+ prefixes.add(prefixRar);
+ prefixes.add(prefixWar);
+ // Create all resource files (they are empty but it's enough for this test).
+ for (File prefix : prefixes) {
+ final File sunResource = new File(prefix, "sun-resources.xml");
+ final File gfResource = new File(prefix, "glassfish-resources.xml");
+ prefix.mkdirs();
+ sunResource.createNewFile();
+ gfResource.createNewFile();
+ }
+ for (GlassFishVersion version : GlassFishVersion.values()) {
+ File resourcesCar = GlassfishConfiguration.getExistingResourceFile(moduleCar, version);
+ File resourcesEar = GlassfishConfiguration.getExistingResourceFile(moduleEar, version);
+ File resourcesEjb = GlassfishConfiguration.getExistingResourceFile(moduleEjb, version);
+ File resourcesRar = GlassfishConfiguration.getExistingResourceFile(moduleRar, version);
+ File resourcesWar = GlassfishConfiguration.getExistingResourceFile(moduleWar, version);
+ final File verifyPrefixCar = moduleCar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleCar.getType()));
+ final File verifyPrefixEar = moduleEar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleEar.getType()));
+ final File verifyPrefixEjb = moduleEjb.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleEjb.getType()));
+ final File verifyPrefixRar = moduleRar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleRar.getType()));
+ final File verifyPrefixWar = moduleWar.getDeploymentConfigurationFile(
+ JavaEEModule.getConfigDir(moduleWar.getType()));
+ final String fileName = GlassFishVersion.lt(version, GlassFishVersion.GF_3_1)
+ ? "sun-resources.xml"
+ : "glassfish-resources.xml";
+ final File verifyFileCar = new File(verifyPrefixCar, fileName);
+ final File verifyFileEar = new File(verifyPrefixEar, fileName);
+ final File verifyFileEjb = new File(verifyPrefixEjb, fileName);
+ final File verifyFileRar = new File(verifyPrefixRar, fileName);
+ final File verifyFileWar = new File(verifyPrefixWar, fileName);
+ assertTrue("Existing resource file for " + version.toString() + " CAR: " + verifyFileCar.toString(),
+ verifyFileCar.equals(resourcesCar));
+ assertTrue("Existing resource file for " + version.toString() + " EAR: " + verifyFileEar.toString(),
+ verifyFileEar.equals(resourcesEar));
+ assertTrue("Existing resource file for " + version.toString() + " EJB: " + verifyFileEjb.toString(),
+ verifyFileEjb.equals(resourcesEjb));
+ assertTrue("Existing resource file for " + version.toString() + " RAR: " + verifyFileRar.toString(),
+ verifyFileRar.equals(resourcesRar));
+ assertTrue("Existing resource file for " + version.toString() + " WAR: " + verifyFileWar.toString(),
+ verifyFileWar.equals(resourcesWar));
+ }
+ // Delete all resource files.
+ for (File prefix : prefixes) {
+ final File sunResource = new File(prefix, "sun-resources.xml");
+ final File gfResource = new File(prefix, "glassfish-resources.xml");
+ sunResource.delete();
+ gfResource.delete();
+ }
+ }
+
+}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/AbstractHk2ConfigurationFactory.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/AbstractHk2ConfigurationFactory.java Tue Mar 17 16:39:16 2015 +0100
@@ -0,0 +1,152 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2015 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 2015 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.glassfish.javaee;
+
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.modules.glassfish.common.GlassfishInstance;
+import org.netbeans.modules.glassfish.common.GlassfishInstanceProvider;
+import org.netbeans.modules.glassfish.eecommon.api.config.J2eeModuleHelper;
+import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
+import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
+import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
+import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
+import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfigurationFactory2;
+
+/**
+ * Abstract factory to construct Java EE server configuration API support object.
+ *
+ * @author Vince Kraemer, Tomas Kraus
+ */
+abstract class AbstractHk2ConfigurationFactory implements ModuleConfigurationFactory2 {
+ /** Deployment manager. */
+ private final Hk2DeploymentManager hk2dm;
+
+ /**
+ * Creates a new instance of {@link GlassFishConfigurationFactory
+ */
+ AbstractHk2ConfigurationFactory(final Hk2DeploymentManager hk2dm) {
+ this.hk2dm = hk2dm;
+ }
+
+ /**
+ * Constructs proper module configuration object without having
+ * GlassFish server.
+ *
+ * Proper configuration object is selected depending on GlassFish specific
+ * web application meta data file (WEB-INFsun-web.xml
+ * or WEB-INF/glassfish-web.xml
) existence.
+ * GlassFish version 3.0 is passed to old module configuration object
+ * to rely on {@code sun-resources.xml} resource file.
+ * GlassFish version 3.1 is passed to new module configuration object
+ * to rely on {@code glassfish-resources.xml} resource file.
+ *
+ * @param module Java EE module.
+ * @return Module configuration object.
+ * @throws ConfigurationException if there is a problem with the server-specific
+ * configuration.
+ */
+ @Override
+ public ModuleConfiguration create(final J2eeModule module)
+ throws ConfigurationException {
+ ModuleConfiguration retVal = null;
+ try {
+ if (J2eeModuleHelper.isGlassFishWeb(module)) {
+ retVal = new ModuleConfigurationImpl(
+ module, new Three1Configuration(module, GlassFishVersion.GF_3_1), hk2dm);
+ } else {
+ retVal = new ModuleConfigurationImpl(
+ module, new Hk2Configuration(module, GlassFishVersion.GF_3), hk2dm);
+ }
+ } catch (ConfigurationException ce) {
+ throw ce;
+ } catch (Exception ex) {
+ throw new ConfigurationException(module.toString(), ex);
+ }
+ return retVal;
+ }
+
+ /**
+ * Constructs proper module configuration object depending on
+ * GlassFish server.
+ *
+ * Proper configuration object is selected depending on GlassFish version.
+ * Old module configuration object is created for server before version 3.1
+ * and new module configuration object for server version 3.1 and later.
+ *
+ * @param module Java EE module.
+ * @param instanceUrl GlassFish server internal URL.
+ * @return Module configuration object.
+ * @throws ConfigurationException if there is a problem with the server-specific
+ * configuration.
+ */
+ @Override
+ @SuppressWarnings("UseSpecificCatch")
+ public ModuleConfiguration create(final @NonNull J2eeModule module,
+ final @NonNull String instanceUrl) throws ConfigurationException {
+ ModuleConfiguration retVal = null;
+ final GlassfishInstance instance
+ = GlassfishInstanceProvider.getProvider()
+ .getGlassfishInstance(instanceUrl);
+ final GlassFishVersion version = instance != null
+ ? instance.getVersion() : null;
+ try {
+ final Hk2DeploymentManager dm = hk2dm != null
+ ? hk2dm
+ : (Hk2DeploymentManager) Hk2DeploymentFactory.createEe6()
+ .getDisconnectedDeploymentManager(instanceUrl);
+ if (version != null
+ && GlassFishVersion.ge(version, GlassFishVersion.GF_3_1)) {
+ retVal = new ModuleConfigurationImpl(
+ module, new Three1Configuration(module, version), dm);
+ } else {
+ retVal = new ModuleConfigurationImpl(
+ module, new Hk2Configuration(module, version), dm);
+ }
+ } catch (ConfigurationException ce) {
+ throw ce;
+ } catch (Exception ex) {
+ throw new ConfigurationException(module.toString(), ex);
+ }
+ return retVal;
+ }
+
+}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2Configuration.java
--- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2Configuration.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2Configuration.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 1997-2015 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.
@@ -57,6 +57,7 @@
import org.netbeans.modules.glassfish.eecommon.api.config.GlassfishConfiguration;
import org.netbeans.modules.glassfish.eecommon.api.config.J2eeModuleHelper;
import org.netbeans.modules.glassfish.javaee.db.Hk2DatasourceManager;
+import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
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;
@@ -65,18 +66,43 @@
import org.openide.util.NbBundle;
/**
- *
- * @author Ludovic Champenois
- * @author Peter Williams
+ * Java EE server configuration API support for GlassFish servers before 3.1.
+ * Covers GlassFish servers before 3.1. Old {@code sun-resources.xml} files are used.
+ *
+ * @author Ludovic Champenois, Peter Williams, Tomas Kraus
*/
public class Hk2Configuration extends GlassfishConfiguration implements DeploymentConfiguration {
- public Hk2Configuration(J2eeModule module) throws ConfigurationException {
- super(module);
+ /**
+ * Creates an instance of Java EE server configuration API support
+ * for GlassFish servers before 3.1.
+ *
+ * @param module Java EE module (project).
+ * @param version GlassFish server version.
+ * @throws ConfigurationException when there is a problem with Java EE server
+ * configuration initialization.
+ */
+ public Hk2Configuration(
+ final J2eeModule module, final GlassFishVersion version
+ ) throws ConfigurationException {
+ super(module, version);
}
- public Hk2Configuration(J2eeModule module, J2eeModuleHelper jmh) throws ConfigurationException {
- super(module, jmh);
+ /**
+ * Creates an instance of Java EE server configuration API support
+ * for GlassFish servers before 3.1 with existing {@link J2eeModuleHelper} instance.
+ *
+ * @param module Java EE module (project).
+ * @param moduleHelper Already existing {@link J2eeModuleHelper} instance.
+ * @param version GlassFish server version.
+ * @throws ConfigurationException when there is a problem with Java EE server
+ * configuration initialization.
+ */
+ public Hk2Configuration(
+ final J2eeModule module, final J2eeModuleHelper jmh,
+ final GlassFishVersion version
+ ) throws ConfigurationException {
+ super(module, jmh, version);
}
@Deprecated
@@ -88,8 +114,8 @@
// DatasourceConfiguration support
// ------------------------------------------------------------------------
@Override
- public Set getDatasources() throws org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException {
- return Hk2DatasourceManager.getDatasources(module.getResourceDirectory());
+ public Set getDatasources() throws ConfigurationException {
+ return Hk2DatasourceManager.getDatasources(module, version);
}
@Override
@@ -98,25 +124,20 @@
}
@Override
- public Datasource createDatasource(String jndiName, String url, String username, String password, String driver) throws UnsupportedOperationException, org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException, DatasourceAlreadyExistsException {
- File resourceDir = module.getResourceDirectory();
- if (resourceDir == null) {
- // Unable to create JDBC data source for resource ref.
-// postResourceError(NbBundle.getMessage(ModuleConfigurationImpl.class,
-// "ERR_NoRefJdbcDataSource", jndiName)); // NOI18N
- Logger.getLogger("glassfish-javaee").log(Level.WARNING, "Null Resource Folder");
- throw new ConfigurationException(NbBundle.getMessage(
- ModuleConfigurationImpl.class, "ERR_NoRefJdbcDataSource", jndiName)); // NOI18N
- }
-
- return Hk2DatasourceManager.createDataSource(jndiName, url, username, password, driver, resourceDir,"sun-resources");
+ public Datasource createDatasource(
+ final String jndiName, final String url, final String username,
+ final String password, final String driver
+ ) throws UnsupportedOperationException, ConfigurationException, DatasourceAlreadyExistsException {
+ return Hk2DatasourceManager.createDataSource(
+ jndiName, url, username, password, driver, module, version);
}
// ------------------------------------------------------------------------
// MessageDestinationConfiguration support
// ------------------------------------------------------------------------
@Override
- public Set getMessageDestinations() throws org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException {
+ public Set getMessageDestinations()
+ throws ConfigurationException {
return Hk2MessageDestinationManager.getMessageDestinations(module.getResourceDirectory(),"sun-resources");
}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2ModuleConfigFactory.java
--- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2ModuleConfigFactory.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2ModuleConfigFactory.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 1997-2015 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.
@@ -39,17 +39,8 @@
*
* Portions Copyrighted 2008 Sun Microsystems, Inc.
*/
-
package org.netbeans.modules.glassfish.javaee;
-import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
-import org.netbeans.api.annotations.common.NonNull;
-import org.netbeans.modules.glassfish.common.GlassfishInstance;
-import org.netbeans.modules.glassfish.common.GlassfishInstanceProvider;
-import org.netbeans.modules.glassfish.eecommon.api.config.J2eeModuleHelper;
-import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
-import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
-import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfigurationFactory2;
/**
@@ -57,86 +48,14 @@
*
* @author Vince Kraemer, Tomas Kraus
*/
-public class Hk2ModuleConfigFactory implements ModuleConfigurationFactory2 {
+public class Hk2ModuleConfigFactory extends AbstractHk2ConfigurationFactory
+implements ModuleConfigurationFactory2 {
- /** Creates a new instance of Hk2ModuleConfigFactory */
+ /**
+ * Creates a new instance of {@link Hk2ModuleConfigFactory}
+ */
public Hk2ModuleConfigFactory() {
+ super(null);
}
- /**
- * Constructs proper module configuration object without having
- * GlassFish server.
- *
- * Proper configuration object is selected depending on GlassFish specific
- * web application meta data file (WEB-INFsun-web.xml
- * or WEB-INF/glassfish-web.xml
) existence.
- *
- * @param module Java EE module.
- * @return Module configuration object.
- * @throws ConfigurationException if there is a problem with
- * the server-specific configuration.
- */
- @Override
- public ModuleConfiguration create(final J2eeModule module)
- throws ConfigurationException {
- ModuleConfiguration retVal = null;
- try {
- if (J2eeModuleHelper.isGlassFishWeb(module)) {
- retVal = new ModuleConfigurationImpl(
- module, new Three1Configuration(module), null);
- } else {
- retVal = new ModuleConfigurationImpl(
- module, new Hk2Configuration(module), null);
- }
- } catch (ConfigurationException ce) {
- throw ce;
- } catch (Exception ex) {
- throw new ConfigurationException(module.toString(), ex);
- }
- return retVal;
- }
-
- /**
- * Constructs proper module configuration object depending on
- * GlassFish server.
- *
- * Proper configuration object is selected depending on GlassFish version.
- * Old module configuration object is created for server before version 3.1
- * and new module configuration object for server version 3.1 and later.
- *
- * @param module Java EE module.
- * @param instanceUrl GlassFish server internal URL.
- * @return Module configuration object.
- * @throws ConfigurationException if there is a problem with
- * the server-specific configuration.
- */
- @Override
- public ModuleConfiguration create(final @NonNull J2eeModule module,
- final @NonNull String instanceUrl) throws ConfigurationException {
- ModuleConfiguration retVal = null;
- GlassfishInstance instance
- = GlassfishInstanceProvider.getProvider()
- .getGlassfishInstance(instanceUrl);
- GlassFishVersion version = instance != null
- ? instance.getVersion() : null;
- try {
- Hk2DeploymentManager hk2Dm =
- (Hk2DeploymentManager) Hk2DeploymentFactory.createEe6()
- .getDisconnectedDeploymentManager(instanceUrl);
- if (version != null
- && version.ordinal() >= GlassFishVersion.GF_3_1.ordinal()) {
- retVal = new ModuleConfigurationImpl(
- module, new Three1Configuration(module), hk2Dm);
- } else {
- retVal = new ModuleConfigurationImpl(
- module, new Hk2Configuration(module), hk2Dm);
- }
- } catch (ConfigurationException ce) {
- throw ce;
- } catch (Exception ex) {
- throw new ConfigurationException(module.toString(), ex);
- }
- return retVal;
- }
-
}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Three1Configuration.java
--- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Three1Configuration.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Three1Configuration.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 1997-2015 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.
@@ -57,6 +57,7 @@
import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
import org.netbeans.modules.glassfish.eecommon.api.config.J2eeModuleHelper;
import org.netbeans.modules.glassfish.javaee.db.Hk2DatasourceManager;
+import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
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;
@@ -67,14 +68,25 @@
import org.openide.util.NbBundle;
/**
- *
- * @author Ludovic Champenois
- * @author Peter Williams
+ * Java EE server configuration API support for GlassFish servers 3.1 and later.
+ *
+ * @author Ludovic Champenois, Peter Williams, Tomas Kraus
*/
public class Three1Configuration extends Hk2Configuration implements DeploymentConfiguration {
- public Three1Configuration(J2eeModule module) throws ConfigurationException {
- super(module, J2eeModuleHelper.getGlassfishDDModuleHelper(module.getType()));
+ /**
+ * Creates an instance of Java EE server configuration API support
+ * for GlassFish servers 3.1 and later.
+ *
+ * @param module Java EE module (project).
+ * @param version GlassFish server version.
+ * @throws ConfigurationException when there is a problem with Java EE server
+ * configuration initialization.
+ */
+ public Three1Configuration(
+ final J2eeModule module, final GlassFishVersion version
+ ) throws ConfigurationException {
+ super(module, J2eeModuleHelper.getGlassfishDDModuleHelper(module.getType()), version);
}
@Deprecated
@@ -87,7 +99,7 @@
// ------------------------------------------------------------------------
@Override
public Set getDatasources() throws org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException {
- return Hk2DatasourceManager.getDatasources(module.getResourceDirectory());
+ return Hk2DatasourceManager.getDatasources(module, version);
}
@Override
@@ -97,18 +109,8 @@
@Override
public Datasource createDatasource(String jndiName, String url, String username, String password, String driver) throws UnsupportedOperationException, org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException, DatasourceAlreadyExistsException {
- File resourceDir = module.getResourceDirectory();
- if (resourceDir == null) {
- // Unable to create JDBC data source for resource ref.
-// postResourceError(NbBundle.getMessage(ModuleConfigurationImpl.class,
-// "ERR_NoRefJdbcDataSource", jndiName)); // NOI18N
- Logger.getLogger("glassfish-javaee").log(Level.WARNING,
- "Resource Folder " + resourceDir + " does not exist.");
- throw new ConfigurationException(NbBundle.getMessage(
- ModuleConfigurationImpl.class, "ERR_NoRefJdbcDataSource", jndiName)); // NOI18N
- }
-
- return Hk2DatasourceManager.createDataSource(jndiName, url, username, password, driver, resourceDir,"glassfish-resources");
+ return Hk2DatasourceManager.createDataSource(
+ jndiName, url, username, password, driver, module, version);
}
// ------------------------------------------------------------------------
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Three1ModuleConfigFactory.java
--- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Three1ModuleConfigFactory.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Three1ModuleConfigFactory.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 1997-2015 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.
@@ -42,36 +42,23 @@
package org.netbeans.modules.glassfish.javaee;
-import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
-import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
-import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
-import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfigurationFactory;
+import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfigurationFactory2;
/**
- *
- * @author vbk
+ * Factory to construct proper module configuration object.
+ *
+ * @author Vince Kraemer, Tomas Kraus
*/
-public class Three1ModuleConfigFactory implements ModuleConfigurationFactory {
- private final Hk2DeploymentManager hk2Dm;
+public class Three1ModuleConfigFactory extends AbstractHk2ConfigurationFactory
+implements ModuleConfigurationFactory2 {
- /** Creates a new instance of Hk2ModuleConfigFactory */
- public Three1ModuleConfigFactory(Hk2DeploymentManager hk2Dm) {
- this.hk2Dm = hk2Dm;
+ /**
+ * Creates a new instance of {@link Three1ModuleConfigFactory}.
+ *
+ * @param hk2dm Deployment manager.
+ */
+ public Three1ModuleConfigFactory(final Hk2DeploymentManager hk2dm) {
+ super(hk2dm);
}
-
- @Override
- public ModuleConfiguration create(J2eeModule module) throws ConfigurationException {
- ModuleConfiguration retVal = null;
- try {
- retVal = new ModuleConfigurationImpl(module, new Three1Configuration(module), hk2Dm);
- } catch (ConfigurationException ce) {
- throw ce;
- } catch (Exception ex) {
- ConfigurationException ce = new ConfigurationException(module.toString());
- ce.initCause(ex);
- throw ce;
- }
- return retVal;
- }
-
+
}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/db/Hk2DatasourceManager.java
--- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/db/Hk2DatasourceManager.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/db/Hk2DatasourceManager.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 2008-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2008-2015 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.
@@ -60,17 +60,19 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.netbeans.modules.glassfish.common.GlassFishState;
+import org.netbeans.modules.glassfish.common.parser.TreeParser;
+import org.netbeans.modules.glassfish.eecommon.api.UrlData;
+import org.netbeans.modules.glassfish.eecommon.api.config.GlassfishConfiguration;
+import org.netbeans.modules.glassfish.javaee.Hk2DeploymentManager;
import org.netbeans.modules.glassfish.tooling.data.GlassFishServer;
import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
import org.netbeans.modules.glassfish.tooling.utils.OsUtils;
import org.netbeans.modules.glassfish.tooling.utils.ServerUtils;
-import org.netbeans.modules.glassfish.common.GlassFishState;
-import org.netbeans.modules.glassfish.eecommon.api.UrlData;
-import org.netbeans.modules.glassfish.javaee.*;
-import org.netbeans.modules.glassfish.common.parser.TreeParser;
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.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.plugins.spi.DatasourceManager;
import org.netbeans.modules.j2ee.sun.dd.api.RootInterface;
import org.openide.filesystems.FileLock;
@@ -105,12 +107,6 @@
ServerUtils.GF_DOMAIN_CONFIG_DIR_NAME,
ServerUtils.GF_DOMAIN_CONFIG_FILE_NAME);
- /** List of base file names containing server resources. */
- public static final String[] RESOURCE_FILES = {
- "glassfish-resources",
- "sun-resources"
- };
-
////////////////////////////////////////////////////////////////////////////
// Instance attributes //
////////////////////////////////////////////////////////////////////////////
@@ -162,7 +158,7 @@
if (!server.isRemote() && null != domainsDir) {
File domainXml = new File(domainsDir, domainName + File.separatorChar + DOMAIN_XML_PATH);
return readDatasources(
- domainXml, "/domain/", null, server.getVersion());
+ domainXml, "/domain/", server.getVersion());
} else {
return Collections.EMPTY_SET;
}
@@ -170,7 +166,7 @@
/**
* Deploys the given set of data sources.
- *
+ *
* @param Set of datasources to deploy.
* @throws ConfigurationException if there is some problem with data source
* configuration.
@@ -180,97 +176,156 @@
@Override
public void deployDatasources(Set datasources)
throws ConfigurationException, DatasourceAlreadyExistsException {
- // since a connection pool is not a Datasource, the deploy has to
+ // Since a connection pool is not a Datasource, the deploy has to
// happen in a different part of the deploy processing...
}
-
-
-
- // ------------------------------------------------------------------------
- // Used by ModuleConfigurationImpl since
- // ------------------------------------------------------------------------
-
- // Making this method private because there is no reason to provide resources
- // file base names manually.
+
/**
- * Get Datasource
objects from first available resources file.
- *
- * @param resourceDir Directory containing resource files.
- * @param baseNames List of resource file base names to search for.
- * @return Datasource
objects found in first available file.
+ * Get {@link Datasource} objects from first available resources file.
+ *
+ * @param version Resources file names depend on GlassFish server version.
+ * @param module Java EE module (project).
+ * @return {@link Datasource} objects found in first available file.
*/
- private static Set getDatasources(
- final File resourceDir, final String[] baseNames,
- final GlassFishVersion version) {
- for (String baseName : baseNames) {
- File file = new File(resourceDir, baseName+".xml");
- // Return Datasource objects from first available file.
- if (file.isFile())
- return readDatasources(file, "/", resourceDir, version);
+ public static Set getDatasources(
+ final J2eeModule module, final GlassFishVersion version) {
+ File file = GlassfishConfiguration.getExistingResourceFile(module, version);
+ if (file != null) {
+ return readDatasources(file, "/", version);
+ } else {
+ return new HashSet<>();
}
- // Return empty set when no resource file was found.
- return new HashSet<>();
}
- /**
- * Get Datasource
objects from first available resources file.
- * Default resource base names list is used.
- *
- * @param resourceDir Directory containing resource files.
- * @return Datasource
objects found in first available file.
- */
- public static Set getDatasources(File resourceDir) {
- return getDatasources(resourceDir, RESOURCE_FILES, null);
- }
-
-// public Datasource createDataSource(String jndiName, String url, String username,
-// String password, String driver, File resourceDir) throws DatasourceAlreadyExistsException {
-// SunDatasource result = null;
-// try {
-// // Throw an exception if the data source already exists.
-// for(Datasource ds: getDatasources(resourceDir)) {
-// if(jndiName.equals(ds.getJndiName())) {
-// throw new DatasourceAlreadyExistsException(new SunDatasource(
-// jndiName, url, username, password, driver));
-// }
-// }
-//
-// if(url != null) {
-//// String vendorName = convertToValidName(url);
-//// if(vendorName == null) {
-//// vendorName = jndiName;
-//// }else{
-//// if(vendorName.equals("derby_embedded")){ //NOI18N
-//// NotifyDescriptor d = new NotifyDescriptor.Message(bundle.getString("Err_UnSupportedDerby"), NotifyDescriptor.WARNING_MESSAGE); // NOI18N
-//// DialogDisplayer.getDefault().notify(d);
-//// return null;
-//// }
-//// }
-// if(resourceDir.exists()) {
-// FileUtil.createFolder(resourceDir);
-// }
-//
-// // Create connection pool if needed.
-// String poolName = createCheckForConnectionPool(vendorName, url, username, password, driver, resourceDir);
-// boolean jdbcExists = requiredResourceExists(jndiName, resourceDir, JDBC_RESOURCE);
-// if (jdbcExists) {
-// result = null;
-// } else {
-// createJDBCResource(jndiName, poolName, resourceDir);
-// result = new SunDatasource(jndiName, url, username, password, driver);
-// }
-// }
-// } catch(IOException ex) {
-// Logger.getLogger("glassfish-javaee").log(Level.WARNING, ex.getLocalizedMessage(), ex);
-// }
-// return result;
-// }
-
-
// ------------------------------------------------------------------------
// Internal logic
// ------------------------------------------------------------------------
+ /**
+ * Get resource file for new data source creation and verify it.
+ * Verifies existing resource file syntax and data sources or provides
+ * a new file when no resource file exists.
+ *
+ * Internal {@link #createDataSource(String, String, String,
+ * String, String, J2eeModule, GlassFishVersion)} helper method.
+ *
+ * @param jndiName Data source JNDI name.
+ * @param url Database URL.
+ * @param username Database user name.
+ * @param password Database user password.
+ * @param driver Database JDBC driver.
+ * @param module Java EE module (project).
+ * @param version GlassFish server version.
+ * @param cpFinder Connection pool finder.
+ * @return Resource file for new data source creation.
+ * @throws ConfigurationException if there is a problem with resource
+ * file parsing.
+ * @throws DatasourceAlreadyExistsException if the required data source
+ * already exists in resource file.
+ */
+ private static File resourceFileForDSCreation(
+ final String jndiName, final String url, final String username,
+ final String password, final String driver, final J2eeModule module,
+ final GlassFishVersion version,final ConnectionPoolFinder cpFinder
+ ) throws ConfigurationException, DatasourceAlreadyExistsException {
+ final DuplicateJdbcResourceFinder jdbcFinder
+ = new DuplicateJdbcResourceFinder(jndiName);
+ File file = GlassfishConfiguration.getExistingResourceFile(module, version);
+ if (file.exists()) {
+ List pathList = new ArrayList<>();
+ pathList.add(new TreeParser.Path("/resources/jdbc-resource", jdbcFinder));
+ pathList.add(new TreeParser.Path("/resources/jdbc-connection-pool", cpFinder));
+ try {
+ TreeParser.readXml(file, pathList);
+ if(jdbcFinder.isDuplicate()) {
+ throw new DatasourceAlreadyExistsException(new SunDatasource(
+ jndiName, url, username, password, driver));
+ }
+ } catch(IllegalStateException ex) {
+ Logger.getLogger("glassfish-javaee").log(
+ Level.INFO, ex.getLocalizedMessage(), ex);
+ throw new ConfigurationException(ex.getLocalizedMessage(), ex);
+ }
+ }
+ return file != null
+ ? file : GlassfishConfiguration.getNewResourceFile(module, version);
+ }
+
+ /**
+ * Create a data source (jdbc-resource and jdbc-connection-pool) and add it
+ * to sun-resources.xml in the specified resource folder.
+ *
+ * @param jndiName Data source JNDI name.
+ * @param url Database URL.
+ * @param username Database user name.
+ * @param password Database user password.
+ * @param driver Database JDBC driver.
+ * @param module Java EE module (project).
+ * @param version GlassFish server version.
+ * @return New {@link Datasource} object.
+ * @throws ConfigurationException if there is a problem with resource
+ * file parsing.
+ * @throws DatasourceAlreadyExistsException if the required data source
+ * already exists in resource file.
+ */
+ public static Datasource createDataSource(
+ final String jndiName, final String url, final String username,
+ final String password, final String driver,
+ final J2eeModule module, final GlassFishVersion version
+ ) throws ConfigurationException, DatasourceAlreadyExistsException {
+ SunDatasource ds;
+ ConnectionPoolFinder cpFinder = new ConnectionPoolFinder();
+
+ File xmlFile = resourceFileForDSCreation(
+ jndiName, url, username, password, driver, module, version, cpFinder);
+
+ try {
+ String vendorName = VendorNameMgr.vendorNameFromDbUrl(url);
+ if(vendorName == null) {
+ vendorName = jndiName;
+ } else {
+ if("derby_embedded".equals(vendorName)) {
+ // !PW FIXME display as dialog warning?
+ Logger.getLogger("glassfish-javaee").log(Level.WARNING,
+ "Embedded derby not supported as a datasource");
+ return null;
+ }
+ }
+
+ // Is there a connection pool we can reuse, or do we need to create one?
+ String defaultPoolName = computePoolName(url, vendorName, username);
+ Map pools = cpFinder.getPoolData();
+ CPool defaultPool = pools.get(defaultPoolName);
+
+ String poolName = null;
+ if(defaultPool != null && isSameDatabaseConnection(defaultPool, url, username, password)) {
+ poolName = defaultPoolName;
+ } else {
+ for(CPool pool: pools.values()) {
+ if(isSameDatabaseConnection(pool, url, username, password)) {
+ poolName = pool.getPoolName();
+ break;
+ }
+ }
+ }
+
+ if(poolName == null) {
+ poolName = defaultPool == null ? defaultPoolName : generateUniqueName(defaultPoolName, pools.keySet());
+ createConnectionPool(xmlFile, poolName, url, username, password, driver);
+ }
+
+ // create jdbc resource
+ createJdbcResource(xmlFile, jndiName, poolName);
+
+ ds = new SunDatasource(jndiName, url, username, password, driver);
+ } catch(IOException ex) {
+ Logger.getLogger("glassfish-javaee").log(Level.INFO, ex.getLocalizedMessage(), ex);
+ throw new ConfigurationException(ex.getLocalizedMessage(), ex);
+ }
+
+ return ds;
+ }
+
/**
* Parse resource file and build Datasource
objects from it.
*
@@ -289,14 +344,14 @@
*/
private static Set readDatasources(
final File xmlFile, final String xPathPrefix,
- final File resourcesDir, final GlassFishVersion version) {
- Set dataSources = new HashSet<>();
+ final GlassFishVersion version) {
+ final Set dataSources = new HashSet<>();
if (xmlFile.canRead()) {
- Map jdbcResourceMap = new HashMap<>();
- Map connectionPoolMap = new HashMap<>();
+ final Map jdbcResourceMap = new HashMap<>();
+ final Map connectionPoolMap = new HashMap<>();
- List pathList = new ArrayList<>();
+ final List pathList = new ArrayList<>();
pathList.add(new TreeParser.Path(xPathPrefix + "resources/jdbc-resource", new JdbcReader(jdbcResourceMap)));
pathList.add(new TreeParser.Path(xPathPrefix + "resources/jdbc-connection-pool", new ConnectionPoolReader(connectionPoolMap)));
@@ -307,19 +362,19 @@
}
for (JdbcResource jdbc : jdbcResourceMap.values()) {
- ConnectionPool pool = connectionPoolMap.get(jdbc.getPoolName());
+ final ConnectionPool pool = connectionPoolMap.get(jdbc.getPoolName());
if (pool != null) {
try {
pool.normalize();
// add to sun datasource list
- String url = pool.getProperty("URL"); //NOI18N
- String username = pool.getProperty("User"); //NOI18N
- String password = pool.getProperty("Password"); //NOI18N
- String driverClassName = pool.getProperty("driverClass"); //NOI18N
- SunDatasource dataSource = new SunDatasource(
+ final String url = pool.getProperty("URL"); //NOI18N
+ final String username = pool.getProperty("User"); //NOI18N
+ final String password = pool.getProperty("Password"); //NOI18N
+ final String driverClassName = pool.getProperty("driverClass"); //NOI18N
+ final SunDatasource dataSource = new SunDatasource(
jdbc.getJndiName(), url, username,
- password, driverClassName, resourcesDir);
+ password, driverClassName);
dataSources.add(dataSource);
// Add Java EE 7 comp/DefaultDataSource data source
// as jdbc/__default clone (since GF 4).
@@ -470,93 +525,7 @@
}
}
}
-
- /**
- * Create a data source (jdbc-resource and jdbc-connection-pool) and add it
- * to sun-resources.xml in the specified resource folder.
- *
- * @param jndiName
- * @param url
- * @param username
- * @param password
- * @param driver
- * @param resourceDir
- * @return
- * @throws DatasourceAlreadyExistsException if the required resources already
- * exist.
- */
- public static Datasource createDataSource(String jndiName, String url,
- String username, String password, String driver, File resourceDir, String baseName)
- throws ConfigurationException, DatasourceAlreadyExistsException {
- SunDatasource ds;
- DuplicateJdbcResourceFinder jdbcFinder = new DuplicateJdbcResourceFinder(jndiName);
- ConnectionPoolFinder cpFinder = new ConnectionPoolFinder();
-
- File xmlFile = new File(resourceDir, baseName+".xml");
- if(xmlFile.exists()) {
- List pathList = new ArrayList<>();
- pathList.add(new TreeParser.Path("/resources/jdbc-resource", jdbcFinder));
- pathList.add(new TreeParser.Path("/resources/jdbc-connection-pool", cpFinder));
-
- try {
- TreeParser.readXml(xmlFile, pathList);
- if(jdbcFinder.isDuplicate()) {
- throw new DatasourceAlreadyExistsException(new SunDatasource(
- jndiName, url, username, password, driver));
- }
- } catch(IllegalStateException ex) {
- Logger.getLogger("glassfish-javaee").log(Level.INFO, ex.getLocalizedMessage(), ex);
- throw new ConfigurationException(ex.getLocalizedMessage(), ex);
- }
- }
-
- try {
- String vendorName = VendorNameMgr.vendorNameFromDbUrl(url);
- if(vendorName == null) {
- vendorName = jndiName;
- } else {
- if("derby_embedded".equals(vendorName)) {
- // !PW FIXME display as dialog warning?
- Logger.getLogger("glassfish-javaee").log(Level.WARNING,
- "Embedded derby not supported as a datasource");
- return null;
- }
- }
-
- // Is there a connection pool we can reuse, or do we need to create one?
- String defaultPoolName = computePoolName(url, vendorName, username);
- Map pools = cpFinder.getPoolData();
- CPool defaultPool = pools.get(defaultPoolName);
-
- String poolName = null;
- if(defaultPool != null && isSameDatabaseConnection(defaultPool, url, username, password)) {
- poolName = defaultPoolName;
- } else {
- for(CPool pool: pools.values()) {
- if(isSameDatabaseConnection(pool, url, username, password)) {
- poolName = pool.getPoolName();
- break;
- }
- }
- }
-
- if(poolName == null) {
- poolName = defaultPool == null ? defaultPoolName : generateUniqueName(defaultPoolName, pools.keySet());
- createConnectionPool(xmlFile, poolName, url, username, password, driver);
- }
-
- // create jdbc resource
- createJdbcResource(xmlFile, jndiName, poolName);
-
- ds = new SunDatasource(jndiName, url, username, password, driver, resourceDir);
- } catch(IOException ex) {
- Logger.getLogger("glassfish-javaee").log(Level.INFO, ex.getLocalizedMessage(), ex);
- throw new ConfigurationException(ex.getLocalizedMessage(), ex);
- }
-
- return ds;
- }
-
+
private static String generateUniqueName(String prefix, Set keys) {
for(int i = 1; ; i++) {
String candidate = prefix + "_" + i; // NOI18N
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/db/SunDatasource.java
--- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/db/SunDatasource.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/db/SunDatasource.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2010-2015 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.
@@ -42,7 +42,6 @@
package org.netbeans.modules.glassfish.javaee.db;
-import java.io.File;
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
/**
@@ -57,21 +56,14 @@
private final String username;
private final String password;
private final String driverClassName;
- private File resourceDir;
public SunDatasource(String jndiName, String url, String username,
- String password, String driverClassName) {
- this(jndiName, url, username, password, driverClassName, null);
- }
-
- public SunDatasource(String jndiName, String url, String username,
- String password, String driverClassName, File resourceDir) {
+ String password, String driverClassName/*, File resourceDir*/) {
this.jndiName = jndiName;
this.url = url;
this.username = username;
this.password = password;
this.driverClassName = driverClassName;
- this.resourceDir = resourceDir;
}
@Override
@@ -104,14 +96,6 @@
return driverClassName;
}
- File getResourceDir() {
- return resourceDir;
- }
-
- void setResourceDir(File resourceDir) {
- this.resourceDir = resourceDir;
- }
-
@Override
public String toString() {
return "[ " + jndiName + " : " + url
@@ -120,6 +104,7 @@
}
@Override
+ @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject")
public boolean equals(Object obj) {
if (obj == null) {
return false;
@@ -140,7 +125,8 @@
if (this.password == null || !this.password.equals(other.password)) {
return false;
}
- if (this.driverClassName == null || !this.driverClassName.equals(other.driverClassName)) {
+ if (this.driverClassName == null
+ || !this.driverClassName.equals(other.driverClassName)) {
return false;
}
return true;
@@ -159,7 +145,7 @@
public SunDatasource copy(String jndiName) {
return new SunDatasource(jndiName, this.url, this.username,
- this.password, this.driverClassName, this.resourceDir);
+ this.password, this.driverClassName/*, this.resourceDir*/);
}
}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/test/unit/src/org/netbeans/modules/glassfish/javaee/db/HK2TestEEModuleImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/glassfish.javaee/test/unit/src/org/netbeans/modules/glassfish/javaee/db/HK2TestEEModuleImpl.java Tue Mar 17 16:39:16 2015 +0100
@@ -0,0 +1,137 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2015 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 2015 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.glassfish.javaee.db;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collections;
+import java.util.Iterator;
+import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
+import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleImplementation2;
+import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+/**
+ * Java EE module for GlassFish features tests.
+ *
+ * @author Tomas Kraus
+ */
+public class HK2TestEEModuleImpl implements J2eeModuleImplementation2 {
+
+ private final FileObject appRoot;
+ private final File srcDir;
+ private final File configDir;
+ private final J2eeModule.Type moduleType;
+ private final String moduleVersion;
+
+ /** Creates a new instance of TestJ2eeModule
+ * @param appRoot Application root directory.
+ * @param moduleType Java EE module type.
+ * @param moduleVersion Java EE version.
+ */
+ public HK2TestEEModuleImpl(
+ final FileObject appRoot, final J2eeModule.Type moduleType,
+ final String moduleVersion
+ ) {
+ this.appRoot = appRoot;
+ this.srcDir = new File(FileUtil.toFile(appRoot), "src");
+ this.configDir = new File(srcDir, "conf");
+ this.moduleType = moduleType;
+ this.moduleVersion = moduleVersion;
+ }
+
+ @Override
+ public FileObject getArchive() {
+ return null;
+ }
+
+ @Override
+ public Iterator getArchiveContents() {
+ return Collections.emptySet().iterator();
+ }
+
+ @Override
+ public FileObject getContentDirectory() {
+ return appRoot;
+ }
+
+ @Override
+ public J2eeModule.Type getModuleType() {
+ return moduleType;
+ }
+
+ @Override
+ public String getModuleVersion() {
+ return moduleVersion;
+ }
+
+ @Override
+ public String getUrl() {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ @Override
+ public File getResourceDirectory() {
+ return new File(FileUtil.toFile(appRoot), "setup");
+ }
+
+ @Override
+ public File getDeploymentConfigurationFile(String name) {
+ return new File(configDir, name);
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ @Override
+ public MetadataModel getMetadataModel(Class type) {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.javaee/test/unit/src/org/netbeans/modules/glassfish/javaee/db/Hk2DatasourceManagerTest.java
--- a/glassfish.javaee/test/unit/src/org/netbeans/modules/glassfish/javaee/db/Hk2DatasourceManagerTest.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.javaee/test/unit/src/org/netbeans/modules/glassfish/javaee/db/Hk2DatasourceManagerTest.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2010-2015 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.
@@ -51,16 +51,27 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.netbeans.api.j2ee.core.Profile;
+import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
-import static org.junit.Assert.*;
+import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
+import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleFactory;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
/**
- *
- * @author vkraemer
+ * GlassFish server data source manager tests.
+ *
+ * @author Vince Kraemer, Tomas Kraus
*/
-public class Hk2DatasourceManagerTest {
+public class Hk2DatasourceManagerTest extends NbTestCase {
- public Hk2DatasourceManagerTest() {
+ private J2eeModule j2eeModule;
+ private HK2TestEEModuleImpl j2eeModuleImpl;
+
+ public Hk2DatasourceManagerTest(String testName) {
+ super(testName);
}
@BeforeClass
@@ -72,10 +83,19 @@
}
@Before
- public void setUp() {
+ @Override
+ public void setUp() throws Exception {
+ File dataDir = getDataDir();
+ File rootFolder = new File(dataDir, "hk2sample");
+ rootFolder.mkdirs();
+ FileObject rootFolderFO = FileUtil.toFileObject(rootFolder);
+ j2eeModuleImpl = new HK2TestEEModuleImpl(
+ rootFolderFO, J2eeModule.Type.WAR, Profile.JAVA_EE_7_FULL.toPropertiesString());
+ j2eeModule = J2eeModuleFactory.createJ2eeModule(j2eeModuleImpl);
}
@After
+ @Override
public void tearDown() {
}
@@ -93,11 +113,13 @@
}
File resourceDir = null;
try {
- resourceDir = new File(new File(codebase.toURI()).getParentFile(), "data/178776"); // NOI18N
+ resourceDir = new File(
+ new File(codebase.toURI()).getParentFile(), "data/178776"); // NOI18N
} catch (URISyntaxException x) {
throw new Error(x);
}
- Set result = Hk2DatasourceManager.getDatasources(resourceDir);
+ Set result = Hk2DatasourceManager.getDatasources(
+ j2eeModule, GlassFishVersion.GF_3);
// assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
assert null != result : "null result";
diff -r 3a3c32bf146f -r d075b556b189 glassfish.tooling/nbproject/project.xml
--- a/glassfish.tooling/nbproject/project.xml Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.tooling/nbproject/project.xml Tue Mar 17 16:39:16 2015 +0100
@@ -29,6 +29,7 @@
org.netbeans.modules.glassfish.eecommon
org.netbeans.modules.glassfish.javaee
org.netbeans.modules.j2ee.sun.appsrv81
+ org.netbeans.modules.j2ee.sun.ddui
org.netbeans.modules.glassfish.tooling
org.netbeans.modules.glassfish.tooling.data
org.netbeans.modules.glassfish.tooling.data.cloud
diff -r 3a3c32bf146f -r d075b556b189 glassfish.tooling/src/org/netbeans/modules/glassfish/tooling/data/GlassFishVersion.java
--- a/glassfish.tooling/src/org/netbeans/modules/glassfish/tooling/data/GlassFishVersion.java Thu Mar 12 11:03:48 2015 +0100
+++ b/glassfish.tooling/src/org/netbeans/modules/glassfish/tooling/data/GlassFishVersion.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 2012-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012-2015 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.
@@ -42,6 +42,7 @@
import java.util.HashMap;
import java.util.Map;
import org.netbeans.modules.glassfish.tooling.logging.Logger;
+import org.netbeans.modules.glassfish.tooling.utils.EnumUtils;
/**
* GlassFish server version.
@@ -271,7 +272,7 @@
}
////////////////////////////////////////////////////////////////////////////
- // Class attributes //
+ // Instance attributes //
////////////////////////////////////////////////////////////////////////////
/** Major version number. */
@@ -372,6 +373,7 @@
* @return Value of true
when all parts of version numbers are
* the same or false
otherwise.
*/
+ @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject")
public boolean equals(final GlassFishVersion version) {
if (version == null) {
return false;
@@ -383,6 +385,36 @@
}
}
+ /** {@inheritDoc} */
+ public static boolean eq(Enum v1, Enum v2) {
+ return EnumUtils.eq(v1, v2);
+ }
+
+ /** {@inheritDoc} */
+ public static boolean ne(Enum v1, Enum v2) {
+ return EnumUtils.ne(v1, v2);
+ }
+
+ /** {@inheritDoc} */
+ public static boolean lt(Enum v1, Enum v2) {
+ return EnumUtils.lt(v1, v2);
+ }
+
+ /** {@inheritDoc} */
+ public static boolean le(Enum v1, Enum v2) {
+ return EnumUtils.le(v1, v2);
+ }
+
+ /** {@inheritDoc} */
+ public static boolean gt(Enum v1, Enum v2) {
+ return EnumUtils.gt(v1, v2);
+ }
+
+ /** {@inheritDoc} */
+ public static boolean ge(Enum v1, Enum v2) {
+ return EnumUtils.ge(v1, v2);
+ }
+
/**
* Convert GlassFishVersion
value to String
.
*
diff -r 3a3c32bf146f -r d075b556b189 glassfish.tooling/src/org/netbeans/modules/glassfish/tooling/utils/EnumUtils.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/glassfish.tooling/src/org/netbeans/modules/glassfish/tooling/utils/EnumUtils.java Tue Mar 17 16:39:16 2015 +0100
@@ -0,0 +1,157 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2015 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 2015 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.glassfish.tooling.utils;
+
+/**
+ * Enumeration helper methods:
+ * Ordinal value based comparison.
+ *
+ * @author Tomas Kraus
+ */
+public final class EnumUtils {
+
+ /**
+ * Ordinal value based comparison: equals {@code v1 == v2}.
+ *
+ * @param v1 First {@link Enum} instance to be compared.
+ * @param v2 Second {@link Enum} instance to be compared.
+ * @return Value of {@code true} when ordinal values of {@code v1}
+ * and {@code v2} are equal or both values are {@code null}.
+ * Value of {@code false} otherwise.
+ */
+ public static final boolean eq(
+ final Enum extends Enum> v1, final Enum extends Enum> v2) {
+ return v1 != null
+ ? (v2 != null ? v1.ordinal() == v2.ordinal() : false)
+ : v2 == null;
+ }
+
+ /**
+ * Ordinal value based comparison: not equals {@code v1 != v2}.
+ *
+ * @param v1 First {@link Enum} instance to be compared.
+ * @param v2 Second {@link Enum} instance to be compared.
+ * @return Value of {@code true} when ordinal values of {@code v1}
+ * and {@code v2} are not equal or one of the values
+ * is {@code null} and second one is not {@code null}. Value
+ * of {@code false} otherwise.
+ */
+ public static final boolean ne(
+ final Enum extends Enum> v1, final Enum extends Enum> v2) {
+ return v1 != null
+ ? (v2 != null ? v1.ordinal() != v2.ordinal() : true)
+ : v2 != null;
+ }
+
+ /**
+ * Ordinal value based comparison: less than {@code v1 < v2}.
+ * Value of {@code null} is considered less than any ordinal value.
+ *
+ * @param v1 First {@link Enum} instance to be compared.
+ * @param v2 Second {@link Enum} instance to be compared.
+ * @return Value of {@code true} when ordinal values of {@code v1}
+ * is less than {@code v2} or {@code v1} is {@code null}
+ * and {@code v2} is not {@code null}. Value of {@code false}
+ * otherwise.
+ */
+ public static final boolean lt(
+ final Enum extends Enum> v1, final Enum extends Enum> v2) {
+ return v1 != null
+ ? (v2 != null ? v1.ordinal() < v2.ordinal() : false)
+ : v2 != null;
+ }
+
+ /**
+ * Ordinal value based comparison: less than or equal {@code v1 <= v2}.
+ * Value of {@code null} is considered less than any ordinal value.
+ *
+ * @param v1 First {@link Enum} instance to be compared.
+ * @param v2 Second {@link Enum} instance to be compared.
+ * @return Value of {@code true} when ordinal values of {@code v1}
+ * is less than or equal to {@code v2} or {@code v1} is {@code null}
+ * and {@code v2} is not {@code null}. Value of {@code false}
+ * otherwise.
+ */
+ public static final boolean le(
+ final Enum extends Enum> v1, final Enum extends Enum> v2) {
+ return v1 != null
+ ? (v2 != null ? v1.ordinal() <= v2.ordinal() : false)
+ : true;
+ }
+
+ /**
+ * Ordinal value based comparison: greater than {@code v1 > v2}.
+ * Value of {@code null} is considered less than any ordinal value.
+ *
+ * @param v1 First {@link Enum} instance to be compared.
+ * @param v2 Second {@link Enum} instance to be compared.
+ * @return Value of {@code true} when ordinal values of {@code v1}
+ * is greater than {@code v2} or {@code v1} is {@code null}
+ * and {@code v2} is not {@code null}. Value of {@code false}
+ * otherwise.
+ */
+ public static final boolean gt(
+ final Enum extends Enum> v1, final Enum extends Enum> v2) {
+ return v1 != null
+ ? (v2 != null ? v1.ordinal() > v2.ordinal() : true)
+ : false;
+ }
+
+ /**
+ * Ordinal value based comparison: greater than or equal {@code v1 >= v2}.
+ * Value of {@code null} is considered less than any ordinal value.
+ *
+ * @param v1 First {@link Enum} instance to be compared.
+ * @param v2 Second {@link Enum} instance to be compared.
+ * @return Value of {@code true} when ordinal values of {@code v1}
+ * is greater than or equal to {@code v2} or {@code v1} is not {@code null}
+ * and {@code v2} is {@code null}. Value of {@code false}
+ * otherwise.
+ */
+ public static final boolean ge(
+ final Enum extends Enum> v1, final Enum extends Enum> v2) {
+ return v1 != null
+ ? (v2 != null ? v1.ordinal() >= v2.ordinal() : true)
+ : v2 == null;
+ }
+
+}
diff -r 3a3c32bf146f -r d075b556b189 glassfish.tooling/test/unit/src/org/netbeans/modules/glassfish/tooling/utils/EnumUtilsTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/glassfish.tooling/test/unit/src/org/netbeans/modules/glassfish/tooling/utils/EnumUtilsTest.java Tue Mar 17 16:39:16 2015 +0100
@@ -0,0 +1,179 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2015 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 2015 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.glassfish.tooling.utils;
+
+import static org.netbeans.modules.glassfish.tooling.data.GlassFishVersion.GF_3;
+import static org.netbeans.modules.glassfish.tooling.data.GlassFishVersion.GF_4;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+/**
+ * Test enumeration utilities.
+ *
+ * @author Tomas Kraus
+ */
+@Test(groups = {"unit-tests"})
+public class EnumUtilsTest {
+
+
+ /**
+ * Test equals method.
+ * Expected results:
+ * {@code a > b}: false
+ * {@code a == b}: true
+ * {@code a < b}: false
+ * {@code a, null}: false
+ * {@code null, b}: false
+ * {@code null, null}: true
+ */
+ @Test
+ public void testEq() {
+ assertFalse(EnumUtils.eq(GF_4, GF_3), "Equals for a > b shall be false.");
+ assertTrue(EnumUtils.eq(GF_4, GF_4), "Equals for a == b shall be true.");
+ assertFalse(EnumUtils.eq(GF_3, GF_4), "Equals for a < b shall be false.");
+ assertFalse(EnumUtils.eq(GF_3, null), "Equals for a, null shall be false.");
+ assertFalse(EnumUtils.eq(null, GF_3), "Equals for null, b shall be false.");
+ assertTrue(EnumUtils.eq(null, null), "Equals for null, null shall be true.");
+ }
+
+ /**
+ * Test not equals method.
+ * Expected results:
+ * {@code a > b}: true
+ * {@code a == b}: false
+ * {@code a < b}: true
+ * {@code a, null}: true
+ * {@code null, b}: true
+ * {@code null, null}: false
+ */
+ @Test
+ public void testNe() {
+ assertTrue(EnumUtils.ne(GF_4, GF_3), "Not equals for a > b shall be true.");
+ assertFalse(EnumUtils.ne(GF_4, GF_4), "Not equals for a == b shall be false.");
+ assertTrue(EnumUtils.ne(GF_3, GF_4), "Not equals for a < b shall be true.");
+ assertTrue(EnumUtils.ne(GF_3, null), "Not equals for a, null shall be true.");
+ assertTrue(EnumUtils.ne(null, GF_3), "Not equals for null, b shall be true.");
+ assertFalse(EnumUtils.ne(null, null), "Not equals for null, null shall be false.");
+ }
+
+ /**
+ * Test less than method.
+ * Expected results:
+ * {@code a > b}: false
+ * {@code a == b}: false
+ * {@code a < b}: true
+ * {@code a, null}: false
+ * {@code null, b}: true
+ * {@code null, null}: false
+ */
+ @Test
+ public void testLt() {
+ assertFalse(EnumUtils.lt(GF_4, GF_3), "Less than for a > b shall be false.");
+ assertFalse(EnumUtils.lt(GF_4, GF_4), "Less than for a == b shall be false.");
+ assertTrue(EnumUtils.lt(GF_3, GF_4), "Less than for a < b shall be true.");
+ assertFalse(EnumUtils.lt(GF_3, null), "Less than for a, null shall be false.");
+ assertTrue(EnumUtils.lt(null, GF_3), "Less than for null, b shall be true.");
+ assertFalse(EnumUtils.lt(null, null), "Less than for null, null shall be false.");
+ }
+
+ /**
+ * Test less than or equal method.
+ * Expected results:
+ * {@code a > b}: false
+ * {@code a == b}: true
+ * {@code a < b}: true
+ * {@code a, null}: false
+ * {@code null, b}: true
+ * {@code null, null}: true
+ */
+ @Test
+ public void testLe() {
+ assertFalse(EnumUtils.le(GF_4, GF_3), "Less than or equal for a > b shall be false.");
+ assertTrue(EnumUtils.le(GF_4, GF_4), "Less than or equal for a == b shall be true.");
+ assertTrue(EnumUtils.le(GF_3, GF_4), "Less than or equal for a < b shall be true.");
+ assertFalse(EnumUtils.le(GF_3, null), "Less than or equal for a, null shall be false.");
+ assertTrue(EnumUtils.le(null, GF_3), "Less than or equal for null, b shall be true.");
+ assertTrue(EnumUtils.le(null, null), "Less than or equal for null, null shall be true.");
+ }
+
+ /**
+ * Test greater than method.
+ * Expected results:
+ * {@code a > b}: true
+ * {@code a == b}: false
+ * {@code a < b}: false
+ * {@code a, null}: true
+ * {@code null, b}: false
+ * {@code null, null}: false
+ */
+ @Test
+ public void testGt() {
+ assertTrue(EnumUtils.gt(GF_4, GF_3), "Greater than for a > b shall be true.");
+ assertFalse(EnumUtils.gt(GF_4, GF_4), "Greater than for a == b shall be false.");
+ assertFalse(EnumUtils.gt(GF_3, GF_4), "Greater than for a < b shall be false.");
+ assertTrue(EnumUtils.gt(GF_3, null), "Greater than for a, null shall be true.");
+ assertFalse(EnumUtils.gt(null, GF_3), "Greater than for null, b shall be false.");
+ assertFalse(EnumUtils.gt(null, null), "Greater than for null, null shall be false.");
+ }
+
+ /**
+ * Test greater than or equal method.
+ * Expected results:
+ * {@code a > b}: true
+ * {@code a == b}: true
+ * {@code a < b}: false
+ * {@code a, null}: true
+ * {@code null, b}: false
+ * {@code null, null}: true
+ */
+ @Test
+ public void testGe() {
+ assertTrue(EnumUtils.ge(GF_4, GF_3), "Greater than or equal for a > b shall be true.");
+ assertTrue(EnumUtils.ge(GF_4, GF_4), "Greater than or equal for a == b shall be true.");
+ assertFalse(EnumUtils.ge(GF_3, GF_4), "Greater than or equal for a < b shall be false.");
+ assertTrue(EnumUtils.ge(GF_3, null), "Greater than or equal for a, null shall be true.");
+ assertFalse(EnumUtils.ge(null, GF_3), "Greater than or equal for null, b shall be false.");
+ assertTrue(EnumUtils.ge(null, null), "Greater than or equal for null, null shall be true.");
+ }
+
+}
diff -r 3a3c32bf146f -r d075b556b189 j2ee.sun.ddui/nbproject/project.xml
--- a/j2ee.sun.ddui/nbproject/project.xml Thu Mar 12 11:03:48 2015 +0100
+++ b/j2ee.sun.ddui/nbproject/project.xml Tue Mar 17 16:39:16 2015 +0100
@@ -130,6 +130,15 @@
+ org.netbeans.modules.glassfish.tooling
+
+
+
+ 0-1
+ 1.0
+
+
+
org.netbeans.modules.j2ee.dd
@@ -337,14 +346,6 @@
- org.openide.util.ui
-
-
-
- 9.3
-
-
-
org.openide.util
@@ -361,6 +362,14 @@
+ org.openide.util.ui
+
+
+
+ 9.3
+
+
+
org.openide.windows
diff -r 3a3c32bf146f -r d075b556b189 j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/SunONEDeploymentConfiguration.java
--- a/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/SunONEDeploymentConfiguration.java Thu Mar 12 11:03:48 2015 +0100
+++ b/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/SunONEDeploymentConfiguration.java Tue Mar 17 16:39:16 2015 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 1997-2015 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.
@@ -44,8 +44,8 @@
package org.netbeans.modules.j2ee.sun.share.configbean;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
-import java.io.IOException;
import java.io.OutputStream;
import java.util.Collections;
import java.util.Set;
@@ -59,12 +59,13 @@
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.modules.glassfish.eecommon.api.config.GlassfishConfiguration;
import org.netbeans.modules.glassfish.eecommon.api.config.J2eeModuleHelper;
+import org.netbeans.modules.glassfish.tooling.data.GlassFishVersion;
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.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
+import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.sun.api.CmpMappingProvider;
import org.netbeans.modules.j2ee.sun.api.ResourceConfiguratorInterface;
import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface;
@@ -84,12 +85,13 @@
import org.openide.util.RequestProcessor;
-/** Manages the deployment plan I/O and access for initializing DConfigBeans
- *
- * @author Vince Kraemer
- * @author Peter Williams
+/**
+ * Manages the deployment plan I/O and access for initializing DConfigBeans
+ *
+ * @author Vince Kraemer, Peter Williams, Tomas Kraus
*/
-public class SunONEDeploymentConfiguration extends GlassfishConfiguration implements DeploymentConfiguration { //implements Constants, SunDeploymentConfigurationInterface {
+public class SunONEDeploymentConfiguration
+extends GlassfishConfiguration implements DeploymentConfiguration {
/**
* inject cmp bean & field update support into descriptor listener factories
@@ -108,28 +110,38 @@
private SunDeploymentManagerInterface sdmi;
- /** Create an instance of SunONEDeploymentConfiguration for GF V2
- * and earlier servers.
+ /**
+ * Create an instance of SunONEDeploymentConfiguration for GF V2
+ * and earlier servers.
*
- * @param module J2eeModule instance for the project represented by this config.
+ * @param module J2eeModule instance for the project represented by this config.
+ * @param mySdmi Sun deployment manager.
+ * @param version GlassFish server version.
*
* @throws org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException
*/
- public SunONEDeploymentConfiguration(J2eeModule module, SunDeploymentManagerInterface mySdmi)
- throws ConfigurationException {
- super(module);
+ public SunONEDeploymentConfiguration(
+ final J2eeModule module, final SunDeploymentManagerInterface mySdmi,
+ final GlassFishVersion version
+ ) throws ConfigurationException {
+ super(module, version);
this.sdmi = mySdmi;
}
- /** Create an instance of SunONEDeploymentConfiguration for Webserver.
+ /**
+ * Create an instance of SunONEDeploymentConfiguration for Webserver.
*
* @param module J2eeModule instance for the project represented by this config.
* @param webServerDDName short name for web server sun dd
+ * @param version GlassFish server version.
*
* @throws org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException
*/
- public SunONEDeploymentConfiguration(J2eeModule module, String webServerDDName) throws ConfigurationException {
- super(module, J2eeModuleHelper.getWsModuleHelper(webServerDDName));
+ public SunONEDeploymentConfiguration(
+ final J2eeModule module, final String webServerDDName,
+ final GlassFishVersion version
+ ) throws ConfigurationException {
+ super(module, J2eeModuleHelper.getWsModuleHelper(webServerDDName), version);
}
/** Deprecated form used for JSR-88. Only exists to keep legacy parts of