[175782] RoS should use launch config
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/EJBBean.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/EJBBean.java
index f9b1406..41cb052 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/EJBBean.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/EJBBean.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.jst.server.core;
+import org.eclipse.jst.server.core.internal.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
/**
* An EJB bean.
* <p>
@@ -20,10 +22,9 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
-public class EJBBean implements IModuleArtifact {
- private IModule module;
+public class EJBBean extends ModuleArtifactDelegate {
private String jndiName;
private boolean local;
private boolean remote;
@@ -39,17 +40,17 @@
* <code>false</code> otherwise
*/
public EJBBean(IModule module, String jndiName, boolean remote, boolean local) {
- this.module = module;
+ super(module);
this.jndiName = jndiName;
this.remote = remote;
this.local = local;
}
/**
- * @see IModuleArtifact#getModule()
+ * Create a new empty EJBBean.
*/
- public IModule getModule() {
- return module;
+ public EJBBean() {
+ super();
}
/**
@@ -80,4 +81,46 @@
public boolean hasLocalInterface() {
return local;
}
+
+ /*
+ * @see ModuleArtifactDelegate#getName()
+ */
+ public String getName() {
+ return NLS.bind(Messages.artifactEJB, jndiName.toString());
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#deserialize(String)
+ */
+ public void deserialize(String s) {
+ int ind = s.indexOf("//");
+ super.deserialize(s.substring(0, ind));
+ if ('T' == s.charAt(ind+2))
+ local = true;
+ else
+ local = false;
+ if ('T' == s.charAt(ind+3))
+ remote = true;
+ else
+ remote = false;
+ jndiName = s.substring(ind+4);
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#serialize()
+ */
+ public String serialize() {
+ StringBuffer sb = new StringBuffer(super.serialize());
+ sb.append("//");
+ if (local)
+ sb.append("T");
+ else
+ sb.append("F");
+ if (remote)
+ sb.append("T");
+ else
+ sb.append("F");
+ sb.append(jndiName);
+ return sb.toString();
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IApplicationClientModule.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IApplicationClientModule.java
index 1f41d34..e98407c 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IApplicationClientModule.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IApplicationClientModule.java
@@ -17,7 +17,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public interface IApplicationClientModule extends IJ2EEModule {
// intentionally empty
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IConnectorModule.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IConnectorModule.java
index a459c74..1fd7102 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IConnectorModule.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IConnectorModule.java
@@ -19,7 +19,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public interface IConnectorModule extends IJ2EEModule {
/**
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IEJBModule.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IEJBModule.java
index 9596a04..e7b16aa 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IEJBModule.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IEJBModule.java
@@ -17,7 +17,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public interface IEJBModule extends IJ2EEModule {
// intentionally empty
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IEnterpriseApplication.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IEnterpriseApplication.java
index 6b9797b..0418d6d 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IEnterpriseApplication.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IEnterpriseApplication.java
@@ -20,7 +20,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public interface IEnterpriseApplication {
/**
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IJ2EEModule.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IJ2EEModule.java
index c3fc24e..59e9de8 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IJ2EEModule.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IJ2EEModule.java
@@ -20,7 +20,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public interface IJ2EEModule {
/**
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IJavaRuntime.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IJavaRuntime.java
index c39b43d..d8dbd86 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IJavaRuntime.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IJavaRuntime.java
@@ -19,7 +19,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @since 2.0
+ * @since 3.0
*/
public interface IJavaRuntime {
/**
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IUtilityModule.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IUtilityModule.java
index 96e4f00..0f7e22d 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IUtilityModule.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IUtilityModule.java
@@ -20,7 +20,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public interface IUtilityModule {
/**
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IWebModule.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IWebModule.java
index 92dffcf..05d37cd 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IWebModule.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/IWebModule.java
@@ -19,7 +19,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public interface IWebModule extends IJ2EEModule {
/**
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/JndiLaunchable.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/JndiLaunchable.java
index abc0d8f..b83cc9a 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/JndiLaunchable.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/JndiLaunchable.java
@@ -19,7 +19,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public class JndiLaunchable {
private Properties props;
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/JndiObject.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/JndiObject.java
index b7a3751..f02e922 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/JndiObject.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/JndiObject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.jst.server.core;
+import org.eclipse.jst.server.core.internal.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
/**
* A representation of an object in JNDI that can be tested on a server.
* <p>
@@ -20,10 +22,9 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
-public class JndiObject implements IModuleArtifact {
- private IModule module;
+public class JndiObject extends ModuleArtifactDelegate {
private String jndiName;
/**
@@ -33,15 +34,15 @@
* @param jndiName the JNDI name of the object
*/
public JndiObject(IModule module, String jndiName) {
- this.module = module;
+ super(module);
this.jndiName = jndiName;
}
/**
- * @see IModuleArtifact#getModule()
+ * Create an empty reference to an object in JNDI.
*/
- public IModule getModule() {
- return module;
+ public JndiObject() {
+ super();
}
/**
@@ -52,4 +53,30 @@
public String getJndiName() {
return jndiName;
}
+
+ /*
+ * @see ModuleArtifactDelegate#getName()
+ */
+ public String getName() {
+ return NLS.bind(Messages.artifactJNDI, jndiName);
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#deserialize(String)
+ */
+ public void deserialize(String s) {
+ int ind = s.indexOf("//");
+ super.deserialize(s.substring(0, ind));
+ jndiName = s.substring(ind+2);
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#serialize()
+ */
+ public String serialize() {
+ StringBuffer sb = new StringBuffer(super.serialize());
+ sb.append("//");
+ sb.append(jndiName);
+ return sb.toString();
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/PublishUtil.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/PublishUtil.java
index c26d722..601817a 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/PublishUtil.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/PublishUtil.java
@@ -41,7 +41,7 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public final class PublishUtil {
// size of the buffer
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/RuntimeClasspathProviderDelegate.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/RuntimeClasspathProviderDelegate.java
index c688304..2ecf375 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/RuntimeClasspathProviderDelegate.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/RuntimeClasspathProviderDelegate.java
@@ -44,7 +44,7 @@
* (repeatedly) as the API evolves.
* </p>
*
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
public abstract class RuntimeClasspathProviderDelegate {
protected class SourceAttachmentUpdate {
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/Servlet.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/Servlet.java
index f2a78cd..b3cc4dc 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/Servlet.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/Servlet.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.jst.server.core;
+import org.eclipse.jst.server.core.internal.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
/**
* A J2EE Servlet.
* <p>
@@ -20,10 +22,9 @@
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
- * @plannedfor 2.0
+ * @plannedfor 3.0
*/
-public class Servlet implements IModuleArtifact {
- private IModule module;
+public class Servlet extends ModuleArtifactDelegate {
private String className;
private String alias;
@@ -35,16 +36,16 @@
* @param alias the servlet's alias
*/
public Servlet(IModule module, String className, String alias) {
- this.module = module;
+ super(module);
this.className = className;
this.alias = alias;
}
/**
- * @see IModuleArtifact#getModule()
+ * Create a new empty servlet.
*/
- public IModule getModule() {
- return module;
+ public Servlet() {
+ super();
}
/**
@@ -65,10 +66,41 @@
return alias;
}
+ /*
+ * @see ModuleArtifactDelegate#getName()
+ */
+ public String getName() {
+ return NLS.bind(Messages.artifactServlet, className);
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#deserialize(String)
+ */
+ public void deserialize(String s) {
+ int ind = s.indexOf("//");
+ super.deserialize(s.substring(0, ind));
+ s = s.substring(ind+2);
+ ind = s.indexOf("//");
+ className = s.substring(0, ind);
+ alias = s.substring(ind+2);
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#serialize()
+ */
+ public String serialize() {
+ StringBuffer sb = new StringBuffer(super.serialize());
+ sb.append("//");
+ sb.append(className);
+ sb.append("//");
+ sb.append(alias);
+ return sb.toString();
+ }
+
/**
* @see Object#toString()
*/
public String toString() {
- return "Servlet [module=" + module + ", class=" + className + ", alias=" + alias + "]";
+ return "Servlet [module=" + getModule() + ", class=" + className + ", alias=" + alias + "]";
}
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/Messages.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/Messages.java
index ad24995..2bbf268 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/Messages.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/Messages.java
@@ -35,6 +35,11 @@
public static String errorNotADirectory;
public static String errorMkdir;
+ public static String artifactServlet;
+ public static String artifactEJB;
+ public static String artifactJNDI;
+ public static String artifactCactusTest;
+
static {
NLS.initializeMessages(JavaServerPlugin.PLUGIN_ID + ".internal.Messages", Messages.class);
}
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/Messages.properties b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/Messages.properties
index 97f0fe5..9ecb27d 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/Messages.properties
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/Messages.properties
@@ -29,4 +29,9 @@
errorNotADirectory=Could not delete {0} since it is not a directory.
errorMkdir=Could not create directory {0}.
-updateClasspathContainers=Updating classpath container for {0}
\ No newline at end of file
+updateClasspathContainers=Updating classpath container for {0}
+
+artifactServlet=Servlet {0}
+artifactEJB=EJB {0}
+artifactJNDI=JNDI {0}
+artifactCactusTest=Cactus test {0}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java
index c760ce8..9e6873a 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc. and others
+ * Copyright (c) 2005, 2007 BEA Systems, Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,14 +8,14 @@
* Contributors:
* Daniel R. Somerfield - initial API and implementation
*******************************************************************************/
-
package org.eclipse.jst.server.core.internal.cactus;
+import org.eclipse.jst.server.core.internal.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
-public class WebTestableResource implements IModuleArtifact {
- private IModule fModule;
+public class WebTestableResource extends ModuleArtifactDelegate {
private boolean fServletIsConfigured;
private String fClassName;
private String fTestName;
@@ -23,13 +23,17 @@
public WebTestableResource(IModule module, boolean servletIsConfigured,
String projectName, String className, String testName) {
- fModule = module;
+ super(module);
fServletIsConfigured = servletIsConfigured;
fClassName = className;
fTestName = testName;
fProjectName = projectName;
}
+ public WebTestableResource() {
+ super();
+ }
+
public String getProjectName() {
return fProjectName;
}
@@ -38,10 +42,6 @@
return fServletIsConfigured;
}
- public IModule getModule() {
- return fModule;
- }
-
public String getClassName() {
return fClassName;
}
@@ -49,4 +49,50 @@
public String getTestName() {
return fTestName;
}
+
+ /*
+ * @see ModuleArtifactDelegate#getName()
+ */
+ public String getName() {
+ return NLS.bind(Messages.artifactCactusTest, fTestName);
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#deserialize(String)
+ */
+ public void deserialize(String s) {
+ int ind = s.indexOf("//");
+ super.deserialize(s.substring(0, ind));
+ s = s.substring(ind+2);
+ ind = s.indexOf("//");
+ fProjectName = s.substring(0, ind);
+
+ s = s.substring(ind+2);
+ ind = s.indexOf("//");
+ fClassName = s.substring(0, ind);
+
+ if ('T' == s.charAt(ind+2))
+ fServletIsConfigured = true;
+ else
+ fServletIsConfigured = false;
+ fTestName = s.substring(ind+3);
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#serialize()
+ */
+ public String serialize() {
+ StringBuffer sb = new StringBuffer(super.serialize());
+ sb.append("//");
+ sb.append(fProjectName);
+ sb.append("//");
+ sb.append(fClassName);
+ sb.append("//");
+ if (fServletIsConfigured)
+ sb.append("T");
+ else
+ sb.append("F");
+ sb.append(fTestName);
+ return sb.toString();
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java
index 9228504..0cdf2e7 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java
@@ -587,7 +587,7 @@
* Returns the module's sync state.
*
* @param module the module
- * @return one of the PUBLISH_XXX state flags
+ * @return one of the PUBLISH_STATE_XXX state flags
*/
public int getModulePublishState(IModule[] module);
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleArtifactDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleArtifactDelegate.java
new file mode 100644
index 0000000..3c3c859
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleArtifactDelegate.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.core.model;
+
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.ServerUtil;
+/**
+ * A module artifact is a resource within a module, which can be launched
+ * on the server. Examples of module artifacts are servlets, HTML pages,
+ * or EJB beans.
+ * <p>
+ * Objects that provide an adapter to this type will be considered by the
+ * contextual Run on Server launch support.
+ * </p>
+ * <p>
+ * Subclasses should provide a default (no-arg) constructor, implement
+ * the serialize/deserialize methods, and provide a useful name.
+ * </p>
+ *
+ * @see org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate
+ * @since 2.0
+ */
+public abstract class ModuleArtifactDelegate implements IModuleArtifact {
+ private IModule module;
+
+ /**
+ * Create a new module artifact.
+ *
+ * @param module a module
+ */
+ public ModuleArtifactDelegate(IModule module) {
+ this.module = module;
+ }
+
+ /**
+ * Create a new module artifact.
+ */
+ public ModuleArtifactDelegate() {
+ super();
+ }
+
+ /**
+ * @see IModuleArtifact#getModule()
+ */
+ public IModule getModule() {
+ return module;
+ }
+
+ /**
+ * Returns a user-presentable name for this artifact.
+ *
+ * @return a user-presentable name
+ */
+ public abstract String getName();
+
+ /**
+ * Serialize this object into a string.
+ *
+ * @return a serialized string
+ */
+ public String serialize() {
+ return module.getId();
+ }
+
+ /**
+ * Deserialize this object from a serialized string.
+ *
+ * @param s a serialized string.
+ */
+ public void deserialize(String s) {
+ this.module = ServerUtil.getModule(s);
+ }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/NullModuleArtifact.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/NullModuleArtifact.java
index 88bf49b..618208f 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/NullModuleArtifact.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/NullModuleArtifact.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,35 +11,40 @@
package org.eclipse.wst.server.core.util;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
/**
* A dummy module artifact.
*
* @since 1.0
*/
-public class NullModuleArtifact implements IModuleArtifact {
- private IModule module;
-
+public class NullModuleArtifact extends ModuleArtifactDelegate {
/**
* Create a new reference to a module.
*
* @param module the module
*/
public NullModuleArtifact(IModule module) {
- this.module = module;
+ super(module);
}
/**
- * @see IModuleArtifact#getModule()
+ * Create a new empty reference to a module.
*/
- public IModule getModule() {
- return module;
+ public NullModuleArtifact() {
+ super();
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#getName()
+ */
+ public String getName() {
+ return "";
}
/**
* @see Object#toString()
*/
public String toString() {
- return "NullModuleArtifact [module=" + module + "]";
+ return "NullModuleArtifact [module=" + getModule() + "]";
}
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/WebResource.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/WebResource.java
index 4863f75..a7010d4 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/WebResource.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/WebResource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,16 +11,16 @@
package org.eclipse.wst.server.core.util;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
/**
* A Web module resource.
*
* @since 1.0
*/
-public class WebResource implements IModuleArtifact {
- private IModule module;
+public class WebResource extends ModuleArtifactDelegate {
private IPath path;
/**
@@ -30,15 +30,12 @@
* @param path a relative path within the module
*/
public WebResource(IModule module, IPath path) {
- this.module = module;
+ super(module);
this.path = path;
}
- /**
- * @see IModuleArtifact#getModule()
- */
- public IModule getModule() {
- return module;
+ public WebResource() {
+ super();
}
/**
@@ -50,10 +47,36 @@
return path;
}
+ /*
+ * @see ModuleArtifactDelegate#getName()
+ */
+ public String getName() {
+ return path.toString();
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#deserialize(String)
+ */
+ public void deserialize(String s) {
+ int ind = s.indexOf("//");
+ super.deserialize(s.substring(0, ind));
+ path = new Path(s.substring(ind+2));
+ }
+
+ /*
+ * @see ModuleArtifactDelegate#serialize()
+ */
+ public String serialize() {
+ StringBuffer sb = new StringBuffer(super.serialize());
+ sb.append("//");
+ sb.append(path.toPortableString());
+ return sb.toString();
+ }
+
/**
* @see Object#toString()
*/
public String toString() {
- return "WebResource [module=" + module + ", path=" + path + "]";
+ return "WebResource [module=" + getModule() + ", path=" + path + "]";
}
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/icons/obj16/state_started.gif b/plugins/org.eclipse.wst.server.ui/icons/obj16/state_started.gif
new file mode 100644
index 0000000..496e04f
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/icons/obj16/state_started.gif
Binary files differ
diff --git a/plugins/org.eclipse.wst.server.ui/icons/obj16/state_stopped.gif b/plugins/org.eclipse.wst.server.ui/icons/obj16/state_stopped.gif
new file mode 100644
index 0000000..61bbe3c
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/icons/obj16/state_stopped.gif
Binary files differ
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.properties b/plugins/org.eclipse.wst.server.ui/plugin.properties
index 8326a5d..2bc3179 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.properties
+++ b/plugins/org.eclipse.wst.server.ui/plugin.properties
@@ -79,6 +79,8 @@
moduleProjectDecoratorLabel=Module Project
moduleProjectDecoratorDescription=Decorates server modules with information on the project that they come from
+runOnServerLaunchConfiguration=Run on Server
+
# --------------- Action Sets (toolbar icon groups) ---------------
# Web Browser action set
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml
index 7666f8d..f21fb07 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.xml
+++ b/plugins/org.eclipse.wst.server.ui/plugin.xml
@@ -431,4 +431,28 @@
</decorator>
</extension>
+<extension point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ id="org.eclipse.wst.server.ui.launchConfigurationType"
+ name="%runOnServerLaunchConfiguration"
+ delegate="org.eclipse.wst.server.ui.internal.actions.RunOnServerLaunchConfigurationDelegate"
+ modes="run,debug,profile"/>
+</extension>
+
+<extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ id="org.eclipse.wst.server.ui.launchConfigurationTypeImage"
+ configTypeID="org.eclipse.wst.server.ui.launchConfigurationType"
+ icon="icons/etool16/run_on_server.gif">
+ </launchConfigurationTypeImage>
+</extension>
+
+<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ id="org.eclipse.wst.server.ui.launchConfigurationTabGroup"
+ type="org.eclipse.wst.server.ui.launchConfigurationType"
+ class="org.eclipse.wst.server.ui.internal.RunOnServerLaunchConfigurationTabGroup">
+ </launchConfigurationTabGroup>
+</extension>
+
</plugin>
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ImageResource.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ImageResource.java
index 2ac3b00..74997d1 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ImageResource.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ImageResource.java
@@ -99,6 +99,9 @@
public static final String IMG_SERVER_STATE_STARTED_PROFILE = "stateStartedProfile";
public static final String IMG_SERVER_STATE_STOPPED = "stateStopped";
+ public static final String IMG_STATE_STARTED = "stateStarted2";
+ public static final String IMG_STATE_STOPPED = "stateStopped2";
+
public static final String IMG_SERVER_STATE_STARTING_1 = "stateStarting1";
public static final String IMG_SERVER_STATE_STARTING_2 = "stateStarting2";
public static final String IMG_SERVER_STATE_STARTING_3 = "stateStarting3";
@@ -228,6 +231,9 @@
registerImage(IMG_SERVER_STATE_STARTED_PROFILE, URL_OBJ + "server_started_profile.gif");
registerImage(IMG_SERVER_STATE_STOPPED, URL_OBJ + "server_stopped.gif");
+ registerImage(IMG_STATE_STARTED, URL_OBJ + "state_started.gif");
+ registerImage(IMG_STATE_STOPPED, URL_OBJ + "state_stopped.gif");
+
registerImage(IMG_SERVER_STATE_STARTING_1, URL_OBJ + "server_starting1.gif");
registerImage(IMG_SERVER_STATE_STARTING_2, URL_OBJ + "server_starting2.gif");
registerImage(IMG_SERVER_STATE_STARTING_3, URL_OBJ + "server_starting3.gif");
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
index 645e934..68f936a 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -58,6 +58,7 @@
public static String errorServerAlreadyRunning;
public static String errorInvalidServer;
public static String serverLaunchConfigurationTab;
+ public static String runOnServerLaunchConfigName;
public static String wizSelectClientMessage;
public static String errorCouldNotCreateServerProject;
public static String errorDialogTitle;
@@ -151,6 +152,7 @@
public static String actionSetNewServer;
public static String errorNoArtifact;
public static String errorNoModules;
+ public static String errorLaunchConfig;
public static String dialogModeWarningRun;
public static String dialogModeWarningDebug;
public static String dialogModeWarningProfile;
@@ -240,7 +242,7 @@
public static String actionOpen;
public static String viewServer;
public static String viewStatus;
- public static String viewSync;
+ public static String viewState;
public static String actionStopToolTip;
public static String actionStop;
public static String actionModifyModulesToolTip;
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
index 420cf3b..0fabed1 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
@@ -108,7 +108,7 @@
# Column titles
viewServer=Server
viewStatus=Status
-viewSync=State
+viewState=State
# Actions
actionStart=Start
@@ -369,15 +369,17 @@
serverLaunchServer=Server:
serverLaunchRuntime=Runtime:
serverLaunchHost=Host name:
+runOnServerLaunchConfigName={0}
# Error Messages
errorDialogTitle=Server Error
errorServerAlreadyRunning=Server already running
errorNoServerSelected=No server selected
-errorInvalidServer=Invalid server
+errorInvalidServer=The server is invalid or missing
errorCouldNotCreateServerProject=Could not create server project
errorCouldNotCreateServerProjectStatus=Could not create server project: {0}
errorNoArtifact=The selection did not contain anything that can be run on a server.
+errorLaunchConfig=This launch configuration is invalid and may be out of sync with the workspace
errorNoModules=The selection is not within a valid module.
errorNoServer=Could not find a server to run the selection.
errorCouldNotSavePreference=Could not save server preference information.
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RunOnServerLaunchConfigurationTab.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RunOnServerLaunchConfigurationTab.java
new file mode 100644
index 0000000..5c5e43f
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RunOnServerLaunchConfigurationTab.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.ui.internal;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.wst.server.core.*;
+import org.eclipse.wst.server.core.internal.IClient;
+import org.eclipse.wst.server.core.internal.ILaunchableAdapter;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
+import org.eclipse.wst.server.ui.internal.actions.RunOnServerLaunchConfigurationDelegate;
+/**
+ * Run on Server launch configuration tab.
+ */
+public class RunOnServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
+ //private ILaunchConfigurationWorkingCopy wc;
+
+ protected IServer server;
+ protected IModule module;
+ protected ModuleArtifactDelegate moduleArtifact;
+ protected ILaunchableAdapter launchableAdapter;
+ protected IClient client;
+
+ protected Label serverLabel;
+ protected Label moduleArtifactLabel;
+ protected Label clientLabel;
+
+ /**
+ * Create a new launch configuration tab.
+ */
+ public RunOnServerLaunchConfigurationTab() {
+ super();
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 5;
+ layout.marginHeight = 5;
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(Messages.serverLaunchServer);
+ serverLabel = new Label(composite, SWT.NONE);
+ serverLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ label = new Label(composite, SWT.NONE);
+ label.setText("Artifact:");
+ moduleArtifactLabel = new Label(composite, SWT.NONE);
+ moduleArtifactLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ label = new Label(composite, SWT.NONE);
+ label.setText("Client:");
+ clientLabel = new Label(composite, SWT.NONE);
+ clientLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Dialog.applyDialogFont(composite);
+ setControl(composite);
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ setErrorMessage(null);
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ setErrorMessage(null);
+
+ try {
+ String serverId = configuration.getAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_SERVER_ID, (String)null);
+ String moduleArt = configuration.getAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_MODULE_ARTIFACT, (String)null);
+ String moduleArtifactClass = configuration.getAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_MODULE_ARTIFACT_CLASS, (String)null);
+ String laId = configuration.getAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_LAUNCHABLE_ADAPTER_ID, (String)null);
+ String clientId = configuration.getAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_CLIENT_ID, (String)null);
+
+ server = ServerCore.findServer(serverId);
+ module = null;
+ moduleArtifact = null;
+ launchableAdapter = ServerPlugin.findLaunchableAdapter(laId);
+ client = ServerPlugin.findClient(clientId);
+
+ try {
+ Class c = Class.forName(moduleArtifactClass);
+ moduleArtifact = (ModuleArtifactDelegate) c.newInstance();
+ moduleArtifact.deserialize(moduleArt);
+ module = moduleArtifact.getModule();
+ } catch (Throwable t) {
+ Trace.trace(Trace.WARNING, "Could not load module artifact delegate class");
+ }
+
+ if (server == null)
+ serverLabel.setText("unknown");
+ else
+ serverLabel.setText(server.getName());
+
+ if (moduleArtifact == null)
+ moduleArtifactLabel.setText("unknown");
+ else
+ moduleArtifactLabel.setText(moduleArtifact.getName());
+
+ if (client == null)
+ clientLabel.setText("unknown");
+ else
+ clientLabel.setText(client.getName());
+ } catch (CoreException e) {
+ // ignore
+ }
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ // do nothing
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(ILaunchConfiguration)
+ */
+ public boolean isValid(ILaunchConfiguration launchConfig) {
+ try {
+ String id = launchConfig.getAttribute(Server.ATTR_SERVER_ID, "");
+ if (id != null && !id.equals("")) {
+ IServer server2 = ServerCore.findServer(id);
+ if (server2 == null)
+ return false;
+ if (server2.getServerState() == IServer.STATE_STOPPED)
+ return true;
+ }
+ } catch (CoreException e) {
+ // ignore
+ }
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return ImageResource.getImage(ImageResource.IMG_ETOOL_RUN_ON_SERVER);
+ }
+
+ /*
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return Messages.serverLaunchConfigurationTab;
+ }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RunOnServerLaunchConfigurationTabGroup.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RunOnServerLaunchConfigurationTabGroup.java
new file mode 100644
index 0000000..495a862
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RunOnServerLaunchConfigurationTabGroup.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.ui.internal;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+/**
+ * Run on Server launch configuration tab group.
+ */
+public class RunOnServerLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[2];
+ tabs[0] = new RunOnServerLaunchConfigurationTab();
+ tabs[0].setLaunchConfigurationDialog(dialog);
+ tabs[1] = new CommonTab();
+ tabs[1].setLaunchConfigurationDialog(dialog);
+ setTabs(tabs);
+ }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
index 2dccce9..0403863 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
@@ -12,15 +12,14 @@
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IBreakpointManager;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.*;
+import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.ISelection;
@@ -35,8 +34,11 @@
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.core.internal.ServerType;
import org.eclipse.wst.server.core.internal.StartServerJob;
+import org.eclipse.wst.server.core.internal.Trace;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
import org.eclipse.wst.server.ui.internal.*;
import org.eclipse.wst.server.ui.internal.wizard.*;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
@@ -59,8 +61,8 @@
protected boolean tasksAndClientShown;
- public ILaunchableAdapter launchableAdapter;
- public IClient client;
+ protected ILaunchableAdapter launchableAdapter;
+ protected IClient client;
/**
* RunOnServerActionDelegate constructor comment.
@@ -157,7 +159,9 @@
*/
protected void run() {
// final String launchMode2 = getLaunchMode();
- final IModuleArtifact moduleArtifact = ServerPlugin.getModuleArtifact(selection);
+ IModuleArtifact[] moduleArtifacts = ServerPlugin.getModuleArtifacts(selection);
+ // TODO - multiple module artifacts
+ final IModuleArtifact moduleArtifact = moduleArtifacts[0];
Shell shell2 = null;
if (window != null)
@@ -273,6 +277,27 @@
launchableAdapter = wizard.getLaunchableAdapter();
}
+ if (moduleArtifact instanceof ModuleArtifactDelegate) {
+ boolean canLoad = false;
+ try {
+ Class c = Class.forName(moduleArtifact.getClass().getName());
+ if (c.newInstance() != null)
+ canLoad = true;
+ } catch (Throwable t) {
+ Trace.trace(Trace.WARNING, "Could not load module artifact delegate class, switching to backup");
+ }
+ if (canLoad) {
+ try {
+ IProgressMonitor monitor = new NullProgressMonitor();
+ ILaunchConfiguration config = getLaunchConfiguration(server, (ModuleArtifactDelegate) moduleArtifact, launchableAdapter, client, monitor);
+ config.launch(launchMode, monitor);
+ } catch (CoreException ce) {
+ Trace.trace(Trace.SEVERE, "Could not launch Run on Server", ce);
+ }
+ return;
+ }
+ }
+
Thread thread = new Thread("Run on Server") {
public void run() {
if (client == null) {
@@ -408,6 +433,73 @@
thread.start();
}
+ protected void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy config, IServer server, ModuleArtifactDelegate moduleArtifact, ILaunchableAdapter launchableAdapter, IClient client) {
+ config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_SERVER_ID, server.getId());
+ config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_MODULE_ARTIFACT, moduleArtifact.serialize());
+ config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_MODULE_ARTIFACT_CLASS, moduleArtifact.getClass().getName());
+ config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_LAUNCHABLE_ADAPTER_ID, launchableAdapter.getId());
+ config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_CLIENT_ID, client.getId());
+ }
+
+ protected ILaunchConfiguration getLaunchConfiguration(IServer server, ModuleArtifactDelegate moduleArtifact, ILaunchableAdapter launchableAdapter2, IClient client2, IProgressMonitor monitor) throws CoreException {
+ String serverId = server.getId();
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigType = launchManager.getLaunchConfigurationType("org.eclipse.wst.server.ui.launchConfigurationType");
+ ILaunchConfiguration[] launchConfigs = null;
+ try {
+ launchConfigs = launchManager.getLaunchConfigurations(launchConfigType);
+ } catch (CoreException e) {
+ // ignore
+ }
+
+ if (launchConfigs != null) {
+ int size = launchConfigs.length;
+ for (int i = 0; i < size; i++) {
+ List list = launchConfigs[i].getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null);
+ if (list == null || list.isEmpty()) {
+ try {
+ String serverId2 = launchConfigs[i].getAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_SERVER_ID, (String) null);
+ if (serverId.equals(serverId2)) {
+ final ILaunchConfigurationWorkingCopy wc = launchConfigs[i].getWorkingCopy();
+ setupLaunchConfiguration(wc, server, moduleArtifact, launchableAdapter2, client2);
+ if (wc.isDirty()) {
+ try {
+ return wc.doSave();
+ } catch (CoreException ce) {
+ Trace.trace(Trace.SEVERE, "Error configuring launch", ce);
+ }
+ }
+ return launchConfigs[i];
+ }
+ } catch (CoreException e) {
+ Trace.trace(Trace.SEVERE, "Error configuring launch", e);
+ }
+ }
+ }
+ }
+
+ // create a new launch configuration
+ String launchName = NLS.bind(Messages.runOnServerLaunchConfigName, moduleArtifact.getName());
+ launchName = getValidLaunchConfigurationName(launchName);
+ launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName);
+ ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName);
+ wc.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_SERVER_ID, serverId);
+ setupLaunchConfiguration(wc, server, moduleArtifact, launchableAdapter2, client2);
+ return wc.doSave();
+ }
+
+ //protected static final char[] INVALID_CHARS = new char[] {'\\', '/', ':', '*', '?', '"', '<', '>', '|', '\0', '@', '&'};
+ protected static final char[] INVALID_CHARS = new char[] {'\\', ':', '*', '?', '"', '<', '>', '|', '\0', '@', '&'};
+ protected String getValidLaunchConfigurationName(String s) {
+ if (s == null || s.length() == 0)
+ return "1";
+ int size = INVALID_CHARS.length;
+ for (int i = 0; i < size; i++) {
+ s = s.replace(INVALID_CHARS[i], '_');
+ }
+ return s;
+ }
+
/**
* Open an options dialog.
*
@@ -417,7 +509,7 @@
* @param breakpointsOption
* @return a dialog return constant
*/
- protected int openOptionsDialog(final Shell shell, final String title, final String message, final boolean breakpointsOption) {
+ protected static int openOptionsDialog(final Shell shell, final String title, final String message, final boolean breakpointsOption) {
if (breakpointsOption) {
int current = ServerUIPlugin.getPreferences().getLaunchMode2();
if (current == ServerUIPreferences.LAUNCH_MODE2_RESTART)
@@ -480,7 +572,7 @@
* @param shell
* @return a dialog return constant
*/
- protected int openBreakpointDialog(final Shell shell) {
+ protected static int openBreakpointDialog(final Shell shell) {
int current = ServerUIPlugin.getPreferences().getEnableBreakpoints();
if (current == ServerUIPreferences.ENABLE_BREAKPOINTS_ALWAYS)
return 0;
@@ -511,7 +603,7 @@
* @param shell
* @return a dialog return constant
*/
- protected int openRestartDialog(final Shell shell) {
+ protected static int openRestartDialog(final Shell shell) {
int current = ServerUIPlugin.getPreferences().getRestart();
if (current == ServerUIPreferences.RESTART_ALWAYS)
return 0;
@@ -618,8 +710,10 @@
}
Trace.trace(Trace.FINEST, "checking for module artifact");
- IModuleArtifact moduleArtifact = ServerPlugin.getModuleArtifact(globalSelection);
+ IModuleArtifact[] moduleArtifacts = ServerPlugin.getModuleArtifacts(globalSelection);
IModule module = null;
+ // TODO - multiple module artifacts
+ IModuleArtifact moduleArtifact = moduleArtifacts[0];
if (moduleArtifact != null)
module = moduleArtifact.getModule();
Trace.trace(Trace.FINEST, "moduleArtifact= " + moduleArtifact + ", module= " + module);
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java
new file mode 100644
index 0000000..6db6a6b
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.ui.internal.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
+import org.eclipse.debug.ui.ILaunchGroup;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.ChainedJob;
+import org.eclipse.wst.server.core.internal.IClient;
+import org.eclipse.wst.server.core.internal.ILaunchableAdapter;
+import org.eclipse.wst.server.core.internal.PublishServerJob;
+import org.eclipse.wst.server.core.internal.RestartServerJob;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.core.internal.ServerType;
+import org.eclipse.wst.server.core.internal.StartServerJob;
+import org.eclipse.wst.server.core.model.ModuleArtifactDelegate;
+import org.eclipse.wst.server.ui.internal.EclipseUtil;
+import org.eclipse.wst.server.ui.internal.LaunchClientJob;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.Trace;
+
+public class RunOnServerLaunchConfigurationDelegate extends LaunchConfigurationDelegate {
+ public static final String ATTR_SERVER_ID = "server-id";
+ public static final String ATTR_MODULE_ARTIFACT = "module-artifact";
+ public static final String ATTR_MODULE_ARTIFACT_CLASS = "module-artifact-class";
+
+ public static final String ATTR_LAUNCHABLE_ADAPTER_ID = "launchable-adapter-id";
+ public static final String ATTR_CLIENT_ID = "client-id";
+
+ public void launch(ILaunchConfiguration configuration, String launchMode, final ILaunch launch2,
+ IProgressMonitor monitor) throws CoreException {
+
+ String serverId = configuration.getAttribute(ATTR_SERVER_ID, (String)null);
+ String moduleArt = configuration.getAttribute(ATTR_MODULE_ARTIFACT, (String)null);
+ String moduleArtifactClass = configuration.getAttribute(ATTR_MODULE_ARTIFACT_CLASS, (String)null);
+ String laId = configuration.getAttribute(ATTR_LAUNCHABLE_ADAPTER_ID, (String)null);
+ String clientId = configuration.getAttribute(ATTR_CLIENT_ID, (String)null);
+
+ IServer server = ServerCore.findServer(serverId);
+ IModule module = null;
+ ModuleArtifactDelegate moduleArtifact = null;
+ ILaunchableAdapter launchableAdapter = ServerPlugin.findLaunchableAdapter(laId);
+ IClient client = ServerPlugin.findClient(clientId);
+
+ try {
+ Class c = Class.forName(moduleArtifactClass);
+ moduleArtifact = (ModuleArtifactDelegate) c.newInstance();
+ moduleArtifact.deserialize(moduleArt);
+ module = moduleArtifact.getModule();
+ } catch (Throwable t) {
+ Trace.trace(Trace.WARNING, "Could not load module artifact delegate class");
+ }
+
+ if (moduleArtifact == null)
+ throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorLaunchConfig));
+
+ if (module == null)
+ throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorLaunchConfig));
+
+ if (server == null)
+ throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorInvalidServer));
+
+ if (launchableAdapter == null)
+ throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorLaunchConfig));
+
+ final Shell[] shell2 = new Shell[1];
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ shell2[0] = EclipseUtil.getShell();
+ }
+ });
+ Shell shell = shell2[0];
+
+ if (client == null) {
+ // if there is no client, use a dummy
+ client = new IClient() {
+ public String getDescription() {
+ return Messages.clientDefaultDescription;
+ }
+
+ public String getId() {
+ return "org.eclipse.wst.server.ui.client.default";
+ }
+
+ public String getName() {
+ return Messages.clientDefaultName;
+ }
+
+ public IStatus launch(IServer server3, Object launchable2, String launchMode3, ILaunch launch) {
+ return Status.OK_STATUS;
+ }
+
+ public boolean supports(IServer server3, Object launchable2, String launchMode3) {
+ return true;
+ }
+ };
+ }
+
+ Trace.trace(Trace.FINEST, "Ready to launch");
+
+ // start server if it's not already started
+ // and cue the client to start
+ IModule[] modules = new IModule[] { module }; // TODO: get parent heirarchy correct
+ int state = server.getServerState();
+ if (state == IServer.STATE_STARTING) {
+ LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client);
+ clientJob.schedule();
+ } else if (state == IServer.STATE_STARTED) {
+ boolean restart = false;
+ String mode = server.getMode();
+ IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
+ boolean disabledBreakpoints = false;
+
+ if (server.getServerRestartState()) {
+ int result = RunOnServerActionDelegate.openRestartDialog(shell);
+ if (result == 0) {
+ launchMode = mode;
+ restart = true;
+ } else if (result == 9) // cancel
+ return;
+ }
+ if (!restart) {
+ if (!ILaunchManager.RUN_MODE.equals(mode) && ILaunchManager.RUN_MODE.equals(launchMode)) {
+ boolean breakpointsOption = false;
+ if (breakpointManager.isEnabled() && ILaunchManager.DEBUG_MODE.equals(mode))
+ breakpointsOption = true;
+ int result = RunOnServerActionDelegate.openOptionsDialog(shell, Messages.wizRunOnServerTitle, Messages.dialogModeWarningRun, breakpointsOption);
+ if (result == 0)
+ restart = true;
+ else if (result == 1) {
+ breakpointManager.setEnabled(false);
+ disabledBreakpoints = true;
+ launchMode = mode;
+ } else if (result == 2)
+ launchMode = mode;
+ else // result == 9 // cancel
+ return;
+ } else if (!ILaunchManager.DEBUG_MODE.equals(mode) && ILaunchManager.DEBUG_MODE.equals(launchMode)) {
+ int result = RunOnServerActionDelegate.openOptionsDialog(shell, Messages.wizDebugOnServerTitle, Messages.dialogModeWarningDebug, false);
+ if (result == 0)
+ restart = true;
+ else if (result == 1)
+ launchMode = mode;
+ else // result == 9 // cancel
+ return;
+ } else if (!ILaunchManager.PROFILE_MODE.equals(mode) && ILaunchManager.PROFILE_MODE.equals(launchMode)) {
+ boolean breakpointsOption = false;
+ if (breakpointManager.isEnabled() && ILaunchManager.DEBUG_MODE.equals(mode))
+ breakpointsOption = true;
+ int result = RunOnServerActionDelegate.openOptionsDialog(shell, Messages.wizProfileOnServerTitle, Messages.dialogModeWarningProfile, breakpointsOption);
+ if (result == 0)
+ restart = true;
+ else if (result == 1) {
+ breakpointManager.setEnabled(false);
+ disabledBreakpoints = true;
+ launchMode = mode;
+ } else if (result == 2)
+ launchMode = mode;
+ else // result == 9 // cancel
+ return;
+ }
+
+ if (ILaunchManager.DEBUG_MODE.equals(launchMode)) {
+ if (!breakpointManager.isEnabled() && !disabledBreakpoints) {
+ int result = RunOnServerActionDelegate.openBreakpointDialog(shell);
+ if (result == 0)
+ breakpointManager.setEnabled(true);
+ else if (result == 1) {
+ // ignore
+ } else // result == 2
+ return;
+ }
+ }
+ }
+
+ PublishServerJob publishJob = new PublishServerJob(server, IServer.PUBLISH_INCREMENTAL, false);
+ LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client);
+ publishJob.setNextJob(clientJob);
+
+ if (restart) {
+ RestartServerJob restartJob = new RestartServerJob(server, launchMode);
+ restartJob.setNextJob(publishJob);
+ restartJob.schedule();
+ } else
+ publishJob.schedule();
+ } else if (state != IServer.STATE_STOPPING) {
+ PublishServerJob publishJob = new PublishServerJob(server);
+ StartServerJob startServerJob = new StartServerJob(server, launchMode);
+ LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client);
+
+ ChainedJob myJob = new ChainedJob("test", server) {
+ protected IStatus run(IProgressMonitor monitor2) {
+ try {
+ LaunchConfigurationManager lcm = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
+ ILaunchGroup[] groups = lcm.getLaunchGroups();
+ int size = groups.length;
+ for (int i = 0; i < size; i++) {
+ String id = groups[i].getIdentifier();
+ LaunchHistory history = lcm.getLaunchHistory(id);
+ if (history != null)
+ history.launchAdded(launch2);
+ }
+ } catch (Throwable t) {
+ Trace.trace(Trace.WARNING, "Could not tweak debug launch history");
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ if (((ServerType)server.getServerType()).startBeforePublish()) {
+ startServerJob.setNextJob(publishJob);
+ publishJob.setNextJob(clientJob);
+ clientJob.setNextJob(myJob);
+ startServerJob.schedule();
+ } else {
+ publishJob.setNextJob(startServerJob);
+ startServerJob.setNextJob(clientJob);
+ clientJob.setNextJob(myJob);
+ publishJob.schedule();
+ }
+ }
+ }
+}
\ No newline at end of file