diff --git a/glassfish.common/manifest.mf b/glassfish.common/manifest.mf --- a/glassfish.common/manifest.mf +++ b/glassfish.common/manifest.mf @@ -3,6 +3,6 @@ OpenIDE-Module-Install: org/netbeans/modules/glassfish/common/Installer.class OpenIDE-Module-Layer: org/netbeans/modules/glassfish/common/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/glassfish/common/Bundle.properties -OpenIDE-Module-Specification-Version: 1.8 +OpenIDE-Module-Specification-Version: 1.9 OpenIDE-Module-Provides: org.netbeans.modules.glassfish.common diff --git a/glassfish.common/src/org/netbeans/modules/glassfish/common/CommandRunner.java b/glassfish.common/src/org/netbeans/modules/glassfish/common/CommandRunner.java --- a/glassfish.common/src/org/netbeans/modules/glassfish/common/CommandRunner.java +++ b/glassfish.common/src/org/netbeans/modules/glassfish/common/CommandRunner.java @@ -390,16 +390,17 @@ } public Future deploy(File dir, String moduleName, String contextRoot) { - return deploy(dir, moduleName, contextRoot, null); + return deploy(dir, moduleName, contextRoot, null, new File[0]); } - Future deploy(File dir, String moduleName, String contextRoot, Map properties) { + public Future deploy(File dir, String moduleName, String contextRoot, Map properties, File[] libraries) { return execute(new Commands.DeployCommand(dir, moduleName, - contextRoot, computePreserveSessions(ip), properties)); + contextRoot, computePreserveSessions(ip), properties, libraries)); } - public Future redeploy(String moduleName, String contextRoot) { + + public Future redeploy(String moduleName, String contextRoot, File[] libraries) { return execute(new Commands.RedeployCommand(moduleName, contextRoot, - computePreserveSessions(ip))); + computePreserveSessions(ip), libraries)); } private static Boolean computePreserveSessions(Map ip) { diff --git a/glassfish.common/src/org/netbeans/modules/glassfish/common/Commands.java b/glassfish.common/src/org/netbeans/modules/glassfish/common/Commands.java --- a/glassfish.common/src/org/netbeans/modules/glassfish/common/Commands.java +++ b/glassfish.common/src/org/netbeans/modules/glassfish/common/Commands.java @@ -287,6 +287,18 @@ } }; + private static void appendLibraries(StringBuilder cmd, File[] libraries) { + cmd.append(ServerCommand.PARAM_SEPARATOR).append("libraries="); // NOI18N + boolean firstOne = true; + for (File f : libraries) { + if (!firstOne) { + cmd.append(","); + } + cmd.append(f.getPath()); // NOI18N + firstOne = false; + } + } + /** * Command to deploy a directory */ @@ -295,7 +307,7 @@ private final boolean isDirDeploy; private final File path; - public DeployCommand(final File path, final String name, final String contextRoot, final Boolean preserveSessions, final Map properties) { + public DeployCommand(final File path, final String name, final String contextRoot, final Boolean preserveSessions, final Map properties, File[] libraries) { super("deploy"); // NOI18N this.isDirDeploy = path.isDirectory(); @@ -312,6 +324,9 @@ cmd.append(PARAM_SEPARATOR).append("contextroot="); // NOI18N cmd.append(contextRoot); } + if (libraries.length > 0) { + appendLibraries(cmd, libraries); + } cmd.append(PARAM_SEPARATOR).append("force=true"); // NOI18N addProperties(cmd,properties); query = cmd.toString(); @@ -377,7 +392,7 @@ */ public static final class RedeployCommand extends ServerCommand { - public RedeployCommand(final String name, final String contextRoot, final Boolean preserveSessions) { + public RedeployCommand(final String name, final String contextRoot, final Boolean preserveSessions, File[] libraries) { super("redeploy"); // NOI18N StringBuilder cmd = new StringBuilder(128); @@ -387,6 +402,9 @@ cmd.append(PARAM_SEPARATOR).append("contextroot="); // NOI18N cmd.append(contextRoot); } + if (libraries.length > 0) { + appendLibraries(cmd, libraries); + } addKeepSessions(cmd, preserveSessions); query = cmd.toString(); } diff --git a/glassfish.common/src/org/netbeans/modules/glassfish/common/CommonServerSupport.java b/glassfish.common/src/org/netbeans/modules/glassfish/common/CommonServerSupport.java --- a/glassfish.common/src/org/netbeans/modules/glassfish/common/CommonServerSupport.java +++ b/glassfish.common/src/org/netbeans/modules/glassfish/common/CommonServerSupport.java @@ -75,6 +75,7 @@ import org.netbeans.modules.glassfish.spi.ServerCommand; import org.netbeans.modules.glassfish.spi.ServerCommand.GetPropertyCommand; import org.netbeans.modules.glassfish.spi.CommandFactory; +import org.netbeans.modules.glassfish.spi.GlassfishModule2; import org.netbeans.modules.glassfish.spi.Utils; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; @@ -90,7 +91,7 @@ * * @author Peter Williams */ -public class CommonServerSupport implements GlassfishModule, RefreshModulesCookie { +public class CommonServerSupport implements GlassfishModule2, RefreshModulesCookie { private final transient Lookup lookup; private final Map properties = @@ -420,9 +421,14 @@ @Override public Future deploy(final OperationStateListener stateListener, final File application, final String name, final String contextRoot, Map properties) { + return deploy(stateListener, application, name, contextRoot, null, new File[0]); + } + + @Override + public Future deploy(OperationStateListener stateListener, File application, String name, String contextRoot, Map properties, File[] libraries) { CommandRunner mgr = new CommandRunner(isReallyRunning(), getCommandFactory(), getInstanceProperties(), stateListener); - return mgr.deploy(application, name, contextRoot, properties); + return mgr.deploy(application, name, contextRoot, properties, libraries); } @Override @@ -434,8 +440,13 @@ @Override public Future redeploy(final OperationStateListener stateListener, final String name, final String contextRoot) { + return redeploy(stateListener, name, contextRoot, new File[0]); + } + + @Override + public Future redeploy(OperationStateListener stateListener, String name, String contextRoot, File[] libraries) { CommandRunner mgr = new CommandRunner(isReallyRunning(), getCommandFactory(), getInstanceProperties(), stateListener); - return mgr.redeploy(name, contextRoot); + return mgr.redeploy(name, contextRoot, libraries); } @Override diff --git a/glassfish.common/src/org/netbeans/modules/glassfish/spi/GlassfishModule2.java b/glassfish.common/src/org/netbeans/modules/glassfish/spi/GlassfishModule2.java new file mode 100644 --- /dev/null +++ b/glassfish.common/src/org/netbeans/modules/glassfish/spi/GlassfishModule2.java @@ -0,0 +1,73 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2007 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.glassfish.spi; + +import java.io.File; +import java.util.Map; +import java.util.concurrent.Future; + + +/** + * Extended version of GlassfishModule supporting deployment of standalone + * EE module with libraries they require. + * + * @since org.netbeans.modules.glassfish.common/0 1.9 + */ +public interface GlassfishModule2 extends GlassfishModule { + + /** + * @param libraries array of jar files on which standalone EE module depends + * and which need to be part of deployment + */ + public Future deploy(OperationStateListener stateListener, + File application, String name, String contextRoot, Map properties, + File[] libraries); + + /** + * @param libraries array of jar files on which standalone EE module depends + * and which need to be part of deployment + */ + public Future redeploy(final OperationStateListener stateListener, + final String name, final String contextRoot, File[] libraries); + +} diff --git a/glassfish.javaee/nbproject/project.xml b/glassfish.javaee/nbproject/project.xml --- a/glassfish.javaee/nbproject/project.xml +++ b/glassfish.javaee/nbproject/project.xml @@ -38,7 +38,7 @@ 0-1 - 1.2 + 1.9 @@ -92,7 +92,7 @@ 4 - 1.65 + 1.69 diff --git a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2DeploymentManager.java b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2DeploymentManager.java --- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2DeploymentManager.java +++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2DeploymentManager.java @@ -48,6 +48,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -56,7 +57,6 @@ import javax.enterprise.deploy.shared.DConfigBeanVersionType; import javax.enterprise.deploy.shared.ModuleType; import javax.enterprise.deploy.spi.DeploymentConfiguration; -import javax.enterprise.deploy.spi.DeploymentManager; import javax.enterprise.deploy.spi.Target; import javax.enterprise.deploy.spi.TargetModuleID; import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException; @@ -76,8 +76,11 @@ import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; import org.netbeans.modules.glassfish.spi.AppDesc; import org.netbeans.modules.glassfish.spi.GlassfishModule; +import org.netbeans.modules.glassfish.spi.GlassfishModule2; import org.netbeans.modules.glassfish.spi.ServerUtilities; import org.netbeans.modules.glassfish.spi.Utils; +import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; +import org.netbeans.modules.j2ee.deployment.plugins.spi.DeploymentManager2; import org.openide.util.NbBundle; import org.xml.sax.SAXException; @@ -86,7 +89,7 @@ * @author Ludovic Champenois * @author Peter Williams */ -public class Hk2DeploymentManager implements DeploymentManager { +public class Hk2DeploymentManager implements DeploymentManager2 { private volatile ServerInstance serverInstance; private volatile InstanceProperties instanceProperties; @@ -118,6 +121,12 @@ @Override public ProgressObject distribute(Target[] targetList, final File moduleArchive, File deploymentPlan) throws IllegalStateException { + return distribute(targetList, moduleArchive, deploymentPlan, null); + } + + @Override + public ProgressObject distribute(Target[] targetList, final File moduleArchive, File deploymentPlan, J2eeModule module) + throws IllegalStateException { String t = moduleArchive.getName(); final String moduleName = org.netbeans.modules.glassfish.spi.Utils.sanitizeName(t.substring(0, t.length() - 4)); // @@ -129,6 +138,8 @@ MonitorProgressObject restartProgress = new MonitorProgressObject(this, moduleId); final GlassfishModule commonSupport = this.getCommonServerSupport(); + final GlassfishModule2 commonSupport2 = (commonSupport instanceof GlassfishModule2 ? + (GlassfishModule2)commonSupport : null); boolean restart = false; try { restart = HttpMonitorHelper.synchronizeMonitor( commonSupport.getInstanceProperties().get(GlassfishModule.DOMAINS_FOLDER_ATTR), @@ -155,7 +166,11 @@ commonSupport.restartServer(restartProgress); return updateCRProgress; } else { + if (commonSupport2 != null && module != null) { + commonSupport2.deploy(deployProgress, moduleArchive, moduleName, null, Collections.emptyMap(), module.getRequiredLibraries()); + } else { commonSupport.deploy(deployProgress, moduleArchive, moduleName); + } return updateCRProgress; } } @@ -172,9 +187,14 @@ @Override public ProgressObject redeploy(TargetModuleID [] moduleIDList, final File moduleArchive, File deploymentPlan) throws UnsupportedOperationException, IllegalStateException { + return redeploy(moduleIDList, moduleArchive, deploymentPlan, null); + } + + @Override + public ProgressObject redeploy(TargetModuleID [] moduleIDList, final File moduleArchive, File deploymentPlan, J2eeModule module) + throws UnsupportedOperationException, IllegalStateException { final Hk2TargetModuleID moduleId = (Hk2TargetModuleID) moduleIDList[0]; final String moduleName = moduleId.getModuleID(); - final MonitorProgressObject progressObject = new MonitorProgressObject(this, moduleId, CommandType.REDEPLOY); MonitorProgressObject restartObject = new MonitorProgressObject(this,moduleId, @@ -182,6 +202,8 @@ final MonitorProgressObject updateCRObject = new MonitorProgressObject(this, moduleId, CommandType.REDEPLOY); final GlassfishModule commonSupport = this.getCommonServerSupport(); + final GlassfishModule2 commonSupport2 = (commonSupport instanceof GlassfishModule2 ? + (GlassfishModule2)commonSupport : null); // FIXME -- broken for remote deploy of web apps progressObject.addProgressListener(new UpdateContextRoot(updateCRObject,moduleId,getServerInstance(), true)); boolean restart = false; @@ -214,7 +236,11 @@ commonSupport.restartServer(restartObject); return updateCRObject; } else { + if (commonSupport2 != null && module != null) { + commonSupport2.deploy(progressObject, moduleArchive, moduleName, null, Collections.emptyMap(), module.getRequiredLibraries()); + } else { commonSupport.deploy(progressObject, moduleArchive, moduleName); + } return updateCRObject; } } diff --git a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/ide/FastDeploy.java b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/ide/FastDeploy.java --- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/ide/FastDeploy.java +++ b/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/ide/FastDeploy.java @@ -46,6 +46,7 @@ import java.io.File; import java.io.IOException; +import java.util.Collections; import java.util.logging.Level; import java.util.logging.Logger; import javax.enterprise.deploy.shared.CommandType; @@ -65,6 +66,7 @@ import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment; import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration; import org.netbeans.modules.glassfish.spi.GlassfishModule; +import org.netbeans.modules.glassfish.spi.GlassfishModule2; import org.netbeans.modules.j2ee.deployment.plugins.api.DeploymentChangeDescriptor; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; @@ -98,7 +100,8 @@ * @param file * @return */ - public ProgressObject initialDeploy(Target target, J2eeModule module, ModuleConfiguration configuration, final File dir) { + @Override + public ProgressObject initialDeploy(Target target, final J2eeModule module, ModuleConfiguration configuration, final File dir) { final String moduleName = org.netbeans.modules.glassfish.spi.Utils.sanitizeName(Utils.computeModuleID(module, dir, Integer.toString(hashCode()))); String contextRoot = null; // XXX fix cast -- need error instance for ProgressObject to return errors @@ -110,6 +113,8 @@ MonitorProgressObject restartProgress = new MonitorProgressObject(dm, moduleId); final GlassfishModule commonSupport = dm.getCommonServerSupport(); + final GlassfishModule2 commonSupport2 = (commonSupport instanceof GlassfishModule2 ? + (GlassfishModule2)commonSupport : null); boolean restart = false; try { restart = HttpMonitorHelper.synchronizeMonitor(commonSupport.getInstanceProperties().get(GlassfishModule.DOMAINS_FOLDER_ATTR), @@ -126,7 +131,11 @@ restartProgress.addProgressListener(new ProgressListener() { public void handleProgressEvent(ProgressEvent event) { if (event.getDeploymentStatus().isCompleted()) { + if (commonSupport2 != null) { + commonSupport2.deploy(deployProgress, dir, moduleName, null, Collections.emptyMap(), module.getRequiredLibraries()); + } else { commonSupport.deploy(deployProgress, dir, moduleName); + } } else { deployProgress.fireHandleProgressEvent(event.getDeploymentStatus()); } @@ -135,7 +144,11 @@ commonSupport.restartServer(restartProgress); return updateCRProgress; } else { + if (commonSupport2 != null) { + commonSupport2.deploy(deployProgress, dir, moduleName, null, Collections.emptyMap(), module.getRequiredLibraries()); + } else { commonSupport.deploy(deployProgress, dir, moduleName); + } return updateCRProgress; } } diff --git a/j2ee.clientproject/nbproject/project.xml b/j2ee.clientproject/nbproject/project.xml --- a/j2ee.clientproject/nbproject/project.xml +++ b/j2ee.clientproject/nbproject/project.xml @@ -209,7 +209,7 @@ 4 - 1.63 + 1.69 diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProvider.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProvider.java --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProvider.java +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProvider.java @@ -49,6 +49,7 @@ import java.beans.PropertyChangeSupport; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Date; import java.util.Enumeration; import java.util.Iterator; @@ -77,14 +78,16 @@ import org.netbeans.modules.j2ee.deployment.devmodules.api.ModuleChangeReporter; import org.netbeans.modules.j2ee.deployment.devmodules.api.ResourceChangeReporter; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleFactory; -import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleImplementation2; +import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleImplementation3; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; import org.netbeans.modules.j2ee.deployment.devmodules.spi.ResourceChangeReporterFactory; import org.netbeans.modules.j2ee.deployment.devmodules.spi.ResourceChangeReporterImplementation; import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.websvc.api.client.WebServicesClientConstants; +import org.netbeans.spi.java.classpath.ClassPathFactory; import org.netbeans.spi.java.classpath.ClassPathProvider; +import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.EditableProperties; import org.openide.DialogDisplayer; @@ -97,7 +100,7 @@ * @author jungi */ public final class AppClientProvider extends J2eeModuleProvider - implements J2eeModuleImplementation2, ModuleChangeReporter, EjbChangeDescriptor, PropertyChangeListener { + implements J2eeModuleImplementation3, ModuleChangeReporter, EjbChangeDescriptor, PropertyChangeListener { public static final String FILE_DD = "application-client.xml";//NOI18N @@ -176,6 +179,22 @@ return project.getClassPathProvider(); } + @Override + public File[] getRequiredLibraries() { + ClassPath cp = ClassPathFactory.createClassPath( + ProjectClassPathSupport.createPropertyBasedClassPathImplementation( + FileUtil.toFile(project.getProjectDirectory()), project.evaluator(), new String[]{"javac.classpath"})); + List files = new ArrayList(); + for (FileObject fo : cp.getRoots()) { + fo = FileUtil.getArchiveFile(fo); + if (fo == null) { + continue; + } + files.add(FileUtil.toFile(fo)); + } + return files.toArray(new File[files.size()]); + } + public FileObject getArchive() { return getFileObject(AppClientProjectProperties.DIST_JAR); } diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/resources/build-impl.xsl b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/resources/build-impl.xsl --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/resources/build-impl.xsl +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/resources/build-impl.xsl @@ -987,7 +987,7 @@ - + diff --git a/j2ee.ejbjarproject/nbproject/project.xml b/j2ee.ejbjarproject/nbproject/project.xml --- a/j2ee.ejbjarproject/nbproject/project.xml +++ b/j2ee.ejbjarproject/nbproject/project.xml @@ -235,7 +235,7 @@ 4 - 1.63 + 1.69 diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProvider.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProvider.java --- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProvider.java +++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProvider.java @@ -42,6 +42,7 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.File; +import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.LinkedList; @@ -79,11 +80,13 @@ import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; import org.netbeans.modules.j2ee.deployment.devmodules.api.ModuleChangeReporter; import org.netbeans.modules.j2ee.deployment.devmodules.api.ResourceChangeReporter; -import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleImplementation2; +import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleImplementation3; import org.netbeans.modules.j2ee.deployment.devmodules.spi.ResourceChangeReporterFactory; import org.netbeans.modules.j2ee.deployment.devmodules.spi.ResourceChangeReporterImplementation; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants; +import org.netbeans.spi.java.classpath.ClassPathFactory; +import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport; /** A ejb module implementation on top of project. @@ -91,7 +94,7 @@ * @author Pavel Buzek */ public final class EjbJarProvider extends J2eeModuleProvider - implements J2eeModuleImplementation2, ModuleChangeReporter, EjbChangeDescriptor, PropertyChangeListener { + implements J2eeModuleImplementation3, ModuleChangeReporter, EjbChangeDescriptor, PropertyChangeListener { public static final String FILE_DD = "ejb-jar.xml";//NOI18N @@ -187,6 +190,7 @@ return project.getClassPathProvider(); } + @Override public FileObject getArchive() { return getFileObject(EjbJarProjectProperties.DIST_JAR); } @@ -477,6 +481,22 @@ } } + @Override + public File[] getRequiredLibraries() { + ClassPath cp = ClassPathFactory.createClassPath( + ProjectClassPathSupport.createPropertyBasedClassPathImplementation( + FileUtil.toFile(project.getProjectDirectory()), project.evaluator(), new String[]{"javac.classpath"})); + List files = new ArrayList(); + for (FileObject fo : cp.getRoots()) { + fo = FileUtil.getArchiveFile(fo); + if (fo == null) { + continue; + } + files.add(FileUtil.toFile(fo)); + } + return files.toArray(new File[files.size()]); + } + private class EjbJarResourceChangeReporter implements ResourceChangeReporterImplementation { public boolean isServerResourceChanged(long lastDeploy) { diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl --- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl +++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl @@ -990,14 +990,14 @@ - + diff --git a/j2eeserver/apichanges.xml b/j2eeserver/apichanges.xml --- a/j2eeserver/apichanges.xml +++ b/j2eeserver/apichanges.xml @@ -116,6 +116,28 @@ + + + + Implement support for deployment of standalone EE modules. + + + + + + +

+ Implemented both SPI and API for communication of requires libraries + from EE module to deployment server. +

+
+ + + + +
+ + Implemented support for handling the server libraries. diff --git a/j2eeserver/nbproject/project.properties b/j2eeserver/nbproject/project.properties --- a/j2eeserver/nbproject/project.properties +++ b/j2eeserver/nbproject/project.properties @@ -42,7 +42,7 @@ is.autoload=true javac.source=1.6 -spec.version.base=1.68.0 +spec.version.base=1.69.0 javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml diff --git a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/J2eeModule.java b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/J2eeModule.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/J2eeModule.java +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/J2eeModule.java @@ -55,8 +55,10 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.j2ee.core.Profile; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleBase; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleImplementation2; +import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleImplementation3; import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel; import org.openide.util.Parameters; @@ -214,6 +216,22 @@ } /** + * Returns array of jar files which this EE module requires in order to be + * successfully deployed. + * @since org.netbeans.modules.j2eeserver/4 1.69 + */ + public File[] getRequiredLibraries() { + if (impl instanceof J2eeModuleImplementation3) { + File libs[] = ((J2eeModuleImplementation3) impl).getRequiredLibraries(); + assert libs != null; + assert (getType() == J2eeModule.Type.WAR || getType() == J2eeModule.Type.EAR) ? libs.length == 0 : true; + return libs; + } else { + return new File[0]; + } + } + + /** * Returns module type. * * @return module type diff --git a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleImplementation3.java b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleImplementation3.java new file mode 100644 --- /dev/null +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleImplementation3.java @@ -0,0 +1,64 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ + +package org.netbeans.modules.j2ee.deployment.devmodules.spi; + +import java.io.File; + +/** + * Standalone EJB and AppClient module can describe library jars they depend on. + * + * @since org.netbeans.modules.j2eeserver/4 1.69 + */ +public interface J2eeModuleImplementation3 extends J2eeModuleImplementation2 { + + /** + * Returns array of jar files this standalone EE module depends on. + * @return never null; can be empty array; file must be absolute and + * a jar file and never a folder; libraries can be returned only for EJB or + * APPCLIENT module + */ + File[] getRequiredLibraries(); + +} diff --git a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java @@ -83,6 +83,7 @@ import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider; import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI; import org.netbeans.modules.j2ee.deployment.plugins.api.DeploymentChangeDescriptor; +import org.netbeans.modules.j2ee.deployment.plugins.spi.DeploymentManager2; import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment; import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration; import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver; @@ -632,7 +633,12 @@ ui.progress(NbBundle.getMessage(TargetServer.class, "MSG_Distributing", application, Arrays.asList(targetz))); plan = dtarget.getConfigurationFile(); - po = instance.getDeploymentManager().distribute(targetz, getApplication(), plan); + DeploymentManager dm = instance.getDeploymentManager(); + if (dm instanceof DeploymentManager2) { + po = ((DeploymentManager2)dm).distribute(targetz, getApplication(), plan, dtarget.getModule()); + } else { + po = dm.distribute(targetz, getApplication(), plan); + } trackDeployProgressObject(ui, po, false); } } @@ -659,7 +665,12 @@ ui.progress(NbBundle.getMessage(TargetServer.class, "MSG_Redeploying", application)); TargetModuleID[] tmids = TargetModule.toTargetModuleID(redeployTargetModules); if (plan == null) plan = dtarget.getConfigurationFile(); - po = instance.getDeploymentManager().redeploy(tmids, getApplication(), plan); + DeploymentManager dm = instance.getDeploymentManager(); + if (dm instanceof DeploymentManager2) { + po = ((DeploymentManager2)dm).redeploy(tmids, getApplication(), plan, dtarget.getModule()); + } else { + po = dm.redeploy(tmids, getApplication(), plan); + } trackDeployProgressObject(ui, po, false); } } diff --git a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/DeploymentManager2.java b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/DeploymentManager2.java new file mode 100644 --- /dev/null +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/DeploymentManager2.java @@ -0,0 +1,81 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ + +/* + * IncrementalDeployment.java + * + * Created on November 14, 2003, 9:13 AM + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi; + +import javax.enterprise.deploy.spi.TargetModuleID; +import javax.enterprise.deploy.spi.status.ProgressObject; +import java.io.File; +import javax.enterprise.deploy.spi.DeploymentManager; +import javax.enterprise.deploy.spi.Target; +import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; + +/** + * Enhanced deployment manager capable of passing EE module description to + * redeploy and distribute methods in order to implement deployment of + * standalone EE modules. + * + * @since org.netbeans.modules.j2eeserver/4 1.69 + */ +public interface DeploymentManager2 extends DeploymentManager { + + /** + * @param module EE module being deployed + */ + public ProgressObject redeploy(TargetModuleID [] moduleIDList, final File moduleArchive, File deploymentPlan, J2eeModule module) + throws UnsupportedOperationException, IllegalStateException; + + /** + * @param module EE module being deployed + */ + public ProgressObject distribute(Target[] targetList, final File moduleArchive, File deploymentPlan, J2eeModule module) + throws IllegalStateException; + +}