format source and resolve many warnings
diff --git a/org.eclipse.jst.server.jetty.core/build.properties b/org.eclipse.jst.server.jetty.core/build.properties
index ff5d1aa..bc4bcb2 100644
--- a/org.eclipse.jst.server.jetty.core/build.properties
+++ b/org.eclipse.jst.server.jetty.core/build.properties
@@ -13,3 +13,4 @@
.,\
plugin.xml,\
plugin.properties
+src.includes = src/
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyConfiguration.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyConfiguration.java
index 9b9fc46..506b30e 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyConfiguration.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyConfiguration.java
@@ -23,84 +23,82 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.ServerPort;
-public interface IJettyConfiguration {
+public interface IJettyConfiguration
+{
- public static final String NAME_PROPERTY = "name";
- public static final String PORT_PROPERTY = "port";
- public static final String MODIFY_PORT_PROPERTY = "modifyPort";
-
- public static final String MODIFY_WEB_MODULE_PROPERTY = "modifyWebModule";
- public static final String ADD_WEB_MODULE_PROPERTY = "addWebModule";
- public static final String REMOVE_WEB_MODULE_PROPERTY = "removeWebModule";
+ public static final String NAME_PROPERTY = "name";
+ public static final String PORT_PROPERTY = "port";
+ public static final String MODIFY_PORT_PROPERTY = "modifyPort";
- /**
- * Returns a list of ServerPorts that this configuration uses.
- *
- * @return the server ports
- */
- Collection<ServerPort> getServerPorts();
+ public static final String MODIFY_WEB_MODULE_PROPERTY = "modifyWebModule";
+ public static final String ADD_WEB_MODULE_PROPERTY = "addWebModule";
+ public static final String REMOVE_WEB_MODULE_PROPERTY = "removeWebModule";
- /**
- * Returns the main server port.
- *
- * @return ServerPort
- */
- ServerPort getMainPort();
+ /**
+ * Returns a list of ServerPorts that this configuration uses.
+ *
+ * @return the server ports
+ */
+ Collection<ServerPort> getServerPorts();
- /**
- *
- * @param path
- * @param monitor
- * @throws CoreException
- */
- void load(IPath path, IPath runtimeBaseDirectory, IProgressMonitor monitor) throws CoreException;
+ /**
+ * Returns the main server port.
+ *
+ * @return ServerPort
+ */
+ ServerPort getMainPort();
- /**
- *
- * @param path
- * @param monitor
- * @throws CoreException
- */
- void load(IFolder folder, IPath runtimeBaseDirectory, IProgressMonitor monitor) throws CoreException;
+ /**
+ *
+ * @param path
+ * @param monitor
+ * @throws CoreException
+ */
+ void load(IPath path, IPath runtimeBaseDirectory, IProgressMonitor monitor) throws CoreException;
- /**
- * Save the information held by this object to the given directory.
- *
- * @param folder
- * a folder
- * @param monitor
- * a progress monitor
- * @throws CoreException
- */
- void save(IFolder folder, IProgressMonitor monitor) throws CoreException;
+ /**
+ *
+ * @param path
+ * @param monitor
+ * @throws CoreException
+ */
+ void load(IFolder folder, IPath runtimeBaseDirectory, IProgressMonitor monitor) throws CoreException;
- /**
- * Return a list of the web modules in this server.
- *
- * @return the web modules
- */
- public List<WebModule> getWebModules();
+ /**
+ * Save the information held by this object to the given directory.
+ *
+ * @param folder
+ * a folder
+ * @param monitor
+ * a progress monitor
+ * @throws CoreException
+ */
+ void save(IFolder folder, IProgressMonitor monitor) throws CoreException;
- void addWebModule(int i, IJettyWebModule module);
+ /**
+ * Return a list of the web modules in this server.
+ *
+ * @return the web modules
+ */
+ public List<WebModule> getWebModules();
- void removeWebModule(int i);
+ void addWebModule(int i, IJettyWebModule module);
- String getWebModuleURL(IModule module);
+ void removeWebModule(int i);
- String getDocBasePrefix();
+ String getWebModuleURL(IModule module);
- void importFromPath(IPath path, IPath runtimeBaseDirectory, boolean isTestEnv, IProgressMonitor monitor)
- throws CoreException;
+ String getDocBasePrefix();
- IStatus cleanupServer(IPath confDir, IPath installDir,
- IProgressMonitor monitor);
+ void importFromPath(IPath path, IPath runtimeBaseDirectory, boolean isTestEnv, IProgressMonitor monitor) throws CoreException;
- IStatus backupAndPublish(IPath confDir, boolean b, IProgressMonitor monitor);
+ IStatus cleanupServer(IPath confDir, IPath installDir, IProgressMonitor monitor);
- IStatus localizeConfiguration(IPath confDir, IPath serverDeployDirectory,
- IJettyServer jettyServer, IProgressMonitor subMonitorFor);
+ IStatus backupAndPublish(IPath confDir, boolean b, IProgressMonitor monitor);
- void addPropertyChangeListener(PropertyChangeListener listener);
+ IStatus localizeConfiguration(IPath confDir, IPath serverDeployDirectory, IJettyServer jettyServer, IProgressMonitor subMonitorFor);
- void removePropertyChangeListener(PropertyChangeListener listener);
+ void addPropertyChangeListener(PropertyChangeListener listener);
+
+ void removePropertyChangeListener(PropertyChangeListener listener);
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyConfigurationWorkingCopy.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyConfigurationWorkingCopy.java
index 0bdba27..2aa770f 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyConfigurationWorkingCopy.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyConfigurationWorkingCopy.java
@@ -12,60 +12,71 @@
import org.eclipse.jst.server.jetty.core.internal.IJettyWebModule;
-public interface IJettyConfigurationWorkingCopy extends IJettyConfiguration {
- /**
- * Add a web module.
- *
- * @param index int
- * @param module org.eclipse.jst.server.jetty.WebModule
- */
- public void addWebModule(int index, IJettyWebModule module);
-
- /**
- * Change a web module.
- *
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable);
+public interface IJettyConfigurationWorkingCopy extends IJettyConfiguration
+{
+ /**
+ * Add a web module.
+ *
+ * @param index
+ * int
+ * @param module
+ * org.eclipse.jst.server.jetty.WebModule
+ */
+ public void addWebModule(int index, IJettyWebModule module);
- /**
- * Remove a web module.
- *
- * @param index int
- */
- public void removeWebModule(int index);
+ /**
+ * Change a web module.
+ *
+ * @param index
+ * int
+ * @param docBase
+ * java.lang.String
+ * @param path
+ * java.lang.String
+ * @param reloadable
+ * boolean
+ */
+ public void modifyWebModule(int index, String docBase, String path, boolean reloadable);
-// /**
-// * Adds a mime mapping.
-// *
-// * @param index int
-// * @param map MimeMapping
-// */
-// public void addMimeMapping(int index, IMimeMapping map);
-//
-// /**
-// * Change a mime mapping.
-// *
-// * @param index int
-// * @param map MimeMapping
-// */
-// public void modifyMimeMapping(int index, IMimeMapping map);
+ /**
+ * Remove a web module.
+ *
+ * @param index
+ * int
+ */
+ public void removeWebModule(int index);
- /**
- * Modify the port with the given id.
- *
- * @param id java.lang.String
- * @param port int
- */
- public void modifyServerPort(String id, int port);
+ // /**
+ // * Adds a mime mapping.
+ // *
+ // * @param index int
+ // * @param map MimeMapping
+ // */
+ // public void addMimeMapping(int index, IMimeMapping map);
+ //
+ // /**
+ // * Change a mime mapping.
+ // *
+ // * @param index int
+ // * @param map MimeMapping
+ // */
+ // public void modifyMimeMapping(int index, IMimeMapping map);
- /**
- * Remove a mime mapping.
- *
- * @param index int
- */
- //public void removeMimeMapping(int index);
+ /**
+ * Modify the port with the given id.
+ *
+ * @param id
+ * java.lang.String
+ * @param port
+ * int
+ */
+ public void modifyServerPort(String id, int port);
+
+ /**
+ * Remove a mime mapping.
+ *
+ * @param index
+ * int
+ */
+ // public void removeMimeMapping(int index);
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyRuntimeWorkingCopy.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyRuntimeWorkingCopy.java
index 8d13e25..7a93ad8 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyRuntimeWorkingCopy.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyRuntimeWorkingCopy.java
@@ -12,9 +12,11 @@
import org.eclipse.jst.server.core.IJavaRuntimeWorkingCopy;
import org.eclipse.jst.server.jetty.core.internal.IJettyRuntime;
+
/**
*
*/
-public interface IJettyRuntimeWorkingCopy extends IJettyRuntime, IJavaRuntimeWorkingCopy {
- // no new methods
+public interface IJettyRuntimeWorkingCopy extends IJettyRuntime, IJavaRuntimeWorkingCopy
+{
+ // no new methods
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyServer.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyServer.java
index 3e39bf7..24967f6 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyServer.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyServer.java
@@ -13,34 +13,32 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.server.core.model.IURLProvider;
-public interface IJettyServer extends IURLProvider {
+public interface IJettyServer extends IURLProvider
+{
- /**
- * Property which specifies whether this server is configured for testing
- * environment.
- */
- public static final String PROPERTY_TEST_ENVIRONMENT = "testEnvironment";
+ /**
+ * Property which specifies whether this server is configured for testing environment.
+ */
+ public static final String PROPERTY_TEST_ENVIRONMENT = "testEnvironment";
- /**
- * Property which specifies the directory where the server instance exists.
- * If not specified, instance directory is derived from the textEnvironment
- * setting.
- */
- public static final String PROPERTY_INSTANCE_DIR = "instanceDir";
+ /**
+ * Property which specifies the directory where the server instance exists. If not specified, instance directory is derived from the textEnvironment
+ * setting.
+ */
+ public static final String PROPERTY_INSTANCE_DIR = "instanceDir";
- /**
- * Property which specifies the directory where web applications are
- * published.
- */
- public static final String PROPERTY_DEPLOY_DIR = "deployDir";
+ /**
+ * Property which specifies the directory where web applications are published.
+ */
+ public static final String PROPERTY_DEPLOY_DIR = "deployDir";
- /**
- * Property which specifies if modules should be served without publishing.
- */
- public static final String PROPERTY_SERVE_MODULES_WITHOUT_PUBLISH = "serveModulesWithoutPublish";
+ /**
+ * Property which specifies if modules should be served without publishing.
+ */
+ public static final String PROPERTY_SERVE_MODULES_WITHOUT_PUBLISH = "serveModulesWithoutPublish";
- IJettyConfiguration getJettyConfiguration() throws CoreException;
+ IJettyConfiguration getJettyConfiguration() throws CoreException;
- IJettyConfiguration getServerConfiguration() throws CoreException;
+ IJettyConfiguration getServerConfiguration() throws CoreException;
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyServerWorkingCopy.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyServerWorkingCopy.java
index 4d20ac2..886f22f 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyServerWorkingCopy.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/IJettyServerWorkingCopy.java
@@ -10,40 +10,40 @@
*******************************************************************************/
package org.eclipse.jst.server.jetty.core;
-public interface IJettyServerWorkingCopy extends IJettyServer {
+public interface IJettyServerWorkingCopy extends IJettyServer
+{
- /**
- * The default deployment directory. Avoid "webapps" due to
- * side effects.
- */
- public static final String DEFAULT_DEPLOYDIR = "wtpwebapps";
+ /**
+ * The default deployment directory. Avoid "webapps" due to side effects.
+ */
+ public static final String DEFAULT_DEPLOYDIR = "wtpwebapps";
- /**
- * The deployment directory used by default in prior versions.
- */
- public static final String LEGACY_DEPLOYDIR = "webapps";
+ /**
+ * The deployment directory used by default in prior versions.
+ */
+ public static final String LEGACY_DEPLOYDIR = "webapps";
- /**
- * Sets this server to test environment mode.
- *
- * @param b boolean
- */
- public void setTestEnvironment(boolean b);
-
- /**
- * Sets the instance directory for the server. If set to
- * null, the instance directory is derived from the
- * testEnvironment setting.'
- *
- * @param instanceDir absolule path to the instance directory.
- */
- public void setInstanceDirectory(String instanceDir);
+ /**
+ * Sets this server to test environment mode.
+ *
+ * @param b
+ * boolean
+ */
+ public void setTestEnvironment(boolean b);
- /**
- * Set the deployment directory for the server. May be absolute
- * or relative to runtime base directory.
- *
- * @param deployDir deployment directory for the server
- */
- public void setDeployDirectory(String deployDir);
+ /**
+ * Sets the instance directory for the server. If set to null, the instance directory is derived from the testEnvironment setting.'
+ *
+ * @param instanceDir
+ * absolule path to the instance directory.
+ */
+ public void setInstanceDirectory(String instanceDir);
+
+ /**
+ * Set the deployment directory for the server. May be absolute or relative to runtime base directory.
+ *
+ * @param deployDir
+ * deployment directory for the server
+ */
+ public void setDeployDirectory(String deployDir);
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/JettyPlugin.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/JettyPlugin.java
index 27bc23a..554a333 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/JettyPlugin.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/JettyPlugin.java
@@ -27,132 +27,143 @@
/**
* The activator class controls the plug-in life cycle
*/
-public class JettyPlugin extends AbstractUIPlugin {
+public class JettyPlugin extends AbstractUIPlugin
+{
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.jst.server.jetty.core"; //$NON-NLS-1$
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.jst.server.jetty.core"; //$NON-NLS-1$
- // The shared instance
- private static JettyPlugin plugin;
+ // The shared instance
+ private static JettyPlugin plugin;
- /**
- * The constructor
- */
- public JettyPlugin() {
- }
+ /**
+ * The constructor
+ */
+ public JettyPlugin()
+ {
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext )
+ */
+ public void start(BundleContext context) throws Exception
+ {
+ super.start(context);
+ plugin = this;
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext )
+ */
+ public void stop(BundleContext context) throws Exception
+ {
+ plugin = null;
+ super.stop(context);
+ }
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static JettyPlugin getDefault() {
- return plugin;
- }
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static JettyPlugin getDefault()
+ {
+ return plugin;
+ }
- /**
- * Return the install location preference.
- *
- * @param id
- * a runtime type id
- * @return the install location
- */
- public static String getPreference(String id) {
- return getDefault().getPluginPreferences().getString(id);
- }
+ /**
+ * Return the install location preference.
+ *
+ * @param id
+ * a runtime type id
+ * @return the install location
+ */
+ public static String getPreference(String id)
+ {
+ return getDefault().getPluginPreferences().getString(id);
+ }
- /**
- * Set the install location preference.
- *
- * @param id
- * the runtimt type id
- * @param value
- * the location
- */
- public static void setPreference(String id, String value) {
- getDefault().getPluginPreferences().setValue(id, value);
- getDefault().savePluginPreferences();
- }
-
- /**
- * Return a <code>java.io.File</code> object that corresponds to the
- * specified <code>IPath</code> in the plugin directory.
- *
- * @return a file
- */
- public static File getPlugin() {
- try {
- URL installURL = getDefault().getBundle().getEntry("/");
- URL localURL = FileLocator.toFileURL(installURL);
- return new File(localURL.getFile());
- } catch (IOException ioe) {
- return null;
- }
- }
+ /**
+ * Set the install location preference.
+ *
+ * @param id
+ * the runtimt type id
+ * @param value
+ * the location
+ */
+ public static void setPreference(String id, String value)
+ {
+ getDefault().getPluginPreferences().setValue(id,value);
+ getDefault().savePluginPreferences();
+ }
- /**
- * Convenience method for logging.
- *
- * @param status
- * a status object
- */
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
+ /**
+ * Return a <code>java.io.File</code> object that corresponds to the specified <code>IPath</code> in the plugin directory.
+ *
+ * @return a file
+ */
+ public static File getPlugin()
+ {
+ try
+ {
+ URL installURL = getDefault().getBundle().getEntry("/");
+ URL localURL = FileLocator.toFileURL(installURL);
+ return new File(localURL.getFile());
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ }
- /**
- * Log message.
- *
- * @param message
- */
- public static void log(String message) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, null));
- }
+ /**
+ * Convenience method for logging.
+ *
+ * @param status
+ * a status object
+ */
+ public static void log(IStatus status)
+ {
+ getDefault().getLog().log(status);
+ }
- /**
- * Log error.
- *
- * @param e
- */
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, e.getMessage(),
- e));
- }
+ /**
+ * Log message.
+ *
+ * @param message
+ */
+ public static void log(String message)
+ {
+ log(new Status(IStatus.ERROR,PLUGIN_ID,IStatus.ERROR,message,null));
+ }
- public static IJettyVersionHandler getJettyVersionHandler(String id) {
- return JettyVersionManager.INSTANCE.getJettyVersionHandler(id);
- }
-
- public static IJettyConfiguration getJettyConfiguration(String id, IFolder path) {
- return JettyVersionManager.INSTANCE.getJettyConfiguration(id, path);
- }
-
- public static Collection<String> getRuntimeTypes() {
- return JettyVersionManager.INSTANCE.getRuntimeTypes();
- }
+ /**
+ * Log error.
+ *
+ * @param e
+ */
+ public static void log(Throwable e)
+ {
+ log(new Status(IStatus.ERROR,PLUGIN_ID,IStatus.ERROR,e.getMessage(),e));
+ }
+
+ public static IJettyVersionHandler getJettyVersionHandler(String id)
+ {
+ return JettyVersionManager.INSTANCE.getJettyVersionHandler(id);
+ }
+
+ public static IJettyConfiguration getJettyConfiguration(String id, IFolder path)
+ {
+ return JettyVersionManager.INSTANCE.getJettyConfiguration(id,path);
+ }
+
+ public static Collection<String> getRuntimeTypes()
+ {
+ return JettyVersionManager.INSTANCE.getRuntimeTypes();
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/WebModule.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/WebModule.java
index 1e6e69c..eb6e031 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/WebModule.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/WebModule.java
@@ -16,83 +16,94 @@
/**
* A Web module.
*/
-public class WebModule implements IJettyWebModule {
- private String docBase;
- private String path;
- private String memento;
- private boolean reloadable;
+public class WebModule implements IJettyWebModule
+{
+ private String docBase;
+ private String path;
+ private String memento;
+ private boolean reloadable;
- /**
- * WebModule constructor comment.
- *
- * @param path a path
- * @param docBase a document base
- * @param memento a memento
- * @param reloadable <code>true</code> if reloadable
- */
- public WebModule(String path, String docBase, String memento, boolean reloadable) {
- super();
- this.path = path;
- this.docBase = docBase;
- this.memento = memento;
- this.reloadable = reloadable;
- }
-
- /**
- * Get the document base.
- *
- * @return java.lang.String
- */
- public String getDocumentBase() {
- return docBase;
- }
-
- /**
- * Return the path. (context root)
- *
- * @return java.lang.String
- */
- public String getPath() {
- return path;
- }
-
- /**
- * Return the memento.
- *
- * @return java.lang.String
- */
- public String getMemento() {
- return memento;
- }
-
- /**
- * Return true if the web module is auto-reloadable.
- *
- * @return java.lang.String
- */
- public boolean isReloadable() {
- return reloadable;
- }
-
- public int hashCode()
- {
- return getDocumentBase().hashCode() + getPath().hashCode() + getMemento().hashCode();
+ /**
+ * WebModule constructor comment.
+ *
+ * @param path
+ * a path
+ * @param docBase
+ * a document base
+ * @param memento
+ * a memento
+ * @param reloadable
+ * <code>true</code> if reloadable
+ */
+ public WebModule(String path, String docBase, String memento, boolean reloadable)
+ {
+ super();
+ this.path = path;
+ this.docBase = docBase;
+ this.memento = memento;
+ this.reloadable = reloadable;
}
-
- /**
- * @see Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (!(obj instanceof WebModule))
- return false;
-
- WebModule wm = (WebModule) obj;
- if (!getDocumentBase().equals(wm.getDocumentBase()))
- return false;
- if (!getPath().equals(wm.getPath()))
- return false;
- if (!getMemento().equals(wm.getMemento()))
- return false;
- return true;
- }
+
+ /**
+ * Get the document base.
+ *
+ * @return java.lang.String
+ */
+ public String getDocumentBase()
+ {
+ return docBase;
+ }
+
+ /**
+ * Return the path. (context root)
+ *
+ * @return java.lang.String
+ */
+ public String getPath()
+ {
+ return path;
+ }
+
+ /**
+ * Return the memento.
+ *
+ * @return java.lang.String
+ */
+ public String getMemento()
+ {
+ return memento;
+ }
+
+ /**
+ * Return true if the web module is auto-reloadable.
+ *
+ * @return java.lang.String
+ */
+ public boolean isReloadable()
+ {
+ return reloadable;
+ }
+
+ public int hashCode()
+ {
+ return getDocumentBase().hashCode() + getPath().hashCode() + getMemento().hashCode();
+ }
+
+ /**
+ * @see Object#equals(Object)
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof WebModule))
+ return false;
+
+ WebModule wm = (WebModule)obj;
+ if (!getDocumentBase().equals(wm.getDocumentBase()))
+ return false;
+ if (!getPath().equals(wm.getPath()))
+ return false;
+ if (!getMemento().equals(wm.getMemento()))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/AddModuleCommand.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/AddModuleCommand.java
index 9aa746a..4925b39 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/AddModuleCommand.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/AddModuleCommand.java
@@ -20,45 +20,61 @@
import org.eclipse.jst.server.jetty.core.internal.Messages;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+
/**
* Command to add a web module to a server.
*/
-public class AddModuleCommand extends AbstractOperation {
- protected IServerWorkingCopy server;
- protected IModule module;
- protected int modules = -1;
+public class AddModuleCommand extends AbstractOperation
+{
+ protected IServerWorkingCopy server;
+ protected IModule module;
+ protected int modules = -1;
- /**
- * AddModuleCommand constructor comment.
- *
- * @param server a server
- * @param module a web module
- */
- public AddModuleCommand(IServerWorkingCopy server, IModule module) {
- super(Messages.configurationEditorActionAddWebModule);
- this.server = server;
- this.module = module;
- }
+ /**
+ * AddModuleCommand constructor comment.
+ *
+ * @param server
+ * a server
+ * @param module
+ * a web module
+ */
+ public AddModuleCommand(IServerWorkingCopy server, IModule module)
+ {
+ super(Messages.configurationEditorActionAddWebModule);
+ this.server = server;
+ this.module = module;
+ }
- public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- server.modifyModules(new IModule[] { module }, null, monitor);
- } catch (Exception e) {
- // ignore
- }
- return Status.OK_STATUS;
- }
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ try
+ {
+ server.modifyModules(new IModule[]
+ { module },null,monitor);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ return Status.OK_STATUS;
+ }
- public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- return execute(monitor, info);
- }
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return execute(monitor,info);
+ }
- public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- server.modifyModules(null, new IModule[] { module }, monitor);
- } catch (Exception e) {
- // ignore
- }
- return Status.OK_STATUS;
- }
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ try
+ {
+ server.modifyModules(null,new IModule[]
+ { module },monitor);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ return Status.OK_STATUS;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/AddWebModuleCommand.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/AddWebModuleCommand.java
index 48f9af1..7840fa8 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/AddWebModuleCommand.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/AddWebModuleCommand.java
@@ -15,37 +15,42 @@
import org.eclipse.jst.server.jetty.core.WebModule;
import org.eclipse.jst.server.jetty.core.internal.Messages;
-
/**
* Command to add a web module.
*/
-public class AddWebModuleCommand extends ConfigurationCommand {
- protected WebModule module;
- protected int modules = -1;
+public class AddWebModuleCommand extends ConfigurationCommand
+{
+ protected WebModule module;
+ protected int modules = -1;
- /**
- * AddWebModuleCommand constructor comment.
- *
- * @param configuration a Jetty configuration
- * @param module a web module
- */
- public AddWebModuleCommand(IJettyConfigurationWorkingCopy configuration, WebModule module) {
- super(configuration, Messages.configurationEditorActionAddWebModule);
- this.module = module;
- }
+ /**
+ * AddWebModuleCommand constructor comment.
+ *
+ * @param configuration
+ * a Jetty configuration
+ * @param module
+ * a web module
+ */
+ public AddWebModuleCommand(IJettyConfigurationWorkingCopy configuration, WebModule module)
+ {
+ super(configuration,Messages.configurationEditorActionAddWebModule);
+ this.module = module;
+ }
- /**
- * Execute the command.
- */
- public void execute() {
- modules = configuration.getWebModules().size();
- configuration.addWebModule(-1, module);
- }
+ /**
+ * Execute the command.
+ */
+ public void execute()
+ {
+ modules = configuration.getWebModules().size();
+ configuration.addWebModule(-1,module);
+ }
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.removeWebModule(modules);
- }
+ /**
+ * Undo the command.
+ */
+ public void undo()
+ {
+ configuration.removeWebModule(modules);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ConfigurationCommand.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ConfigurationCommand.java
index 48d115b..39d32ca 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ConfigurationCommand.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ConfigurationCommand.java
@@ -21,41 +21,42 @@
/**
* Configuration command.
*/
-public abstract class ConfigurationCommand extends AbstractOperation {
- protected IJettyConfigurationWorkingCopy configuration;
+public abstract class ConfigurationCommand extends AbstractOperation
+{
+ protected IJettyConfigurationWorkingCopy configuration;
- /**
- * ConfigurationCommand constructor comment.
- *
- * @param configuration
- * a Jetty configuration
- * @param label
- * a label
- */
- public ConfigurationCommand(IJettyConfigurationWorkingCopy configuration,
- String label) {
- super(label);
- this.configuration = configuration;
- }
+ /**
+ * ConfigurationCommand constructor comment.
+ *
+ * @param configuration
+ * a Jetty configuration
+ * @param label
+ * a label
+ */
+ public ConfigurationCommand(IJettyConfigurationWorkingCopy configuration, String label)
+ {
+ super(label);
+ this.configuration = configuration;
+ }
- public IStatus redo(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- return execute(monitor, info);
- }
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return execute(monitor,info);
+ }
- public abstract void execute();
+ public abstract void execute();
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- execute();
- return null;
- }
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ execute();
+ return null;
+ }
- public abstract void undo();
+ public abstract void undo();
- public IStatus undo(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- undo();
- return null;
- }
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ undo();
+ return null;
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ModifyPortCommand.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ModifyPortCommand.java
index a143ab0..436f6b5 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ModifyPortCommand.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ModifyPortCommand.java
@@ -20,48 +20,52 @@
/**
* Command to change the configuration port.
*/
-public class ModifyPortCommand extends ConfigurationCommand {
- protected String id;
- protected int port;
- protected int oldPort;
+public class ModifyPortCommand extends ConfigurationCommand
+{
+ protected String id;
+ protected int port;
+ protected int oldPort;
- /**
- * ModifyPortCommand constructor.
- *
- * @param configuration
- * a Jetty configuration
- * @param id
- * a port id
- * @param port
- * new port number
- */
- public ModifyPortCommand(IJettyConfigurationWorkingCopy configuration,
- String id, int port) {
- super(configuration, Messages.configurationEditorActionModifyPort);
- this.id = id;
- this.port = port;
- }
+ /**
+ * ModifyPortCommand constructor.
+ *
+ * @param configuration
+ * a Jetty configuration
+ * @param id
+ * a port id
+ * @param port
+ * new port number
+ */
+ public ModifyPortCommand(IJettyConfigurationWorkingCopy configuration, String id, int port)
+ {
+ super(configuration,Messages.configurationEditorActionModifyPort);
+ this.id = id;
+ this.port = port;
+ }
- /**
- * Execute the command.
- */
- public void execute() {
- // find old port number
- Iterator iterator = configuration.getServerPorts().iterator();
- while (iterator.hasNext()) {
- ServerPort temp = (ServerPort) iterator.next();
- if (id.equals(temp.getId()))
- oldPort = temp.getPort();
- }
+ /**
+ * Execute the command.
+ */
+ public void execute()
+ {
+ // find old port number
+ Iterator iterator = configuration.getServerPorts().iterator();
+ while (iterator.hasNext())
+ {
+ ServerPort temp = (ServerPort)iterator.next();
+ if (id.equals(temp.getId()))
+ oldPort = temp.getPort();
+ }
- // make the change
- configuration.modifyServerPort(id, port);
- }
+ // make the change
+ configuration.modifyServerPort(id,port);
+ }
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.modifyServerPort(id, oldPort);
- }
+ /**
+ * Undo the command.
+ */
+ public void undo()
+ {
+ configuration.modifyServerPort(id,oldPort);
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ModifyWebModuleCommand.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ModifyWebModuleCommand.java
index 8f65061..9f2136b 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ModifyWebModuleCommand.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/ModifyWebModuleCommand.java
@@ -14,32 +14,37 @@
import org.eclipse.jst.server.jetty.core.IJettyConfigurationWorkingCopy;
import org.eclipse.jst.server.jetty.core.WebModule;
import org.eclipse.jst.server.jetty.core.internal.Messages;
+
/**
* Command to change a web module.
*/
-public class ModifyWebModuleCommand extends ConfigurationCommand {
- protected int index;
- protected WebModule oldModule;
- protected WebModule newModule;
+public class ModifyWebModuleCommand extends ConfigurationCommand
+{
+ protected int index;
+ protected WebModule oldModule;
+ protected WebModule newModule;
- public ModifyWebModuleCommand(IJettyConfigurationWorkingCopy configuration, int index, WebModule module) {
- super(configuration, Messages.configurationEditorActionModifyWebModule);
- this.index = index;
- newModule = module;
- }
+ public ModifyWebModuleCommand(IJettyConfigurationWorkingCopy configuration, int index, WebModule module)
+ {
+ super(configuration,Messages.configurationEditorActionModifyWebModule);
+ this.index = index;
+ newModule = module;
+ }
- /**
- * Execute the command.
- */
- public void execute() {
- oldModule = (WebModule) configuration.getWebModules().get(index);
- configuration.modifyWebModule(index, newModule.getDocumentBase(), newModule.getPath(), newModule.isReloadable());
- }
+ /**
+ * Execute the command.
+ */
+ public void execute()
+ {
+ oldModule = (WebModule)configuration.getWebModules().get(index);
+ configuration.modifyWebModule(index,newModule.getDocumentBase(),newModule.getPath(),newModule.isReloadable());
+ }
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.modifyWebModule(index, oldModule.getDocumentBase(), oldModule.getPath(), oldModule.isReloadable());
- }
+ /**
+ * Undo the command.
+ */
+ public void undo()
+ {
+ configuration.modifyWebModule(index,oldModule.getDocumentBase(),oldModule.getPath(),oldModule.isReloadable());
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/RemoveModuleCommand.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/RemoveModuleCommand.java
index 8d7babc..28d569b 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/RemoveModuleCommand.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/RemoveModuleCommand.java
@@ -20,44 +20,60 @@
import org.eclipse.jst.server.jetty.core.internal.Messages;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+
/**
* Command to remove a web module from a server.
*/
-public class RemoveModuleCommand extends AbstractOperation {
- protected IServerWorkingCopy server;
- protected IModule module;
+public class RemoveModuleCommand extends AbstractOperation
+{
+ protected IServerWorkingCopy server;
+ protected IModule module;
- /**
- * AddModuleCommand constructor comment.
- *
- * @param server a server
- * @param module a web module
- */
- public RemoveModuleCommand(IServerWorkingCopy server, IModule module) {
- super(Messages.configurationEditorActionRemoveWebModule);
- this.server = server;
- this.module = module;
- }
+ /**
+ * AddModuleCommand constructor comment.
+ *
+ * @param server
+ * a server
+ * @param module
+ * a web module
+ */
+ public RemoveModuleCommand(IServerWorkingCopy server, IModule module)
+ {
+ super(Messages.configurationEditorActionRemoveWebModule);
+ this.server = server;
+ this.module = module;
+ }
- public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- server.modifyModules(null, new IModule[] { module }, monitor);
- } catch (Exception e) {
- // ignore
- }
- return Status.OK_STATUS;
- }
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ try
+ {
+ server.modifyModules(null,new IModule[]
+ { module },monitor);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ return Status.OK_STATUS;
+ }
- public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- return execute(monitor, info);
- }
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return execute(monitor,info);
+ }
- public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- server.modifyModules(new IModule[] { module }, null, monitor);
- } catch (Exception e) {
- // ignore
- }
- return Status.OK_STATUS;
- }
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ try
+ {
+ server.modifyModules(new IModule[]
+ { module },null,monitor);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ return Status.OK_STATUS;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/RemoveWebModuleCommand.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/RemoveWebModuleCommand.java
index 0526b50..f394c21 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/RemoveWebModuleCommand.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/command/RemoveWebModuleCommand.java
@@ -14,36 +14,43 @@
import org.eclipse.jst.server.jetty.core.IJettyConfigurationWorkingCopy;
import org.eclipse.jst.server.jetty.core.WebModule;
import org.eclipse.jst.server.jetty.core.internal.Messages;
+
/**
* Command to remove a web module.
*/
-public class RemoveWebModuleCommand extends ConfigurationCommand {
- protected int index;
- protected WebModule module;
+public class RemoveWebModuleCommand extends ConfigurationCommand
+{
+ protected int index;
+ protected WebModule module;
- /**
- * RemoveWebModuleCommand constructor comment.
- *
- * @param configuration a jetty configuration
- * @param index an index
- */
- public RemoveWebModuleCommand(IJettyConfigurationWorkingCopy configuration, int index) {
- super(configuration, Messages.configurationEditorActionRemoveWebModule);
- this.index = index;
- }
+ /**
+ * RemoveWebModuleCommand constructor comment.
+ *
+ * @param configuration
+ * a jetty configuration
+ * @param index
+ * an index
+ */
+ public RemoveWebModuleCommand(IJettyConfigurationWorkingCopy configuration, int index)
+ {
+ super(configuration,Messages.configurationEditorActionRemoveWebModule);
+ this.index = index;
+ }
- /**
- * Execute the command.
- */
- public void execute() {
- module = (WebModule) configuration.getWebModules().get(index);
- configuration.removeWebModule(index);
- }
+ /**
+ * Execute the command.
+ */
+ public void execute()
+ {
+ module = (WebModule)configuration.getWebModules().get(index);
+ configuration.removeWebModule(index);
+ }
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.addWebModule(index, module);
- }
+ /**
+ * Undo the command.
+ */
+ public void undo()
+ {
+ configuration.addWebModule(index,module);
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/ClassDetector.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/ClassDetector.java
index fc0d82f..f5cbb87 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/ClassDetector.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/ClassDetector.java
@@ -10,22 +10,28 @@
* Angelo Zerr <angelo.zerr@gmail.com> - Jetty packages
*******************************************************************************/
package org.eclipse.jst.server.jetty.core.internal;
+
/**
- * Utility class to check for the existence of a class given as an
- * argument.
+ * Utility class to check for the existence of a class given as an argument.
*/
-public class ClassDetector {
- public static void main(String[] args) {
- if (args == null || args.length != 1) {
- System.out.println("Usage: ClassDetector [className]");
- return;
- }
-
- try {
- Class.forName(args[0]);
- System.out.println("true");
- } catch (Exception e) {
- System.out.println("false");
- }
- }
+public class ClassDetector
+{
+ public static void main(String[] args)
+ {
+ if (args == null || args.length != 1)
+ {
+ System.out.println("Usage: ClassDetector [className]");
+ return;
+ }
+
+ try
+ {
+ Class.forName(args[0]);
+ System.out.println("true");
+ }
+ catch (Exception e)
+ {
+ System.out.println("false");
+ }
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/FileUtil.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/FileUtil.java
index 8269846..b881da5 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/FileUtil.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/FileUtil.java
@@ -28,263 +28,337 @@
import org.eclipse.jst.server.jetty.core.JettyPlugin;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.util.PublishHelper;
+
/**
* Utility class with an assortment of useful file methods.
*/
-public class FileUtil {
- // size of the buffer
- private static final int BUFFER = 10240;
+public class FileUtil
+{
+ // size of the buffer
+ private static final int BUFFER = 10240;
- // the buffer
- private static byte[] buf = new byte[BUFFER];
+ // the buffer
+ private static byte[] buf = new byte[BUFFER];
- /**
- * FileUtil cannot be created. Use static methods.
- */
- private FileUtil() {
- super();
- }
+ /**
+ * FileUtil cannot be created. Use static methods.
+ */
+ private FileUtil()
+ {
+ super();
+ }
- /**
- * Copys a directory from a to b.
- *
- * @param from java.lang.String
- * @param to java.lang.String
- * @param monitor a progress monitor, or <code>null</code>
- */
- public static void copyDirectory(String from, String to, IProgressMonitor monitor) {
- try {
- File fromDir = new File(from);
- File toDir = new File(to);
-
- File[] files = fromDir.listFiles();
-
- toDir.mkdir();
-
- // cycle through files
- int size = files.length;
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(NLS.bind(Messages.copyingTask, new String[] {from, to}), size * 50);
-
- for (int i = 0; i < size; i++) {
- File current = files[i];
- String fromFile = current.getAbsolutePath();
- String toFile = to;
- if (!toFile.endsWith(File.separator))
- toFile += File.separator;
- toFile += current.getName();
- if (current.isFile()) {
- copyFile(fromFile, toFile);
- monitor.worked(50);
- } else if (current.isDirectory()) {
- monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {fromFile, toFile}));
- copyDirectory(fromFile, toFile, ProgressUtil.getSubMonitorFor(monitor, 50));
- }
- if (monitor.isCanceled())
- return;
- }
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error copying directory", e);
- }
- }
+ /**
+ * Copys a directory from a to b.
+ *
+ * @param from
+ * java.lang.String
+ * @param to
+ * java.lang.String
+ * @param monitor
+ * a progress monitor, or <code>null</code>
+ */
+ public static void copyDirectory(String from, String to, IProgressMonitor monitor)
+ {
+ try
+ {
+ File fromDir = new File(from);
+ File toDir = new File(to);
- /**
- * Copy a file from a to b. Closes the input stream after use.
- *
- * @param in java.io.InputStream
- * @param to java.lang.String
- * @return a status
- */
- public static IStatus copyFile(InputStream in, String to) {
- OutputStream out = null;
-
- try {
- out = new FileOutputStream(to);
-
- int avail = in.read(buf);
- while (avail > 0) {
- out.write(buf, 0, avail);
- avail = in.read(buf);
- }
- return Status.OK_STATUS;
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error copying file", e);
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (Exception ex) {
- // ignore
- }
- try {
- if (out != null)
- out.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- }
+ File[] files = fromDir.listFiles();
- /**
- * Copy a file from a to b.
- *
- * @param from java.lang.String
- * @param to java.lang.String
- * @return a status
- */
- public static IStatus copyFile(String from, String to) {
- try {
- return copyFile(new FileInputStream(from), to);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error copying file", e);
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
- }
- }
+ toDir.mkdir();
- /**
- * Copy a file from a to b.
- *
- * @param from java.net.URL
- * @param to java.lang.String
- * @return a status
- */
- public static IStatus copyFile(URL from, String to) {
- try {
- return copyFile(from.openStream(), to);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error copying file", e);
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
- }
- }
+ // cycle through files
+ int size = files.length;
+ monitor = ProgressUtil.getMonitorFor(monitor);
+ monitor.beginTask(NLS.bind(Messages.copyingTask,new String[]
+ { from, to }),size * 50);
- /**
- * Copys a directory from a to b, only modifying as needed
- * and deleting old files and directories.
- *
- * @param from a directory
- * @param to a directory
- * @param monitor a progress monitor
- * @deprecated will be removed in next release
- */
- public static void smartCopyDirectory(String from, String to, IProgressMonitor monitor) {
- try {
- File fromDir = new File(from);
- File toDir = new File(to);
-
- File[] fromFiles = fromDir.listFiles();
- int fromSize = fromFiles.length;
-
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(NLS.bind(Messages.copyingTask, new String[] {from, to}), 550);
-
- File[] toFiles = null;
-
- // delete old files and directories from this directory
- if (toDir.exists() && toDir.isDirectory()) {
- toFiles = toDir.listFiles();
- int toSize = toFiles.length;
-
- // check if this exact file exists in the new directory
- for (int i = 0; i < toSize; i++) {
- String name = toFiles[i].getName();
- boolean isDir = toFiles[i].isDirectory();
- boolean found = false;
- for (int j = 0; j < fromSize; j++) {
- if (name.equals(fromFiles[j].getName()) && isDir == fromFiles[j].isDirectory())
- found = true;
- }
-
- // delete file if it can't be found or isn't the correct type
- if (!found) {
- if (isDir)
- PublishHelper.deleteDirectory(toFiles[i], null);
- else
- toFiles[i].delete();
- }
- if (monitor.isCanceled())
- return;
- }
- } else {
- if (toDir.isFile())
- toDir.delete();
- toDir.mkdir();
- }
- monitor.worked(50);
-
- // cycle through files and only copy when it doesn't exist
- // or is newer
- toFiles = toDir.listFiles();
- int toSize = toFiles.length;
- int dw = 0;
- if (toSize > 0)
- dw = 500 / toSize;
-
- for (int i = 0; i < fromSize; i++) {
- File current = fromFiles[i];
-
- // check if this is a new or newer file
- boolean copy = true;
- if (!current.isDirectory()) {
- String name = current.getName();
- long mod = current.lastModified();
- for (int j = 0; j < toSize; j++) {
- if (name.equals(toFiles[j].getName()) && mod <= toFiles[j].lastModified())
- copy = false;
- }
- }
-
- if (copy) {
- String fromFile = current.getAbsolutePath();
- String toFile = to;
- if (!toFile.endsWith(File.separator))
- toFile += File.separator;
- toFile += current.getName();
- if (current.isFile()) {
- copyFile(fromFile, toFile);
- monitor.worked(dw);
- } else if (current.isDirectory()) {
- monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {fromFile, toFile}));
- smartCopyDirectory(fromFile, toFile, ProgressUtil.getSubMonitorFor(monitor, dw));
- }
- }
- if (monitor.isCanceled())
- return;
- }
- monitor.worked(500 - dw * toSize);
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error smart copying directory " + from + " - " + to, e);
- }
- }
-
- /**
- * Reads the from the specified InputStream and returns
- * the result as a String. Each line is terminated by
- * "\n". Returns whatever is read regardless
- * of any errors that occurs while reading.
- *
- * @param stream InputStream for the contents to be read
- * @return contents read
- * @throws IOException if error occurs closing the stream
- */
- public static String getFileContents(InputStream stream) throws IOException {
- BufferedReader br = null;
- StringBuffer sb = new StringBuffer();
- try {
- br = new BufferedReader(new InputStreamReader(stream));
- String temp = br.readLine();
- while (temp != null) {
- sb.append(temp).append("\n");
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load file contents.", e);
- } finally {
- if (br != null)
- br.close();
- }
- return sb.toString();
- }
+ for (int i = 0; i < size; i++)
+ {
+ File current = files[i];
+ String fromFile = current.getAbsolutePath();
+ String toFile = to;
+ if (!toFile.endsWith(File.separator))
+ toFile += File.separator;
+ toFile += current.getName();
+ if (current.isFile())
+ {
+ copyFile(fromFile,toFile);
+ monitor.worked(50);
+ }
+ else if (current.isDirectory())
+ {
+ monitor.subTask(NLS.bind(Messages.copyingTask,new String[]
+ { fromFile, toFile }));
+ copyDirectory(fromFile,toFile,ProgressUtil.getSubMonitorFor(monitor,50));
+ }
+ if (monitor.isCanceled())
+ return;
+ }
+ monitor.done();
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error copying directory",e);
+ }
+ }
+
+ /**
+ * Copy a file from a to b. Closes the input stream after use.
+ *
+ * @param in
+ * java.io.InputStream
+ * @param to
+ * java.lang.String
+ * @return a status
+ */
+ public static IStatus copyFile(InputStream in, String to)
+ {
+ OutputStream out = null;
+
+ try
+ {
+ out = new FileOutputStream(to);
+
+ int avail = in.read(buf);
+ while (avail > 0)
+ {
+ out.write(buf,0,avail);
+ avail = in.read(buf);
+ }
+ return Status.OK_STATUS;
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error copying file",e);
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorCopyingFile,new String[]
+ { to, e.getLocalizedMessage() }),e);
+ }
+ finally
+ {
+ try
+ {
+ if (in != null)
+ in.close();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ try
+ {
+ if (out != null)
+ out.close();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ }
+ }
+
+ /**
+ * Copy a file from a to b.
+ *
+ * @param from
+ * java.lang.String
+ * @param to
+ * java.lang.String
+ * @return a status
+ */
+ public static IStatus copyFile(String from, String to)
+ {
+ try
+ {
+ return copyFile(new FileInputStream(from),to);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error copying file",e);
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorCopyingFile,new String[]
+ { to, e.getLocalizedMessage() }),e);
+ }
+ }
+
+ /**
+ * Copy a file from a to b.
+ *
+ * @param from
+ * java.net.URL
+ * @param to
+ * java.lang.String
+ * @return a status
+ */
+ public static IStatus copyFile(URL from, String to)
+ {
+ try
+ {
+ return copyFile(from.openStream(),to);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error copying file",e);
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorCopyingFile,new String[]
+ { to, e.getLocalizedMessage() }),e);
+ }
+ }
+
+ /**
+ * Copys a directory from a to b, only modifying as needed and deleting old files and directories.
+ *
+ * @param from
+ * a directory
+ * @param to
+ * a directory
+ * @param monitor
+ * a progress monitor
+ * @deprecated will be removed in next release
+ */
+ public static void smartCopyDirectory(String from, String to, IProgressMonitor monitor)
+ {
+ try
+ {
+ File fromDir = new File(from);
+ File toDir = new File(to);
+
+ File[] fromFiles = fromDir.listFiles();
+ int fromSize = fromFiles.length;
+
+ monitor = ProgressUtil.getMonitorFor(monitor);
+ monitor.beginTask(NLS.bind(Messages.copyingTask,new String[]
+ { from, to }),550);
+
+ File[] toFiles = null;
+
+ // delete old files and directories from this directory
+ if (toDir.exists() && toDir.isDirectory())
+ {
+ toFiles = toDir.listFiles();
+ int toSize = toFiles.length;
+
+ // check if this exact file exists in the new directory
+ for (int i = 0; i < toSize; i++)
+ {
+ String name = toFiles[i].getName();
+ boolean isDir = toFiles[i].isDirectory();
+ boolean found = false;
+ for (int j = 0; j < fromSize; j++)
+ {
+ if (name.equals(fromFiles[j].getName()) && isDir == fromFiles[j].isDirectory())
+ found = true;
+ }
+
+ // delete file if it can't be found or isn't the correct type
+ if (!found)
+ {
+ if (isDir)
+ PublishHelper.deleteDirectory(toFiles[i],null);
+ else
+ toFiles[i].delete();
+ }
+ if (monitor.isCanceled())
+ return;
+ }
+ }
+ else
+ {
+ if (toDir.isFile())
+ toDir.delete();
+ toDir.mkdir();
+ }
+ monitor.worked(50);
+
+ // cycle through files and only copy when it doesn't exist
+ // or is newer
+ toFiles = toDir.listFiles();
+ int toSize = toFiles.length;
+ int dw = 0;
+ if (toSize > 0)
+ dw = 500 / toSize;
+
+ for (int i = 0; i < fromSize; i++)
+ {
+ File current = fromFiles[i];
+
+ // check if this is a new or newer file
+ boolean copy = true;
+ if (!current.isDirectory())
+ {
+ String name = current.getName();
+ long mod = current.lastModified();
+ for (int j = 0; j < toSize; j++)
+ {
+ if (name.equals(toFiles[j].getName()) && mod <= toFiles[j].lastModified())
+ copy = false;
+ }
+ }
+
+ if (copy)
+ {
+ String fromFile = current.getAbsolutePath();
+ String toFile = to;
+ if (!toFile.endsWith(File.separator))
+ toFile += File.separator;
+ toFile += current.getName();
+ if (current.isFile())
+ {
+ copyFile(fromFile,toFile);
+ monitor.worked(dw);
+ }
+ else if (current.isDirectory())
+ {
+ monitor.subTask(NLS.bind(Messages.copyingTask,new String[]
+ { fromFile, toFile }));
+ smartCopyDirectory(fromFile,toFile,ProgressUtil.getSubMonitorFor(monitor,dw));
+ }
+ }
+ if (monitor.isCanceled())
+ return;
+ }
+ monitor.worked(500 - dw * toSize);
+ monitor.done();
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error smart copying directory " + from + " - " + to,e);
+ }
+ }
+
+ /**
+ * Reads the from the specified InputStream and returns the result as a String. Each line is terminated by "\n". Returns whatever is read
+ * regardless of any errors that occurs while reading.
+ *
+ * @param stream
+ * InputStream for the contents to be read
+ * @return contents read
+ * @throws IOException
+ * if error occurs closing the stream
+ */
+ public static String getFileContents(InputStream stream) throws IOException
+ {
+ BufferedReader br = null;
+ StringBuffer sb = new StringBuffer();
+ try
+ {
+ br = new BufferedReader(new InputStreamReader(stream));
+ String temp = br.readLine();
+ while (temp != null)
+ {
+ sb.append(temp).append("\n");
+ temp = br.readLine();
+ }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.WARNING,"Could not load file contents.",e);
+ }
+ finally
+ {
+ if (br != null)
+ br.close();
+ }
+ return sb.toString();
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyRuntime.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyRuntime.java
index 4cb17fe..ac23fb8 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyRuntime.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyRuntime.java
@@ -19,11 +19,12 @@
/**
*
*/
-public interface IJettyRuntime extends IJavaRuntime {
- /**
- * Returns the runtime classpath that is used by this runtime.
- *
- * @return the runtime classpath
- */
- public Collection<IRuntimeClasspathEntry> getRuntimeClasspath(IPath configPath);
+public interface IJettyRuntime extends IJavaRuntime
+{
+ /**
+ * Returns the runtime classpath that is used by this runtime.
+ *
+ * @return the runtime classpath
+ */
+ public Collection<IRuntimeClasspathEntry> getRuntimeClasspath(IPath configPath);
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyServerBehaviour.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyServerBehaviour.java
index 43a2c3f..bc907d8 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyServerBehaviour.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyServerBehaviour.java
@@ -14,22 +14,27 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
-public interface IJettyServerBehaviour {
+public interface IJettyServerBehaviour
+{
- /**
- * Returns the main class that is used to launch the Jetty server.
- *
- * @return the main runtime class
- */
- public String getRuntimeClass();
+ /**
+ * Returns the main class that is used to launch the Jetty server.
+ *
+ * @return the main runtime class
+ */
+ public String getRuntimeClass();
- /**
- * Setup for starting the server.
- *
- * @param launch ILaunch
- * @param launchMode String
- * @param monitor IProgressMonitor
- * @throws CoreException if anything goes wrong
- */
- public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException;
+ /**
+ * Setup for starting the server.
+ *
+ * @param launch
+ * ILaunch
+ * @param launchMode
+ * String
+ * @param monitor
+ * IProgressMonitor
+ * @throws CoreException
+ * if anything goes wrong
+ */
+ public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException;
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyVersionHandler.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyVersionHandler.java
index 238ec1a..9fcf8dc 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyVersionHandler.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyVersionHandler.java
@@ -18,122 +18,114 @@
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.wst.server.core.IModule;
-public interface IJettyVersionHandler {
+public interface IJettyVersionHandler
+{
- /**
- * Verifies if the specified path points to a a Jetty installation of this
- * version.
- *
- * @param installPath
- * an installation path
- * @return OK status if a valid installation exists at the location. If not
- * valid, the IStatus contains an indication of why.
- */
- public IStatus verifyInstallPath(IPath installPath);
+ /**
+ * Verifies if the specified path points to a a Jetty installation of this version.
+ *
+ * @param installPath
+ * an installation path
+ * @return OK status if a valid installation exists at the location. If not valid, the IStatus contains an indication of why.
+ */
+ public IStatus verifyInstallPath(IPath installPath);
- /**
- * Gets the startup class for the Jetty server.
- *
- * @return server startup class
- */
- public String getRuntimeClass();
+ /**
+ * Gets the startup class for the Jetty server.
+ *
+ * @return server startup class
+ */
+ public String getRuntimeClass();
- /**
- * Gets the startup classpath for the Jetty server.
- *
- * @param installPath
- * an installation path
- * @return list of classpath entries required to start the Jetty server.
- */
- public Collection<IRuntimeClasspathEntry> getRuntimeClasspath(
- IPath installPath, IPath configPath);
+ /**
+ * Gets the startup classpath for the Jetty server.
+ *
+ * @param installPath
+ * an installation path
+ * @return list of classpath entries required to start the Jetty server.
+ */
+ public Collection<IRuntimeClasspathEntry> getRuntimeClasspath(IPath installPath, IPath configPath);
- /**
- * Return the program's runtime arguments.
- *
- * @param configPath
- * a config path
- * @param debug
- * <code>true</code> if debug mode is on
- * @param starting
- * <code>true</code> if the server is starting
- * @return a string array of program arguments
- */
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug,
- boolean starting);
-
- /**
- * Arguments that should not appear in the runtime arguments based on the
- * specified configuration.
- *
- * @param debug
- * <code>true</code> if debug mode is on
- * @param starting
- * <code>true</code> if the server is starting
- * @return array of excluded arguments
- */
- public String[] getExcludedRuntimeProgramArguments(boolean debug,
- boolean starting);
-
- /**
- * Gets the startup VM arguments for the Jetty server.
- *
- * @param installPath
- * installation path for the server
- * @param configPath
- * configuration path for the server
- * @param deployPath
- * deploy path for the server
- * @param isTestEnv
- * test environment flag
- * @return array of VM arguments for starting the server
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath,
- IPath deployPath, boolean isTestEnv);
+ /**
+ * Return the program's runtime arguments.
+ *
+ * @param configPath
+ * a config path
+ * @param debug
+ * <code>true</code> if debug mode is on
+ * @param starting
+ * <code>true</code> if the server is starting
+ * @return a string array of program arguments
+ */
+ public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting);
- /**
- * Gets the contents of the Java policy file for the Jetty server.
- *
- * @param configPath
- * path to configuration
- * @return contents of Java policy file in the configuration
- */
- public String getRuntimePolicyFile(IPath configPath);
+ /**
+ * Arguments that should not appear in the runtime arguments based on the specified configuration.
+ *
+ * @param debug
+ * <code>true</code> if debug mode is on
+ * @param starting
+ * <code>true</code> if the server is starting
+ * @return array of excluded arguments
+ */
+ public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting);
- /**
- * Returns the runtime base path for relative paths in the server
- * configuration.
- *
- * @param server
- * JettyServer instance from which to determine the base path.
- * @return path to Jetty instance directory
- */
- public IPath getRuntimeBaseDirectory(JettyServer server);
+ /**
+ * Gets the startup VM arguments for the Jetty server.
+ *
+ * @param installPath
+ * installation path for the server
+ * @param configPath
+ * configuration path for the server
+ * @param deployPath
+ * deploy path for the server
+ * @param isTestEnv
+ * test environment flag
+ * @return array of VM arguments for starting the server
+ */
+ public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv);
- /**
- *
- * @param path
- * @param vmInstall
- * @return
- */
- public IStatus validate(IPath path, IVMInstall vmInstall);
+ /**
+ * Gets the contents of the Java policy file for the Jetty server.
+ *
+ * @param configPath
+ * path to configuration
+ * @return contents of Java policy file in the configuration
+ */
+ public String getRuntimePolicyFile(IPath configPath);
- /**
- * Returns true if the given project is supported by this server, and false
- * otherwise.
- *
- * @param module
- * a web module
- * @return the status
- */
- public IStatus canAddModule(IModule module);
+ /**
+ * Returns the runtime base path for relative paths in the server configuration.
+ *
+ * @param server
+ * JettyServer instance from which to determine the base path.
+ * @return path to Jetty instance directory
+ */
+ public IPath getRuntimeBaseDirectory(JettyServer server);
- /**
- * Returns true if this server supports serving modules without publishing.
- *
- * @return true if serving modules without publishing is supported
- */
- public boolean supportsServeModulesWithoutPublish();
+ /**
+ *
+ * @param path
+ * @param vmInstall
+ * @return
+ */
+ public IStatus validate(IPath path, IVMInstall vmInstall);
- public IStatus prepareRuntimeDirectory(IPath confDir);
+ /**
+ * Returns true if the given project is supported by this server, and false otherwise.
+ *
+ * @param module
+ * a web module
+ * @return the status
+ */
+ public IStatus canAddModule(IModule module);
+
+ /**
+ * Returns true if this server supports serving modules without publishing.
+ *
+ * @return true if serving modules without publishing is supported
+ */
+ public boolean supportsServeModulesWithoutPublish();
+
+ public IStatus prepareRuntimeDirectory(IPath confDir);
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyVersionProvider.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyVersionProvider.java
index 8a45350..3c2e4b7 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyVersionProvider.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyVersionProvider.java
@@ -13,9 +13,10 @@
import org.eclipse.core.resources.IFolder;
import org.eclipse.jst.server.jetty.core.IJettyConfiguration;
-public interface IJettyVersionProvider {
+public interface IJettyVersionProvider
+{
- IJettyVersionHandler getJettyVersionHandler();
-
- IJettyConfiguration createJettyConfiguration(IFolder path);
+ IJettyVersionHandler getJettyVersionHandler();
+
+ IJettyConfiguration createJettyConfiguration(IFolder path);
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyWebModule.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyWebModule.java
index 97324a1..8a0fed1 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyWebModule.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/IJettyWebModule.java
@@ -10,35 +10,37 @@
* Angelo Zerr <angelo.zerr@gmail.com> - Jetty packages
*******************************************************************************/
package org.eclipse.jst.server.jetty.core.internal;
+
/**
* A Web module deployed on Jetty.
*/
-public interface IJettyWebModule {
- /**
- * Get the document base.
- *
- * @return java.lang.String
- */
- public String getDocumentBase();
+public interface IJettyWebModule
+{
+ /**
+ * Get the document base.
+ *
+ * @return java.lang.String
+ */
+ public String getDocumentBase();
- /**
- * Return the path. (context root)
- *
- * @return java.lang.String
- */
- public String getPath();
+ /**
+ * Return the path. (context root)
+ *
+ * @return java.lang.String
+ */
+ public String getPath();
- /**
- * Return the memento.
- *
- * @return java.lang.String
- */
- public String getMemento();
+ /**
+ * Return the memento.
+ *
+ * @return java.lang.String
+ */
+ public String getMemento();
- /**
- * Return true if the web module is auto-reloadable.
- *
- * @return java.lang.String
- */
- public boolean isReloadable();
+ /**
+ * Return true if the web module is auto-reloadable.
+ *
+ * @return java.lang.String
+ */
+ public boolean isReloadable();
}
\ No newline at end of file
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyConfiguration.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyConfiguration.java
index 9252e53..c173740 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyConfiguration.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyConfiguration.java
@@ -36,256 +36,265 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.ServerPort;
-public abstract class JettyConfiguration implements IJettyConfiguration,
- IJettyConfigurationWorkingCopy {
+public abstract class JettyConfiguration implements IJettyConfiguration, IJettyConfigurationWorkingCopy
+{
- private IFolder configPath;
+ private IFolder configPath;
- /**
- * JettyConfiguration constructor.
- *
- * @param path
- * a path
- */
- public JettyConfiguration(IFolder path) {
- super();
- this.configPath = path;
- }
+ /**
+ * JettyConfiguration constructor.
+ *
+ * @param path
+ * a path
+ */
+ public JettyConfiguration(IFolder path)
+ {
+ super();
+ this.configPath = path;
+ }
- protected IFolder getFolder() {
- return configPath;
- }
+ protected IFolder getFolder()
+ {
+ return configPath;
+ }
- /**
- * Return the port number.
- *
- * @return int
- */
- public ServerPort getMainPort() {
- Collection<ServerPort> serverPorts = getServerPorts();
- for (ServerPort serverPort : serverPorts) {
- // Return only an HTTP port from the selected Service
- if (serverPort.getProtocol().toLowerCase().equals("http")
- && serverPort.getId().indexOf('/') < 0)
- return serverPort;
- }
- return null;
- }
+ /**
+ * Return the port number.
+ *
+ * @return int
+ */
+ public ServerPort getMainPort()
+ {
+ Collection<ServerPort> serverPorts = getServerPorts();
+ for (ServerPort serverPort : serverPorts)
+ {
+ // Return only an HTTP port from the selected Service
+ if (serverPort.getProtocol().toLowerCase().equals("http") && serverPort.getId().indexOf('/') < 0)
+ return serverPort;
+ }
+ return null;
+ }
- /**
- * Returns the partial URL applicable to this module.
- *
- * @param webModule
- * a web module
- * @return the partial URL
- */
- public String getWebModuleURL(IModule webModule) {
- WebModule module = getWebModule(webModule);
- if (module != null)
- return module.getPath();
+ /**
+ * Returns the partial URL applicable to this module.
+ *
+ * @param webModule
+ * a web module
+ * @return the partial URL
+ */
+ public String getWebModuleURL(IModule webModule)
+ {
+ WebModule module = getWebModule(webModule);
+ if (module != null)
+ return module.getPath();
- IWebModule webModule2 = (IWebModule) webModule.loadAdapter(
- IWebModule.class, null);
- return "/" + webModule2.getContextRoot();
- }
+ IWebModule webModule2 = (IWebModule)webModule.loadAdapter(IWebModule.class,null);
+ return "/" + webModule2.getContextRoot();
+ }
- /**
- * Returns the given module from the config.
- *
- * @param module
- * a web module
- * @return a web module
- */
- public WebModule getWebModule(IModule module) {
- if (module == null)
- return null;
+ /**
+ * Returns the given module from the config.
+ *
+ * @param module
+ * a web module
+ * @return a web module
+ */
+ public WebModule getWebModule(IModule module)
+ {
+ if (module == null)
+ return null;
- String memento = module.getId();
+ String memento = module.getId();
- List<WebModule> modules = getWebModules();
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- WebModule webModule = modules.get(i);
- if (memento.equals(webModule.getMemento())) {
- return webModule;
- }
- }
- return null;
- }
+ List<WebModule> modules = getWebModules();
+ int size = modules.size();
+ for (int i = 0; i < size; i++)
+ {
+ WebModule webModule = modules.get(i);
+ if (memento.equals(webModule.getMemento()))
+ {
+ return webModule;
+ }
+ }
+ return null;
+ }
- /**
- * Returns the prefix that is used in front of the web module path property.
- * (e.g. "webapps")
- *
- * @return java.lang.String
- */
- public String getDocBasePrefix() {
- return "";
- }
+ /**
+ * Returns the prefix that is used in front of the web module path property. (e.g. "webapps")
+ *
+ * @return java.lang.String
+ */
+ public String getDocBasePrefix()
+ {
+ return "";
+ }
- /**
- * Copies all files from the given directory in the workbench to the given
- * location. Can be overridden by version specific class to modify or
- * enhance what publish does.
- *
- * @param jettyDir
- * Destination Jetty directory. Equivalent to catalina.base for
- * Jetty 4.x and up.
- * @param doBackup
- * Backup existing configuration files (true if not test mode).
- * @param monitor
- * Progress monitor to use
- * @return result of operation
- */
- public IStatus backupAndPublish(IPath jettyDir, boolean doBackup,
- IProgressMonitor monitor) {
- MultiStatus ms = new MultiStatus(JettyPlugin.PLUGIN_ID, 0,
- Messages.publishConfigurationTask, null);
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Backup and publish");
- monitor = ProgressUtil.getMonitorFor(monitor);
+ /**
+ * Copies all files from the given directory in the workbench to the given location. Can be overridden by version specific class to modify or enhance what
+ * publish does.
+ *
+ * @param jettyDir
+ * Destination Jetty directory. Equivalent to catalina.base for Jetty 4.x and up.
+ * @param doBackup
+ * Backup existing configuration files (true if not test mode).
+ * @param monitor
+ * Progress monitor to use
+ * @return result of operation
+ */
+ public IStatus backupAndPublish(IPath jettyDir, boolean doBackup, IProgressMonitor monitor)
+ {
+ MultiStatus ms = new MultiStatus(JettyPlugin.PLUGIN_ID,0,Messages.publishConfigurationTask,null);
+ if (Trace.isTraceEnabled())
+ Trace.trace(Trace.FINER,"Backup and publish");
+ monitor = ProgressUtil.getMonitorFor(monitor);
- try {
- IPath backup = null;
- if (doBackup) {
- // create backup directory
- backup = jettyDir.append("backup");
- if (!backup.toFile().exists())
- backup.toFile().mkdir();
- }
- backupFolder(getFolder(), jettyDir, backup, ms, monitor);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
- IStatus s = new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorPublishConfiguration,
- new String[] { e.getLocalizedMessage() }), e);
- ms.add(s);
- }
+ try
+ {
+ IPath backup = null;
+ if (doBackup)
+ {
+ // create backup directory
+ backup = jettyDir.append("backup");
+ if (!backup.toFile().exists())
+ backup.toFile().mkdir();
+ }
+ backupFolder(getFolder(),jettyDir,backup,ms,monitor);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"backupAndPublish() error",e);
+ IStatus s = new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorPublishConfiguration,new String[]
+ { e.getLocalizedMessage() }),e);
+ ms.add(s);
+ }
- monitor.done();
- return ms;
- }
+ monitor.done();
+ return ms;
+ }
- protected void backupFolder(IFolder folder, IPath confDir, IPath backup,
- MultiStatus ms, IProgressMonitor monitor) throws CoreException {
- IResource[] children = folder.members();
- if (children == null)
- return;
+ protected void backupFolder(IFolder folder, IPath confDir, IPath backup, MultiStatus ms, IProgressMonitor monitor) throws CoreException
+ {
+ IResource[] children = folder.members();
+ if (children == null)
+ return;
- IResource resource = null;
- int size = children.length;
- monitor.beginTask(Messages.publishConfigurationTask, size * 100);
- for (int i = 0; i < size; i++) {
- resource = children[i];
- switch (resource.getType()) {
- case IResource.FILE:
- try {
- IFile file = (IFile) resource;
- String name = file.getName();
- monitor.subTask(NLS.bind(Messages.publisherPublishTask,
- new String[] { name }));
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINEST, "Publishing " + name);
+ IResource resource = null;
+ int size = children.length;
+ monitor.beginTask(Messages.publishConfigurationTask,size * 100);
+ for (int i = 0; i < size; i++)
+ {
+ resource = children[i];
+ switch (resource.getType())
+ {
+ case IResource.FILE:
+ try
+ {
+ IFile file = (IFile)resource;
+ String name = file.getName();
+ monitor.subTask(NLS.bind(Messages.publisherPublishTask,new String[]
+ { name }));
+ if (Trace.isTraceEnabled())
+ Trace.trace(Trace.FINEST,"Publishing " + name);
- // backup and copy file
- boolean copy = true;
- if (backup != null
- && !(backup.append(name).toFile().exists())) {
- IStatus status = FileUtil.copyFile(confDir.append(name)
- .toOSString(), backup + File.separator + name);
- ms.add(status);
- if (!status.isOK())
- copy = false;
- }
+ // backup and copy file
+ boolean copy = true;
+ if (backup != null && !(backup.append(name).toFile().exists()))
+ {
+ IStatus status = FileUtil.copyFile(confDir.append(name).toOSString(),backup + File.separator + name);
+ ms.add(status);
+ if (!status.isOK())
+ copy = false;
+ }
- if (copy) {
- String destPath = confDir.append(name).toOSString();
- String destContents = null;
- String srcContents = null;
- File dest = new File(destPath);
- if (dest.exists()) {
- InputStream fis = new FileInputStream(destPath);
- destContents = FileUtil.getFileContents(fis);
- if (destContents != null) {
- fis = file.getContents();
- srcContents = FileUtil.getFileContents(fis);
- }
- }
- if (destContents == null || srcContents == null
- || !srcContents.equals(destContents)) {
- InputStream in = file.getContents();
- ms.add(FileUtil.copyFile(in, destPath));
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
- ms.add(new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorPublishConfiguration,
- new String[] { e.getLocalizedMessage() }),
- e));
- }
- break;
- case IResource.FOLDER:
- IFolder childFolder = (IFolder) resource;
- backupFolder(childFolder,
- confDir.append(childFolder.getName()),
- (backup != null ? backup.append(childFolder.getName())
- : null), ms, monitor);
- break;
- }
- monitor.worked(100);
- }
- }
+ if (copy)
+ {
+ String destPath = confDir.append(name).toOSString();
+ String destContents = null;
+ String srcContents = null;
+ File dest = new File(destPath);
+ if (dest.exists())
+ {
+ InputStream fis = new FileInputStream(destPath);
+ destContents = FileUtil.getFileContents(fis);
+ if (destContents != null)
+ {
+ fis = file.getContents();
+ srcContents = FileUtil.getFileContents(fis);
+ }
+ }
+ if (destContents == null || srcContents == null || !srcContents.equals(destContents))
+ {
+ InputStream in = file.getContents();
+ ms.add(FileUtil.copyFile(in,destPath));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"backupAndPublish() error",e);
+ ms.add(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorPublishConfiguration,new String[]
+ { e.getLocalizedMessage() }),e));
+ }
+ break;
+ case IResource.FOLDER:
+ IFolder childFolder = (IFolder)resource;
+ backupFolder(childFolder,confDir.append(childFolder.getName()),(backup != null?backup.append(childFolder.getName()):null),ms,monitor);
+ break;
+ }
+ monitor.worked(100);
+ }
+ }
- protected void backupPath(IPath path, IPath confDir, IPath backup,
- MultiStatus ms, IProgressMonitor monitor) {
- File[] files = path.toFile().listFiles();
- if (files == null)
- return;
+ protected void backupPath(IPath path, IPath confDir, IPath backup, MultiStatus ms, IProgressMonitor monitor)
+ {
+ File[] files = path.toFile().listFiles();
+ if (files == null)
+ return;
- int size = files.length;
- monitor.beginTask(Messages.publishConfigurationTask, size * 100);
- for (int i = 0; i < size; i++) {
- try {
- File file = files[i];
- String name = file.getName();
- monitor.subTask(NLS.bind(Messages.publisherPublishTask,
- new String[] { name }));
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINEST, "Publishing " + name);
+ int size = files.length;
+ monitor.beginTask(Messages.publishConfigurationTask,size * 100);
+ for (int i = 0; i < size; i++)
+ {
+ try
+ {
+ File file = files[i];
+ String name = file.getName();
+ monitor.subTask(NLS.bind(Messages.publisherPublishTask,new String[]
+ { name }));
+ if (Trace.isTraceEnabled())
+ Trace.trace(Trace.FINEST,"Publishing " + name);
- // backup and copy file
- boolean copy = true;
- if (backup != null && !(backup.append(name).toFile().exists())) {
- IStatus status = FileUtil.copyFile(confDir.append(name)
- .toOSString(), backup + File.separator + name);
- ms.add(status);
- if (!status.isOK())
- copy = false;
- }
+ // backup and copy file
+ boolean copy = true;
+ if (backup != null && !(backup.append(name).toFile().exists()))
+ {
+ IStatus status = FileUtil.copyFile(confDir.append(name).toOSString(),backup + File.separator + name);
+ ms.add(status);
+ if (!status.isOK())
+ copy = false;
+ }
- if (copy)
- ms.add(FileUtil.copyFile(file.getAbsolutePath(), confDir
- .append(name).toOSString()));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
- ms.add(new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0, NLS
- .bind(Messages.errorPublishConfiguration,
- new String[] { e.getLocalizedMessage() }), e));
- }
- monitor.worked(100);
- }
- }
+ if (copy)
+ ms.add(FileUtil.copyFile(file.getAbsolutePath(),confDir.append(name).toOSString()));
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"backupAndPublish() error",e);
+ ms.add(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorPublishConfiguration,new String[]
+ { e.getLocalizedMessage() }),e));
+ }
+ monitor.worked(100);
+ }
+ }
- public IStatus cleanupServer(IPath confDir, IPath installDir,
- IProgressMonitor monitor) {
- // Default implementation assumes nothing to clean
- return Status.OK_STATUS;
- }
+ public IStatus cleanupServer(IPath confDir, IPath installDir, IProgressMonitor monitor)
+ {
+ // Default implementation assumes nothing to clean
+ return Status.OK_STATUS;
+ }
- public IStatus localizeConfiguration(IPath confDir,
- IPath serverDeployDirectory, IJettyServer jettyServer,
- IProgressMonitor subMonitorFor) {
- return Status.OK_STATUS;
- }
+ public IStatus localizeConfiguration(IPath confDir, IPath serverDeployDirectory, IJettyServer jettyServer, IProgressMonitor subMonitorFor)
+ {
+ return Status.OK_STATUS;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyConstants.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyConstants.java
index 6d33725..4eaf97f 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyConstants.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyConstants.java
@@ -10,13 +10,14 @@
*******************************************************************************/
package org.eclipse.jst.server.jetty.core.internal;
-public interface JettyConstants {
-
- String START_JAR = "start.jar";
- String START_INI = "start.ini";
- String LIB_FOLDER = "lib";
- String JSP_FOLDER = "jsp";
- String JAR_EXT = "jar";
-
- String HTTP = "http";
+public interface JettyConstants
+{
+
+ String START_JAR = "start.jar";
+ String START_INI = "start.ini";
+ String LIB_FOLDER = "lib";
+ String JSP_FOLDER = "jsp";
+ String JAR_EXT = "jar";
+
+ String HTTP = "http";
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyHandler.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyHandler.java
index 2b85e7c..7781f1e 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyHandler.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyHandler.java
@@ -20,61 +20,68 @@
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jst.server.jetty.core.internal.util.JettyVersionHelper;
-public abstract class JettyHandler implements IJettyVersionHandler,
- JettyConstants {
+public abstract class JettyHandler implements IJettyVersionHandler, JettyConstants
+{
- /** configuration attribute for the full class name of the bootstrap class. */
- private static final String BOOTSTRAP_CLASS_NAME = "org.eclipse.jetty.start.Main";
+ /** configuration attribute for the full class name of the bootstrap class. */
+ private static final String BOOTSTRAP_CLASS_NAME = "org.eclipse.jetty.start.Main";
- /**
- * @see IJettyVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return BOOTSTRAP_CLASS_NAME;
- }
+ /**
+ * @see IJettyVersionHandler#getRuntimeClass()
+ */
+ public String getRuntimeClass()
+ {
+ return BOOTSTRAP_CLASS_NAME;
+ }
- public Collection<IRuntimeClasspathEntry> getRuntimeClasspath(
- IPath installPath, IPath configPath) {
- Collection<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
+ public Collection<IRuntimeClasspathEntry> getRuntimeClasspath(IPath installPath, IPath configPath)
+ {
+ Collection<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
- // Add ${jetty.home}/start.jar
- IPath startJAR = installPath.append(START_JAR);
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(startJAR));
+ // Add ${jetty.home}/start.jar
+ IPath startJAR = installPath.append(START_JAR);
+ cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(startJAR));
- // add all jars from the Jetty ${jetty.home}/lib directory
- IPath libPath = installPath.append(LIB_FOLDER);
- File libDir = libPath.toFile();
- if (libDir.exists()) {
- // lib folder, exists, loop for each JAR
- String[] libs = libDir.list();
- for (int i = 0; i < libs.length; i++) {
- if (libs[i].endsWith(JAR_EXT)) {
- IPath path = installPath.append(LIB_FOLDER).append(libs[i]);
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
- }
- }
+ // add all jars from the Jetty ${jetty.home}/lib directory
+ IPath libPath = installPath.append(LIB_FOLDER);
+ File libDir = libPath.toFile();
+ if (libDir.exists())
+ {
+ // lib folder, exists, loop for each JAR
+ String[] libs = libDir.list();
+ for (int i = 0; i < libs.length; i++)
+ {
+ if (libs[i].endsWith(JAR_EXT))
+ {
+ IPath path = installPath.append(LIB_FOLDER).append(libs[i]);
+ cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
+ }
+ }
- // add all jars from the Jetty ${jetty.home}/lib/jsp directory
- IPath jspLibPath = libPath.append(JSP_FOLDER);
- File jspLibDir = jspLibPath.toFile();
- if (jspLibDir.exists()) {
- libs = jspLibDir.list();
- for (int i = 0; i < libs.length; i++) {
- if (libs[i].endsWith(JAR_EXT)) {
- IPath path = jspLibPath.append(libs[i]);
- cp.add(JavaRuntime
- .newArchiveRuntimeClasspathEntry(path));
- }
- }
- }
- }
- return cp;
- }
+ // add all jars from the Jetty ${jetty.home}/lib/jsp directory
+ IPath jspLibPath = libPath.append(JSP_FOLDER);
+ File jspLibDir = jspLibPath.toFile();
+ if (jspLibDir.exists())
+ {
+ libs = jspLibDir.list();
+ for (int i = 0; i < libs.length; i++)
+ {
+ if (libs[i].endsWith(JAR_EXT))
+ {
+ IPath path = jspLibPath.append(libs[i]);
+ cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
+ }
+ }
+ }
+ }
+ return cp;
+ }
- /**
- * @see IJettyVersionHandler#prepareRuntimeDirectory(IPath)
- */
- public IStatus prepareRuntimeDirectory(IPath baseDir) {
- return JettyVersionHelper.createJettyInstanceDirectory(baseDir);
- }
+ /**
+ * @see IJettyVersionHandler#prepareRuntimeDirectory(IPath)
+ */
+ public IStatus prepareRuntimeDirectory(IPath baseDir)
+ {
+ return JettyVersionHelper.createJettyInstanceDirectory(baseDir);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyLaunchConfigurationDelegate.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyLaunchConfigurationDelegate.java
index 7ddcdc7..351a1f8 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyLaunchConfigurationDelegate.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyLaunchConfigurationDelegate.java
@@ -31,81 +31,90 @@
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
-public class JettyLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate {
+public class JettyLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate
+{
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
- if (server == null) {
- Trace.trace(Trace.FINEST, "Launch configuration could not find server");
- // throw CoreException();
- return;
- }
-
- if (server.shouldPublish() && ServerCore.isAutoPublishing())
- server.publish(IServer.PUBLISH_INCREMENTAL, monitor);
-
- JettyServerBehaviour jettyServer = (JettyServerBehaviour) server.loadAdapter(JettyServerBehaviour.class, null);
-
- String mainTypeName = jettyServer.getRuntimeClass();
-
- IVMInstall vm = verifyVMInstall(configuration);
-
- IVMRunner runner = vm.getVMRunner(mode);
- if (runner == null)
- runner = vm.getVMRunner(ILaunchManager.RUN_MODE);
-
- File workingDir = verifyWorkingDirectory(configuration);
- String workingDirName = null;
- if (workingDir != null)
- workingDirName = workingDir.getAbsolutePath();
-
- // Program & VM args
- String pgmArgs = getProgramArguments(configuration);
- String vmArgs = getVMArguments(configuration);
- String[] envp = getEnvironment(configuration);
-
- ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
-
- // VM-specific attributes
- Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
-
- // Classpath
- String[] classpath = getClasspath(configuration);
-
- // Create VM config
- VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
- runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
- runConfig.setVMArguments(execArgs.getVMArgumentsArray());
- runConfig.setWorkingDirectory(workingDirName);
- runConfig.setEnvironment(envp);
- runConfig.setVMSpecificAttributesMap(vmAttributesMap);
-
- // Bootpath
- String[] bootpath = getBootpath(configuration);
- if (bootpath != null && bootpath.length > 0)
- runConfig.setBootClassPath(bootpath);
-
- setDefaultSourceLocator(launch, configuration);
-
- if (ILaunchManager.PROFILE_MODE.equals(mode)) {
- try {
- ServerProfilerDelegate.configureProfiling(launch, vm, runConfig, monitor);
- } catch (CoreException ce) {
- jettyServer.stopImpl();
- throw ce;
- }
- }
-
- // Launch the configuration
- jettyServer.setupLaunch(launch, mode, monitor);
- try {
- runner.run(runConfig, launch, monitor);
- jettyServer.addProcessListener(launch.getProcesses()[0]);
- } catch (Exception e) {
- // Ensure we don't continue to think the server is starting
- jettyServer.stopImpl();
- }
- }
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException
+ {
+ IServer server = ServerUtil.getServer(configuration);
+ if (server == null)
+ {
+ Trace.trace(Trace.FINEST,"Launch configuration could not find server");
+ // throw CoreException();
+ return;
+ }
+
+ if (server.shouldPublish() && ServerCore.isAutoPublishing())
+ server.publish(IServer.PUBLISH_INCREMENTAL,monitor);
+
+ JettyServerBehaviour jettyServer = (JettyServerBehaviour)server.loadAdapter(JettyServerBehaviour.class,null);
+
+ String mainTypeName = jettyServer.getRuntimeClass();
+
+ IVMInstall vm = verifyVMInstall(configuration);
+
+ IVMRunner runner = vm.getVMRunner(mode);
+ if (runner == null)
+ runner = vm.getVMRunner(ILaunchManager.RUN_MODE);
+
+ File workingDir = verifyWorkingDirectory(configuration);
+ String workingDirName = null;
+ if (workingDir != null)
+ workingDirName = workingDir.getAbsolutePath();
+
+ // Program & VM args
+ String pgmArgs = getProgramArguments(configuration);
+ String vmArgs = getVMArguments(configuration);
+ String[] envp = getEnvironment(configuration);
+
+ ExecutionArguments execArgs = new ExecutionArguments(vmArgs,pgmArgs);
+
+ // VM-specific attributes
+ Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
+
+ // Classpath
+ String[] classpath = getClasspath(configuration);
+
+ // Create VM config
+ VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName,classpath);
+ runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
+ runConfig.setVMArguments(execArgs.getVMArgumentsArray());
+ runConfig.setWorkingDirectory(workingDirName);
+ runConfig.setEnvironment(envp);
+ runConfig.setVMSpecificAttributesMap(vmAttributesMap);
+
+ // Bootpath
+ String[] bootpath = getBootpath(configuration);
+ if (bootpath != null && bootpath.length > 0)
+ runConfig.setBootClassPath(bootpath);
+
+ setDefaultSourceLocator(launch,configuration);
+
+ if (ILaunchManager.PROFILE_MODE.equals(mode))
+ {
+ try
+ {
+ ServerProfilerDelegate.configureProfiling(launch,vm,runConfig,monitor);
+ }
+ catch (CoreException ce)
+ {
+ jettyServer.stopImpl();
+ throw ce;
+ }
+ }
+
+ // Launch the configuration
+ jettyServer.setupLaunch(launch,mode,monitor);
+ try
+ {
+ runner.run(runConfig,launch,monitor);
+ jettyServer.addProcessListener(launch.getProcesses()[0]);
+ }
+ catch (Exception e)
+ {
+ // Ensure we don't continue to think the server is starting
+ jettyServer.stopImpl();
+ }
+ }
}
-
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyLaunchableAdapterDelegate.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyLaunchableAdapterDelegate.java
index 2eec0e9..a0e423f 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyLaunchableAdapterDelegate.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyLaunchableAdapterDelegate.java
@@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.jst.server.jetty.core.internal;
-
import java.net.URL;
import org.eclipse.jst.server.core.IWebModule;
@@ -22,53 +21,63 @@
import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate;
import org.eclipse.wst.server.core.util.HttpLaunchable;
import org.eclipse.wst.server.core.util.WebResource;
+
/**
* Launchable adapter delegate for Web resources in Jetty.
*/
-public class JettyLaunchableAdapterDelegate extends LaunchableAdapterDelegate {
-
- private static final String SERVLET_PATH = "servlet/";
+public class JettyLaunchableAdapterDelegate extends LaunchableAdapterDelegate
+{
- /*
- * @see LaunchableAdapterDelegate#getLaunchable(IServer, IModuleArtifact)
- */
- public Object getLaunchable(IServer server, IModuleArtifact moduleObject) {
- Trace.trace(Trace.FINER, "JettyLaunchableAdapter " + server + "-" + moduleObject);
- if (server.getAdapter(JettyServer.class) == null)
- return null;
- if (!(moduleObject instanceof Servlet) &&
- !(moduleObject instanceof WebResource))
- return null;
- if (moduleObject.getModule().loadAdapter(IWebModule.class, null) == null)
- return null;
-
- try {
- URL url = ((IURLProvider) server.loadAdapter(IURLProvider.class, null)).getModuleRootURL(moduleObject.getModule());
-
- Trace.trace(Trace.FINER, "root: " + url);
-
- if (moduleObject instanceof Servlet) {
- Servlet servlet = (Servlet) moduleObject;
- if (servlet.getAlias() != null) {
- String path = servlet.getAlias();
- if (path.startsWith("/"))
- path = path.substring(1);
- url = new URL(url, path);
- } else
- url = new URL(url, SERVLET_PATH + servlet.getServletClassName());
- } else if (moduleObject instanceof WebResource) {
- WebResource resource = (WebResource) moduleObject;
- String path = resource.getPath().toString();
- Trace.trace(Trace.FINER, "path: " + path);
- if (path != null && path.startsWith("/") && path.length() > 0)
- path = path.substring(1);
- if (path != null && path.length() > 0)
- url = new URL(url, path);
- }
- return new HttpLaunchable(url);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting URL for " + moduleObject, e);
- return null;
- }
- }
+ private static final String SERVLET_PATH = "servlet/";
+
+ /*
+ * @see LaunchableAdapterDelegate#getLaunchable(IServer, IModuleArtifact)
+ */
+ public Object getLaunchable(IServer server, IModuleArtifact moduleObject)
+ {
+ Trace.trace(Trace.FINER,"JettyLaunchableAdapter " + server + "-" + moduleObject);
+ if (server.getAdapter(JettyServer.class) == null)
+ return null;
+ if (!(moduleObject instanceof Servlet) && !(moduleObject instanceof WebResource))
+ return null;
+ if (moduleObject.getModule().loadAdapter(IWebModule.class,null) == null)
+ return null;
+
+ try
+ {
+ URL url = ((IURLProvider)server.loadAdapter(IURLProvider.class,null)).getModuleRootURL(moduleObject.getModule());
+
+ Trace.trace(Trace.FINER,"root: " + url);
+
+ if (moduleObject instanceof Servlet)
+ {
+ Servlet servlet = (Servlet)moduleObject;
+ if (servlet.getAlias() != null)
+ {
+ String path = servlet.getAlias();
+ if (path.startsWith("/"))
+ path = path.substring(1);
+ url = new URL(url,path);
+ }
+ else
+ url = new URL(url,SERVLET_PATH + servlet.getServletClassName());
+ }
+ else if (moduleObject instanceof WebResource)
+ {
+ WebResource resource = (WebResource)moduleObject;
+ String path = resource.getPath().toString();
+ Trace.trace(Trace.FINER,"path: " + path);
+ if (path != null && path.startsWith("/") && path.length() > 0)
+ path = path.substring(1);
+ if (path != null && path.length() > 0)
+ url = new URL(url,path);
+ }
+ return new HttpLaunchable(url);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error getting URL for " + moduleObject,e);
+ return null;
+ }
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntime.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntime.java
index 832d069..3dde6dd 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntime.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntime.java
@@ -41,313 +41,350 @@
/**
* Jetty Runtime.
- *
+ *
*/
-public class JettyRuntime extends RuntimeDelegate implements IJettyRuntime, IJettyRuntimeWorkingCopy {
+public class JettyRuntime extends RuntimeDelegate implements IJettyRuntime, IJettyRuntimeWorkingCopy
+{
- //private static final String TOOLS_JAR_PATH = "lib" + File.separator + "tools.jar";
- private static final String JAVAC_MAIN = "com.sun.tools.javac.Main";
- private static final String CLASS_DETECTOR = "org.eclipse.jst.server.Jetty.core.internal.ClassDetector";
-
- protected static final String PROP_VM_INSTALL_TYPE_ID = "vm-install-type-id";
- protected static final String PROP_VM_INSTALL_ID = "vm-install-id";
+ // private static final String TOOLS_JAR_PATH = "lib" + File.separator + "tools.jar";
+ private static final String JAVAC_MAIN = "com.sun.tools.javac.Main";
+ private static final String CLASS_DETECTOR = "org.eclipse.jst.server.Jetty.core.internal.ClassDetector";
- protected final static Map<File, Boolean> sdkMap = new HashMap<File, Boolean>(2);
- private static Map<String, Integer> javaVersionMap = new ConcurrentHashMap<String, Integer>();
+ protected static final String PROP_VM_INSTALL_TYPE_ID = "vm-install-type-id";
+ protected static final String PROP_VM_INSTALL_ID = "vm-install-id";
- public JettyRuntime() {
- // do nothing
- }
+ protected final static Map<File, Boolean> sdkMap = new HashMap<File, Boolean>(2);
+ private static Map<String, Integer> javaVersionMap = new ConcurrentHashMap<String, Integer>();
- public IJettyVersionHandler getVersionHandler() {
- IRuntimeType type = getRuntime().getRuntimeType();
- return JettyPlugin.getJettyVersionHandler(type.getId());
- }
+ public JettyRuntime()
+ {
+ // do nothing
+ }
- protected String getVMInstallTypeId() {
- return getAttribute(PROP_VM_INSTALL_TYPE_ID, (String) null);
- }
+ public IJettyVersionHandler getVersionHandler()
+ {
+ IRuntimeType type = getRuntime().getRuntimeType();
+ return JettyPlugin.getJettyVersionHandler(type.getId());
+ }
- protected String getVMInstallId() {
- return getAttribute(PROP_VM_INSTALL_ID, (String) null);
- }
+ protected String getVMInstallTypeId()
+ {
+ return getAttribute(PROP_VM_INSTALL_TYPE_ID,(String)null);
+ }
- public boolean isUsingDefaultJRE() {
- return getVMInstallTypeId() == null;
- }
+ protected String getVMInstallId()
+ {
+ return getAttribute(PROP_VM_INSTALL_ID,(String)null);
+ }
- public IVMInstall getVMInstall() {
- if (getVMInstallTypeId() == null)
- return JavaRuntime.getDefaultVMInstall();
- try {
- IVMInstallType vmInstallType = JavaRuntime
- .getVMInstallType(getVMInstallTypeId());
- IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
- int size = vmInstalls.length;
- String id = getVMInstallId();
- for (int i = 0; i < size; i++) {
- if (id.equals(vmInstalls[i].getId()))
- return vmInstalls[i];
- }
- } catch (Exception e) {
- // ignore
- }
- return null;
- }
+ public boolean isUsingDefaultJRE()
+ {
+ return getVMInstallTypeId() == null;
+ }
- public Collection<IRuntimeClasspathEntry> getRuntimeClasspath(
- IPath configPath) {
- IPath installPath = getRuntime().getLocation();
- // If installPath is relative, convert to canonical path and hope for
- // the best
- if (!installPath.isAbsolute()) {
- try {
- String installLoc = (new File(installPath.toOSString()))
- .getCanonicalPath();
- installPath = new Path(installLoc);
- } catch (IOException e) {
- // Ignore if there is a problem
- }
- }
- return getVersionHandler().getRuntimeClasspath(installPath, configPath);
- }
+ public IVMInstall getVMInstall()
+ {
+ if (getVMInstallTypeId() == null)
+ return JavaRuntime.getDefaultVMInstall();
+ try
+ {
+ IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId());
+ IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
+ int size = vmInstalls.length;
+ String id = getVMInstallId();
+ for (int i = 0; i < size; i++)
+ {
+ if (id.equals(vmInstalls[i].getId()))
+ return vmInstalls[i];
+ }
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ return null;
+ }
- /**
- * Verifies the Jetty installation directory. If it is correct, true is
- * returned. Otherwise, the user is notified and false is returned.
- *
- * @return boolean
- */
- public IStatus verifyLocation() {
- return getVersionHandler()
- .verifyInstallPath(getRuntime().getLocation());
- }
+ public Collection<IRuntimeClasspathEntry> getRuntimeClasspath(IPath configPath)
+ {
+ IPath installPath = getRuntime().getLocation();
+ // If installPath is relative, convert to canonical path and hope for
+ // the best
+ if (!installPath.isAbsolute())
+ {
+ try
+ {
+ String installLoc = (new File(installPath.toOSString())).getCanonicalPath();
+ installPath = new Path(installLoc);
+ }
+ catch (IOException e)
+ {
+ // Ignore if there is a problem
+ }
+ }
+ return getVersionHandler().getRuntimeClasspath(installPath,configPath);
+ }
- /*
- * Validate the runtime
- */
- public IStatus validate() {
- IStatus status = super.validate();
- if (!status.isOK())
- return status;
+ /**
+ * Verifies the Jetty installation directory. If it is correct, true is returned. Otherwise, the user is notified and false is returned.
+ *
+ * @return boolean
+ */
+ public IStatus verifyLocation()
+ {
+ return getVersionHandler().verifyInstallPath(getRuntime().getLocation());
+ }
- status = verifyLocation();
- if (!status.isOK())
- return status;
- // don't accept trailing space since that can cause startup problems
- if (getRuntime().getLocation().hasTrailingSeparator())
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- Messages.errorInstallDirTrailingSlash, null);
- if (getVMInstall() == null)
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- Messages.errorJRE, null);
+ /*
+ * Validate the runtime
+ */
+ public IStatus validate()
+ {
+ IStatus status = super.validate();
+ if (!status.isOK())
+ return status;
- // check for tools.jar (contains the javac compiler on Windows & Linux)
- // to see whether
- // Jetty will be able to compile JSPs.
-// boolean found = false;
-// File file = getVMInstall().getInstallLocation();
-// if (file != null) {
-// File toolsJar = new File(file, TOOLS_JAR_PATH);
-// if (toolsJar.exists())
-// found = true;
-// }
-
- status = getVersionHandler().validate(getRuntime().getLocation(), getVMInstall());
- if (status != null) {
- return status;
- }
- return Status.OK_STATUS;
-// // on Jetty 5.5 and 6.0, the Eclipse JDT compiler is used for JSP's
-// String id = getRuntime().getRuntimeType().getId();
-// if (!found) {
-// if (id != null && (id.indexOf("55") > 0 || id.indexOf("60") > 0))
-// found = true;
-// }
-//
-// // on Mac, tools.jar is merged into classes.zip. if tools.jar wasn't
-// // found,
-// // try loading the javac class by running a check inside the VM
-// if (!found) {
-// String os = Platform.getOS();
-// if (os != null && os.toLowerCase().indexOf("mac") >= 0)
-// found = checkForCompiler();
-// }
-//
-// if (!found)
-// return new Status(IStatus.WARNING, JettyPlugin.PLUGIN_ID, 0,
-// Messages.warningJRE, null);
-//
-// File f = getRuntime().getLocation().append("conf").toFile();
-// File[] conf = f.listFiles();
-// if (conf != null) {
-// int size = conf.length;
-// for (int i = 0; i < size; i++) {
-// if (!f.canRead())
-// return new Status(IStatus.WARNING, JettyPlugin.PLUGIN_ID,
-// 0, Messages.warningCantReadConfig, null);
-// }
-// }
-//
-// // For Jetty 6.0, ensure we have J2SE 5.0
-// if (id != null && id.indexOf("60") > 0) {
-// IVMInstall vmInstall = getVMInstall();
-// if (vmInstall instanceof IVMInstall2) {
-// String javaVersion = ((IVMInstall2) vmInstall).getJavaVersion();
-// if (javaVersion != null
-// && !isVMMinimumVersion(javaVersion, 105)) {
-// return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
-// Messages.errorJREJetty60, null);
-// }
-// }
-// }
-// // Else for Jetty 7.0, ensure we have J2SE 6.0
-// else if (id != null && id.indexOf("70") > 0) {
-// IVMInstall vmInstall = getVMInstall();
-// if (vmInstall instanceof IVMInstall2) {
-// String javaVersion = ((IVMInstall2) vmInstall).getJavaVersion();
-// if (javaVersion != null
-// && !isVMMinimumVersion(javaVersion, 106)) {
-// return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
-// Messages.errorJREJetty70, null);
-// }
-// }
-// }
+ status = verifyLocation();
+ if (!status.isOK())
+ return status;
+ // don't accept trailing space since that can cause startup problems
+ if (getRuntime().getLocation().hasTrailingSeparator())
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,Messages.errorInstallDirTrailingSlash,null);
+ if (getVMInstall() == null)
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,Messages.errorJRE,null);
-// return Status.OK_STATUS;
- }
+ // check for tools.jar (contains the javac compiler on Windows & Linux)
+ // to see whether
+ // Jetty will be able to compile JSPs.
+ // boolean found = false;
+ // File file = getVMInstall().getInstallLocation();
+ // if (file != null) {
+ // File toolsJar = new File(file, TOOLS_JAR_PATH);
+ // if (toolsJar.exists())
+ // found = true;
+ // }
- /**
- * @see RuntimeDelegate#setDefaults(IProgressMonitor)
- */
- public void setDefaults(IProgressMonitor monitor) {
- IRuntimeType type = getRuntimeWorkingCopy().getRuntimeType();
- getRuntimeWorkingCopy().setLocation(
- new Path(JettyPlugin.getPreference("location" + type.getId())));
- }
+ status = getVersionHandler().validate(getRuntime().getLocation(),getVMInstall());
+ if (status != null)
+ {
+ return status;
+ }
+ return Status.OK_STATUS;
+ // // on Jetty 5.5 and 6.0, the Eclipse JDT compiler is used for JSP's
+ // String id = getRuntime().getRuntimeType().getId();
+ // if (!found) {
+ // if (id != null && (id.indexOf("55") > 0 || id.indexOf("60") > 0))
+ // found = true;
+ // }
+ //
+ // // on Mac, tools.jar is merged into classes.zip. if tools.jar wasn't
+ // // found,
+ // // try loading the javac class by running a check inside the VM
+ // if (!found) {
+ // String os = Platform.getOS();
+ // if (os != null && os.toLowerCase().indexOf("mac") >= 0)
+ // found = checkForCompiler();
+ // }
+ //
+ // if (!found)
+ // return new Status(IStatus.WARNING, JettyPlugin.PLUGIN_ID, 0,
+ // Messages.warningJRE, null);
+ //
+ // File f = getRuntime().getLocation().append("conf").toFile();
+ // File[] conf = f.listFiles();
+ // if (conf != null) {
+ // int size = conf.length;
+ // for (int i = 0; i < size; i++) {
+ // if (!f.canRead())
+ // return new Status(IStatus.WARNING, JettyPlugin.PLUGIN_ID,
+ // 0, Messages.warningCantReadConfig, null);
+ // }
+ // }
+ //
+ // // For Jetty 6.0, ensure we have J2SE 5.0
+ // if (id != null && id.indexOf("60") > 0) {
+ // IVMInstall vmInstall = getVMInstall();
+ // if (vmInstall instanceof IVMInstall2) {
+ // String javaVersion = ((IVMInstall2) vmInstall).getJavaVersion();
+ // if (javaVersion != null
+ // && !isVMMinimumVersion(javaVersion, 105)) {
+ // return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
+ // Messages.errorJREJetty60, null);
+ // }
+ // }
+ // }
+ // // Else for Jetty 7.0, ensure we have J2SE 6.0
+ // else if (id != null && id.indexOf("70") > 0) {
+ // IVMInstall vmInstall = getVMInstall();
+ // if (vmInstall instanceof IVMInstall2) {
+ // String javaVersion = ((IVMInstall2) vmInstall).getJavaVersion();
+ // if (javaVersion != null
+ // && !isVMMinimumVersion(javaVersion, 106)) {
+ // return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
+ // Messages.errorJREJetty70, null);
+ // }
+ // }
+ // }
- public void setVMInstall(IVMInstall vmInstall) {
- if (vmInstall == null) {
- setVMInstall(null, null);
- } else
- setVMInstall(vmInstall.getVMInstallType().getId(),
- vmInstall.getId());
- }
+ // return Status.OK_STATUS;
+ }
- protected void setVMInstall(String typeId, String id) {
- if (typeId == null)
- setAttribute(PROP_VM_INSTALL_TYPE_ID, (String) null);
- else
- setAttribute(PROP_VM_INSTALL_TYPE_ID, typeId);
+ /**
+ * @see RuntimeDelegate#setDefaults(IProgressMonitor)
+ */
+ public void setDefaults(IProgressMonitor monitor)
+ {
+ IRuntimeType type = getRuntimeWorkingCopy().getRuntimeType();
+ getRuntimeWorkingCopy().setLocation(new Path(JettyPlugin.getPreference("location" + type.getId())));
+ }
- if (id == null)
- setAttribute(PROP_VM_INSTALL_ID, (String) null);
- else
- setAttribute(PROP_VM_INSTALL_ID, id);
- }
+ public void setVMInstall(IVMInstall vmInstall)
+ {
+ if (vmInstall == null)
+ {
+ setVMInstall(null,null);
+ }
+ else
+ setVMInstall(vmInstall.getVMInstallType().getId(),vmInstall.getId());
+ }
- /**
- * Checks for the existence of the Java compiler in the given java
- * executable. A main program is run (<code>org.eclipse.jst.Jetty.core.
- * internal.ClassDetector</code>), that dumps a true or false value
- * depending on whether the compiler is found. This output is then parsed
- * and cached for future reference.
- *
- * @return true if the compiler was found
- */
- protected boolean checkForCompiler() {
- // first try the cache
- File javaHome = getVMInstall().getInstallLocation();
- try {
- Boolean b = (Boolean) sdkMap.get(javaHome);
- return b.booleanValue();
- } catch (Exception e) {
- // ignore
- }
+ protected void setVMInstall(String typeId, String id)
+ {
+ if (typeId == null)
+ setAttribute(PROP_VM_INSTALL_TYPE_ID,(String)null);
+ else
+ setAttribute(PROP_VM_INSTALL_TYPE_ID,typeId);
- // locate Jettycore.jar - it contains the class detector main program
- File file = JettyPlugin.getPlugin();
- if (file != null && file.exists()) {
- IVMRunner vmRunner = getVMInstall().getVMRunner(
- ILaunchManager.RUN_MODE);
- VMRunnerConfiguration config = new VMRunnerConfiguration(
- CLASS_DETECTOR,
- new String[] { file.getAbsolutePath() });
- config.setProgramArguments(new String[] { JAVAC_MAIN });
- ILaunch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
- try {
- vmRunner.run(config, launch, null);
- for (int i = 0; i < 600; i++) {
- // wait no more than 30 seconds (600 * 50 mils)
- if (launch.isTerminated()) {
- break;
- }
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- // ignore
- }
- }
- IStreamsProxy streamsProxy = launch.getProcesses()[0]
- .getStreamsProxy();
- String text = null;
- if (streamsProxy != null) {
- text = streamsProxy.getOutputStreamMonitor().getContents();
+ if (id == null)
+ setAttribute(PROP_VM_INSTALL_ID,(String)null);
+ else
+ setAttribute(PROP_VM_INSTALL_ID,id);
+ }
- if (text != null && text.length() > 0) {
- boolean found = false;
- if (StringUtils.isTrue(text))
- found = true;
+ /**
+ * Checks for the existence of the Java compiler in the given java executable. A main program is run (<code>org.eclipse.jst.Jetty.core.
+ * internal.ClassDetector</code>), that dumps a true or false value depending on whether the compiler is found. This output is then parsed and cached for
+ * future reference.
+ *
+ * @return true if the compiler was found
+ */
+ protected boolean checkForCompiler()
+ {
+ // first try the cache
+ File javaHome = getVMInstall().getInstallLocation();
+ try
+ {
+ Boolean b = (Boolean)sdkMap.get(javaHome);
+ return b.booleanValue();
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
- sdkMap.put(javaHome, Boolean.valueOf(found));
- return found;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error checking for JDK", e);
- } finally {
- if (!launch.isTerminated()) {
- try {
- launch.terminate();
- } catch (Exception ex) {
- // ignore
- }
- }
- }
- }
+ // locate Jettycore.jar - it contains the class detector main program
+ File file = JettyPlugin.getPlugin();
+ if (file != null && file.exists())
+ {
+ IVMRunner vmRunner = getVMInstall().getVMRunner(ILaunchManager.RUN_MODE);
+ VMRunnerConfiguration config = new VMRunnerConfiguration(CLASS_DETECTOR,new String[]
+ { file.getAbsolutePath() });
+ config.setProgramArguments(new String[]
+ { JAVAC_MAIN });
+ ILaunch launch = new Launch(null,ILaunchManager.RUN_MODE,null);
+ try
+ {
+ vmRunner.run(config,launch,null);
+ for (int i = 0; i < 600; i++)
+ {
+ // wait no more than 30 seconds (600 * 50 mils)
+ if (launch.isTerminated())
+ {
+ break;
+ }
+ try
+ {
+ Thread.sleep(50);
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ }
+ IStreamsProxy streamsProxy = launch.getProcesses()[0].getStreamsProxy();
+ String text = null;
+ if (streamsProxy != null)
+ {
+ text = streamsProxy.getOutputStreamMonitor().getContents();
- // log error that we were unable to check for the compiler
- JettyPlugin.log(MessageFormat.format("Failed compiler check for {0}",
- javaHome.getAbsolutePath()));
- return false;
- }
+ if (text != null && text.length() > 0)
+ {
+ boolean found = false;
+ if (StringUtils.isTrue(text))
+ found = true;
- private boolean isVMMinimumVersion(String javaVersion, int minimumVersion) {
- Integer version = (Integer) javaVersionMap.get(javaVersion);
- if (version == null) {
- int index = javaVersion.indexOf('.');
- if (index > 0) {
- try {
- int major = Integer.parseInt(javaVersion
- .substring(0, index)) * 100;
- index++;
- int index2 = javaVersion.indexOf('.', index);
- if (index2 > 0) {
- int minor = Integer.parseInt(javaVersion.substring(
- index, index2));
- version = Integer.valueOf(major + minor);
- javaVersionMap.put(javaVersion, version);
- }
- } catch (NumberFormatException e) {
- // Ignore
- }
- }
- }
- // If we have a version, and it's less than the minimum, fail the check
- if (version != null && version.intValue() < minimumVersion) {
- return false;
- }
- return true;
- }
+ sdkMap.put(javaHome,Boolean.valueOf(found));
+ return found;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error checking for JDK",e);
+ }
+ finally
+ {
+ if (!launch.isTerminated())
+ {
+ try
+ {
+ launch.terminate();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ // log error that we were unable to check for the compiler
+ JettyPlugin.log(MessageFormat.format("Failed compiler check for {0}",javaHome.getAbsolutePath()));
+ return false;
+ }
+
+ private boolean isVMMinimumVersion(String javaVersion, int minimumVersion)
+ {
+ Integer version = (Integer)javaVersionMap.get(javaVersion);
+ if (version == null)
+ {
+ int index = javaVersion.indexOf('.');
+ if (index > 0)
+ {
+ try
+ {
+ int major = Integer.parseInt(javaVersion.substring(0,index)) * 100;
+ index++;
+ int index2 = javaVersion.indexOf('.',index);
+ if (index2 > 0)
+ {
+ int minor = Integer.parseInt(javaVersion.substring(index,index2));
+ version = Integer.valueOf(major + minor);
+ javaVersionMap.put(javaVersion,version);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ // Ignore
+ }
+ }
+ }
+ // If we have a version, and it's less than the minimum, fail the check
+ if (version != null && version.intValue() < minimumVersion)
+ {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntimeClasspathProvider.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntimeClasspathProvider.java
index 6a18ce6..76d979c 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntimeClasspathProvider.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntimeClasspathProvider.java
@@ -20,36 +20,36 @@
import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate;
import org.eclipse.wst.server.core.IRuntime;
-public class JettyRuntimeClasspathProvider extends
- RuntimeClasspathProviderDelegate implements JettyConstants {
- private static final IClasspathEntry[] EMPTY_CLASSPATH_ENTRY = new IClasspathEntry[0];
+public class JettyRuntimeClasspathProvider extends RuntimeClasspathProviderDelegate implements JettyConstants
+{
+ private static final IClasspathEntry[] EMPTY_CLASSPATH_ENTRY = new IClasspathEntry[0];
- @Override
- public IClasspathEntry[] resolveClasspathContainer(IProject project,
- IRuntime runtime) {
- IPath installPath = runtime.getLocation();
- if (installPath == null)
- return EMPTY_CLASSPATH_ENTRY;
- //String runtimeId = runtime.getRuntimeType().getId();
+ @Override
+ public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime)
+ {
+ IPath installPath = runtime.getLocation();
+ if (installPath == null)
+ return EMPTY_CLASSPATH_ENTRY;
+ // String runtimeId = runtime.getRuntimeType().getId();
- // TODO : switch Jetty version, is there different classpath?
-
- List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
- IPath libPath = installPath.append(LIB_FOLDER);
- File libDir = libPath.toFile();
- if (libDir.exists()) {
- // add all jars from the Jetty ${jetty.home}/lib
- RuntimeClasspathProviderDelegate.addLibraryEntries(entries, libDir,
- true);
- // add all jars from the Jetty ${jetty.home}/lib/jsp directory
- IPath jspLibPath = libPath.append(JSP_FOLDER);
- File jspLibDir = jspLibPath.toFile();
- if (jspLibDir.exists()) {
- RuntimeClasspathProviderDelegate.addLibraryEntries(entries,
- jspLibDir, true);
- }
- }
- return entries.toArray(new IClasspathEntry[entries.size()]);
- }
+ // TODO : switch Jetty version, is there different classpath?
+
+ List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+ IPath libPath = installPath.append(LIB_FOLDER);
+ File libDir = libPath.toFile();
+ if (libDir.exists())
+ {
+ // add all jars from the Jetty ${jetty.home}/lib
+ RuntimeClasspathProviderDelegate.addLibraryEntries(entries,libDir,true);
+ // add all jars from the Jetty ${jetty.home}/lib/jsp directory
+ IPath jspLibPath = libPath.append(JSP_FOLDER);
+ File jspLibDir = jspLibPath.toFile();
+ if (jspLibDir.exists())
+ {
+ RuntimeClasspathProviderDelegate.addLibraryEntries(entries,jspLibDir,true);
+ }
+ }
+ return entries.toArray(new IClasspathEntry[entries.size()]);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntimeLocator.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntimeLocator.java
index b9f4714..47b1ffc 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntimeLocator.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyRuntimeLocator.java
@@ -27,101 +27,110 @@
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.model.RuntimeLocatorDelegate;
-public class JettyRuntimeLocator extends RuntimeLocatorDelegate {
+public class JettyRuntimeLocator extends RuntimeLocatorDelegate
+{
- @Override
- public void searchForRuntimes(IPath path, IRuntimeSearchListener listener,
- IProgressMonitor monitor) {
- searchForRuntimes2(path, listener, monitor);
- }
+ @Override
+ public void searchForRuntimes(IPath path, IRuntimeSearchListener listener, IProgressMonitor monitor)
+ {
+ searchForRuntimes2(path,listener,monitor);
+ }
- protected static void searchForRuntimes2(IPath path,
- IRuntimeSearchListener listener, IProgressMonitor monitor) {
- File[] files = null;
- if (path != null) {
- File f = path.toFile();
- if (f.exists())
- files = f.listFiles();
- else
- return;
- } else
- files = File.listRoots();
+ protected static void searchForRuntimes2(IPath path, IRuntimeSearchListener listener, IProgressMonitor monitor)
+ {
+ File[] files = null;
+ if (path != null)
+ {
+ File f = path.toFile();
+ if (f.exists())
+ files = f.listFiles();
+ else
+ return;
+ }
+ else
+ files = File.listRoots();
- if (files != null) {
- int size = files.length;
- int work = 100 / size;
- int workLeft = 100 - (work * size);
- for (int i = 0; i < size; i++) {
- if (monitor.isCanceled())
- return;
- if (files[i] != null && files[i].isDirectory())
- searchDir(listener, files[i], 4, monitor);
- monitor.worked(work);
- }
- monitor.worked(workLeft);
- } else
- monitor.worked(100);
- }
+ if (files != null)
+ {
+ int size = files.length;
+ int work = 100 / size;
+ int workLeft = 100 - (work * size);
+ for (int i = 0; i < size; i++)
+ {
+ if (monitor.isCanceled())
+ return;
+ if (files[i] != null && files[i].isDirectory())
+ searchDir(listener,files[i],4,monitor);
+ monitor.worked(work);
+ }
+ monitor.worked(workLeft);
+ }
+ else
+ monitor.worked(100);
+ }
- protected static void searchDir(IRuntimeSearchListener listener, File dir,
- int depth, IProgressMonitor monitor) {
- if ("conf".equals(dir.getName())) {
- IRuntimeWorkingCopy runtime = getRuntimeFromDir(
- dir.getParentFile(), monitor);
- if (runtime != null) {
- listener.runtimeFound(runtime);
- return;
- }
- }
+ protected static void searchDir(IRuntimeSearchListener listener, File dir, int depth, IProgressMonitor monitor)
+ {
+ if ("conf".equals(dir.getName()))
+ {
+ IRuntimeWorkingCopy runtime = getRuntimeFromDir(dir.getParentFile(),monitor);
+ if (runtime != null)
+ {
+ listener.runtimeFound(runtime);
+ return;
+ }
+ }
- if (depth == 0)
- return;
+ if (depth == 0)
+ return;
- File[] files = dir.listFiles(new FileFilter() {
- public boolean accept(File file) {
- return file.isDirectory();
- }
- });
- if (files != null) {
- int size = files.length;
- for (int i = 0; i < size; i++) {
- if (monitor.isCanceled())
- return;
- searchDir(listener, files[i], depth - 1, monitor);
- }
- }
- }
+ File[] files = dir.listFiles(new FileFilter()
+ {
+ public boolean accept(File file)
+ {
+ return file.isDirectory();
+ }
+ });
+ if (files != null)
+ {
+ int size = files.length;
+ for (int i = 0; i < size; i++)
+ {
+ if (monitor.isCanceled())
+ return;
+ searchDir(listener,files[i],depth - 1,monitor);
+ }
+ }
+ }
- protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir,
- IProgressMonitor monitor) {
+ protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir, IProgressMonitor monitor)
+ {
- Collection<String> runtimeTypes = JettyPlugin.getRuntimeTypes();
- for (String runtimeTypeName : runtimeTypes) {
- try {
- IRuntimeType runtimeType = ServerCore
- .findRuntimeType(runtimeTypeName);
+ Collection<String> runtimeTypes = JettyPlugin.getRuntimeTypes();
+ for (String runtimeTypeName : runtimeTypes)
+ {
+ try
+ {
+ IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypeName);
- String absolutePath = dir.getAbsolutePath();
- String id = absolutePath.replace(File.separatorChar, '_')
- .replace(':', '-');
- IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id,
- monitor);
- runtime.setName(dir.getName());
- runtime.setLocation(new Path(absolutePath));
- IJettyRuntimeWorkingCopy wc = (IJettyRuntimeWorkingCopy) runtime
- .loadAdapter(IJettyRuntimeWorkingCopy.class, null);
- wc.setVMInstall(JavaRuntime.getDefaultVMInstall());
- IStatus status = runtime.validate(monitor);
- if (status == null || status.getSeverity() != IStatus.ERROR)
- return runtime;
+ String absolutePath = dir.getAbsolutePath();
+ String id = absolutePath.replace(File.separatorChar,'_').replace(':','-');
+ IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id,monitor);
+ runtime.setName(dir.getName());
+ runtime.setLocation(new Path(absolutePath));
+ IJettyRuntimeWorkingCopy wc = (IJettyRuntimeWorkingCopy)runtime.loadAdapter(IJettyRuntimeWorkingCopy.class,null);
+ wc.setVMInstall(JavaRuntime.getDefaultVMInstall());
+ IStatus status = runtime.validate(monitor);
+ if (status == null || status.getSeverity() != IStatus.ERROR)
+ return runtime;
- Trace.trace(Trace.FINER,
- "False runtime found at " + dir.getAbsolutePath()
- + ": " + status.getMessage());
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not find runtime", e);
- }
- }
- return null;
- }
+ Trace.trace(Trace.FINER,"False runtime found at " + dir.getAbsolutePath() + ": " + status.getMessage());
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Could not find runtime",e);
+ }
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServer.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServer.java
index 7f80864..9fd9dd9 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServer.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServer.java
@@ -39,454 +39,486 @@
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.model.ServerDelegate;
-public class JettyServer extends ServerDelegate implements IJettyServer,
- IJettyServerWorkingCopy {
+public class JettyServer extends ServerDelegate implements IJettyServer, IJettyServerWorkingCopy
+{
- private static final ServerPort[] EMPTY_SERVER_PORTS = new ServerPort[0];
- public static final String PROPERTY_SECURE = "secure";
- public static final String PROPERTY_DEBUG = "debug";
+ private static final ServerPort[] EMPTY_SERVER_PORTS = new ServerPort[0];
+ public static final String PROPERTY_SECURE = "secure";
+ public static final String PROPERTY_DEBUG = "debug";
- private static final String JST_WEB_MODULETYPE = "jst.web";
+ private static final String JST_WEB_MODULETYPE = "jst.web";
- private static final IModule[] EMPTY_MODULES = new IModule[0];
- protected transient IJettyConfiguration configuration;
- protected transient IJettyVersionHandler versionHandler;
+ private static final IModule[] EMPTY_MODULES = new IModule[0];
+ protected transient IJettyConfiguration configuration;
+ protected transient IJettyVersionHandler versionHandler;
- /**
- * JettyServer.
- */
- public JettyServer() {
- super();
- }
+ /**
+ * JettyServer.
+ */
+ public JettyServer()
+ {
+ super();
+ }
- /**
- * Get the Jetty runtime for this server.
- *
- * @return Jetty runtime for this server
- */
- public JettyRuntime getJettyRuntime() {
- if (getServer().getRuntime() == null)
- return null;
+ /**
+ * Get the Jetty runtime for this server.
+ *
+ * @return Jetty runtime for this server
+ */
+ public JettyRuntime getJettyRuntime()
+ {
+ if (getServer().getRuntime() == null)
+ return null;
- return (JettyRuntime) getServer().getRuntime().loadAdapter(
- JettyRuntime.class, null);
- }
+ return (JettyRuntime)getServer().getRuntime().loadAdapter(JettyRuntime.class,null);
+ }
- /**
- * Gets the Jetty version handler for this server.
- *
- * @return version handler for this server
- */
- public IJettyVersionHandler getJettyVersionHandler() {
- if (versionHandler == null) {
- if (getServer().getRuntime() == null || getJettyRuntime() == null)
- return null;
+ /**
+ * Gets the Jetty version handler for this server.
+ *
+ * @return version handler for this server
+ */
+ public IJettyVersionHandler getJettyVersionHandler()
+ {
+ if (versionHandler == null)
+ {
+ if (getServer().getRuntime() == null || getJettyRuntime() == null)
+ return null;
- versionHandler = getJettyRuntime().getVersionHandler();
- }
- return versionHandler;
- }
+ versionHandler = getJettyRuntime().getVersionHandler();
+ }
+ return versionHandler;
+ }
- public IJettyConfiguration getJettyConfiguration() throws CoreException {
- if (configuration == null) {
- IFolder folder = getServer().getServerConfiguration();
- if (folder == null || !folder.exists()) {
- String path = null;
- if (folder != null) {
- path = folder.getFullPath().toOSString();
- IProject project = folder.getProject();
- if (project != null && project.exists()
- && !project.isOpen())
- throw new CoreException(
- new Status(
- IStatus.ERROR,
- JettyPlugin.PLUGIN_ID,
- 0,
- NLS.bind(
- Messages.errorConfigurationProjectClosed,
- path, project.getName()), null));
- }
- throw new CoreException(new Status(IStatus.ERROR,
- JettyPlugin.PLUGIN_ID, 0, NLS.bind(
- Messages.errorNoConfiguration, path), null));
- }
+ public IJettyConfiguration getJettyConfiguration() throws CoreException
+ {
+ if (configuration == null)
+ {
+ IFolder folder = getServer().getServerConfiguration();
+ if (folder == null || !folder.exists())
+ {
+ String path = null;
+ if (folder != null)
+ {
+ path = folder.getFullPath().toOSString();
+ IProject project = folder.getProject();
+ if (project != null && project.exists() && !project.isOpen())
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorConfigurationProjectClosed,path,
+ project.getName()),null));
+ }
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorNoConfiguration,path),null));
+ }
- String id = getServer().getServerType().getId();
- configuration = JettyPlugin.getJettyConfiguration(id, folder);
- try {
- configuration.load(folder, getRuntimeBaseDirectory(), null);
- } catch (CoreException ce) {
- // ignore
- configuration = null;
- throw ce;
- }
- }
- return configuration;
- }
+ String id = getServer().getServerType().getId();
+ configuration = JettyPlugin.getJettyConfiguration(id,folder);
+ try
+ {
+ configuration.load(folder,getRuntimeBaseDirectory(),null);
+ }
+ catch (CoreException ce)
+ {
+ // ignore
+ configuration = null;
+ throw ce;
+ }
+ }
+ return configuration;
+ }
- @Override
- public void configurationChanged() {
- configuration = null;
- }
+ @Override
+ public void configurationChanged()
+ {
+ configuration = null;
+ }
- @Override
- public void importRuntimeConfiguration(IRuntime runtime,
- IProgressMonitor monitor) throws CoreException {
- if (runtime == null) {
- configuration = null;
- return;
- }
- IPath path = runtime.getLocation();
- String id = getServer().getServerType().getId();
- IPath runtimeBaseDirectory = getRuntimeBaseDirectory();
- IFolder folder = getServer().getServerConfiguration();
- configuration = JettyPlugin.getJettyConfiguration(id, folder);
- try {
- configuration.importFromPath(path, runtimeBaseDirectory,
- isTestEnvironment(), monitor);
- } catch (CoreException ce) {
- // ignore
- configuration = null;
- throw ce;
- }
- }
+ @Override
+ public void importRuntimeConfiguration(IRuntime runtime, IProgressMonitor monitor) throws CoreException
+ {
+ if (runtime == null)
+ {
+ configuration = null;
+ return;
+ }
+ IPath path = runtime.getLocation();
+ String id = getServer().getServerType().getId();
+ IPath runtimeBaseDirectory = getRuntimeBaseDirectory();
+ IFolder folder = getServer().getServerConfiguration();
+ configuration = JettyPlugin.getJettyConfiguration(id,folder);
+ try
+ {
+ configuration.importFromPath(path,runtimeBaseDirectory,isTestEnvironment(),monitor);
+ }
+ catch (CoreException ce)
+ {
+ // ignore
+ configuration = null;
+ throw ce;
+ }
+ }
- @Override
- public void saveConfiguration(IProgressMonitor monitor)
- throws CoreException {
- if (configuration == null)
- return;
- configuration.save(getServer().getServerConfiguration(), monitor);
- }
+ @Override
+ public void saveConfiguration(IProgressMonitor monitor) throws CoreException
+ {
+ if (configuration == null)
+ return;
+ configuration.save(getServer().getServerConfiguration(),monitor);
+ }
- @Override
- public ServerPort[] getServerPorts() {
- if (getServer().getServerConfiguration() == null)
- return EMPTY_SERVER_PORTS;
+ @Override
+ public ServerPort[] getServerPorts()
+ {
+ if (getServer().getServerConfiguration() == null)
+ return EMPTY_SERVER_PORTS;
- try {
- Collection<ServerPort> list = getJettyConfiguration()
- .getServerPorts();
- ServerPort[] sp = new ServerPort[list.size()];
- list.toArray(sp);
- return sp;
- } catch (Exception e) {
- return EMPTY_SERVER_PORTS;
- }
- }
+ try
+ {
+ Collection<ServerPort> list = getJettyConfiguration().getServerPorts();
+ ServerPort[] sp = new ServerPort[list.size()];
+ list.toArray(sp);
+ return sp;
+ }
+ catch (Exception e)
+ {
+ return EMPTY_SERVER_PORTS;
+ }
+ }
- @Override
- public void setDefaults(IProgressMonitor monitor) {
- setTestEnvironment(true);
- setAttribute("auto-publish-setting", 2);
- setAttribute("auto-publish-time", 1);
- setDeployDirectory(DEFAULT_DEPLOYDIR);
- }
+ @Override
+ public void setDefaults(IProgressMonitor monitor)
+ {
+ setTestEnvironment(true);
+ setAttribute("auto-publish-setting",2);
+ setAttribute("auto-publish-time",1);
+ setDeployDirectory(DEFAULT_DEPLOYDIR);
+ }
- /**
- * Sets this process to debug mode. This feature only works with Jetty v4.0.
- *
- * @param b
- * boolean
- */
- public void setDebug(boolean b) {
- setAttribute(PROPERTY_DEBUG, b);
- }
+ /**
+ * Sets this process to debug mode. This feature only works with Jetty v4.0.
+ *
+ * @param b
+ * boolean
+ */
+ public void setDebug(boolean b)
+ {
+ setAttribute(PROPERTY_DEBUG,b);
+ }
- /**
- * Sets this process to secure mode.
- *
- * @param b
- * boolean
- */
- public void setSecure(boolean b) {
- setAttribute(PROPERTY_SECURE, b);
- }
+ /**
+ * Sets this process to secure mode.
+ *
+ * @param b
+ * boolean
+ */
+ public void setSecure(boolean b)
+ {
+ setAttribute(PROPERTY_SECURE,b);
+ }
- /**
- * Sets this server to test environment mode.
- *
- * @param b
- * boolean
- */
- public void setTestEnvironment(boolean b) {
- setAttribute(PROPERTY_TEST_ENVIRONMENT, b);
- }
+ /**
+ * Sets this server to test environment mode.
+ *
+ * @param b
+ * boolean
+ */
+ public void setTestEnvironment(boolean b)
+ {
+ setAttribute(PROPERTY_TEST_ENVIRONMENT,b);
+ }
- /**
- * @see IJettyServerWorkingCopy#setInstanceDirectory(String)
- */
- public void setInstanceDirectory(String instanceDir) {
- setAttribute(PROPERTY_INSTANCE_DIR, instanceDir);
- }
+ /**
+ * @see IJettyServerWorkingCopy#setInstanceDirectory(String)
+ */
+ public void setInstanceDirectory(String instanceDir)
+ {
+ setAttribute(PROPERTY_INSTANCE_DIR,instanceDir);
+ }
- /**
- * @see IJettyServerWorkingCopy#setDeployDirectory(String)
- */
- public void setDeployDirectory(String deployDir) {
- // Remove attribute if setting to legacy value assumed in prior versions
- // of WTP.
- // Allowing values that differ only in case is asking for more trouble
- // that it is worth.
- if (LEGACY_DEPLOYDIR.equalsIgnoreCase(deployDir))
- setAttribute(PROPERTY_DEPLOY_DIR, (String) null);
- else
- setAttribute(PROPERTY_DEPLOY_DIR, deployDir);
- }
+ /**
+ * @see IJettyServerWorkingCopy#setDeployDirectory(String)
+ */
+ public void setDeployDirectory(String deployDir)
+ {
+ // Remove attribute if setting to legacy value assumed in prior versions
+ // of WTP.
+ // Allowing values that differ only in case is asking for more trouble
+ // that it is worth.
+ if (LEGACY_DEPLOYDIR.equalsIgnoreCase(deployDir))
+ setAttribute(PROPERTY_DEPLOY_DIR,(String)null);
+ else
+ setAttribute(PROPERTY_DEPLOY_DIR,deployDir);
+ }
- /**
- * Gets the base directory where the server instance runs. This path can
- * vary depending on the configuration. Null may be returned if a runtime
- * hasn't been specified for the server.
- *
- * @return path to base directory for the server or null if runtime hasn't
- * been specified.
- */
- public IPath getRuntimeBaseDirectory() {
- IJettyVersionHandler tvh = getJettyVersionHandler();
- if (tvh != null)
- return tvh.getRuntimeBaseDirectory(this);
- return null;
- }
+ /**
+ * Gets the base directory where the server instance runs. This path can vary depending on the configuration. Null may be returned if a runtime hasn't been
+ * specified for the server.
+ *
+ * @return path to base directory for the server or null if runtime hasn't been specified.
+ */
+ public IPath getRuntimeBaseDirectory()
+ {
+ IJettyVersionHandler tvh = getJettyVersionHandler();
+ if (tvh != null)
+ return tvh.getRuntimeBaseDirectory(this);
+ return null;
+ }
- /**
- * Gets the directory to which modules should be deployed for this server.
- *
- * @return full path to deployment directory for the server
- */
- public IPath getServerDeployDirectory() {
- String deployDir = getDeployDirectory();
- IPath deployPath = new Path(deployDir);
- if (!deployPath.isAbsolute()) {
- IPath base = getRuntimeBaseDirectory();
- deployPath = base.append(deployPath);
- }
- return deployPath;
- }
+ /**
+ * Gets the directory to which modules should be deployed for this server.
+ *
+ * @return full path to deployment directory for the server
+ */
+ public IPath getServerDeployDirectory()
+ {
+ String deployDir = getDeployDirectory();
+ IPath deployPath = new Path(deployDir);
+ if (!deployPath.isAbsolute())
+ {
+ IPath base = getRuntimeBaseDirectory();
+ deployPath = base.append(deployPath);
+ }
+ return deployPath;
+ }
- /**
- * Returns true if the given project is supported by this server, and false
- * otherwise.
- *
- * @param add
- * modules
- * @param remove
- * modules
- * @return the status
- */
- @Override
- public IStatus canModifyModules(IModule[] add, IModule[] remove) {
- if (add != null) {
- int size = add.length;
- for (int i = 0; i < size; i++) {
- IModule module = add[i];
- if (!JST_WEB_MODULETYPE.equals(module.getModuleType().getId()))
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- Messages.errorWebModulesOnly, null);
+ /**
+ * Returns true if the given project is supported by this server, and false otherwise.
+ *
+ * @param add
+ * modules
+ * @param remove
+ * modules
+ * @return the status
+ */
+ @Override
+ public IStatus canModifyModules(IModule[] add, IModule[] remove)
+ {
+ if (add != null)
+ {
+ int size = add.length;
+ for (int i = 0; i < size; i++)
+ {
+ IModule module = add[i];
+ if (!JST_WEB_MODULETYPE.equals(module.getModuleType().getId()))
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,Messages.errorWebModulesOnly,null);
- if (getJettyVersionHandler() == null)
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- Messages.errorNoRuntime, null);
+ if (getJettyVersionHandler() == null)
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,Messages.errorNoRuntime,null);
- IStatus status = getJettyVersionHandler().canAddModule(module);
- if (status != null && !status.isOK())
- return status;
+ IStatus status = getJettyVersionHandler().canAddModule(module);
+ if (status != null && !status.isOK())
+ return status;
- if (module.getProject() != null) {
- status = FacetUtil.verifyFacets(module.getProject(),
- getServer());
- if (status != null && !status.isOK())
- return status;
- }
- }
- }
+ if (module.getProject() != null)
+ {
+ status = FacetUtil.verifyFacets(module.getProject(),getServer());
+ if (status != null && !status.isOK())
+ return status;
+ }
+ }
+ }
- return Status.OK_STATUS;
- }
+ return Status.OK_STATUS;
+ }
- /**
- * @see ServerDelegate#modifyModules(IModule[], IModule[], IProgressMonitor)
- */
- @Override
- public void modifyModules(IModule[] add, IModule[] remove,
- IProgressMonitor monitor) throws CoreException {
- IStatus status = canModifyModules(add, remove);
- if (status == null || !status.isOK())
- throw new CoreException(status);
+ /**
+ * @see ServerDelegate#modifyModules(IModule[], IModule[], IProgressMonitor)
+ */
+ @Override
+ public void modifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor) throws CoreException
+ {
+ IStatus status = canModifyModules(add,remove);
+ if (status == null || !status.isOK())
+ throw new CoreException(status);
- IJettyConfiguration config = getJettyConfiguration();
+ IJettyConfiguration config = getJettyConfiguration();
- if (add != null) {
- int size = add.length;
- for (int i = 0; i < size; i++) {
- IModule module3 = add[i];
- IWebModule module = (IWebModule) module3.loadAdapter(
- IWebModule.class, monitor);
- String contextRoot = module.getContextRoot();
- if (contextRoot != null && !contextRoot.startsWith("/")
- && contextRoot.length() > 0)
- contextRoot = "/" + contextRoot;
- String docBase = config.getDocBasePrefix() + module3.getName();
- WebModule module2 = new WebModule(contextRoot, docBase,
- module3.getId(), true);
- config.addWebModule(-1, module2);
- }
- }
+ if (add != null)
+ {
+ int size = add.length;
+ for (int i = 0; i < size; i++)
+ {
+ IModule module3 = add[i];
+ IWebModule module = (IWebModule)module3.loadAdapter(IWebModule.class,monitor);
+ String contextRoot = module.getContextRoot();
+ if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0)
+ contextRoot = "/" + contextRoot;
+ String docBase = config.getDocBasePrefix() + module3.getName();
+ WebModule module2 = new WebModule(contextRoot,docBase,module3.getId(),true);
+ config.addWebModule(-1,module2);
+ }
+ }
- if (remove != null) {
- int size2 = remove.length;
- for (int j = 0; j < size2; j++) {
- IModule module3 = remove[j];
- String memento = module3.getId();
- List<WebModule> modules = getJettyConfiguration()
- .getWebModules();
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- WebModule module = (WebModule) modules.get(i);
- if (memento.equals(module.getMemento()))
- config.removeWebModule(i);
- }
- }
- }
- // config.save(config.getFolder(), monitor);
- }
+ if (remove != null)
+ {
+ int size2 = remove.length;
+ for (int j = 0; j < size2; j++)
+ {
+ IModule module3 = remove[j];
+ String memento = module3.getId();
+ List<WebModule> modules = getJettyConfiguration().getWebModules();
+ int size = modules.size();
+ for (int i = 0; i < size; i++)
+ {
+ WebModule module = (WebModule)modules.get(i);
+ if (memento.equals(module.getMemento()))
+ config.removeWebModule(i);
+ }
+ }
+ }
+ // config.save(config.getFolder(), monitor);
+ }
- /**
- * Returns the child module(s) of this module.
- *
- * @param module
- * module from which to get child module(s)
- * @return array of child module(s)
- */
- @Override
- public IModule[] getChildModules(IModule[] module) {
- if (module == null)
- return null;
+ /**
+ * Returns the child module(s) of this module.
+ *
+ * @param module
+ * module from which to get child module(s)
+ * @return array of child module(s)
+ */
+ @Override
+ public IModule[] getChildModules(IModule[] module)
+ {
+ if (module == null)
+ return null;
- IModuleType moduleType = module[0].getModuleType();
+ IModuleType moduleType = module[0].getModuleType();
- if (module.length == 1 && moduleType != null
- && JST_WEB_MODULETYPE.equals(moduleType.getId())) {
- IWebModule webModule = (IWebModule) module[0].loadAdapter(
- IWebModule.class, null);
- if (webModule != null) {
- IModule[] modules = webModule.getModules();
- // if (modules != null)
- // System.out.println(modules.length);
- return modules;
- }
- }
- return EMPTY_MODULES;
- }
+ if (module.length == 1 && moduleType != null && JST_WEB_MODULETYPE.equals(moduleType.getId()))
+ {
+ IWebModule webModule = (IWebModule)module[0].loadAdapter(IWebModule.class,null);
+ if (webModule != null)
+ {
+ IModule[] modules = webModule.getModules();
+ // if (modules != null)
+ // System.out.println(modules.length);
+ return modules;
+ }
+ }
+ return EMPTY_MODULES;
+ }
- /**
- * Returns the root module(s) of this module.
- *
- * @param module
- * module from which to get the root module
- * @return root module
- * @throws CoreException
- */
- @Override
- public IModule[] getRootModules(IModule module) throws CoreException {
- if (JST_WEB_MODULETYPE.equals(module.getModuleType().getId())) {
- IStatus status = canModifyModules(new IModule[] { module }, null);
- if (status == null || !status.isOK())
- throw new CoreException(status);
- return new IModule[] { module };
- }
+ /**
+ * Returns the root module(s) of this module.
+ *
+ * @param module
+ * module from which to get the root module
+ * @return root module
+ * @throws CoreException
+ */
+ @Override
+ public IModule[] getRootModules(IModule module) throws CoreException
+ {
+ if (JST_WEB_MODULETYPE.equals(module.getModuleType().getId()))
+ {
+ IStatus status = canModifyModules(new IModule[]
+ { module },null);
+ if (status == null || !status.isOK())
+ throw new CoreException(status);
+ return new IModule[]
+ { module };
+ }
- return J2EEUtil.getWebModules(module, null);
- }
+ return J2EEUtil.getWebModules(module,null);
+ }
- /**
- * Return the root URL of this module.
- *
- * @param module
- * org.eclipse.wst.server.core.model.IModule
- * @return java.net.URL IJettyServerWorkingCopy.java
- */
+ /**
+ * Return the root URL of this module.
+ *
+ * @param module
+ * org.eclipse.wst.server.core.model.IModule
+ * @return java.net.URL IJettyServerWorkingCopy.java
+ */
- public URL getModuleRootURL(IModule module) {
- try {
- if (module == null)
- return null;
+ public URL getModuleRootURL(IModule module)
+ {
+ try
+ {
+ if (module == null)
+ return null;
- IJettyConfiguration config = getJettyConfiguration();
- if (config == null)
- return null;
+ IJettyConfiguration config = getJettyConfiguration();
+ if (config == null)
+ return null;
- String url = "http://" + getServer().getHost();
- int port = config.getMainPort().getPort();
- port = ServerUtil.getMonitoredPort(getServer(), port, "web");
- if (port != 80)
- url += ":" + port;
+ String url = "http://" + getServer().getHost();
+ int port = config.getMainPort().getPort();
+ port = ServerUtil.getMonitoredPort(getServer(),port,"web");
+ if (port != 80)
+ url += ":" + port;
- url += config.getWebModuleURL(module);
+ url += config.getWebModuleURL(module);
- if (!url.endsWith("/"))
- url += "/";
+ if (!url.endsWith("/"))
+ url += "/";
- return new URL(url);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not get root URL", e);
- return null;
- }
- }
+ return new URL(url);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Could not get root URL",e);
+ return null;
+ }
+ }
- /**
- * Returns true if the process is set to run in debug mode.
- *
- * @return boolean
- */
- public boolean isDebug() {
- return getAttribute(PROPERTY_DEBUG, false);
- }
+ /**
+ * Returns true if the process is set to run in debug mode.
+ *
+ * @return boolean
+ */
+ public boolean isDebug()
+ {
+ return getAttribute(PROPERTY_DEBUG,false);
+ }
- /**
- * Returns true if this is a test (run code out of the workbench) server.
- *
- * @return boolean
- */
- public boolean isTestEnvironment() {
- return getAttribute(PROPERTY_TEST_ENVIRONMENT, false);
- }
+ /**
+ * Returns true if this is a test (run code out of the workbench) server.
+ *
+ * @return boolean
+ */
+ public boolean isTestEnvironment()
+ {
+ return getAttribute(PROPERTY_TEST_ENVIRONMENT,false);
+ }
- /**
- * Returns true if the process is set to run in secure mode.
- *
- * @return boolean
- */
- public boolean isSecure() {
- return getAttribute(PROPERTY_SECURE, false);
- }
+ /**
+ * Returns true if the process is set to run in secure mode.
+ *
+ * @return boolean
+ */
+ public boolean isSecure()
+ {
+ return getAttribute(PROPERTY_SECURE,false);
+ }
- public String getInstanceDirectory() {
- return getAttribute(PROPERTY_INSTANCE_DIR, (String) null);
- }
+ public String getInstanceDirectory()
+ {
+ return getAttribute(PROPERTY_INSTANCE_DIR,(String)null);
+ }
- /**
- * @see IJettyServer#getDeployDirectory()
- */
- public String getDeployDirectory() {
- // Default to value used by prior WTP versions
- return getAttribute(PROPERTY_DEPLOY_DIR, LEGACY_DEPLOYDIR);
- }
+ /**
+ * @see IJettyServer#getDeployDirectory()
+ */
+ public String getDeployDirectory()
+ {
+ // Default to value used by prior WTP versions
+ return getAttribute(PROPERTY_DEPLOY_DIR,LEGACY_DEPLOYDIR);
+ }
- /**
- * Returns true if modules should be served without publishing.
- *
- * @return boolean
- */
- public boolean isServeModulesWithoutPublish() {
- // If feature is supported, return current setting
- IJettyVersionHandler tvh = getJettyVersionHandler();
- if (tvh != null && tvh.supportsServeModulesWithoutPublish())
- return getAttribute(PROPERTY_SERVE_MODULES_WITHOUT_PUBLISH, false);
- return false;
- }
+ /**
+ * Returns true if modules should be served without publishing.
+ *
+ * @return boolean
+ */
+ public boolean isServeModulesWithoutPublish()
+ {
+ // If feature is supported, return current setting
+ IJettyVersionHandler tvh = getJettyVersionHandler();
+ if (tvh != null && tvh.supportsServeModulesWithoutPublish())
+ return getAttribute(PROPERTY_SERVE_MODULES_WITHOUT_PUBLISH,false);
+ return false;
+ }
- public IJettyConfiguration getServerConfiguration() throws CoreException {
- return getJettyConfiguration();
- }
+ public IJettyConfiguration getServerConfiguration() throws CoreException
+ {
+ return getJettyConfiguration();
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServerBehaviour.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServerBehaviour.java
index ed0ec69..d05867f 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServerBehaviour.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServerBehaviour.java
@@ -61,1134 +61,1205 @@
import org.eclipse.wst.server.core.util.PublishHelper;
import org.eclipse.wst.server.core.util.SocketUtil;
-public class JettyServerBehaviour extends ServerBehaviourDelegate implements
- IJettyServerBehaviour, IModulePublishHelper {
+public class JettyServerBehaviour extends ServerBehaviourDelegate implements IJettyServerBehaviour, IModulePublishHelper
+{
- private static final String ATTR_STOP = "stop-server";
+ private static final String ATTR_STOP = "stop-server";
- private static final String[] JMX_EXCLUDE_ARGS = new String[] {
- "-Dcom.sun.management.jmxremote",
- "-Dcom.sun.management.jmxremote.port=",
- "-Dcom.sun.management.jmxremote.ssl=",
- "-Dcom.sun.management.jmxremote.authenticate=" };
+ private static final String[] JMX_EXCLUDE_ARGS = new String[]
+ { "-Dcom.sun.management.jmxremote", "-Dcom.sun.management.jmxremote.port=", "-Dcom.sun.management.jmxremote.ssl=",
+ "-Dcom.sun.management.jmxremote.authenticate=" };
- // the thread used to ping the server to check for startup
- protected transient PingThread ping = null;
- protected transient IDebugEventSetListener processListener;
+ // the thread used to ping the server to check for startup
+ protected transient PingThread ping = null;
+ protected transient IDebugEventSetListener processListener;
- /**
- * JettyServerBehaviour.
- */
- public JettyServerBehaviour() {
- super();
- }
+ /**
+ * JettyServerBehaviour.
+ */
+ public JettyServerBehaviour()
+ {
+ super();
+ }
- public void initialize(IProgressMonitor monitor) {
- // do nothing
- }
+ public void initialize(IProgressMonitor monitor)
+ {
+ // do nothing
+ }
- public JettyRuntime getJettyRuntime() {
- if (getServer().getRuntime() == null)
- return null;
+ public JettyRuntime getJettyRuntime()
+ {
+ if (getServer().getRuntime() == null)
+ return null;
- return (JettyRuntime) getServer().getRuntime().loadAdapter(
- JettyRuntime.class, null);
- }
+ return (JettyRuntime)getServer().getRuntime().loadAdapter(JettyRuntime.class,null);
+ }
- public IJettyVersionHandler getJettyVersionHandler() {
- return getJettyServer().getJettyVersionHandler();
- }
+ public IJettyVersionHandler getJettyVersionHandler()
+ {
+ return getJettyServer().getJettyVersionHandler();
+ }
- public IJettyConfiguration getJettyConfiguration() throws CoreException {
- return getJettyServer().getJettyConfiguration();
- }
+ public IJettyConfiguration getJettyConfiguration() throws CoreException
+ {
+ return getJettyServer().getJettyConfiguration();
+ }
- public JettyServer getJettyServer() {
- return (JettyServer) getServer().loadAdapter(JettyServer.class, null);
- }
+ public JettyServer getJettyServer()
+ {
+ return (JettyServer)getServer().loadAdapter(JettyServer.class,null);
+ }
- /**
- * Return the runtime class name.
- *
- * @return the class name
- */
- public String getRuntimeClass() {
- return getJettyVersionHandler().getRuntimeClass();
- }
+ /**
+ * Return the runtime class name.
+ *
+ * @return the class name
+ */
+ public String getRuntimeClass()
+ {
+ return getJettyVersionHandler().getRuntimeClass();
+ }
- /**
- * Returns the runtime base path for relative paths in the server
- * configuration.
- *
- * @return the base path
- */
- public IPath getRuntimeBaseDirectory() {
- return getJettyServer().getRuntimeBaseDirectory();
- }
+ /**
+ * Returns the runtime base path for relative paths in the server configuration.
+ *
+ * @return the base path
+ */
+ public IPath getRuntimeBaseDirectory()
+ {
+ return getJettyServer().getRuntimeBaseDirectory();
+ }
- /**
- * Return the program's runtime arguments to start or stop.
- *
- * @param starting
- * true if starting
- * @return an array of runtime program arguments
- */
- protected String[] getRuntimeProgramArguments(boolean starting) {
- IPath configPath = null;
- if (getJettyServer().isTestEnvironment())
- configPath = getRuntimeBaseDirectory();
- return getJettyVersionHandler().getRuntimeProgramArguments(configPath,
- getJettyServer().isDebug(), starting);
- }
+ /**
+ * Return the program's runtime arguments to start or stop.
+ *
+ * @param starting
+ * true if starting
+ * @return an array of runtime program arguments
+ */
+ protected String[] getRuntimeProgramArguments(boolean starting)
+ {
+ IPath configPath = null;
+ if (getJettyServer().isTestEnvironment())
+ configPath = getRuntimeBaseDirectory();
+ return getJettyVersionHandler().getRuntimeProgramArguments(configPath,getJettyServer().isDebug(),starting);
+ }
- protected String[] getExcludedRuntimeProgramArguments(boolean starting) {
- return getJettyVersionHandler().getExcludedRuntimeProgramArguments(
- getJettyServer().isDebug(), starting);
- }
+ protected String[] getExcludedRuntimeProgramArguments(boolean starting)
+ {
+ return getJettyVersionHandler().getExcludedRuntimeProgramArguments(getJettyServer().isDebug(),starting);
+ }
- /**
- * Return the runtime (VM) arguments.
- *
- * @return an array of runtime arguments
- */
- protected String[] getRuntimeVMArguments() {
- IPath installPath = getServer().getRuntime().getLocation();
- // If installPath is relative, convert to canonical path and hope for
- // the best
- if (!installPath.isAbsolute()) {
- try {
- String installLoc = (new File(installPath.toOSString()))
- .getCanonicalPath();
- installPath = new Path(installLoc);
- } catch (IOException e) {
- // Ignore if there is a problem
- }
- }
- IPath configPath = getRuntimeBaseDirectory();
- IPath deployPath;
- // If serving modules without publishing, use workspace path as the
- // deploy path
- if (getJettyServer().isServeModulesWithoutPublish()) {
- deployPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- }
- // Else normal publishing for modules
- else {
- deployPath = getServerDeployDirectory();
- // If deployPath is relative, convert to canonical path and hope for
- // the best
- if (!deployPath.isAbsolute()) {
- try {
- String deployLoc = (new File(deployPath.toOSString()))
- .getCanonicalPath();
- deployPath = new Path(deployLoc);
- } catch (IOException e) {
- // Ignore if there is a problem
- }
- }
- }
- return getJettyVersionHandler().getRuntimeVMArguments(installPath,
- configPath, deployPath, getJettyServer().isTestEnvironment());
- }
+ /**
+ * Return the runtime (VM) arguments.
+ *
+ * @return an array of runtime arguments
+ */
+ protected String[] getRuntimeVMArguments()
+ {
+ IPath installPath = getServer().getRuntime().getLocation();
+ // If installPath is relative, convert to canonical path and hope for
+ // the best
+ if (!installPath.isAbsolute())
+ {
+ try
+ {
+ String installLoc = (new File(installPath.toOSString())).getCanonicalPath();
+ installPath = new Path(installLoc);
+ }
+ catch (IOException e)
+ {
+ // Ignore if there is a problem
+ }
+ }
+ IPath configPath = getRuntimeBaseDirectory();
+ IPath deployPath;
+ // If serving modules without publishing, use workspace path as the
+ // deploy path
+ if (getJettyServer().isServeModulesWithoutPublish())
+ {
+ deployPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ }
+ // Else normal publishing for modules
+ else
+ {
+ deployPath = getServerDeployDirectory();
+ // If deployPath is relative, convert to canonical path and hope for
+ // the best
+ if (!deployPath.isAbsolute())
+ {
+ try
+ {
+ String deployLoc = (new File(deployPath.toOSString())).getCanonicalPath();
+ deployPath = new Path(deployLoc);
+ }
+ catch (IOException e)
+ {
+ // Ignore if there is a problem
+ }
+ }
+ }
+ return getJettyVersionHandler().getRuntimeVMArguments(installPath,configPath,deployPath,getJettyServer().isTestEnvironment());
+ }
- protected String getRuntimePolicyFile() {
- IPath configPath = getRuntimeBaseDirectory();
- return getJettyVersionHandler().getRuntimePolicyFile(configPath);
- }
+ protected String getRuntimePolicyFile()
+ {
+ IPath configPath = getRuntimeBaseDirectory();
+ return getJettyVersionHandler().getRuntimePolicyFile(configPath);
+ }
- protected static String renderCommandLine(String[] commandLine,
- String separator) {
- if (commandLine == null || commandLine.length < 1)
- return "";
- StringBuffer buf = new StringBuffer(commandLine[0]);
- for (int i = 1; i < commandLine.length; i++) {
- buf.append(separator);
- buf.append(commandLine[i]);
- }
- return buf.toString();
- }
+ protected static String renderCommandLine(String[] commandLine, String separator)
+ {
+ if (commandLine == null || commandLine.length < 1)
+ return "";
+ StringBuffer buf = new StringBuffer(commandLine[0]);
+ for (int i = 1; i < commandLine.length; i++)
+ {
+ buf.append(separator);
+ buf.append(commandLine[i]);
+ }
+ return buf.toString();
+ }
- /**
- * Setup for starting the server.
- *
- * @param launch
- * ILaunch
- * @param launchMode
- * String
- * @param monitor
- * IProgressMonitor
- * @throws CoreException
- * if anything goes wrong
- */
- public void setupLaunch(ILaunch launch, String launchMode,
- IProgressMonitor monitor) throws CoreException {
- if (StringUtils.isTrue(launch.getLaunchConfiguration().getAttribute(
- ATTR_STOP, StringUtils.FALSE)))
- return;
- // if (getJettyRuntime() == null)
- // throw new CoreException();
+ /**
+ * Setup for starting the server.
+ *
+ * @param launch
+ * ILaunch
+ * @param launchMode
+ * String
+ * @param monitor
+ * IProgressMonitor
+ * @throws CoreException
+ * if anything goes wrong
+ */
+ public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException
+ {
+ if (StringUtils.isTrue(launch.getLaunchConfiguration().getAttribute(ATTR_STOP,StringUtils.FALSE)))
+ return;
+ // if (getJettyRuntime() == null)
+ // throw new CoreException();
- IStatus status = getJettyRuntime().validate();
- if (status != null && status.getSeverity() == IStatus.ERROR)
- throw new CoreException(status);
+ IStatus status = getJettyRuntime().validate();
+ if (status != null && status.getSeverity() == IStatus.ERROR)
+ throw new CoreException(status);
- // setRestartNeeded(false);
- IJettyConfiguration configuration = getJettyConfiguration();
+ // setRestartNeeded(false);
+ IJettyConfiguration configuration = getJettyConfiguration();
- // check that ports are free
- Iterator iterator = configuration.getServerPorts().iterator();
- List usedPorts = new ArrayList();
- while (iterator.hasNext()) {
- ServerPort sp = (ServerPort) iterator.next();
- if (sp.getPort() < 0)
- throw new CoreException(new Status(IStatus.ERROR,
- JettyPlugin.PLUGIN_ID, 0, Messages.errorPortInvalid,
- null));
- if (SocketUtil.isPortInUse(sp.getPort(), 5)) {
- usedPorts.add(sp);
- }
- }
- if (usedPorts.size() == 1) {
- ServerPort port = (ServerPort) usedPorts.get(0);
- throw new CoreException(new Status(IStatus.ERROR,
- JettyPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPortInUse,
- new String[] { port.getPort() + "",
- getServer().getName() }), null));
- } else if (usedPorts.size() > 1) {
- String portStr = "";
- iterator = usedPorts.iterator();
- boolean first = true;
- while (iterator.hasNext()) {
- if (!first)
- portStr += ", ";
- first = false;
- ServerPort sp = (ServerPort) iterator.next();
- portStr += "" + sp.getPort();
- }
- throw new CoreException(new Status(IStatus.ERROR,
- JettyPlugin.PLUGIN_ID, 0, NLS.bind(
- Messages.errorPortsInUse, new String[] { portStr,
- getServer().getName() }), null));
- }
+ // check that ports are free
+ Iterator<ServerPort> iterator = configuration.getServerPorts().iterator();
+ List<ServerPort> usedPorts = new ArrayList<ServerPort>();
+ while (iterator.hasNext())
+ {
+ ServerPort sp = (ServerPort)iterator.next();
+ if (sp.getPort() < 0)
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,Messages.errorPortInvalid,null));
+ if (SocketUtil.isPortInUse(sp.getPort(),5))
+ {
+ usedPorts.add(sp);
+ }
+ }
+ if (usedPorts.size() == 1)
+ {
+ ServerPort port = (ServerPort)usedPorts.get(0);
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorPortInUse,new String[]
+ { port.getPort() + "", getServer().getName() }),null));
+ }
+ else if (usedPorts.size() > 1)
+ {
+ String portStr = "";
+ iterator = usedPorts.iterator();
+ boolean first = true;
+ while (iterator.hasNext())
+ {
+ if (!first)
+ portStr += ", ";
+ first = false;
+ ServerPort sp = (ServerPort)iterator.next();
+ portStr += "" + sp.getPort();
+ }
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorPortsInUse,new String[]
+ { portStr, getServer().getName() }),null));
+ }
- // check that there is only one app for each context root
- iterator = configuration.getWebModules().iterator();
- List contextRoots = new ArrayList();
- while (iterator.hasNext()) {
- WebModule module = (WebModule) iterator.next();
- String contextRoot = module.getPath();
- if (contextRoots.contains(contextRoot))
- throw new CoreException(new Status(IStatus.ERROR,
- JettyPlugin.PLUGIN_ID, 0, NLS.bind(
- Messages.errorDuplicateContextRoot,
- new String[] { contextRoot }), null));
+ // check that there is only one app for each context root
+ Iterator<WebModule> wmIterator = configuration.getWebModules().iterator();
+ List<String> contextRoots = new ArrayList<String>();
+ while (iterator.hasNext())
+ {
+ WebModule module = (WebModule)wmIterator.next();
+ String contextRoot = module.getPath();
+ if (contextRoots.contains(contextRoot))
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorDuplicateContextRoot,new String[]
+ { contextRoot }),null));
- contextRoots.add(contextRoot);
- }
+ contextRoots.add(contextRoot);
+ }
- setServerRestartState(false);
- setServerState(IServer.STATE_STARTING);
- setMode(launchMode);
+ setServerRestartState(false);
+ setServerState(IServer.STATE_STARTING);
+ setMode(launchMode);
- // ping server to check for startup
- try {
- String url = "http://" + getServer().getHost();
- int port = configuration.getMainPort().getPort();
- if (port != 80)
- url += ":" + port;
- ping = new PingThread(getServer(), url, -1, this);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Can't ping for Jetty startup.");
- }
- }
+ // ping server to check for startup
+ try
+ {
+ String url = "http://" + getServer().getHost();
+ int port = configuration.getMainPort().getPort();
+ if (port != 80)
+ url += ":" + port;
+ ping = new PingThread(getServer(),url,-1,this);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Can't ping for Jetty startup.");
+ }
+ }
- /**
- * Cleanly shuts down and terminates the server.
- *
- * @param force
- * <code>true</code> to kill the server
- */
- @Override
- public void stop(boolean force) {
- if (force) {
- terminate();
- return;
- }
- int state = getServer().getServerState();
- // If stopped or stopping, no need to run stop command again
- if (state == IServer.STATE_STOPPED || state == IServer.STATE_STOPPING)
- return;
- else if (state == IServer.STATE_STARTING) {
- terminate();
- return;
- }
+ /**
+ * Cleanly shuts down and terminates the server.
+ *
+ * @param force
+ * <code>true</code> to kill the server
+ */
+ @Override
+ public void stop(boolean force)
+ {
+ if (force)
+ {
+ terminate();
+ return;
+ }
+ int state = getServer().getServerState();
+ // If stopped or stopping, no need to run stop command again
+ if (state == IServer.STATE_STOPPED || state == IServer.STATE_STOPPING)
+ return;
+ else if (state == IServer.STATE_STARTING)
+ {
+ terminate();
+ return;
+ }
- try {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Stopping Jetty");
- if (state != IServer.STATE_STOPPED)
- setServerState(IServer.STATE_STOPPING);
+ try
+ {
+ if (Trace.isTraceEnabled())
+ Trace.trace(Trace.FINER,"Stopping Jetty");
+ if (state != IServer.STATE_STOPPED)
+ setServerState(IServer.STATE_STOPPING);
- ILaunchConfiguration launchConfig = ((Server) getServer())
- .getLaunchConfiguration(true, null);
- ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
+ ILaunchConfiguration launchConfig = ((Server)getServer()).getLaunchConfiguration(true,null);
+ ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
- String args = renderCommandLine(getRuntimeProgramArguments(false),
- " ");
- // Remove JMX arguments if present
- String existingVMArgs = wc.getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- (String) null);
- if (existingVMArgs.indexOf(JMX_EXCLUDE_ARGS[0]) >= 0) {
- wc.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- mergeArguments(existingVMArgs, new String[] {},
- JMX_EXCLUDE_ARGS, false));
- }
- wc.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
- args);
- wc.setAttribute("org.eclipse.debug.ui.private", true);
- wc.setAttribute(ATTR_STOP, "true");
- wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error stopping Jetty", e);
- }
- }
+ String args = renderCommandLine(getRuntimeProgramArguments(false)," ");
+ // Remove JMX arguments if present
+ String existingVMArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,(String)null);
+ if (existingVMArgs.indexOf(JMX_EXCLUDE_ARGS[0]) >= 0)
+ {
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,mergeArguments(existingVMArgs,new String[] {},JMX_EXCLUDE_ARGS,false));
+ }
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,args);
+ wc.setAttribute("org.eclipse.debug.ui.private",true);
+ wc.setAttribute(ATTR_STOP,"true");
+ wc.launch(ILaunchManager.RUN_MODE,new NullProgressMonitor());
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error stopping Jetty",e);
+ }
+ }
- /**
- * Terminates the server.
- */
- protected void terminate() {
- if (getServer().getServerState() == IServer.STATE_STOPPED)
- return;
+ /**
+ * Terminates the server.
+ */
+ protected void terminate()
+ {
+ if (getServer().getServerState() == IServer.STATE_STOPPED)
+ return;
- try {
- setServerState(IServer.STATE_STOPPING);
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Killing the Jetty process");
- ILaunch launch = getServer().getLaunch();
- if (launch != null) {
- launch.terminate();
- stopImpl();
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error killing the process", e);
- }
- }
+ try
+ {
+ setServerState(IServer.STATE_STOPPING);
+ if (Trace.isTraceEnabled())
+ Trace.trace(Trace.FINER,"Killing the Jetty process");
+ ILaunch launch = getServer().getLaunch();
+ if (launch != null)
+ {
+ launch.terminate();
+ stopImpl();
+ }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error killing the process",e);
+ }
+ }
- public IPath getTempDirectory() {
- return super.getTempDirectory(false);
- }
+ public IPath getTempDirectory()
+ {
+ return super.getTempDirectory(false);
+ }
- protected static int getNextToken(String s, int start) {
- int i = start;
- int length = s.length();
- char lookFor = ' ';
+ protected static int getNextToken(String s, int start)
+ {
+ int i = start;
+ int length = s.length();
+ char lookFor = ' ';
- while (i < length) {
- char c = s.charAt(i);
- if (lookFor == c) {
- if (lookFor == '"')
- return i + 1;
- return i;
- }
- if (c == '"')
- lookFor = '"';
- i++;
- }
- return -1;
- }
+ while (i < length)
+ {
+ char c = s.charAt(i);
+ if (lookFor == c)
+ {
+ if (lookFor == '"')
+ return i + 1;
+ return i;
+ }
+ if (c == '"')
+ lookFor = '"';
+ i++;
+ }
+ return -1;
+ }
- /**
- * Merge the given arguments into the original argument string, replacing
- * invalid values if they have been changed. Special handling is provided if
- * the keepActionLast argument is true and the last vmArg is a simple
- * string. The vmArgs will be merged such that the last vmArg is guaranteed
- * to be the last argument in the merged string.
- *
- * @param originalArg
- * String of original arguments.
- * @param vmArgs
- * Arguments to merge into the original arguments string
- * @param excludeArgs
- * Arguments to exclude from the original arguments string
- * @param keepActionLast
- * If <b>true</b> the vmArguments are assumed to be Jetty program
- * arguments, the last of which is the action to perform which
- * must remain the last argument. This only has an impact if the
- * last vmArg is a simple string argument, like
- * "start".
- * @return merged argument string
- */
- public static String mergeArguments(String originalArg, String[] vmArgs,
- String[] excludeArgs, boolean keepActionLast) {
- if (vmArgs == null)
- return originalArg;
+ /**
+ * Merge the given arguments into the original argument string, replacing invalid values if they have been changed. Special handling is provided if the
+ * keepActionLast argument is true and the last vmArg is a simple string. The vmArgs will be merged such that the last vmArg is guaranteed to be the last
+ * argument in the merged string.
+ *
+ * @param originalArg
+ * String of original arguments.
+ * @param vmArgs
+ * Arguments to merge into the original arguments string
+ * @param excludeArgs
+ * Arguments to exclude from the original arguments string
+ * @param keepActionLast
+ * If <b>true</b> the vmArguments are assumed to be Jetty program arguments, the last of which is the action to perform which must remain the
+ * last argument. This only has an impact if the last vmArg is a simple string argument, like "start".
+ * @return merged argument string
+ */
+ public static String mergeArguments(String originalArg, String[] vmArgs, String[] excludeArgs, boolean keepActionLast)
+ {
+ if (vmArgs == null)
+ return originalArg;
- if (originalArg == null)
- originalArg = "";
+ if (originalArg == null)
+ originalArg = "";
- // replace and null out all vmargs that already exist
- int size = vmArgs.length;
- for (int i = 0; i < size; i++) {
- int ind = vmArgs[i].indexOf(" ");
- int ind2 = vmArgs[i].indexOf("=");
- if (ind >= 0 && (ind2 == -1 || ind < ind2)) { // -a bc style
- int index = originalArg
- .indexOf(vmArgs[i].substring(0, ind + 1));
- if (index == 0
- || (index > 0 && Character.isWhitespace(originalArg
- .charAt(index - 1)))) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index + ind + 1);
- if (index2 >= 0)
- originalArg = s + vmArgs[i]
- + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- }
- } else if (ind2 >= 0) { // a=b style
- int index = originalArg.indexOf(vmArgs[i]
- .substring(0, ind2 + 1));
- if (index == 0
- || (index > 0 && Character.isWhitespace(originalArg
- .charAt(index - 1)))) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (index2 >= 0)
- originalArg = s + vmArgs[i]
- + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- }
- } else { // abc style
- int index = originalArg.indexOf(vmArgs[i]);
- if (index == 0
- || (index > 0 && Character.isWhitespace(originalArg
- .charAt(index - 1)))) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (!keepActionLast || i < (size - 1)) {
- if (index2 >= 0)
- originalArg = s + vmArgs[i]
- + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- } else {
- // The last VM argument needs to remain last,
- // remove original arg and append the vmArg later
- if (index2 >= 0)
- originalArg = s + originalArg.substring(index2);
- else
- originalArg = s;
- }
- }
- }
- }
+ // replace and null out all vmargs that already exist
+ int size = vmArgs.length;
+ for (int i = 0; i < size; i++)
+ {
+ int ind = vmArgs[i].indexOf(" ");
+ int ind2 = vmArgs[i].indexOf("=");
+ if (ind >= 0 && (ind2 == -1 || ind < ind2))
+ { // -a bc style
+ int index = originalArg.indexOf(vmArgs[i].substring(0,ind + 1));
+ if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1))))
+ {
+ // replace
+ String s = originalArg.substring(0,index);
+ int index2 = getNextToken(originalArg,index + ind + 1);
+ if (index2 >= 0)
+ originalArg = s + vmArgs[i] + originalArg.substring(index2);
+ else
+ originalArg = s + vmArgs[i];
+ vmArgs[i] = null;
+ }
+ }
+ else if (ind2 >= 0)
+ { // a=b style
+ int index = originalArg.indexOf(vmArgs[i].substring(0,ind2 + 1));
+ if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1))))
+ {
+ // replace
+ String s = originalArg.substring(0,index);
+ int index2 = getNextToken(originalArg,index);
+ if (index2 >= 0)
+ originalArg = s + vmArgs[i] + originalArg.substring(index2);
+ else
+ originalArg = s + vmArgs[i];
+ vmArgs[i] = null;
+ }
+ }
+ else
+ { // abc style
+ int index = originalArg.indexOf(vmArgs[i]);
+ if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1))))
+ {
+ // replace
+ String s = originalArg.substring(0,index);
+ int index2 = getNextToken(originalArg,index);
+ if (!keepActionLast || i < (size - 1))
+ {
+ if (index2 >= 0)
+ originalArg = s + vmArgs[i] + originalArg.substring(index2);
+ else
+ originalArg = s + vmArgs[i];
+ vmArgs[i] = null;
+ }
+ else
+ {
+ // The last VM argument needs to remain last,
+ // remove original arg and append the vmArg later
+ if (index2 >= 0)
+ originalArg = s + originalArg.substring(index2);
+ else
+ originalArg = s;
+ }
+ }
+ }
+ }
- // remove excluded arguments
- if (excludeArgs != null && excludeArgs.length > 0) {
- for (int i = 0; i < excludeArgs.length; i++) {
- int ind = excludeArgs[i].indexOf(" ");
- int ind2 = excludeArgs[i].indexOf("=");
- if (ind >= 0 && (ind2 == -1 || ind < ind2)) { // -a bc style
- int index = originalArg.indexOf(excludeArgs[i].substring(0,
- ind + 1));
- if (index == 0
- || (index > 0 && Character.isWhitespace(originalArg
- .charAt(index - 1)))) {
- // remove
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index + ind + 1);
- if (index2 >= 0) {
- // If remainder will become the first argument,
- // remove leading blanks
- while (index2 < originalArg.length()
- && Character.isWhitespace(originalArg
- .charAt(index2)))
- index2 += 1;
- originalArg = s + originalArg.substring(index2);
- } else
- originalArg = s;
- }
- } else if (ind2 >= 0) { // a=b style
- int index = originalArg.indexOf(excludeArgs[i].substring(0,
- ind2 + 1));
- if (index == 0
- || (index > 0 && Character.isWhitespace(originalArg
- .charAt(index - 1)))) {
- // remove
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (index2 >= 0) {
- // If remainder will become the first argument,
- // remove leading blanks
- while (index2 < originalArg.length()
- && Character.isWhitespace(originalArg
- .charAt(index2)))
- index2 += 1;
- originalArg = s + originalArg.substring(index2);
- } else
- originalArg = s;
- }
- } else { // abc style
- int index = originalArg.indexOf(excludeArgs[i]);
- if (index == 0
- || (index > 0 && Character.isWhitespace(originalArg
- .charAt(index - 1)))) {
- // remove
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (index2 >= 0) {
- // Remove leading blanks
- while (index2 < originalArg.length()
- && Character.isWhitespace(originalArg
- .charAt(index2)))
- index2 += 1;
- originalArg = s + originalArg.substring(index2);
- } else
- originalArg = s;
- }
- }
- }
- }
+ // remove excluded arguments
+ if (excludeArgs != null && excludeArgs.length > 0)
+ {
+ for (int i = 0; i < excludeArgs.length; i++)
+ {
+ int ind = excludeArgs[i].indexOf(" ");
+ int ind2 = excludeArgs[i].indexOf("=");
+ if (ind >= 0 && (ind2 == -1 || ind < ind2))
+ { // -a bc style
+ int index = originalArg.indexOf(excludeArgs[i].substring(0,ind + 1));
+ if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1))))
+ {
+ // remove
+ String s = originalArg.substring(0,index);
+ int index2 = getNextToken(originalArg,index + ind + 1);
+ if (index2 >= 0)
+ {
+ // If remainder will become the first argument,
+ // remove leading blanks
+ while (index2 < originalArg.length() && Character.isWhitespace(originalArg.charAt(index2)))
+ index2 += 1;
+ originalArg = s + originalArg.substring(index2);
+ }
+ else
+ originalArg = s;
+ }
+ }
+ else if (ind2 >= 0)
+ { // a=b style
+ int index = originalArg.indexOf(excludeArgs[i].substring(0,ind2 + 1));
+ if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1))))
+ {
+ // remove
+ String s = originalArg.substring(0,index);
+ int index2 = getNextToken(originalArg,index);
+ if (index2 >= 0)
+ {
+ // If remainder will become the first argument,
+ // remove leading blanks
+ while (index2 < originalArg.length() && Character.isWhitespace(originalArg.charAt(index2)))
+ index2 += 1;
+ originalArg = s + originalArg.substring(index2);
+ }
+ else
+ originalArg = s;
+ }
+ }
+ else
+ { // abc style
+ int index = originalArg.indexOf(excludeArgs[i]);
+ if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1))))
+ {
+ // remove
+ String s = originalArg.substring(0,index);
+ int index2 = getNextToken(originalArg,index);
+ if (index2 >= 0)
+ {
+ // Remove leading blanks
+ while (index2 < originalArg.length() && Character.isWhitespace(originalArg.charAt(index2)))
+ index2 += 1;
+ originalArg = s + originalArg.substring(index2);
+ }
+ else
+ originalArg = s;
+ }
+ }
+ }
+ }
- // add remaining vmargs to the end
- for (int i = 0; i < size; i++) {
- if (vmArgs[i] != null) {
- if (originalArg.length() > 0 && !originalArg.endsWith(" "))
- originalArg += " ";
- originalArg += vmArgs[i];
- }
- }
+ // add remaining vmargs to the end
+ for (int i = 0; i < size; i++)
+ {
+ if (vmArgs[i] != null)
+ {
+ if (originalArg.length() > 0 && !originalArg.endsWith(" "))
+ originalArg += " ";
+ originalArg += vmArgs[i];
+ }
+ }
- return originalArg;
- }
+ return originalArg;
+ }
- /**
- * Replace the current JRE container classpath with the given entry.
- *
- * @param cp
- * @param entry
- */
- public static void replaceJREContainer(List cp, IRuntimeClasspathEntry entry) {
- int size = cp.size();
- for (int i = 0; i < size; i++) {
- IRuntimeClasspathEntry entry2 = (IRuntimeClasspathEntry) cp.get(i);
- if (entry2.getPath().uptoSegment(2).isPrefixOf(entry.getPath())) {
- cp.set(i, entry);
- return;
- }
- }
+ /**
+ * Replace the current JRE container classpath with the given entry.
+ *
+ * @param cp
+ * @param entry
+ */
+ public static void replaceJREContainer(List cp, IRuntimeClasspathEntry entry)
+ {
+ int size = cp.size();
+ for (int i = 0; i < size; i++)
+ {
+ IRuntimeClasspathEntry entry2 = (IRuntimeClasspathEntry)cp.get(i);
+ if (entry2.getPath().uptoSegment(2).isPrefixOf(entry.getPath()))
+ {
+ cp.set(i,entry);
+ return;
+ }
+ }
- cp.add(0, entry);
- }
+ cp.add(0,entry);
+ }
- /**
- * Merge a single classpath entry into the classpath list.
- *
- * @param cp
- * @param entry
- */
- public static void mergeClasspath(List cp, IRuntimeClasspathEntry entry) {
- Iterator iterator = cp.iterator();
- while (iterator.hasNext()) {
- IRuntimeClasspathEntry entry2 = (IRuntimeClasspathEntry) iterator
- .next();
+ /**
+ * Merge a single classpath entry into the classpath list.
+ *
+ * @param cp
+ * @param entry
+ */
+ public static void mergeClasspath(List cp, IRuntimeClasspathEntry entry)
+ {
+ Iterator iterator = cp.iterator();
+ while (iterator.hasNext())
+ {
+ IRuntimeClasspathEntry entry2 = (IRuntimeClasspathEntry)iterator.next();
- if (entry2.getPath().equals(entry.getPath()))
- return;
- }
+ if (entry2.getPath().equals(entry.getPath()))
+ return;
+ }
- cp.add(entry);
- }
+ cp.add(entry);
+ }
- @Override
- public void setupLaunchConfiguration(
- ILaunchConfigurationWorkingCopy workingCopy,
- IProgressMonitor monitor) throws CoreException {
- String existingProgArgs = workingCopy.getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
- (String) null);
- workingCopy.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
- mergeArguments(existingProgArgs,
- getRuntimeProgramArguments(true),
- getExcludedRuntimeProgramArguments(true), true));
+ @Override
+ public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException
+ {
+ String existingProgArgs = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,(String)null);
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
+ mergeArguments(existingProgArgs,getRuntimeProgramArguments(true),getExcludedRuntimeProgramArguments(true),true));
- String existingVMArgs = workingCopy.getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- (String) null);
- String[] parsedVMArgs = null;
- if (null != existingVMArgs) {
- parsedVMArgs = DebugPlugin.parseArguments(existingVMArgs);
- }
- String[] configVMArgs = getRuntimeVMArguments();
- if (getJettyServer().isSecure()) {
- boolean addSecurityArgs = true;
- if (null != parsedVMArgs) {
- for (int i = 0; i < parsedVMArgs.length; i++) {
- if (parsedVMArgs[i].startsWith("wtp.configured.security")) {
- addSecurityArgs = false;
- break;
- }
- }
- }
- if (addSecurityArgs) {
- String[] newVMArgs = new String[configVMArgs.length + 3];
- System.arraycopy(configVMArgs, 0, newVMArgs, 0,
- configVMArgs.length);
- newVMArgs[configVMArgs.length] = "-Djava.security.manager";
- newVMArgs[configVMArgs.length + 1] = "-Djava.security.policy=\""
- + getRuntimePolicyFile() + "\"";
- newVMArgs[configVMArgs.length + 2] = "-Dwtp.configured.security=true";
- configVMArgs = newVMArgs;
- }
- } else if (null != parsedVMArgs) {
- boolean removeSecurityArgs = false;
- for (int i = 0; i < parsedVMArgs.length; i++) {
- if (parsedVMArgs[i].startsWith("-Dwtp.configured.security")) {
- removeSecurityArgs = true;
- break;
- }
- }
- if (removeSecurityArgs) {
- StringBuffer filteredVMArgs = new StringBuffer();
- for (int i = 0; i < parsedVMArgs.length; i++) {
- String arg = parsedVMArgs[i];
- if (!arg.startsWith("-Djava.security.manager")
- && !arg.startsWith("-Djava.security.policy=")
- && !arg.startsWith("-Dwtp.configured.security=")) {
- if (filteredVMArgs.length() > 0) {
- filteredVMArgs.append(' ');
- }
- filteredVMArgs.append(arg);
- }
- }
- existingVMArgs = filteredVMArgs.toString();
- }
- }
- workingCopy.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- mergeArguments(existingVMArgs, configVMArgs, null, false));
+ String existingVMArgs = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,(String)null);
+ String[] parsedVMArgs = null;
+ if (null != existingVMArgs)
+ {
+ parsedVMArgs = DebugPlugin.parseArguments(existingVMArgs);
+ }
+ String[] configVMArgs = getRuntimeVMArguments();
+ if (getJettyServer().isSecure())
+ {
+ boolean addSecurityArgs = true;
+ if (null != parsedVMArgs)
+ {
+ for (int i = 0; i < parsedVMArgs.length; i++)
+ {
+ if (parsedVMArgs[i].startsWith("wtp.configured.security"))
+ {
+ addSecurityArgs = false;
+ break;
+ }
+ }
+ }
+ if (addSecurityArgs)
+ {
+ String[] newVMArgs = new String[configVMArgs.length + 3];
+ System.arraycopy(configVMArgs,0,newVMArgs,0,configVMArgs.length);
+ newVMArgs[configVMArgs.length] = "-Djava.security.manager";
+ newVMArgs[configVMArgs.length + 1] = "-Djava.security.policy=\"" + getRuntimePolicyFile() + "\"";
+ newVMArgs[configVMArgs.length + 2] = "-Dwtp.configured.security=true";
+ configVMArgs = newVMArgs;
+ }
+ }
+ else if (null != parsedVMArgs)
+ {
+ boolean removeSecurityArgs = false;
+ for (int i = 0; i < parsedVMArgs.length; i++)
+ {
+ if (parsedVMArgs[i].startsWith("-Dwtp.configured.security"))
+ {
+ removeSecurityArgs = true;
+ break;
+ }
+ }
+ if (removeSecurityArgs)
+ {
+ StringBuffer filteredVMArgs = new StringBuffer();
+ for (int i = 0; i < parsedVMArgs.length; i++)
+ {
+ String arg = parsedVMArgs[i];
+ if (!arg.startsWith("-Djava.security.manager") && !arg.startsWith("-Djava.security.policy=")
+ && !arg.startsWith("-Dwtp.configured.security="))
+ {
+ if (filteredVMArgs.length() > 0)
+ {
+ filteredVMArgs.append(' ');
+ }
+ filteredVMArgs.append(arg);
+ }
+ }
+ existingVMArgs = filteredVMArgs.toString();
+ }
+ }
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,mergeArguments(existingVMArgs,configVMArgs,null,false));
- IJettyRuntime runtime = getJettyRuntime();
- IVMInstall vmInstall = runtime.getVMInstall();
- if (vmInstall != null)
- workingCopy.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH,
- JavaRuntime.newJREContainerPath(vmInstall)
- .toPortableString());
+ IJettyRuntime runtime = getJettyRuntime();
+ IVMInstall vmInstall = runtime.getVMInstall();
+ if (vmInstall != null)
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH,JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
- // update classpath
- IRuntimeClasspathEntry[] originalClasspath = JavaRuntime
- .computeUnresolvedRuntimeClasspath(workingCopy);
- int size = originalClasspath.length;
- List oldCp = new ArrayList(originalClasspath.length + 2);
- for (int i = 0; i < size; i++)
- oldCp.add(originalClasspath[i]);
+ // update classpath
+ IRuntimeClasspathEntry[] originalClasspath = JavaRuntime.computeUnresolvedRuntimeClasspath(workingCopy);
+ int size = originalClasspath.length;
+ List<IRuntimeClasspathEntry> oldCp = new ArrayList<IRuntimeClasspathEntry>(originalClasspath.length + 2);
+ for (int i = 0; i < size; i++)
+ oldCp.add(originalClasspath[i]);
- Collection cp2 = runtime.getRuntimeClasspath(getRuntimeBaseDirectory());
- Iterator iterator = cp2.iterator();
- while (iterator.hasNext()) {
- IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) iterator
- .next();
- mergeClasspath(oldCp, entry);
- }
+ Collection<IRuntimeClasspathEntry> cp2 = runtime.getRuntimeClasspath(getRuntimeBaseDirectory());
+ Iterator<IRuntimeClasspathEntry> iterator = cp2.iterator();
+ while (iterator.hasNext())
+ {
+ IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry)iterator.next();
+ mergeClasspath(oldCp,entry);
+ }
- if (vmInstall != null) {
- try {
- String typeId = vmInstall.getVMInstallType().getId();
- replaceJREContainer(oldCp,
- JavaRuntime.newRuntimeContainerClasspathEntry(new Path(
- JavaRuntime.JRE_CONTAINER).append(typeId)
- .append(vmInstall.getName()),
- IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
- } catch (Exception e) {
- // ignore
- }
+ if (vmInstall != null)
+ {
+ try
+ {
+ String typeId = vmInstall.getVMInstallType().getId();
+ replaceJREContainer(oldCp,JavaRuntime.newRuntimeContainerClasspathEntry(
+ new Path(JavaRuntime.JRE_CONTAINER).append(typeId).append(vmInstall.getName()),IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
- IPath jrePath = new Path(vmInstall.getInstallLocation()
- .getAbsolutePath());
- if (jrePath != null) {
- IPath toolsPath = jrePath.append("lib").append("tools.jar");
- if (toolsPath.toFile().exists()) {
- IRuntimeClasspathEntry toolsJar = JavaRuntime
- .newArchiveRuntimeClasspathEntry(toolsPath);
- // Search for index to any existing tools.jar entry
- int toolsIndex;
- for (toolsIndex = 0; toolsIndex < oldCp.size(); toolsIndex++) {
- IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) oldCp
- .get(toolsIndex);
- if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE
- && entry.getPath().lastSegment()
- .equals("tools.jar")) {
- break;
- }
- }
- // If existing tools.jar found, replace in case it's
- // different. Otherwise add.
- if (toolsIndex < oldCp.size())
- oldCp.set(toolsIndex, toolsJar);
- else
- mergeClasspath(oldCp, toolsJar);
- }
- }
- }
+ IPath jrePath = new Path(vmInstall.getInstallLocation().getAbsolutePath());
+ if (jrePath != null)
+ {
+ IPath toolsPath = jrePath.append("lib").append("tools.jar");
+ if (toolsPath.toFile().exists())
+ {
+ IRuntimeClasspathEntry toolsJar = JavaRuntime.newArchiveRuntimeClasspathEntry(toolsPath);
+ // Search for index to any existing tools.jar entry
+ int toolsIndex;
+ for (toolsIndex = 0; toolsIndex < oldCp.size(); toolsIndex++)
+ {
+ IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry)oldCp.get(toolsIndex);
+ if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE && entry.getPath().lastSegment().equals("tools.jar"))
+ {
+ break;
+ }
+ }
+ // If existing tools.jar found, replace in case it's
+ // different. Otherwise add.
+ if (toolsIndex < oldCp.size())
+ oldCp.set(toolsIndex,toolsJar);
+ else
+ mergeClasspath(oldCp,toolsJar);
+ }
+ }
+ }
- iterator = oldCp.iterator();
- List list = new ArrayList();
- while (iterator.hasNext()) {
- IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) iterator
- .next();
- try {
- list.add(entry.getMemento());
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not resolve classpath entry: "
- + entry, e);
- }
- }
+ iterator = oldCp.iterator();
+ List<String> list = new ArrayList<String>();
+ while (iterator.hasNext())
+ {
+ IRuntimeClasspathEntry entry = iterator.next();
+ try
+ {
+ list.add(entry.getMemento());
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Could not resolve classpath entry: " + entry,e);
+ }
+ }
- workingCopy.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, list);
- workingCopy
- .setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
- false);
- }
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,list);
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,false);
+ }
- protected void addProcessListener(final IProcess newProcess) {
- if (processListener != null || newProcess == null)
- return;
+ protected void addProcessListener(final IProcess newProcess)
+ {
+ if (processListener != null || newProcess == null)
+ return;
- processListener = new IDebugEventSetListener() {
- public void handleDebugEvents(DebugEvent[] events) {
- if (events != null) {
- int size = events.length;
- for (int i = 0; i < size; i++) {
- if (newProcess != null
- && newProcess.equals(events[i].getSource())
- && events[i].getKind() == DebugEvent.TERMINATE) {
- stopImpl();
- }
- }
- }
- }
- };
- DebugPlugin.getDefault().addDebugEventListener(processListener);
- }
+ processListener = new IDebugEventSetListener()
+ {
+ public void handleDebugEvents(DebugEvent[] events)
+ {
+ if (events != null)
+ {
+ int size = events.length;
+ for (int i = 0; i < size; i++)
+ {
+ if (newProcess != null && newProcess.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE)
+ {
+ stopImpl();
+ }
+ }
+ }
+ }
+ };
+ DebugPlugin.getDefault().addDebugEventListener(processListener);
+ }
- protected void setServerStarted() {
- setServerState(IServer.STATE_STARTED);
- }
+ protected void setServerStarted()
+ {
+ setServerState(IServer.STATE_STARTED);
+ }
- protected void stopImpl() {
- if (ping != null) {
- ping.stop();
- ping = null;
- }
- if (processListener != null) {
- DebugPlugin.getDefault().removeDebugEventListener(processListener);
- processListener = null;
- }
- setServerState(IServer.STATE_STOPPED);
- }
+ protected void stopImpl()
+ {
+ if (ping != null)
+ {
+ ping.stop();
+ ping = null;
+ }
+ if (processListener != null)
+ {
+ DebugPlugin.getDefault().removeDebugEventListener(processListener);
+ processListener = null;
+ }
+ setServerState(IServer.STATE_STOPPED);
+ }
- @Override
- protected void publishServer(int kind, IProgressMonitor monitor)
- throws CoreException {
- if (getServer().getRuntime() == null)
- return;
+ @Override
+ protected void publishServer(int kind, IProgressMonitor monitor) throws CoreException
+ {
+ if (getServer().getRuntime() == null)
+ return;
- IPath installDir = getServer().getRuntime().getLocation();
- IPath confDir = null;
- if (getJettyServer().isTestEnvironment()) {
- confDir = getRuntimeBaseDirectory();
- IStatus status = getJettyVersionHandler().prepareRuntimeDirectory(
- confDir);
- if (status != null && !status.isOK())
- throw new CoreException(status);
- } else
- confDir = installDir;
- // IStatus status =
- // getJettyVersionHandler().prepareDeployDirectory(getServerDeployDirectory());
- // if (status != null && !status.isOK())
- // throw new CoreException(status);
+ IPath installDir = getServer().getRuntime().getLocation();
+ IPath confDir = null;
+ if (getJettyServer().isTestEnvironment())
+ {
+ confDir = getRuntimeBaseDirectory();
+ IStatus status = getJettyVersionHandler().prepareRuntimeDirectory(confDir);
+ if (status != null && !status.isOK())
+ throw new CoreException(status);
+ }
+ else
+ confDir = installDir;
+ // IStatus status =
+ // getJettyVersionHandler().prepareDeployDirectory(getServerDeployDirectory());
+ // if (status != null && !status.isOK())
+ // throw new CoreException(status);
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishServerTask, 600);
+ monitor = ProgressUtil.getMonitorFor(monitor);
+ monitor.beginTask(Messages.publishServerTask,600);
- IStatus status = getJettyConfiguration().cleanupServer(confDir,
- installDir, ProgressUtil.getSubMonitorFor(monitor, 100));
- if (status != null && !status.isOK())
- throw new CoreException(status);
+ IStatus status = getJettyConfiguration().cleanupServer(confDir,installDir,ProgressUtil.getSubMonitorFor(monitor,100));
+ if (status != null && !status.isOK())
+ throw new CoreException(status);
- status = getJettyConfiguration().backupAndPublish(confDir,
- !getJettyServer().isTestEnvironment(),
- ProgressUtil.getSubMonitorFor(monitor, 400));
- if (status != null && !status.isOK())
- throw new CoreException(status);
+ status = getJettyConfiguration().backupAndPublish(confDir,!getJettyServer().isTestEnvironment(),ProgressUtil.getSubMonitorFor(monitor,400));
+ if (status != null && !status.isOK())
+ throw new CoreException(status);
- status = getJettyConfiguration().localizeConfiguration(confDir,
- getServerDeployDirectory(), getJettyServer(),
- ProgressUtil.getSubMonitorFor(monitor, 100));
- if (status != null && !status.isOK())
- throw new CoreException(status);
+ status = getJettyConfiguration().localizeConfiguration(confDir,getServerDeployDirectory(),getJettyServer(),ProgressUtil.getSubMonitorFor(monitor,100));
+ if (status != null && !status.isOK())
+ throw new CoreException(status);
- monitor.done();
+ monitor.done();
- setServerPublishState(IServer.PUBLISH_STATE_NONE);
- }
+ setServerPublishState(IServer.PUBLISH_STATE_NONE);
+ }
- /*
- * Publishes the given module to the server.
- */
- @Override
- protected void publishModule(int kind, int deltaKind, IModule[] moduleTree,
- IProgressMonitor monitor) throws CoreException {
- if (getServer().getServerState() != IServer.STATE_STOPPED) {
- if (deltaKind == ServerBehaviourDelegate.ADDED
- || deltaKind == ServerBehaviourDelegate.REMOVED)
- setServerRestartState(true);
- }
- if (getJettyServer().isTestEnvironment())
- return;
+ /*
+ * Publishes the given module to the server.
+ */
+ @Override
+ protected void publishModule(int kind, int deltaKind, IModule[] moduleTree, IProgressMonitor monitor) throws CoreException
+ {
+ if (getServer().getServerState() != IServer.STATE_STOPPED)
+ {
+ if (deltaKind == ServerBehaviourDelegate.ADDED || deltaKind == ServerBehaviourDelegate.REMOVED)
+ setServerRestartState(true);
+ }
+ if (getJettyServer().isTestEnvironment())
+ return;
- Properties p = loadModulePublishLocations();
+ Properties p = loadModulePublishLocations();
- PublishHelper helper = new PublishHelper(getRuntimeBaseDirectory()
- .append("temp").toFile());
- // If parent web module
- if (moduleTree.length == 1) {
- publishDir(deltaKind, p, moduleTree, helper, monitor);
- }
- // Else a child module
- else {
- // Try to determine the URI for the child module
- IWebModule webModule = (IWebModule) moduleTree[0].loadAdapter(
- IWebModule.class, monitor);
- String childURI = null;
- if (webModule != null) {
- childURI = webModule.getURI(moduleTree[1]);
- }
- // Try to determine if child is binary
- IJ2EEModule childModule = (IJ2EEModule) moduleTree[1].loadAdapter(
- IJ2EEModule.class, monitor);
- boolean isBinary = false;
- if (childModule != null) {
- isBinary = childModule.isBinary();
- }
+ PublishHelper helper = new PublishHelper(getRuntimeBaseDirectory().append("temp").toFile());
+ // If parent web module
+ if (moduleTree.length == 1)
+ {
+ publishDir(deltaKind,p,moduleTree,helper,monitor);
+ }
+ // Else a child module
+ else
+ {
+ // Try to determine the URI for the child module
+ IWebModule webModule = (IWebModule)moduleTree[0].loadAdapter(IWebModule.class,monitor);
+ String childURI = null;
+ if (webModule != null)
+ {
+ childURI = webModule.getURI(moduleTree[1]);
+ }
+ // Try to determine if child is binary
+ IJ2EEModule childModule = (IJ2EEModule)moduleTree[1].loadAdapter(IJ2EEModule.class,monitor);
+ boolean isBinary = false;
+ if (childModule != null)
+ {
+ isBinary = childModule.isBinary();
+ }
- if (isBinary) {
- publishArchiveModule(childURI, kind, deltaKind, p, moduleTree,
- helper, monitor);
- } else {
- publishJar(childURI, kind, deltaKind, p, moduleTree, helper,
- monitor);
- }
- }
+ if (isBinary)
+ {
+ publishArchiveModule(childURI,kind,deltaKind,p,moduleTree,helper,monitor);
+ }
+ else
+ {
+ publishJar(childURI,kind,deltaKind,p,moduleTree,helper,monitor);
+ }
+ }
- setModulePublishState(moduleTree, IServer.PUBLISH_STATE_NONE);
+ setModulePublishState(moduleTree,IServer.PUBLISH_STATE_NONE);
- saveModulePublishLocations(p);
- }
+ saveModulePublishLocations(p);
+ }
- /**
- * Publish a web module.
- *
- * @param deltaKind
- * @param p
- * @param module
- * @param monitor
- * @throws CoreException
- */
- private void publishDir(int deltaKind, Properties p, IModule module[],
- PublishHelper helper, IProgressMonitor monitor)
- throws CoreException {
- List status = new ArrayList();
- // Remove if requested or if previously published and are now serving
- // without publishing
- if (deltaKind == REMOVED
- || getJettyServer().isServeModulesWithoutPublish()) {
- String publishPath = (String) p.get(module[0].getId());
- if (publishPath != null) {
- try {
- File f = new File(publishPath);
- if (f.exists()) {
- IStatus[] stat = PublishHelper.deleteDirectory(f,
- monitor);
- PublishOperation2.addArrayToList(status, stat);
- }
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.WARNING,
- JettyPlugin.PLUGIN_ID, 0, NLS.bind(
- Messages.errorPublishCouldNotRemoveModule,
- module[0].getName()), e));
- }
- p.remove(module[0].getId());
- }
- } else {
- IPath path = getModuleDeployDirectory(module[0]);
- IModuleResource[] mr = getResources(module);
- IPath[] jarPaths = null;
- IWebModule webModule = (IWebModule) module[0].loadAdapter(
- IWebModule.class, monitor);
- IModule[] childModules = getServer().getChildModules(module,
- monitor);
- if (childModules != null && childModules.length > 0) {
- jarPaths = new IPath[childModules.length];
- for (int i = 0; i < childModules.length; i++) {
- if (webModule != null) {
- jarPaths[i] = new Path(
- webModule.getURI(childModules[i]));
- } else {
- IJ2EEModule childModule = (IJ2EEModule) childModules[i]
- .loadAdapter(IJ2EEModule.class, monitor);
- if (childModule != null && childModule.isBinary()) {
- jarPaths[i] = new Path("WEB-INF/lib")
- .append(childModules[i].getName());
- } else {
- jarPaths[i] = new Path("WEB-INF/lib")
- .append(childModules[i].getName() + ".jar");
- }
- }
- }
- }
- IStatus[] stat = helper.publishSmart(mr, path, jarPaths, monitor);
- PublishOperation2.addArrayToList(status, stat);
- p.put(module[0].getId(), path.toOSString());
- }
- PublishOperation2.throwException(status);
- }
+ /**
+ * Publish a web module.
+ *
+ * @param deltaKind
+ * @param p
+ * @param module
+ * @param monitor
+ * @throws CoreException
+ */
+ private void publishDir(int deltaKind, Properties p, IModule module[], PublishHelper helper, IProgressMonitor monitor) throws CoreException
+ {
+ List<IStatus> status = new ArrayList<IStatus>();
+ // Remove if requested or if previously published and are now serving
+ // without publishing
+ if (deltaKind == REMOVED || getJettyServer().isServeModulesWithoutPublish())
+ {
+ String publishPath = (String)p.get(module[0].getId());
+ if (publishPath != null)
+ {
+ try
+ {
+ File f = new File(publishPath);
+ if (f.exists())
+ {
+ IStatus[] stat = PublishHelper.deleteDirectory(f,monitor);
+ PublishOperation2.addArrayToList(status,stat);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new CoreException(new Status(IStatus.WARNING,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorPublishCouldNotRemoveModule,
+ module[0].getName()),e));
+ }
+ p.remove(module[0].getId());
+ }
+ }
+ else
+ {
+ IPath path = getModuleDeployDirectory(module[0]);
+ IModuleResource[] mr = getResources(module);
+ IPath[] jarPaths = null;
+ IWebModule webModule = (IWebModule)module[0].loadAdapter(IWebModule.class,monitor);
+ IModule[] childModules = getServer().getChildModules(module,monitor);
+ if (childModules != null && childModules.length > 0)
+ {
+ jarPaths = new IPath[childModules.length];
+ for (int i = 0; i < childModules.length; i++)
+ {
+ if (webModule != null)
+ {
+ jarPaths[i] = new Path(webModule.getURI(childModules[i]));
+ }
+ else
+ {
+ IJ2EEModule childModule = (IJ2EEModule)childModules[i].loadAdapter(IJ2EEModule.class,monitor);
+ if (childModule != null && childModule.isBinary())
+ {
+ jarPaths[i] = new Path("WEB-INF/lib").append(childModules[i].getName());
+ }
+ else
+ {
+ jarPaths[i] = new Path("WEB-INF/lib").append(childModules[i].getName() + ".jar");
+ }
+ }
+ }
+ }
+ IStatus[] stat = helper.publishSmart(mr,path,jarPaths,monitor);
+ PublishOperation2.addArrayToList(status,stat);
+ p.put(module[0].getId(),path.toOSString());
+ }
+ PublishOperation2.throwException(status);
+ }
- /**
- * Publish a jar file.
- *
- * @param deltaKind
- * @param p
- * @param module
- * @param monitor
- * @throws CoreException
- */
- private void publishJar(String jarURI, int kind, int deltaKind,
- Properties p, IModule[] module, PublishHelper helper,
- IProgressMonitor monitor) throws CoreException {
- // Remove if requested or if previously published and are now serving
- // without publishing
- if (deltaKind == REMOVED
- || getJettyServer().isServeModulesWithoutPublish()) {
- try {
- String publishPath = (String) p.get(module[1].getId());
- if (publishPath != null) {
- new File(publishPath).delete();
- p.remove(module[1].getId());
- }
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.WARNING,
- JettyPlugin.PLUGIN_ID, 0, "Could not remove module", e));
- }
- } else {
- IPath path = getModuleDeployDirectory(module[0]);
- if (jarURI == null) {
- jarURI = "WEB-INF/lib" + module[1].getName() + ".jar";
- }
- IPath jarPath = path.append(jarURI);
- path = jarPath.removeLastSegments(1);
- if (!path.toFile().exists()) {
- path.toFile().mkdirs();
- } else {
- // If file still exists and we are not forcing a new one to be
- // built
- if (jarPath.toFile().exists() && kind != IServer.PUBLISH_CLEAN
- && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
- }
+ /**
+ * Publish a jar file.
+ *
+ * @param deltaKind
+ * @param p
+ * @param module
+ * @param monitor
+ * @throws CoreException
+ */
+ private void publishJar(String jarURI, int kind, int deltaKind, Properties p, IModule[] module, PublishHelper helper, IProgressMonitor monitor)
+ throws CoreException
+ {
+ // Remove if requested or if previously published and are now serving
+ // without publishing
+ if (deltaKind == REMOVED || getJettyServer().isServeModulesWithoutPublish())
+ {
+ try
+ {
+ String publishPath = (String)p.get(module[1].getId());
+ if (publishPath != null)
+ {
+ new File(publishPath).delete();
+ p.remove(module[1].getId());
+ }
+ }
+ catch (Exception e)
+ {
+ throw new CoreException(new Status(IStatus.WARNING,JettyPlugin.PLUGIN_ID,0,"Could not remove module",e));
+ }
+ }
+ else
+ {
+ IPath path = getModuleDeployDirectory(module[0]);
+ if (jarURI == null)
+ {
+ jarURI = "WEB-INF/lib" + module[1].getName() + ".jar";
+ }
+ IPath jarPath = path.append(jarURI);
+ path = jarPath.removeLastSegments(1);
+ if (!path.toFile().exists())
+ {
+ path.toFile().mkdirs();
+ }
+ else
+ {
+ // If file still exists and we are not forcing a new one to be
+ // built
+ if (jarPath.toFile().exists() && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL)
+ {
+ // avoid changes if no changes to module since last publish
+ IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
+ if (delta == null || delta.length == 0)
+ return;
+ }
+ }
- IModuleResource[] mr = getResources(module);
- IStatus[] stat = helper.publishZip(mr, jarPath, monitor);
- List status = new ArrayList();
- PublishOperation2.addArrayToList(status, stat);
- PublishOperation2.throwException(status);
- p.put(module[1].getId(), jarPath.toOSString());
- }
- }
+ IModuleResource[] mr = getResources(module);
+ IStatus[] stat = helper.publishZip(mr,jarPath,monitor);
+ List<IStatus> status = new ArrayList<IStatus>();
+ PublishOperation2.addArrayToList(status,stat);
+ PublishOperation2.throwException(status);
+ p.put(module[1].getId(),jarPath.toOSString());
+ }
+ }
- private void publishArchiveModule(String jarURI, int kind, int deltaKind,
- Properties p, IModule[] module, PublishHelper helper,
- IProgressMonitor monitor) throws CoreException {
- // Remove if requested or if previously published and are now serving
- // without publishing
- if (deltaKind == REMOVED
- || getJettyServer().isServeModulesWithoutPublish()) {
- try {
- String publishPath = (String) p.get(module[1].getId());
- if (publishPath != null) {
- new File(publishPath).delete();
- p.remove(module[1].getId());
- }
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.WARNING,
- JettyPlugin.PLUGIN_ID, 0,
- "Could not remove archive module", e));
- }
- } else {
- List status = new ArrayList();
- IPath path = getModuleDeployDirectory(module[0]);
- if (jarURI == null) {
- jarURI = "WEB-INF/lib" + module[1].getName();
- }
- IPath jarPath = path.append(jarURI);
- path = jarPath.removeLastSegments(1);
- if (!path.toFile().exists()) {
- path.toFile().mkdirs();
- } else {
- // If file still exists and we are not forcing a new one to be
- // built
- if (jarPath.toFile().exists() && kind != IServer.PUBLISH_CLEAN
- && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
- }
+ private void publishArchiveModule(String jarURI, int kind, int deltaKind, Properties p, IModule[] module, PublishHelper helper, IProgressMonitor monitor)
+ throws CoreException
+ {
+ // Remove if requested or if previously published and are now serving
+ // without publishing
+ if (deltaKind == REMOVED || getJettyServer().isServeModulesWithoutPublish())
+ {
+ try
+ {
+ String publishPath = (String)p.get(module[1].getId());
+ if (publishPath != null)
+ {
+ new File(publishPath).delete();
+ p.remove(module[1].getId());
+ }
+ }
+ catch (Exception e)
+ {
+ throw new CoreException(new Status(IStatus.WARNING,JettyPlugin.PLUGIN_ID,0,"Could not remove archive module",e));
+ }
+ }
+ else
+ {
+ List<IStatus> status = new ArrayList<IStatus>();
+ IPath path = getModuleDeployDirectory(module[0]);
+ if (jarURI == null)
+ {
+ jarURI = "WEB-INF/lib" + module[1].getName();
+ }
+ IPath jarPath = path.append(jarURI);
+ path = jarPath.removeLastSegments(1);
+ if (!path.toFile().exists())
+ {
+ path.toFile().mkdirs();
+ }
+ else
+ {
+ // If file still exists and we are not forcing a new one to be
+ // built
+ if (jarPath.toFile().exists() && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL)
+ {
+ // avoid changes if no changes to module since last publish
+ IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
+ if (delta == null || delta.length == 0)
+ return;
+ }
+ }
- IModuleResource[] mr = getResources(module);
- IStatus[] stat = helper.publishToPath(mr, jarPath, monitor);
- PublishOperation2.addArrayToList(status, stat);
- PublishOperation2.throwException(status);
- p.put(module[1].getId(), jarPath.toOSString());
- }
- }
+ IModuleResource[] mr = getResources(module);
+ IStatus[] stat = helper.publishToPath(mr,jarPath,monitor);
+ PublishOperation2.addArrayToList(status,stat);
+ PublishOperation2.throwException(status);
+ p.put(module[1].getId(),jarPath.toOSString());
+ }
+ }
-// @Override
-// protected void publishFinish(IProgressMonitor monitor) throws CoreException {
-// IStatus status;
-// IPath baseDir = getRuntimeBaseDirectory();
-// JettyServer ts = getJettyServer();
-// IJettyVersionHandler tvh = getJettyVersionHandler();
-// // Include or remove loader jar depending on state of serving directly
-// status = tvh.prepareForServingDirectly(baseDir, getJettyServer());
-// if (status.isOK()) {
-// // If serving modules directly, update server.xml accordingly
-// // (includes project context.xmls)
-// if (ts.isServeModulesWithoutPublish()) {
-// status = getJettyConfiguration().updateContextsToServeDirectly(
-// baseDir, tvh.getSharedLoader(baseDir), monitor);
-// }
-// // Else serving normally. Add project context.xmls to server.xml
-// else {
-// // Publish context configuration for servers that support
-// // META-INF/context.xml
-// status = getJettyConfiguration().publishContextConfig(baseDir,
-// getServerDeployDirectory(), monitor);
-// }
-// if (status.isOK() && ts.isSaveSeparateContextFiles()) {
-// // Determine if context's path attribute should be removed
-// String id = getServer().getServerType().getId();
-// boolean noPath = id.indexOf("55") > 0 || id.indexOf("60") > 0;
-// boolean serverStopped = getServer().getServerState() == IServer.STATE_STOPPED;
-// // TODO Add a monitor
-// JettyVersionHelper.moveContextsToSeparateFiles(baseDir, noPath,
-// serverStopped, null);
-// }
-// }
-// if (!status.isOK())
-// throw new CoreException(status);
-// }
+ // @Override
+ // protected void publishFinish(IProgressMonitor monitor) throws CoreException {
+ // IStatus status;
+ // IPath baseDir = getRuntimeBaseDirectory();
+ // JettyServer ts = getJettyServer();
+ // IJettyVersionHandler tvh = getJettyVersionHandler();
+ // // Include or remove loader jar depending on state of serving directly
+ // status = tvh.prepareForServingDirectly(baseDir, getJettyServer());
+ // if (status.isOK()) {
+ // // If serving modules directly, update server.xml accordingly
+ // // (includes project context.xmls)
+ // if (ts.isServeModulesWithoutPublish()) {
+ // status = getJettyConfiguration().updateContextsToServeDirectly(
+ // baseDir, tvh.getSharedLoader(baseDir), monitor);
+ // }
+ // // Else serving normally. Add project context.xmls to server.xml
+ // else {
+ // // Publish context configuration for servers that support
+ // // META-INF/context.xml
+ // status = getJettyConfiguration().publishContextConfig(baseDir,
+ // getServerDeployDirectory(), monitor);
+ // }
+ // if (status.isOK() && ts.isSaveSeparateContextFiles()) {
+ // // Determine if context's path attribute should be removed
+ // String id = getServer().getServerType().getId();
+ // boolean noPath = id.indexOf("55") > 0 || id.indexOf("60") > 0;
+ // boolean serverStopped = getServer().getServerState() == IServer.STATE_STOPPED;
+ // // TODO Add a monitor
+ // JettyVersionHelper.moveContextsToSeparateFiles(baseDir, noPath,
+ // serverStopped, null);
+ // }
+ // }
+ // if (!status.isOK())
+ // throw new CoreException(status);
+ // }
- /**
- * Gets the directory to which modules should be deployed for this server.
- *
- * @return full path to deployment directory for the server
- */
- public IPath getServerDeployDirectory() {
- return getJettyServer().getServerDeployDirectory();
- }
+ /**
+ * Gets the directory to which modules should be deployed for this server.
+ *
+ * @return full path to deployment directory for the server
+ */
+ public IPath getServerDeployDirectory()
+ {
+ return getJettyServer().getServerDeployDirectory();
+ }
- protected IModuleResource[] getResources(IModule[] module) {
- return super.getResources(module);
- }
+ protected IModuleResource[] getResources(IModule[] module)
+ {
+ return super.getResources(module);
+ }
- protected IModuleResourceDelta[] getPublishedResourceDelta(IModule[] module) {
- return super.getPublishedResourceDelta(module);
- }
+ protected IModuleResourceDelta[] getPublishedResourceDelta(IModule[] module)
+ {
+ return super.getPublishedResourceDelta(module);
+ }
- /**
- * Gets the directory to which to deploy a module's web application.
- *
- * @param module
- * a module
- * @return full path to deployment directory for the module
- */
- public IPath getModuleDeployDirectory(IModule module) {
- return getServerDeployDirectory().append(module.getName());
- }
+ /**
+ * Gets the directory to which to deploy a module's web application.
+ *
+ * @param module
+ * a module
+ * @return full path to deployment directory for the module
+ */
+ public IPath getModuleDeployDirectory(IModule module)
+ {
+ return getServerDeployDirectory().append(module.getName());
+ }
- /**
- * Temporary method to help web services team. Returns the path that the
- * module is published to.
- *
- * @param module
- * a module on the server
- * @return the path that the module is published to when in test environment
- * mode, or null if the module is not a web module
- */
- public IPath getPublishDirectory(IModule[] module) {
- if (module == null || module.length != 1)
- return null;
+ /**
+ * Temporary method to help web services team. Returns the path that the module is published to.
+ *
+ * @param module
+ * a module on the server
+ * @return the path that the module is published to when in test environment mode, or null if the module is not a web module
+ */
+ public IPath getPublishDirectory(IModule[] module)
+ {
+ if (module == null || module.length != 1)
+ return null;
- return getModuleDeployDirectory(module[0]);
- }
+ return getModuleDeployDirectory(module[0]);
+ }
- public void setModulePublishState2(IModule[] module, int state) {
- setModulePublishState(module, state);
- }
+ public void setModulePublishState2(IModule[] module, int state)
+ {
+ setModulePublishState(module,state);
+ }
- public Properties loadModulePublishLocations() {
- Properties p = new Properties();
- IPath path = getTempDirectory().append("publish.txt");
- FileInputStream fin = null;
- try {
- fin = new FileInputStream(path.toFile());
- p.load(fin);
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- fin.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- return p;
- }
+ public Properties loadModulePublishLocations()
+ {
+ Properties p = new Properties();
+ IPath path = getTempDirectory().append("publish.txt");
+ FileInputStream fin = null;
+ try
+ {
+ fin = new FileInputStream(path.toFile());
+ p.load(fin);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ finally
+ {
+ try
+ {
+ fin.close();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ }
+ return p;
+ }
- public void saveModulePublishLocations(Properties p) {
- IPath path = getTempDirectory().append("publish.txt");
- FileOutputStream fout = null;
- try {
- fout = new FileOutputStream(path.toFile());
- p.store(fout, "Jetty publish data");
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- fout.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- }
+ public void saveModulePublishLocations(Properties p)
+ {
+ IPath path = getTempDirectory().append("publish.txt");
+ FileOutputStream fout = null;
+ try
+ {
+ fout = new FileOutputStream(path.toFile());
+ p.store(fout,"Jetty publish data");
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ finally
+ {
+ try
+ {
+ fout.close();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ }
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServerLocator.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServerLocator.java
index 15d370f..0557398 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServerLocator.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyServerLocator.java
@@ -19,29 +19,31 @@
import org.eclipse.wst.server.core.internal.IServerLocator.IServerSearchListener;
import org.eclipse.wst.server.core.internal.provisional.ServerLocatorDelegate;
-public class JettyServerLocator extends ServerLocatorDelegate {
-
- public void searchForServers(String host,
- final IServerSearchListener listener, final IProgressMonitor monitor) {
-
- JettyRuntimeLocator.IRuntimeSearchListener listener2 = new JettyRuntimeLocator.IRuntimeSearchListener() {
- public void runtimeFound(IRuntimeWorkingCopy runtime) {
- String runtimeTypeId = runtime.getRuntimeType().getId();
- String serverTypeId = runtimeTypeId.substring(0,
- runtimeTypeId.length() - 8);
- IServerType serverType = ServerCore
- .findServerType(serverTypeId);
- try {
- IServerWorkingCopy server = serverType.createServer(
- serverTypeId, null, runtime, monitor);
- listener.serverFound(server);
- } catch (Exception e) {
- Trace.trace(Trace.WARNING,
- "Could not create Jetty server", e);
- }
- }
- };
- JettyRuntimeLocator.searchForRuntimes2(null, listener2, monitor);
- }
+public class JettyServerLocator extends ServerLocatorDelegate
+{
+
+ public void searchForServers(String host, final IServerSearchListener listener, final IProgressMonitor monitor)
+ {
+
+ JettyRuntimeLocator.IRuntimeSearchListener listener2 = new JettyRuntimeLocator.IRuntimeSearchListener()
+ {
+ public void runtimeFound(IRuntimeWorkingCopy runtime)
+ {
+ String runtimeTypeId = runtime.getRuntimeType().getId();
+ String serverTypeId = runtimeTypeId.substring(0,runtimeTypeId.length() - 8);
+ IServerType serverType = ServerCore.findServerType(serverTypeId);
+ try
+ {
+ IServerWorkingCopy server = serverType.createServer(serverTypeId,null,runtime,monitor);
+ listener.serverFound(server);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.WARNING,"Could not create Jetty server",e);
+ }
+ }
+ };
+ JettyRuntimeLocator.searchForRuntimes2(null,listener2,monitor);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettySourcePathComputerDelegate.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettySourcePathComputerDelegate.java
index 9c03dc6..bb3ab44 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettySourcePathComputerDelegate.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettySourcePathComputerDelegate.java
@@ -37,122 +37,126 @@
/**
*
*/
-public class JettySourcePathComputerDelegate implements
- ISourcePathComputerDelegate {
+public class JettySourcePathComputerDelegate implements ISourcePathComputerDelegate
+{
- /**
- * {@inheritDoc}
- */
- public ISourceContainer[] computeSourceContainers(
- ILaunchConfiguration configuration, IProgressMonitor monitor)
- throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
+ /**
+ * {@inheritDoc}
+ */
+ public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException
+ {
+ IServer server = ServerUtil.getServer(configuration);
- SourcePathComputerVisitor visitor = new SourcePathComputerVisitor(
- configuration);
+ SourcePathComputerVisitor visitor = new SourcePathComputerVisitor(configuration);
- IModule[] modules = server.getModules();
- for (int i = 0; i < modules.length; i++) {
- ModuleTraverser.traverse(modules[i], visitor, monitor);
- }
+ IModule[] modules = server.getModules();
+ for (int i = 0; i < modules.length; i++)
+ {
+ ModuleTraverser.traverse(modules[i],visitor,monitor);
+ }
- return visitor.getSourceContainers();
- }
+ return visitor.getSourceContainers();
+ }
- class SourcePathComputerVisitor implements IModuleVisitor {
+ class SourcePathComputerVisitor implements IModuleVisitor
+ {
- final ILaunchConfiguration configuration;
+ final ILaunchConfiguration configuration;
- /**
- * List<IRuntimeClasspathEntry> of unresolved IRuntimeClasspathEntries
- */
- List<IRuntimeClasspathEntry> runtimeClasspath = new ArrayList<IRuntimeClasspathEntry>();
+ /**
+ * List<IRuntimeClasspathEntry> of unresolved IRuntimeClasspathEntries
+ */
+ List<IRuntimeClasspathEntry> runtimeClasspath = new ArrayList<IRuntimeClasspathEntry>();
- SourcePathComputerVisitor(ILaunchConfiguration configuration) {
- this.configuration = configuration;
- }
+ SourcePathComputerVisitor(ILaunchConfiguration configuration)
+ {
+ this.configuration = configuration;
+ }
- /**
- * {@inheritDoc}
- */
- public void visitWebComponent(IVirtualComponent component)
- throws CoreException {
- IProject project = component.getProject();
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IJavaProject javaProject = JavaCore.create(project);
- runtimeClasspath.add(JavaRuntime
- .newDefaultProjectClasspathEntry(javaProject));
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void visitWebComponent(IVirtualComponent component) throws CoreException
+ {
+ IProject project = component.getProject();
+ if (project.hasNature(JavaCore.NATURE_ID))
+ {
+ IJavaProject javaProject = JavaCore.create(project);
+ runtimeClasspath.add(JavaRuntime.newDefaultProjectClasspathEntry(javaProject));
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public void endVisitWebComponent(IVirtualComponent component)
- throws CoreException {
- // do nothing
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void endVisitWebComponent(IVirtualComponent component) throws CoreException
+ {
+ // do nothing
+ }
- /**
- * {@inheritDoc}
- */
- public void visitArchiveComponent(IPath runtimePath, IPath workspacePath) {
- // do nothing
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void visitArchiveComponent(IPath runtimePath, IPath workspacePath)
+ {
+ // do nothing
+ }
- /**
- * {@inheritDoc}
- */
- public void visitDependentComponent(IPath runtimePath,
- IPath workspacePath) {
- // do nothing
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void visitDependentComponent(IPath runtimePath, IPath workspacePath)
+ {
+ // do nothing
+ }
- /**
- * {@inheritDoc}
- */
- public void visitWebResource(IPath runtimePath, IPath workspacePath) {
- // do nothing
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void visitWebResource(IPath runtimePath, IPath workspacePath)
+ {
+ // do nothing
+ }
- /**
- * {@inheritDoc}
- */
- public void visitDependentContentResource(IPath runtimePath, IPath workspacePath) {
- // do nothing
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void visitDependentContentResource(IPath runtimePath, IPath workspacePath)
+ {
+ // do nothing
+ }
- /**
- * {@inheritDoc}
- */
- public void visitEarResource(IPath runtimePath, IPath workspacePath) {
- // do nothing
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void visitEarResource(IPath runtimePath, IPath workspacePath)
+ {
+ // do nothing
+ }
- /**
- * {@inheritDoc}
- */
- public void endVisitEarComponent(IVirtualComponent component)
- throws CoreException {
- // do nothing
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void endVisitEarComponent(IVirtualComponent component) throws CoreException
+ {
+ // do nothing
+ }
- /**
- * {@inheritDoc}
- */
- public void visitClasspathEntry(IPath rtFolder, IClasspathEntry entry) {
- // do nothing
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void visitClasspathEntry(IPath rtFolder, IClasspathEntry entry)
+ {
+ // do nothing
+ }
- ISourceContainer[] getSourceContainers() throws CoreException {
- runtimeClasspath.addAll(Arrays.asList(JavaRuntime
- .computeUnresolvedSourceLookupPath(configuration)));
- IRuntimeClasspathEntry[] entries = (IRuntimeClasspathEntry[]) runtimeClasspath
- .toArray(new IRuntimeClasspathEntry[runtimeClasspath.size()]);
- IRuntimeClasspathEntry[] resolved = JavaRuntime
- .resolveSourceLookupPath(entries, configuration);
- return JavaRuntime.getSourceContainers(resolved);
- }
+ ISourceContainer[] getSourceContainers() throws CoreException
+ {
+ runtimeClasspath.addAll(Arrays.asList(JavaRuntime.computeUnresolvedSourceLookupPath(configuration)));
+ IRuntimeClasspathEntry[] entries = (IRuntimeClasspathEntry[])runtimeClasspath.toArray(new IRuntimeClasspathEntry[runtimeClasspath.size()]);
+ IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries,configuration);
+ return JavaRuntime.getSourceContainers(resolved);
+ }
- }
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyVersionManager.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyVersionManager.java
index 4681b4c..87e8336 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyVersionManager.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/JettyVersionManager.java
@@ -23,79 +23,89 @@
import org.eclipse.jst.server.jetty.core.internal.jetty70.Jetty70Provider;
import org.eclipse.jst.server.jetty.core.internal.jetty80.Jetty80Provider;
-public class JettyVersionManager {
+public class JettyVersionManager
+{
- public static final JettyVersionManager INSTANCE = new JettyVersionManager();
+ public static final JettyVersionManager INSTANCE = new JettyVersionManager();
- private Map<String, IJettyVersionProvider> versionProviders = new HashMap<String, IJettyVersionProvider>();
+ private Map<String, IJettyVersionProvider> versionProviders = new HashMap<String, IJettyVersionProvider>();
- private List<String> runtimeTypes = new ArrayList<String>();
+ private List<String> runtimeTypes = new ArrayList<String>();
- public enum JettyVersion {
- V70, V80
- }
+ public enum JettyVersion
+ {
+ V70, V80
+ }
- private JettyVersionManager() {
- // Jetty 7.0
- register(JettyVersion.V70, Jetty70Provider.INSTANCE);
- // Jetty 8.0, same than Jetty7.0
- register(JettyVersion.V80, Jetty80Provider.INSTANCE);
- }
+ private JettyVersionManager()
+ {
+ // Jetty 7.0
+ register(JettyVersion.V70,Jetty70Provider.INSTANCE);
+ // Jetty 8.0, same than Jetty7.0
+ register(JettyVersion.V80,Jetty80Provider.INSTANCE);
+ }
- public void register(JettyVersion version,
- IJettyVersionProvider versionProvider) {
- versionProviders.put(version.name(), versionProvider);
+ public void register(JettyVersion version, IJettyVersionProvider versionProvider)
+ {
+ versionProviders.put(version.name(),versionProvider);
- String versionNumber = version.name().substring(1,
- version.name().length());
- runtimeTypes.add("org.eclipse.jst.server.jetty.runtime."
- + versionNumber);
- }
+ String versionNumber = version.name().substring(1,version.name().length());
+ runtimeTypes.add("org.eclipse.jst.server.jetty.runtime." + versionNumber);
+ }
- public IJettyVersionHandler getJettyVersionHandler(String id) {
- String version = getVersion(id);
- IJettyVersionProvider versionProvider = versionProviders.get(version);
- if (versionProvider == null) {
- throw new JettyVersionHandlerNotFoundException(version);
- }
- return versionProvider.getJettyVersionHandler();
- }
+ public IJettyVersionHandler getJettyVersionHandler(String id)
+ {
+ String version = getVersion(id);
+ IJettyVersionProvider versionProvider = versionProviders.get(version);
+ if (versionProvider == null)
+ {
+ throw new JettyVersionHandlerNotFoundException(version);
+ }
+ return versionProvider.getJettyVersionHandler();
+ }
- public IJettyConfiguration getJettyConfiguration(String id, IFolder path) {
- String version = getVersion(id);
- IJettyVersionProvider versionProvider = versionProviders.get(version);
- if (versionProvider == null) {
- throw new JettyVersionHandlerNotFoundException(version);
- }
- return versionProvider.createJettyConfiguration(path);
- }
+ public IJettyConfiguration getJettyConfiguration(String id, IFolder path)
+ {
+ String version = getVersion(id);
+ IJettyVersionProvider versionProvider = versionProviders.get(version);
+ if (versionProvider == null)
+ {
+ throw new JettyVersionHandlerNotFoundException(version);
+ }
+ return versionProvider.createJettyConfiguration(path);
+ }
- private String getVersion(String id) {
- String version = id;
- int index = version.lastIndexOf('.');
- if (index != -1) {
- version = version.substring(index + 1, version.length());
- }
- if (!version.startsWith("v")) {
- version = "v" + version;
- }
- version = version.toUpperCase();
- return version;
- }
+ private String getVersion(String id)
+ {
+ String version = id;
+ int index = version.lastIndexOf('.');
+ if (index != -1)
+ {
+ version = version.substring(index + 1,version.length());
+ }
+ if (!version.startsWith("v"))
+ {
+ version = "v" + version;
+ }
+ version = version.toUpperCase();
+ return version;
+ }
- private static class JettyVersionHandlerNotFoundException extends
- RuntimeException {
- private static final long serialVersionUID = 1L;
+ private static class JettyVersionHandlerNotFoundException extends RuntimeException
+ {
+ private static final long serialVersionUID = 1L;
- private static final String MESSAGE = "Version Handler not founded with serverType={0}.";
+ private static final String MESSAGE = "Version Handler not founded with serverType={0}.";
- public JettyVersionHandlerNotFoundException(String serverType) {
- super(format(MESSAGE, serverType));
- }
- }
+ public JettyVersionHandlerNotFoundException(String serverType)
+ {
+ super(format(MESSAGE,serverType));
+ }
+ }
- public Collection<String> getRuntimeTypes() {
- return runtimeTypes;
- }
+ public Collection<String> getRuntimeTypes()
+ {
+ return runtimeTypes;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/Messages.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/Messages.java
index 0096354..ea7b9c2 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/Messages.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/Messages.java
@@ -15,44 +15,44 @@
/**
* Jetty Core Messages.
- *
+ *
*/
-public class Messages extends NLS {
+public class Messages extends NLS
+{
-
- public static String errorInstallDirTrailingSlash;
- public static String errorJRE;
- public static String portServer;
- public static String errorConfigurationProjectClosed;
- public static String errorNoConfiguration;
- public static String errorWebModulesOnly;
- public static String errorNoRuntime;
- public static String errorPortInvalid;
- public static String errorPortInUse;
- public static String errorPortsInUse;
- public static String errorDuplicateContextRoot;
- public static String errorSpec70;
- public static String errorCouldNotLoadConfiguration;
- public static String errorCouldNotSaveConfiguration;
- public static String savingTask;
- public static String loadingTask;
- public static String errorPublish;
- public static String startJarRequiredInstallDirStatus;
- public static String publishServerTask;
- public static String errorPublishCouldNotRemoveModule;
- public static String copyingTask;
- public static String errorCopyingFile;
- public static String publishConfigurationTask;
- public static String publisherPublishTask;
- public static String errorPublishConfiguration;
- public static String errorXMLNullContextArg;
- public static String configurationEditorActionModifyPort;
- public static String configurationEditorActionAddWebModule;
- public static String configurationEditorActionModifyWebModule;
- public static String configurationEditorActionRemoveWebModule;
+ public static String errorInstallDirTrailingSlash;
+ public static String errorJRE;
+ public static String portServer;
+ public static String errorConfigurationProjectClosed;
+ public static String errorNoConfiguration;
+ public static String errorWebModulesOnly;
+ public static String errorNoRuntime;
+ public static String errorPortInvalid;
+ public static String errorPortInUse;
+ public static String errorPortsInUse;
+ public static String errorDuplicateContextRoot;
+ public static String errorSpec70;
+ public static String errorCouldNotLoadConfiguration;
+ public static String errorCouldNotSaveConfiguration;
+ public static String savingTask;
+ public static String loadingTask;
+ public static String errorPublish;
+ public static String startJarRequiredInstallDirStatus;
+ public static String publishServerTask;
+ public static String errorPublishCouldNotRemoveModule;
+ public static String copyingTask;
+ public static String errorCopyingFile;
+ public static String publishConfigurationTask;
+ public static String publisherPublishTask;
+ public static String errorPublishConfiguration;
+ public static String errorXMLNullContextArg;
+ public static String configurationEditorActionModifyPort;
+ public static String configurationEditorActionAddWebModule;
+ public static String configurationEditorActionModifyWebModule;
+ public static String configurationEditorActionRemoveWebModule;
- static {
- NLS.initializeMessages(JettyPlugin.PLUGIN_ID + ".internal.Messages",
- Messages.class);
- }
+ static
+ {
+ NLS.initializeMessages(JettyPlugin.PLUGIN_ID + ".internal.Messages",Messages.class);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PingThread.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PingThread.java
index 9139ed7..175094e 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PingThread.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PingThread.java
@@ -17,110 +17,138 @@
import java.net.URLConnection;
import org.eclipse.wst.server.core.IServer;
+
/**
* Thread used to ping server to test when it is started.
*/
-public class PingThread {
- // delay before pinging starts
- private static final int PING_DELAY = 2000;
+public class PingThread
+{
+ // delay before pinging starts
+ private static final int PING_DELAY = 2000;
- // delay between pings
- private static final int PING_INTERVAL = 250;
+ // delay between pings
+ private static final int PING_INTERVAL = 250;
- // maximum number of pings before giving up
- private int maxPings;
+ // maximum number of pings before giving up
+ private int maxPings;
- private boolean stop = false;
- private String url;
- private IServer server;
- private JettyServerBehaviour behaviour;
+ private boolean stop = false;
+ private String url;
+ private IServer server;
+ private JettyServerBehaviour behaviour;
- /**
- * Create a new PingThread.
- *
- * @param server
- * @param url
- * @param maxPings the maximum number of times to try pinging, or -1 to continue forever
- * @param behaviour
- */
- public PingThread(IServer server, String url, int maxPings, JettyServerBehaviour behaviour) {
- super();
- this.server = server;
- this.url = url;
- this.maxPings = maxPings;
- this.behaviour = behaviour;
- Thread t = new Thread("Jetty Ping Thread") {
- public void run() {
- ping();
- }
- };
- t.setDaemon(true);
- t.start();
- }
+ /**
+ * Create a new PingThread.
+ *
+ * @param server
+ * @param url
+ * @param maxPings
+ * the maximum number of times to try pinging, or -1 to continue forever
+ * @param behaviour
+ */
+ public PingThread(IServer server, String url, int maxPings, JettyServerBehaviour behaviour)
+ {
+ super();
+ this.server = server;
+ this.url = url;
+ this.maxPings = maxPings;
+ this.behaviour = behaviour;
+ Thread t = new Thread("Jetty Ping Thread")
+ {
+ public void run()
+ {
+ ping();
+ }
+ };
+ t.setDaemon(true);
+ t.start();
+ }
- /**
- * Ping the server until it is started. Then set the server
- * state to STATE_STARTED.
- */
- protected void ping() {
- int count = 0;
- try {
- Thread.sleep(PING_DELAY);
- } catch (Exception e) {
- // ignore
- }
- while (!stop) {
- try {
- if (count == maxPings) {
- try {
- server.stop(false);
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Ping: could not stop server");
- }
- stop = true;
- break;
- }
- count++;
-
- Trace.trace(Trace.FINEST, "Ping: pinging " + count);
- URL pingUrl = new URL(url);
- URLConnection conn = pingUrl.openConnection();
- ((HttpURLConnection)conn).getResponseCode();
-
- // ping worked - server is up
- if (!stop) {
- Trace.trace(Trace.FINEST, "Ping: success");
- Thread.sleep(200);
- behaviour.setServerStarted();
- }
- stop = true;
- } catch (FileNotFoundException fe) {
- try {
- Thread.sleep(200);
- } catch (Exception e) {
- // ignore
- }
- behaviour.setServerStarted();
- stop = true;
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Ping: failed");
- // pinging failed
- if (!stop) {
- try {
- Thread.sleep(PING_INTERVAL);
- } catch (InterruptedException e2) {
- // ignore
- }
- }
- }
- }
- }
+ /**
+ * Ping the server until it is started. Then set the server state to STATE_STARTED.
+ */
+ protected void ping()
+ {
+ int count = 0;
+ try
+ {
+ Thread.sleep(PING_DELAY);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ while (!stop)
+ {
+ try
+ {
+ if (count == maxPings)
+ {
+ try
+ {
+ server.stop(false);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.FINEST,"Ping: could not stop server");
+ }
+ stop = true;
+ break;
+ }
+ count++;
- /**
- * Tell the pinging to stop.
- */
- public void stop() {
- Trace.trace(Trace.FINEST, "Ping: stopping");
- stop = true;
- }
+ Trace.trace(Trace.FINEST,"Ping: pinging " + count);
+ URL pingUrl = new URL(url);
+ URLConnection conn = pingUrl.openConnection();
+ ((HttpURLConnection)conn).getResponseCode();
+
+ // ping worked - server is up
+ if (!stop)
+ {
+ Trace.trace(Trace.FINEST,"Ping: success");
+ Thread.sleep(200);
+ behaviour.setServerStarted();
+ }
+ stop = true;
+ }
+ catch (FileNotFoundException fe)
+ {
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ behaviour.setServerStarted();
+ stop = true;
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.FINEST,"Ping: failed");
+ // pinging failed
+ if (!stop)
+ {
+ try
+ {
+ Thread.sleep(PING_INTERVAL);
+ }
+ catch (InterruptedException e2)
+ {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Tell the pinging to stop.
+ */
+ public void stop()
+ {
+ Trace.trace(Trace.FINEST,"Ping: stopping");
+ stop = true;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PublishOperation2.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PublishOperation2.java
index b3c86fb..9024041 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PublishOperation2.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PublishOperation2.java
@@ -32,262 +32,296 @@
import org.eclipse.wst.server.core.model.PublishOperation;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.eclipse.wst.server.core.util.PublishHelper;
+
/**
* Jetty publish helper.
*/
-public class PublishOperation2 extends PublishOperation {
- protected JettyServerBehaviour server;
- protected IModule[] module;
- protected int kind;
- protected int deltaKind;
- private PublishHelper helper;
+public class PublishOperation2 extends PublishOperation
+{
+ protected JettyServerBehaviour server;
+ protected IModule[] module;
+ protected int kind;
+ protected int deltaKind;
+ private PublishHelper helper;
- /**
- * Construct the operation object to publish the specified module
- * to the specified server.
- *
- * @param server server to which the module will be published
- * @param kind kind of publish
- * @param module module to publish
- * @param deltaKind kind of change
- */
- public PublishOperation2(JettyServerBehaviour server, int kind, IModule[] module, int deltaKind) {
- super("Publish to server", "Publish Web module to Jetty server");
- this.server = server;
- this.module = module;
- this.kind = kind;
- this.deltaKind = deltaKind;
- IPath base = server.getRuntimeBaseDirectory();
- if (base != null) {
- helper = new PublishHelper(base.append("temp").toFile());
- }
- else {
- // We are doomed without a base directory. However, allow the catastrophe
- // to occur elsewhere and hope for a useful error message.
- helper = new PublishHelper(null);
- }
- }
+ /**
+ * Construct the operation object to publish the specified module to the specified server.
+ *
+ * @param server
+ * server to which the module will be published
+ * @param kind
+ * kind of publish
+ * @param module
+ * module to publish
+ * @param deltaKind
+ * kind of change
+ */
+ public PublishOperation2(JettyServerBehaviour server, int kind, IModule[] module, int deltaKind)
+ {
+ super("Publish to server","Publish Web module to Jetty server");
+ this.server = server;
+ this.module = module;
+ this.kind = kind;
+ this.deltaKind = deltaKind;
+ IPath base = server.getRuntimeBaseDirectory();
+ if (base != null)
+ {
+ helper = new PublishHelper(base.append("temp").toFile());
+ }
+ else
+ {
+ // We are doomed without a base directory. However, allow the catastrophe
+ // to occur elsewhere and hope for a useful error message.
+ helper = new PublishHelper(null);
+ }
+ }
- /**
- * @see PublishOperation#getOrder()
- */
- public int getOrder() {
- return 0;
- }
+ /**
+ * @see PublishOperation#getOrder()
+ */
+ public int getOrder()
+ {
+ return 0;
+ }
- /**
- * @see PublishOperation#getKind()
- */
- public int getKind() {
- return REQUIRED;
- }
+ /**
+ * @see PublishOperation#getKind()
+ */
+ public int getKind()
+ {
+ return REQUIRED;
+ }
- /**
- * @see PublishOperation#execute(IProgressMonitor, IAdaptable)
- */
- public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException {
- List status = new ArrayList();
- // If parent web module
- if (module.length == 1) {
- publishDir(module[0], status, monitor);
- }
- // Else a child module
- else {
- Properties p = server.loadModulePublishLocations();
+ /**
+ * @see PublishOperation#execute(IProgressMonitor, IAdaptable)
+ */
+ public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException
+ {
+ List<IStatus> status = new ArrayList<IStatus>();
+ // If parent web module
+ if (module.length == 1)
+ {
+ publishDir(module[0],status,monitor);
+ }
+ // Else a child module
+ else
+ {
+ Properties p = server.loadModulePublishLocations();
- // Try to determine the URI for the child module
- IWebModule webModule = (IWebModule)module[0].loadAdapter(IWebModule.class, monitor);
- String childURI = null;
- if (webModule != null) {
- childURI = webModule.getURI(module[1]);
- }
- // Try to determine if child is binary
- IJ2EEModule childModule = (IJ2EEModule)module[1].loadAdapter(IJ2EEModule.class, monitor);
- boolean isBinary = false;
- if (childModule != null) {
- isBinary = childModule.isBinary();
- }
+ // Try to determine the URI for the child module
+ IWebModule webModule = (IWebModule)module[0].loadAdapter(IWebModule.class,monitor);
+ String childURI = null;
+ if (webModule != null)
+ {
+ childURI = webModule.getURI(module[1]);
+ }
+ // Try to determine if child is binary
+ IJ2EEModule childModule = (IJ2EEModule)module[1].loadAdapter(IJ2EEModule.class,monitor);
+ boolean isBinary = false;
+ if (childModule != null)
+ {
+ isBinary = childModule.isBinary();
+ }
- if (isBinary) {
- publishArchiveModule(childURI, p, status, monitor);
- }
- else {
- publishJar(childURI, p, status, monitor);
- }
- server.saveModulePublishLocations(p);
- }
- throwException(status);
- server.setModulePublishState2(module, IServer.PUBLISH_STATE_NONE);
- }
+ if (isBinary)
+ {
+ publishArchiveModule(childURI,p,status,monitor);
+ }
+ else
+ {
+ publishJar(childURI,p,status,monitor);
+ }
+ server.saveModulePublishLocations(p);
+ }
+ throwException(status);
+ server.setModulePublishState2(module,IServer.PUBLISH_STATE_NONE);
+ }
- private void publishDir(IModule module2, List status, IProgressMonitor monitor) throws CoreException {
- IPath path = server.getModuleDeployDirectory(module2);
-
- // Remove if requested or if previously published and are now serving without publishing
- if (kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getJettyServer().isServeModulesWithoutPublish()) {
- File f = path.toFile();
- if (f.exists()) {
- IStatus[] stat = PublishHelper.deleteDirectory(f, monitor);
- addArrayToList(status, stat);
- }
-
- if (deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getJettyServer().isServeModulesWithoutPublish())
- return;
- }
-
- if (kind == IServer.PUBLISH_CLEAN || kind == IServer.PUBLISH_FULL) {
- IModuleResource[] mr = server.getResources(module);
- IStatus[] stat = helper.publishFull(mr, path, monitor);
- addArrayToList(status, stat);
- return;
- }
-
- IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
-
- int size = delta.length;
- for (int i = 0; i < size; i++) {
- IStatus[] stat = helper.publishDelta(delta[i], path, monitor);
- addArrayToList(status, stat);
- }
- }
+ private void publishDir(IModule module2, List status, IProgressMonitor monitor) throws CoreException
+ {
+ IPath path = server.getModuleDeployDirectory(module2);
- private void publishJar(String jarURI, Properties p, List status, IProgressMonitor monitor) throws CoreException {
- IPath path = server.getModuleDeployDirectory(module[0]);
- boolean moving = false;
- // Get URI used for previous publish, if known
- String oldURI = (String)p.get(module[1].getId());
- if (oldURI != null) {
- // If old URI found, detect if jar is moving or changing its name
- if (jarURI != null) {
- moving = !oldURI.equals(jarURI);
- }
- }
- // If we don't have a jar URI, make a guess so we have one if we need it
- if (jarURI == null) {
- jarURI = "WEB-INF/lib/" + module[1].getName() + ".jar";
- }
- IPath jarPath = path.append(jarURI);
- // Make our best determination of the path to the old jar
- IPath oldJarPath = jarPath;
- if (oldURI != null) {
- oldJarPath = path.append(oldURI);
- }
- // Establish the destination directory
- path = jarPath.removeLastSegments(1);
-
- // Remove if requested or if previously published and are now serving without publishing
- if (moving || kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getJettyServer().isServeModulesWithoutPublish()) {
- File file = oldJarPath.toFile();
- if (file.exists())
- file.delete();
- p.remove(module[1].getId());
+ // Remove if requested or if previously published and are now serving without publishing
+ if (kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED || server.getJettyServer().isServeModulesWithoutPublish())
+ {
+ File f = path.toFile();
+ if (f.exists())
+ {
+ IStatus[] stat = PublishHelper.deleteDirectory(f,monitor);
+ addArrayToList(status,stat);
+ }
- if (deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getJettyServer().isServeModulesWithoutPublish())
- return;
- }
- if (!moving && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
-
- // make directory if it doesn't exist
- if (!path.toFile().exists())
- path.toFile().mkdirs();
+ if (deltaKind == ServerBehaviourDelegate.REMOVED || server.getJettyServer().isServeModulesWithoutPublish())
+ return;
+ }
- IModuleResource[] mr = server.getResources(module);
- IStatus[] stat = helper.publishZip(mr, jarPath, monitor);
- addArrayToList(status, stat);
- p.put(module[1].getId(), jarURI);
- }
+ if (kind == IServer.PUBLISH_CLEAN || kind == IServer.PUBLISH_FULL)
+ {
+ IModuleResource[] mr = server.getResources(module);
+ IStatus[] stat = helper.publishFull(mr,path,monitor);
+ addArrayToList(status,stat);
+ return;
+ }
- private void publishArchiveModule(String jarURI, Properties p, List status, IProgressMonitor monitor) {
- IPath path = server.getModuleDeployDirectory(module[0]);
- boolean moving = false;
- // Get URI used for previous publish, if known
- String oldURI = (String)p.get(module[1].getId());
- if (oldURI != null) {
- // If old URI found, detect if jar is moving or changing its name
- if (jarURI != null) {
- moving = !oldURI.equals(jarURI);
- }
- }
- // If we don't have a jar URI, make a guess so we have one if we need it
- if (jarURI == null) {
- jarURI = "WEB-INF/lib/" + module[1].getName();
- }
- IPath jarPath = path.append(jarURI);
- // Make our best determination of the path to the old jar
- IPath oldJarPath = jarPath;
- if (oldURI != null) {
- oldJarPath = path.append(oldURI);
- }
- // Establish the destination directory
- path = jarPath.removeLastSegments(1);
+ IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
- // Remove if requested or if previously published and are now serving without publishing
- if (moving || kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getJettyServer().isServeModulesWithoutPublish()) {
- File file = oldJarPath.toFile();
- if (file.exists()) {
- file.delete();
- }
- p.remove(module[1].getId());
-
- if (deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getJettyServer().isServeModulesWithoutPublish())
- return;
- }
- if (!moving && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
+ int size = delta.length;
+ for (int i = 0; i < size; i++)
+ {
+ IStatus[] stat = helper.publishDelta(delta[i],path,monitor);
+ addArrayToList(status,stat);
+ }
+ }
- // make directory if it doesn't exist
- if (!path.toFile().exists())
- path.toFile().mkdirs();
+ private void publishJar(String jarURI, Properties p, List status, IProgressMonitor monitor) throws CoreException
+ {
+ IPath path = server.getModuleDeployDirectory(module[0]);
+ boolean moving = false;
+ // Get URI used for previous publish, if known
+ String oldURI = (String)p.get(module[1].getId());
+ if (oldURI != null)
+ {
+ // If old URI found, detect if jar is moving or changing its name
+ if (jarURI != null)
+ {
+ moving = !oldURI.equals(jarURI);
+ }
+ }
+ // If we don't have a jar URI, make a guess so we have one if we need it
+ if (jarURI == null)
+ {
+ jarURI = "WEB-INF/lib/" + module[1].getName() + ".jar";
+ }
+ IPath jarPath = path.append(jarURI);
+ // Make our best determination of the path to the old jar
+ IPath oldJarPath = jarPath;
+ if (oldURI != null)
+ {
+ oldJarPath = path.append(oldURI);
+ }
+ // Establish the destination directory
+ path = jarPath.removeLastSegments(1);
- IModuleResource[] mr = server.getResources(module);
- IStatus[] stat = helper.publishToPath(mr, jarPath, monitor);
- addArrayToList(status, stat);
- p.put(module[1].getId(), jarURI);
- }
+ // Remove if requested or if previously published and are now serving without publishing
+ if (moving || kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED || server.getJettyServer().isServeModulesWithoutPublish())
+ {
+ File file = oldJarPath.toFile();
+ if (file.exists())
+ file.delete();
+ p.remove(module[1].getId());
- /**
- * Utility method to throw a CoreException based on the contents of a list of
- * error and warning status.
- *
- * @param status a List containing error and warning IStatus
- * @throws CoreException
- */
- protected static void throwException(List status) throws CoreException {
- if (status == null || status.size() == 0)
- return;
-
- if (status.size() == 1) {
- IStatus status2 = (IStatus) status.get(0);
- throw new CoreException(status2);
- }
- IStatus[] children = new IStatus[status.size()];
- status.toArray(children);
- String message = Messages.errorPublish;
- MultiStatus status2 = new MultiStatus(JettyPlugin.PLUGIN_ID, 0, children, message, null);
- throw new CoreException(status2);
- }
+ if (deltaKind == ServerBehaviourDelegate.REMOVED || server.getJettyServer().isServeModulesWithoutPublish())
+ return;
+ }
+ if (!moving && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL)
+ {
+ // avoid changes if no changes to module since last publish
+ IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
+ if (delta == null || delta.length == 0)
+ return;
+ }
- protected static void addArrayToList(List list, IStatus[] a) {
- if (list == null || a == null || a.length == 0)
- return;
-
- int size = a.length;
- for (int i = 0; i < size; i++)
- list.add(a[i]);
- }
+ // make directory if it doesn't exist
+ if (!path.toFile().exists())
+ path.toFile().mkdirs();
+
+ IModuleResource[] mr = server.getResources(module);
+ IStatus[] stat = helper.publishZip(mr,jarPath,monitor);
+ addArrayToList(status,stat);
+ p.put(module[1].getId(),jarURI);
+ }
+
+ private void publishArchiveModule(String jarURI, Properties p, List status, IProgressMonitor monitor)
+ {
+ IPath path = server.getModuleDeployDirectory(module[0]);
+ boolean moving = false;
+ // Get URI used for previous publish, if known
+ String oldURI = (String)p.get(module[1].getId());
+ if (oldURI != null)
+ {
+ // If old URI found, detect if jar is moving or changing its name
+ if (jarURI != null)
+ {
+ moving = !oldURI.equals(jarURI);
+ }
+ }
+ // If we don't have a jar URI, make a guess so we have one if we need it
+ if (jarURI == null)
+ {
+ jarURI = "WEB-INF/lib/" + module[1].getName();
+ }
+ IPath jarPath = path.append(jarURI);
+ // Make our best determination of the path to the old jar
+ IPath oldJarPath = jarPath;
+ if (oldURI != null)
+ {
+ oldJarPath = path.append(oldURI);
+ }
+ // Establish the destination directory
+ path = jarPath.removeLastSegments(1);
+
+ // Remove if requested or if previously published and are now serving without publishing
+ if (moving || kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED || server.getJettyServer().isServeModulesWithoutPublish())
+ {
+ File file = oldJarPath.toFile();
+ if (file.exists())
+ {
+ file.delete();
+ }
+ p.remove(module[1].getId());
+
+ if (deltaKind == ServerBehaviourDelegate.REMOVED || server.getJettyServer().isServeModulesWithoutPublish())
+ return;
+ }
+ if (!moving && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL)
+ {
+ // avoid changes if no changes to module since last publish
+ IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
+ if (delta == null || delta.length == 0)
+ return;
+ }
+
+ // make directory if it doesn't exist
+ if (!path.toFile().exists())
+ path.toFile().mkdirs();
+
+ IModuleResource[] mr = server.getResources(module);
+ IStatus[] stat = helper.publishToPath(mr,jarPath,monitor);
+ addArrayToList(status,stat);
+ p.put(module[1].getId(),jarURI);
+ }
+
+ /**
+ * Utility method to throw a CoreException based on the contents of a list of error and warning status.
+ *
+ * @param status
+ * a List containing error and warning IStatus
+ * @throws CoreException
+ */
+ protected static void throwException(List<IStatus> status) throws CoreException
+ {
+ if (status == null || status.size() == 0)
+ return;
+
+ if (status.size() == 1)
+ {
+ IStatus status2 = (IStatus)status.get(0);
+ throw new CoreException(status2);
+ }
+ IStatus[] children = new IStatus[status.size()];
+ status.toArray(children);
+ String message = Messages.errorPublish;
+ MultiStatus status2 = new MultiStatus(JettyPlugin.PLUGIN_ID,0,children,message,null);
+ throw new CoreException(status2);
+ }
+
+ protected static void addArrayToList(List<IStatus> list, IStatus[] a)
+ {
+ if (list == null || a == null || a.length == 0)
+ return;
+
+ int size = a.length;
+ for (int i = 0; i < size; i++)
+ list.add(a[i]);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PublishTask.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PublishTask.java
index d8371bb..f03dfb3 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PublishTask.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/PublishTask.java
@@ -19,24 +19,27 @@
import org.eclipse.wst.server.core.model.PublishOperation;
import org.eclipse.wst.server.core.model.PublishTaskDelegate;
-public class PublishTask extends PublishTaskDelegate {
-
- public PublishOperation[] getTasks(IServer server, int kind, List modules, List kindList) {
- if (modules == null)
- return null;
-
- JettyServerBehaviour jettyServer = (JettyServerBehaviour) server.loadAdapter(JettyServerBehaviour.class, null);
- if (!jettyServer.getJettyServer().isTestEnvironment())
- return null;
-
- List tasks = new ArrayList();
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- IModule[] module = (IModule[]) modules.get(i);
- Integer in = (Integer) kindList.get(i);
- tasks.add(new PublishOperation2(jettyServer, kind, module, in.intValue()));
- }
-
- return (PublishOperation[]) tasks.toArray(new PublishOperation[tasks.size()]);
- }
+public class PublishTask extends PublishTaskDelegate
+{
+
+ public PublishOperation[] getTasks(IServer server, int kind, List modules, List kindList)
+ {
+ if (modules == null)
+ return null;
+
+ JettyServerBehaviour jettyServer = (JettyServerBehaviour)server.loadAdapter(JettyServerBehaviour.class,null);
+ if (!jettyServer.getJettyServer().isTestEnvironment())
+ return null;
+
+ List<PublishOperation> tasks = new ArrayList<PublishOperation>();
+ int size = modules.size();
+ for (int i = 0; i < size; i++)
+ {
+ IModule[] module = (IModule[])modules.get(i);
+ Integer in = (Integer)kindList.get(i);
+ tasks.add(new PublishOperation2(jettyServer,kind,module,in.intValue()));
+ }
+
+ return (PublishOperation[])tasks.toArray(new PublishOperation[tasks.size()]);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/Trace.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/Trace.java
index ed74161..da6583e 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/Trace.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/Trace.java
@@ -19,98 +19,103 @@
/**
* Helper class to route trace output.
*/
-public class Trace {
- public static final byte CONFIG = 0;
- public static final byte WARNING = 1;
- public static final byte SEVERE = 2;
- public static final byte FINEST = 3;
- public static final byte FINER = 4;
+public class Trace
+{
+ public static final byte CONFIG = 0;
+ public static final byte WARNING = 1;
+ public static final byte SEVERE = 2;
+ public static final byte FINEST = 3;
+ public static final byte FINER = 4;
- private static final String[] levelNames = new String[] { "CONFIG ",
- "WARNING ", "SEVERE ", "FINER ", "FINEST " };
- private static final String spacer = " ";
+ private static final String[] levelNames = new String[]
+ { "CONFIG ", "WARNING ", "SEVERE ", "FINER ", "FINEST " };
+ private static final String spacer = " ";
- private static final SimpleDateFormat sdf = new SimpleDateFormat(
- "dd/MM/yy HH:mm.ss.SSS");
+ private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm.ss.SSS");
- protected static int pluginLength = -1;
+ protected static int pluginLength = -1;
- /**
- * Trace constructor comment.
- */
- private Trace() {
- super();
- }
+ /**
+ * Trace constructor comment.
+ */
+ private Trace()
+ {
+ super();
+ }
- /**
- * Trace the given text.
- *
- * @param level
- * the trace level
- * @param s
- * a message
- */
- public static void trace(byte level, String s) {
- Trace.trace(level, s, null);
- }
+ /**
+ * Trace the given text.
+ *
+ * @param level
+ * the trace level
+ * @param s
+ * a message
+ */
+ public static void trace(byte level, String s)
+ {
+ Trace.trace(level,s,null);
+ }
- /**
- * Trace the given message and exception.
- *
- * @param level
- * the trace level
- * @param s
- * a message
- * @param t
- * a throwable
- */
- public static void trace(byte level, String s, Throwable t) {
- if (!JettyPlugin.getDefault().isDebugging())
- return;
- trace(JettyPlugin.PLUGIN_ID, level, s, t);
- }
+ /**
+ * Trace the given message and exception.
+ *
+ * @param level
+ * the trace level
+ * @param s
+ * a message
+ * @param t
+ * a throwable
+ */
+ public static void trace(byte level, String s, Throwable t)
+ {
+ if (!JettyPlugin.getDefault().isDebugging())
+ return;
+ trace(JettyPlugin.PLUGIN_ID,level,s,t);
+ }
- /**
- * Trace the given message and exception.
- *
- * @param level
- * a trace level
- * @param s
- * a message
- * @param t
- * a throwable
- */
- private static void trace(String pluginId, int level, String s, Throwable t) {
- if (pluginId == null || s == null)
- return;
+ /**
+ * Trace the given message and exception.
+ *
+ * @param level
+ * a trace level
+ * @param s
+ * a message
+ * @param t
+ * a throwable
+ */
+ private static void trace(String pluginId, int level, String s, Throwable t)
+ {
+ if (pluginId == null || s == null)
+ return;
- if (!JettyPlugin.getDefault().isDebugging())
- return;
+ if (!JettyPlugin.getDefault().isDebugging())
+ return;
- StringBuilder sb = new StringBuilder(pluginId);
- if (pluginId.length() > pluginLength)
- pluginLength = pluginId.length();
- else if (pluginId.length() < pluginLength)
- sb.append(spacer.substring(0, pluginLength - pluginId.length()));
- sb.append(" ");
- sb.append(levelNames[level]);
- sb.append(" ");
- sb.append(sdf.format(new Date()));
- sb.append(" ");
- sb.append(s);
- // Platform.getDebugOption(ServerCore.PLUGIN_ID + "/" + "resources");
+ StringBuilder sb = new StringBuilder(pluginId);
+ if (pluginId.length() > pluginLength)
+ pluginLength = pluginId.length();
+ else if (pluginId.length() < pluginLength)
+ sb.append(spacer.substring(0,pluginLength - pluginId.length()));
+ sb.append(" ");
+ sb.append(levelNames[level]);
+ sb.append(" ");
+ sb.append(sdf.format(new Date()));
+ sb.append(" ");
+ sb.append(s);
+ // Platform.getDebugOption(ServerCore.PLUGIN_ID + "/" + "resources");
- System.out.println(sb.toString());
- if (t != null)
- t.printStackTrace();
- }
+ System.out.println(sb.toString());
+ if (t != null)
+ t.printStackTrace();
+ }
- /**
- * Gets state of debug flag for the plug-in.
- *
- * @return true if tracing is enabled
- */
- public static boolean isTraceEnabled() {
- return JettyPlugin.getDefault().isDebugging();
- }
+ /**
+ * Gets state of debug flag for the plug-in.
+ *
+ * @return true if tracing is enabled
+ */
+ public static boolean isTraceEnabled()
+ {
+ return JettyPlugin.getDefault().isDebugging();
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/JettyXMLConfig.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/JettyXMLConfig.java
index c7ba1ce..0dd51f3 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/JettyXMLConfig.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/JettyXMLConfig.java
@@ -20,25 +20,28 @@
import org.eclipse.jst.server.jetty.core.internal.util.IOUtils;
-public class JettyXMLConfig {
+public class JettyXMLConfig
+{
- public static InputStream getInputStream(File jettyXMLFile)
- throws IOException {
- InputStream stream = new FileInputStream(jettyXMLFile);
- try {
- InputStreamReader input = new InputStreamReader(stream);
- BufferedReader reader = new BufferedReader(input);
- StringWriter newContent = new StringWriter();
- for (String line = reader.readLine(); line != null; line = reader
- .readLine()) {
- newContent.append(line);
- newContent.append('\n');
- }
- String s = newContent.toString().replaceAll("<Property", "<SystemProperty");
- return IOUtils.toInputStream(s, "UTF-8");
- }
- finally {
- stream.close();
- }
- }
+ public static InputStream getInputStream(File jettyXMLFile) throws IOException
+ {
+ InputStream stream = new FileInputStream(jettyXMLFile);
+ try
+ {
+ InputStreamReader input = new InputStreamReader(stream);
+ BufferedReader reader = new BufferedReader(input);
+ StringWriter newContent = new StringWriter();
+ for (String line = reader.readLine(); line != null; line = reader.readLine())
+ {
+ newContent.append(line);
+ newContent.append('\n');
+ }
+ String s = newContent.toString().replaceAll("<Property","<SystemProperty");
+ return IOUtils.toInputStream(s,"UTF-8");
+ }
+ finally
+ {
+ stream.close();
+ }
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/PathFileConfig.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/PathFileConfig.java
index ade01aa..5b6a91e 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/PathFileConfig.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/PathFileConfig.java
@@ -14,21 +14,25 @@
import org.eclipse.core.runtime.IPath;
-public class PathFileConfig {
+public class PathFileConfig
+{
- private File file;
- private IPath path;
-
- public PathFileConfig(File file, IPath path) {
- this.file =file;
- this.path = path;
- }
-
- public File getFile() {
- return file;
- }
-
- public IPath getPath() {
- return path;
- }
+ private File file;
+ private IPath path;
+
+ public PathFileConfig(File file, IPath path)
+ {
+ this.file = file;
+ this.path = path;
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public IPath getPath()
+ {
+ return path;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/StartConfig.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/StartConfig.java
index 66fc91e..b9a86d7 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/StartConfig.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/StartConfig.java
@@ -20,62 +20,66 @@
import org.eclipse.jst.server.jetty.core.internal.util.IOUtils;
-public class StartConfig {
+public class StartConfig
+{
- public static InputStream getInputStream(File startJARFile)
- throws ZipException, IOException {
- // Load start.config from the start.jar coming from the Jetty serveur
- // install
- InputStream stream = IOUtils.getInputStream(startJARFile,
- "org/eclipse/jetty/start/start.config");
+ public static InputStream getInputStream(File startJARFile) throws ZipException, IOException
+ {
+ // Load start.config from the start.jar coming from the Jetty serveur
+ // install
+ InputStream stream = IOUtils.getInputStream(startJARFile,"org/eclipse/jetty/start/start.config");
- // Read start.config to preprocess the content to :
- // 1) add jetty.home/=$(jetty.home)
- // 2) comments the whole jetty.home= declaration
- // 3) replace for the JAR lib 'jetty.home' to 'install.jetty.home'
- // 4) add JSP support if needed
+ // Read start.config to preprocess the content to :
+ // 1) add jetty.home/=$(jetty.home)
+ // 2) comments the whole jetty.home= declaration
+ // 3) replace for the JAR lib 'jetty.home' to 'install.jetty.home'
+ // 4) add JSP support if needed
- boolean hasJSPModule = false;
+ boolean hasJSPModule = false;
- InputStreamReader input = new InputStreamReader(stream);
- BufferedReader reader = new BufferedReader(input);
- StringWriter newContent = new StringWriter();
+ InputStreamReader input = new InputStreamReader(stream);
+ BufferedReader reader = new BufferedReader(input);
+ StringWriter newContent = new StringWriter();
- // 1) add jetty.home/=$(jetty.home)
- newContent.append("jetty.home/=$(jetty.home)");
- newContent.append('\n');
- for (String line = reader.readLine(); line != null; line = reader
- .readLine()) {
+ // 1) add jetty.home/=$(jetty.home)
+ newContent.append("jetty.home/=$(jetty.home)");
+ newContent.append('\n');
+ for (String line = reader.readLine(); line != null; line = reader.readLine())
+ {
- if (line.startsWith("jetty.home")) {
- // 2) comments the whole jetty.home= declaration
- line = "#" + line;
- } else {
- // 3) replace for the JAR lib 'jetty.home' to
- // 'install.jetty.home'
- if (line.indexOf("$(jetty.home)") != -1) {
- if (line.indexOf("/lib/") != -1
- || line.indexOf(".jar") != -1) {
- line = line.replaceAll("jetty.home",
- "install.jetty.home");
- }
- }
- hasJSPModule = line.startsWith("[jsp]");
- }
- newContent.append(line);
- newContent.append('\n');
- }
+ if (line.startsWith("jetty.home"))
+ {
+ // 2) comments the whole jetty.home= declaration
+ line = "#" + line;
+ }
+ else
+ {
+ // 3) replace for the JAR lib 'jetty.home' to
+ // 'install.jetty.home'
+ if (line.indexOf("$(jetty.home)") != -1)
+ {
+ if (line.indexOf("/lib/") != -1 || line.indexOf(".jar") != -1)
+ {
+ line = line.replaceAll("jetty.home","install.jetty.home");
+ }
+ }
+ hasJSPModule = line.startsWith("[jsp]");
+ }
+ newContent.append(line);
+ newContent.append('\n');
+ }
- // 4) add JSP support if needed
- if (!hasJSPModule) {
- newContent.append("# Add jsp");
- newContent.append('\n');
- newContent.append("[jsp]");
- newContent.append('\n');
- newContent.append("$(install.jetty.home)/lib/jsp/**");
- newContent.append('\n');
- }
- return IOUtils.toInputStream(newContent.toString(), "UTF-8");
- }
+ // 4) add JSP support if needed
+ if (!hasJSPModule)
+ {
+ newContent.append("# Add jsp");
+ newContent.append('\n');
+ newContent.append("[jsp]");
+ newContent.append('\n');
+ newContent.append("$(install.jetty.home)/lib/jsp/**");
+ newContent.append('\n');
+ }
+ return IOUtils.toInputStream(newContent.toString(),"UTF-8");
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/StartIni.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/StartIni.java
index 0f2a955..7a93d15 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/StartIni.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/StartIni.java
@@ -30,181 +30,220 @@
import org.eclipse.jst.server.jetty.core.internal.JettyConstants;
import org.eclipse.jst.server.jetty.core.internal.util.IOUtils;
-public class StartIni implements JettyConstants {
+public class StartIni implements JettyConstants
+{
- private List<PathFileConfig> jettyXMLFiles = new ArrayList<PathFileConfig>();
- private List<PathFileConfig> otherConfigs = new ArrayList<PathFileConfig>();
- private PathFileConfig startConfig = null;
- private PathFileConfig webdefaultXMLConfig = null;
- private File startIniFile;
+ private List<PathFileConfig> jettyXMLFiles = new ArrayList<PathFileConfig>();
+ private List<PathFileConfig> otherConfigs = new ArrayList<PathFileConfig>();
+ private PathFileConfig startConfig = null;
+ private PathFileConfig webdefaultXMLConfig = null;
+ private File startIniFile;
- private boolean isStartIniDirty;
+ private boolean isStartIniDirty;
- public StartIni(IPath baseDirPath) {
- loadStartIni(baseDirPath, null);
- loadOtherConfigs(baseDirPath);
- }
+ public StartIni(IPath baseDirPath)
+ {
+ loadStartIni(baseDirPath,null);
+ loadOtherConfigs(baseDirPath);
+ }
- public StartIni(IFolder baseDirFolder) {
- loadStartIni(null, baseDirFolder);
- //loadOtherConfigs(null, baseDirFolder);
- }
+ public StartIni(IFolder baseDirFolder)
+ {
+ loadStartIni(null,baseDirFolder);
+ // loadOtherConfigs(null, baseDirFolder);
+ }
- private List<String> loadStartIni(IPath baseDirPath, IFolder baseDirFolder) {
- List<String> args = new ArrayList<String>();
- if (baseDirPath != null) {
- IPath startIniPath = baseDirPath.append(START_INI);
- this.startIniFile = startIniPath.toFile();
- } else {
- try {
- this.startIniFile = IOUtils.toLocalFile(
- baseDirFolder.getFile(START_INI), null);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
+ private List<String> loadStartIni(IPath baseDirPath, IFolder baseDirFolder)
+ {
+ List<String> args = new ArrayList<String>();
+ if (baseDirPath != null)
+ {
+ IPath startIniPath = baseDirPath.append(START_INI);
+ this.startIniFile = startIniPath.toFile();
+ }
+ else
+ {
+ try
+ {
+ this.startIniFile = IOUtils.toLocalFile(baseDirFolder.getFile(START_INI),null);
+ }
+ catch (CoreException e)
+ {
+ e.printStackTrace();
+ }
+ }
- if (startIniFile.exists() && startIniFile.canRead()) {
- FileReader reader = null;
- BufferedReader buf = null;
- try {
- reader = new FileReader(startIniFile);
- buf = new BufferedReader(reader);
+ if (startIniFile.exists() && startIniFile.canRead())
+ {
+ FileReader reader = null;
+ BufferedReader buf = null;
+ try
+ {
+ reader = new FileReader(startIniFile);
+ buf = new BufferedReader(reader);
- File jettyXMLFile = null;
- String arg;
- while ((arg = buf.readLine()) != null) {
- arg = arg.trim();
- if (arg.length() == 0 || arg.startsWith("#")) {
- continue;
- }
- if (arg.indexOf('=') == -1) {
- if (baseDirPath != null) {
- jettyXMLFile = baseDirPath.append(arg).toFile();
- } else {
- try {
- jettyXMLFile = IOUtils.toLocalFile(
- baseDirFolder.getFile(arg), null);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
- if (jettyXMLFile != null && jettyXMLFile.exists()
- && jettyXMLFile.canRead()) {
- jettyXMLFiles.add(new PathFileConfig(jettyXMLFile,
- new Path(arg)));
- }
- }
- args.add(arg);
- }
- } catch (IOException e) {
- } finally {
- close(buf);
- close(reader);
- }
- }
- return args;
- }
+ File jettyXMLFile = null;
+ String arg;
+ while ((arg = buf.readLine()) != null)
+ {
+ arg = arg.trim();
+ if (arg.length() == 0 || arg.startsWith("#"))
+ {
+ continue;
+ }
+ if (arg.indexOf('=') == -1)
+ {
+ if (baseDirPath != null)
+ {
+ jettyXMLFile = baseDirPath.append(arg).toFile();
+ }
+ else
+ {
+ try
+ {
+ jettyXMLFile = IOUtils.toLocalFile(baseDirFolder.getFile(arg),null);
+ }
+ catch (CoreException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ if (jettyXMLFile != null && jettyXMLFile.exists() && jettyXMLFile.canRead())
+ {
+ jettyXMLFiles.add(new PathFileConfig(jettyXMLFile,new Path(arg)));
+ }
+ }
+ args.add(arg);
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ close(buf);
+ close(reader);
+ }
+ }
+ return args;
+ }
- private void close(Closeable c) {
- if (c == null) {
- return;
- }
- try {
- c.close();
- } catch (IOException e) {
- e.printStackTrace(System.err);
- }
- }
+ private void close(Closeable c)
+ {
+ if (c == null)
+ {
+ return;
+ }
+ try
+ {
+ c.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace(System.err);
+ }
+ }
- private void loadOtherConfigs(IPath baseDirPath) {
- IPath realmPropertiesPath = baseDirPath.append("etc/realm.properties");
- File realmPropertiesFile = realmPropertiesPath.toFile();
- if (realmPropertiesFile.exists()) {
- otherConfigs.add(new PathFileConfig(realmPropertiesFile, new Path(
- "etc/realm.properties")));
- }
+ private void loadOtherConfigs(IPath baseDirPath)
+ {
+ IPath realmPropertiesPath = baseDirPath.append("etc/realm.properties");
+ File realmPropertiesFile = realmPropertiesPath.toFile();
+ if (realmPropertiesFile.exists())
+ {
+ otherConfigs.add(new PathFileConfig(realmPropertiesFile,new Path("etc/realm.properties")));
+ }
- IPath webdefaultPath = baseDirPath.append("etc/webdefault.xml");
- File webdefaultFile = webdefaultPath.toFile();
- if (webdefaultFile.exists()) {
- webdefaultXMLConfig = new PathFileConfig(webdefaultFile, new Path(
- "etc/webdefault.xml"));
- }
+ IPath webdefaultPath = baseDirPath.append("etc/webdefault.xml");
+ File webdefaultFile = webdefaultPath.toFile();
+ if (webdefaultFile.exists())
+ {
+ webdefaultXMLConfig = new PathFileConfig(webdefaultFile,new Path("etc/webdefault.xml"));
+ }
- IPath startJARPath = baseDirPath.append(START_JAR);
- File startConfigFile = startJARPath.toFile();
- if (startConfigFile.exists()) {
- startConfig = new PathFileConfig(startConfigFile, new Path(
- START_JAR));
- }
- }
+ IPath startJARPath = baseDirPath.append(START_JAR);
+ File startConfigFile = startJARPath.toFile();
+ if (startConfigFile.exists())
+ {
+ startConfig = new PathFileConfig(startConfigFile,new Path(START_JAR));
+ }
+ }
- public List<PathFileConfig> getJettyXMLFiles() {
- return jettyXMLFiles;
- }
+ public List<PathFileConfig> getJettyXMLFiles()
+ {
+ return jettyXMLFiles;
+ }
- public PathFileConfig getWebdefaultXMLConfig() {
- return webdefaultXMLConfig;
- }
- /**
- * Saves the Web app document.
- *
- * @param path
- * a path
- * @param forceDirty
- * true to force a save
- * @throws IOException
- * if anything goes wrong
- */
- // public void save(String path, boolean forceDirty) throws IOException {
- // if (forceDirty || isWebAppDirty)
- // //XMLUtil.save(path, webAppDocument);
- // }
+ public PathFileConfig getWebdefaultXMLConfig()
+ {
+ return webdefaultXMLConfig;
+ }
- /**
- * Saves the Web app document.
- *
- * @param file
- * a file
- * @param monitor
- * a progress monitor
- * @throws Exception
- * if anything goes wrong
- */
- public void save(IFile file, IProgressMonitor monitor) throws Exception {
- if (file.exists() && !isStartIniDirty)
- return;
- if (startIniFile == null
- || !(startIniFile.exists() && startIniFile.canRead()))
- return;
+ /**
+ * Saves the Web app document.
+ *
+ * @param path
+ * a path
+ * @param forceDirty
+ * true to force a save
+ * @throws IOException
+ * if anything goes wrong
+ */
+ // public void save(String path, boolean forceDirty) throws IOException {
+ // if (forceDirty || isWebAppDirty)
+ // //XMLUtil.save(path, webAppDocument);
+ // }
- InputStream in = null;
- try {
- in = new FileInputStream(startIniFile);
- if (file.exists())
- file.setContents(in, true, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- in.close();
- } catch (Exception e) {
- // ignore
- }
- }
- isStartIniDirty = false;
- }
+ /**
+ * Saves the Web app document.
+ *
+ * @param file
+ * a file
+ * @param monitor
+ * a progress monitor
+ * @throws Exception
+ * if anything goes wrong
+ */
+ public void save(IFile file, IProgressMonitor monitor) throws Exception
+ {
+ if (file.exists() && !isStartIniDirty)
+ return;
+ if (startIniFile == null || !(startIniFile.exists() && startIniFile.canRead()))
+ return;
- public List<PathFileConfig> getOtherConfigs() {
- return otherConfigs;
- }
+ InputStream in = null;
+ try
+ {
+ in = new FileInputStream(startIniFile);
+ if (file.exists())
+ file.setContents(in,true,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ else
+ file.create(in,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ finally
+ {
+ try
+ {
+ in.close();
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ }
+ isStartIniDirty = false;
+ }
- public PathFileConfig getStartConfig() {
- return startConfig;
- }
+ public List<PathFileConfig> getOtherConfigs()
+ {
+ return otherConfigs;
+ }
+
+ public PathFileConfig getStartConfig()
+ {
+ return startConfig;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/WebdefaultXMLConfig.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/WebdefaultXMLConfig.java
index e1b0589..a827199 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/WebdefaultXMLConfig.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/config/WebdefaultXMLConfig.java
@@ -20,31 +20,37 @@
import org.eclipse.jst.server.jetty.core.internal.util.IOUtils;
-public class WebdefaultXMLConfig {
+public class WebdefaultXMLConfig
+{
- public static InputStream getInputStream(File webdefaultXMLFile)
- throws IOException {
- InputStream stream = new FileInputStream(webdefaultXMLFile);
- try {
- boolean useFileMappedBuffer = false;
- InputStreamReader input = new InputStreamReader(stream);
- BufferedReader reader = new BufferedReader(input);
- StringWriter newContent = new StringWriter();
- for (String line = reader.readLine(); line != null; line = reader
- .readLine()) {
- if (useFileMappedBuffer) {
- line = "<param-value>false</param-value>";
- useFileMappedBuffer = false;
- }
- if (line.indexOf("<param-name>useFileMappedBuffer</param-name>") != -1) {
- useFileMappedBuffer = true;
- }
- newContent.append(line);
- newContent.append('\n');
- }
- return IOUtils.toInputStream(newContent.toString(), "UTF-8");
- } finally {
- stream.close();
- }
- }
+ public static InputStream getInputStream(File webdefaultXMLFile) throws IOException
+ {
+ InputStream stream = new FileInputStream(webdefaultXMLFile);
+ try
+ {
+ boolean useFileMappedBuffer = false;
+ InputStreamReader input = new InputStreamReader(stream);
+ BufferedReader reader = new BufferedReader(input);
+ StringWriter newContent = new StringWriter();
+ for (String line = reader.readLine(); line != null; line = reader.readLine())
+ {
+ if (useFileMappedBuffer)
+ {
+ line = "<param-value>false</param-value>";
+ useFileMappedBuffer = false;
+ }
+ if (line.indexOf("<param-name>useFileMappedBuffer</param-name>") != -1)
+ {
+ useFileMappedBuffer = true;
+ }
+ newContent.append(line);
+ newContent.append('\n');
+ }
+ return IOUtils.toInputStream(newContent.toString(),"UTF-8");
+ }
+ finally
+ {
+ stream.close();
+ }
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Configuration.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Configuration.java
index 4a7b2b1..072833f 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Configuration.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Configuration.java
@@ -51,604 +51,631 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.ServerPort;
-public class Jetty70Configuration extends JettyConfiguration implements
- JettyConstants {
+public class Jetty70Configuration extends JettyConfiguration implements JettyConstants
+{
- public Jetty70Configuration(IFolder path) {
- super(path);
- }
+ public Jetty70Configuration(IFolder path)
+ {
+ super(path);
+ }
- private StartIni startIniConfig;
+ private StartIni startIniConfig;
- protected ServerInstance serverInstance;
- private boolean isServerDirty;
- // property change listeners
- private transient List<PropertyChangeListener> propertyListeners;
+ protected ServerInstance serverInstance;
+ private boolean isServerDirty;
+ // property change listeners
+ private transient List<PropertyChangeListener> propertyListeners;
- public Collection<ServerPort> getServerPorts() {
- List<ServerPort> ports = new ArrayList<ServerPort>();
+ public Collection<ServerPort> getServerPorts()
+ {
+ List<ServerPort> ports = new ArrayList<ServerPort>();
- // first add server port
- // try {
- // int port = Integer.parseInt(server.getPort());
- // ports.add(new ServerPort("server", Messages.portServer, port,
- // "TCPIP"));
- // } catch (Exception e) {
- // // ignore
- // }
+ // first add server port
+ // try {
+ // int port = Integer.parseInt(server.getPort());
+ // ports.add(new ServerPort("server", Messages.portServer, port,
+ // "TCPIP"));
+ // } catch (Exception e) {
+ // // ignore
+ // }
- // add connectors
- try {
+ // add connectors
+ try
+ {
- Collection<Connector> connectors = serverInstance.getConnectors();
- if (connectors != null) {
- for (Connector connector : connectors) {
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- ports.add(new ServerPort("server", Messages.portServer,
- port, HTTP));
- // TODO : how get HTTP type port???
+ Collection<Connector> connectors = serverInstance.getConnectors();
+ if (connectors != null)
+ {
+ for (Connector connector : connectors)
+ {
+ int port = -1;
+ try
+ {
+ port = Integer.parseInt(connector.getPort());
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ ports.add(new ServerPort("server",Messages.portServer,port,HTTP));
+ // TODO : how get HTTP type port???
- // ports.add(new ServerPort(portId, name, port, protocol2,
- // contentTypes, advanced));
- }
- }
+ // ports.add(new ServerPort(portId, name, port, protocol2,
+ // contentTypes, advanced));
+ }
+ }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting server ports", e);
- }
- if (ports.size() < 1) {
- ports.add(new ServerPort("server", Messages.portServer, 8080, HTTP));
- }
- return ports;
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error getting server ports",e);
+ }
+ if (ports.size() < 1)
+ {
+ ports.add(new ServerPort("server",Messages.portServer,8080,HTTP));
+ }
+ return ports;
- // String instanceServiceName = serverInstance.getService().getName();
- // int size = server.getServiceCount();
- // for (int i = 0; i < size; i++) {
- // Service service = server.getService(i);
- // int size2 = service.getConnectorCount();
- // for (int j = 0; j < size2; j++) {
- // Connector connector = service.getConnector(j);
- // String name = "HTTP/1.1";
- // String protocol2 = "HTTP";
- // boolean advanced = true;
- // String[] contentTypes = null;
- // int port = -1;
- // try {
- // port = Integer.parseInt(connector.getPort());
- // } catch (Exception e) {
- // // ignore
- // }
- // String protocol = connector.getProtocol();
- // if (protocol != null && protocol.length() > 0) {
- // if (protocol.startsWith("HTTP")) {
- // name = protocol;
- // }
- // else if (protocol.startsWith("AJP")) {
- // name = protocol;
- // protocol2 = "AJP";
- // }
- // else {
- // // Get Jetty equivalent name if protocol handler class specified
- // name = (String)protocolHandlerMap.get(protocol);
- // if (name != null) {
- // // Prepare simple protocol string for ServerPort protocol
- // int index = name.indexOf('/');
- // if (index > 0)
- // protocol2 = name.substring(0, index);
- // else
- // protocol2 = name;
- // }
- // // Specified protocol is unknown, just use as is
- // else {
- // name = protocol;
- // protocol2 = protocol;
- // }
- // }
- // }
- // if (protocol2.toLowerCase().equals("http"))
- // contentTypes = new String[] { "web", "webservices" };
- // String secure = connector.getSecure();
- // if (secure != null && secure.length() > 0) {
- // name = "SSL";
- // protocol2 = "SSL";
- // } else
- // advanced = false;
- // String portId;
- // if (instanceServiceName != null &&
- // instanceServiceName.equals(service.getName()))
- // portId = Integer.toString(j);
- // else
- // portId = i +"/" + j;
- // ports.add(new ServerPort(portId, name, port, protocol2, contentTypes,
- // advanced));
- // }
+ // String instanceServiceName = serverInstance.getService().getName();
+ // int size = server.getServiceCount();
+ // for (int i = 0; i < size; i++) {
+ // Service service = server.getService(i);
+ // int size2 = service.getConnectorCount();
+ // for (int j = 0; j < size2; j++) {
+ // Connector connector = service.getConnector(j);
+ // String name = "HTTP/1.1";
+ // String protocol2 = "HTTP";
+ // boolean advanced = true;
+ // String[] contentTypes = null;
+ // int port = -1;
+ // try {
+ // port = Integer.parseInt(connector.getPort());
+ // } catch (Exception e) {
+ // // ignore
+ // }
+ // String protocol = connector.getProtocol();
+ // if (protocol != null && protocol.length() > 0) {
+ // if (protocol.startsWith("HTTP")) {
+ // name = protocol;
+ // }
+ // else if (protocol.startsWith("AJP")) {
+ // name = protocol;
+ // protocol2 = "AJP";
+ // }
+ // else {
+ // // Get Jetty equivalent name if protocol handler class specified
+ // name = (String)protocolHandlerMap.get(protocol);
+ // if (name != null) {
+ // // Prepare simple protocol string for ServerPort protocol
+ // int index = name.indexOf('/');
+ // if (index > 0)
+ // protocol2 = name.substring(0, index);
+ // else
+ // protocol2 = name;
+ // }
+ // // Specified protocol is unknown, just use as is
+ // else {
+ // name = protocol;
+ // protocol2 = protocol;
+ // }
+ // }
+ // }
+ // if (protocol2.toLowerCase().equals("http"))
+ // contentTypes = new String[] { "web", "webservices" };
+ // String secure = connector.getSecure();
+ // if (secure != null && secure.length() > 0) {
+ // name = "SSL";
+ // protocol2 = "SSL";
+ // } else
+ // advanced = false;
+ // String portId;
+ // if (instanceServiceName != null &&
+ // instanceServiceName.equals(service.getName()))
+ // portId = Integer.toString(j);
+ // else
+ // portId = i +"/" + j;
+ // ports.add(new ServerPort(portId, name, port, protocol2, contentTypes,
+ // advanced));
+ // }
- }
+ }
- /**
- * Return a list of the web modules in this server.
- *
- * @return java.util.List
- */
- public List<WebModule> getWebModules() {
- List list = new ArrayList();
+ /**
+ * Return a list of the web modules in this server.
+ *
+ * @return java.util.List
+ */
+ public List<WebModule> getWebModules()
+ {
+ List<WebModule> list = new ArrayList<WebModule>();
- try {
- Collection<WebAppContext> contexts = serverInstance.getContexts();
- if (contexts != null) {
- for (WebAppContext context : contexts) {
- String documentBase = context.getDocumentBase();
- String path = context.getContextPath();
- String memento = context.getMemento();
- WebModule module = new WebModule(path, documentBase,
- memento, true);
- list.add(module);
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting project refs", e);
- }
- return list;
- }
+ try
+ {
+ Collection<WebAppContext> contexts = serverInstance.getContexts();
+ if (contexts != null)
+ {
+ for (WebAppContext context : contexts)
+ {
+ String documentBase = context.getDocumentBase();
+ String path = context.getContextPath();
+ String memento = context.getMemento();
+ WebModule module = new WebModule(path,documentBase,memento,true);
+ list.add(module);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error getting project refs",e);
+ }
+ return list;
+ }
- public void addWebModule(int i, IJettyWebModule module) {
- try {
- WebAppContext context = serverInstance.createContext(
- module.getDocumentBase(), module.getMemento(),
- module.getPath());
- if (context != null) {
- // context.setDocBase(module.getDocumentBase());
- // context.setPath(module.getPath());
- // context.setReloadable(module.isReloadable() ? "true" :
- // "false");
- // if (module.getMemento() != null &&
- // module.getMemento().length() > 0)
- // context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE,
- "Error adding web module " + module.getPath(), e);
- }
+ public void addWebModule(int i, IJettyWebModule module)
+ {
+ try
+ {
+ WebAppContext context = serverInstance.createContext(module.getDocumentBase(),module.getMemento(),module.getPath());
+ if (context != null)
+ {
+ // context.setDocBase(module.getDocumentBase());
+ // context.setPath(module.getPath());
+ // context.setReloadable(module.isReloadable() ? "true" :
+ // "false");
+ // if (module.getMemento() != null &&
+ // module.getMemento().length() > 0)
+ // context.setSource(module.getMemento());
+ isServerDirty = true;
+ firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY,null,module);
+ }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error adding web module " + module.getPath(),e);
+ }
- }
+ }
- /**
- * Removes a web module.
- *
- * @param index
- * int
- */
- public void removeWebModule(int index) {
- try {
- serverInstance.removeContext(index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, index);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
+ /**
+ * Removes a web module.
+ *
+ * @param index
+ * int
+ */
+ public void removeWebModule(int index)
+ {
+ try
+ {
+ serverInstance.removeContext(index);
+ isServerDirty = true;
+ firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY,null,index);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error removing module ref " + index,e);
+ }
+ }
- protected void firePropertyChangeEvent(String propertyName,
- Object oldValue, Object newValue) {
- if (propertyListeners == null)
- return;
+ protected void firePropertyChangeEvent(String propertyName, Object oldValue, Object newValue)
+ {
+ if (propertyListeners == null)
+ return;
- PropertyChangeEvent event = new PropertyChangeEvent(this, propertyName,
- oldValue, newValue);
- try {
- Iterator<PropertyChangeListener> iterator = propertyListeners
- .iterator();
- while (iterator.hasNext()) {
- try {
- PropertyChangeListener listener = iterator.next();
- listener.propertyChange(event);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE,
- "Error firing property change event", e);
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error in property event", e);
- }
- }
+ PropertyChangeEvent event = new PropertyChangeEvent(this,propertyName,oldValue,newValue);
+ try
+ {
+ Iterator<PropertyChangeListener> iterator = propertyListeners.iterator();
+ while (iterator.hasNext())
+ {
+ try
+ {
+ PropertyChangeListener listener = iterator.next();
+ listener.propertyChange(event);
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error firing property change event",e);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error in property event",e);
+ }
+ }
- /**
- * Adds a property change listener to this server.
- *
- * @param listener
- * java.beans.PropertyChangeListener
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- if (propertyListeners == null)
- propertyListeners = new ArrayList<PropertyChangeListener>();
- propertyListeners.add(listener);
- }
+ /**
+ * Adds a property change listener to this server.
+ *
+ * @param listener
+ * java.beans.PropertyChangeListener
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener)
+ {
+ if (propertyListeners == null)
+ propertyListeners = new ArrayList<PropertyChangeListener>();
+ propertyListeners.add(listener);
+ }
- /**
- * Removes a property change listener from this server.
- *
- * @param listener
- * java.beans.PropertyChangeListener
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- if (propertyListeners != null)
- propertyListeners.remove(listener);
- }
+ /**
+ * Removes a property change listener from this server.
+ *
+ * @param listener
+ * java.beans.PropertyChangeListener
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener)
+ {
+ if (propertyListeners != null)
+ propertyListeners.remove(listener);
+ }
- /**
- * @see JettyConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IPath runtimeBaseDirectory,
- IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 5);
+ /**
+ * @see JettyConfiguration#load(IPath, IProgressMonitor)
+ */
+ public void load(IPath path, IPath runtimeBaseDirectory, IProgressMonitor monitor) throws CoreException
+ {
+ try
+ {
+ monitor = ProgressUtil.getMonitorFor(monitor);
+ monitor.beginTask(Messages.loadingTask,5);
- Factory serverFactory = null;
+ Factory serverFactory = null;
- // Load config.ini
- this.startIniConfig = new StartIni(path);
+ // Load config.ini
+ this.startIniConfig = new StartIni(path);
- // Load jetty.xml files
- List<PathFileConfig> jettyXMLConfiFiles = startIniConfig
- .getJettyXMLFiles();
- List<Server> servers = new ArrayList<Server>();
- Server server = null;
- File file = null;
- IPath jettyPath = null;
- if (jettyXMLConfiFiles.size() > 0) {
- for (PathFileConfig jettyXMLConfig : jettyXMLConfiFiles) {
- file = jettyXMLConfig.getFile();
+ // Load jetty.xml files
+ List<PathFileConfig> jettyXMLConfiFiles = startIniConfig.getJettyXMLFiles();
+ List<Server> servers = new ArrayList<Server>();
+ Server server = null;
+ File file = null;
+ IPath jettyPath = null;
+ if (jettyXMLConfiFiles.size() > 0)
+ {
+ for (PathFileConfig jettyXMLConfig : jettyXMLConfiFiles)
+ {
+ file = jettyXMLConfig.getFile();
- jettyPath = jettyXMLConfig.getPath();
- serverFactory = new Factory();
- serverFactory
- .setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.server");
- server = (Server) serverFactory.loadDocument(JettyXMLConfig
- .getInputStream(file));
- server.setFile(file);
- server.setPath(jettyPath);
- servers.add(server);
- }
- }
-
- WebApp webApp = null;
- PathFileConfig pathFileConfig = startIniConfig.getWebdefaultXMLConfig();
- if (pathFileConfig != null) {
- File webAppFile = pathFileConfig.getFile();
- IPath webAppPath = pathFileConfig.getPath();
-
- Factory webdefaultFactory = new Factory();
- webdefaultFactory
- .setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.server");
- webApp = (WebApp) webdefaultFactory.loadDocument(WebdefaultXMLConfig
- .getInputStream(webAppFile));
- webApp.setFile(webAppFile);
- webApp.setPath(webAppPath);
- }
- // check for catalina.policy to verify that this is a v4.0 config
- // InputStream in = new
- // FileInputStream(path.append("catalina.policy").toFile());
- // in.read();
- // in.close();
- monitor.worked(1);
+ jettyPath = jettyXMLConfig.getPath();
+ serverFactory = new Factory();
+ serverFactory.setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.server");
+ server = (Server)serverFactory.loadDocument(JettyXMLConfig.getInputStream(file));
+ server.setFile(file);
+ server.setPath(jettyPath);
+ servers.add(server);
+ }
+ }
- // server = (Server) serverFactory.loadDocument(new FileInputStream(
- // path.append("jetty.xml").toFile()));
- serverInstance = new ServerInstance(servers, webApp, runtimeBaseDirectory);
- // monitor.worked(1);
- //
- // webAppDocument = new
- // WebAppDocument(path.append("webdefault.xml"));
- // monitor.worked(1);
+ WebApp webApp = null;
+ PathFileConfig pathFileConfig = startIniConfig.getWebdefaultXMLConfig();
+ if (pathFileConfig != null)
+ {
+ File webAppFile = pathFileConfig.getFile();
+ IPath webAppPath = pathFileConfig.getPath();
- // jettyUsersDocument = XMLUtil.getDocumentBuilder().parse(new
- // InputSource(new
- // FileInputStream(path.append("jetty-users.xml").toFile())));
- monitor.worked(1);
+ Factory webdefaultFactory = new Factory();
+ webdefaultFactory.setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.server");
+ webApp = (WebApp)webdefaultFactory.loadDocument(WebdefaultXMLConfig.getInputStream(webAppFile));
+ webApp.setFile(webAppFile);
+ webApp.setPath(webAppPath);
+ }
+ // check for catalina.policy to verify that this is a v4.0 config
+ // InputStream in = new
+ // FileInputStream(path.append("catalina.policy").toFile());
+ // in.read();
+ // in.close();
+ monitor.worked(1);
- // load policy file
- // policyFile = JettyVersionHelper.getFileContents(new
- // FileInputStream(path.append("catalina.policy").toFile()));
- monitor.worked(1);
+ // server = (Server) serverFactory.loadDocument(new FileInputStream(
+ // path.append("jetty.xml").toFile()));
+ serverInstance = new ServerInstance(servers,webApp,runtimeBaseDirectory);
+ // monitor.worked(1);
+ //
+ // webAppDocument = new
+ // WebAppDocument(path.append("webdefault.xml"));
+ // monitor.worked(1);
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(
- Trace.WARNING,
- "Could not load Jetty v7.0 configuration from "
- + path.toOSString() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR,
- JettyPlugin.PLUGIN_ID, 0, NLS.bind(
- Messages.errorCouldNotLoadConfiguration,
- path.toOSString()), e));
- }
- }
+ // jettyUsersDocument = XMLUtil.getDocumentBuilder().parse(new
+ // InputSource(new
+ // FileInputStream(path.append("jetty-users.xml").toFile())));
+ monitor.worked(1);
- public void load(IFolder folder, IPath runtimeBaseDirectory,
- IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 800);
+ // load policy file
+ // policyFile = JettyVersionHelper.getFileContents(new
+ // FileInputStream(path.append("catalina.policy").toFile()));
+ monitor.worked(1);
- Factory serverFactory = null;
+ if (monitor.isCanceled())
+ return;
+ monitor.done();
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.WARNING,"Could not load Jetty v7.0 configuration from " + path.toOSString() + ": " + e.getMessage());
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorCouldNotLoadConfiguration,path.toOSString()),e));
+ }
+ }
- // Load config.ini
- this.startIniConfig = new StartIni(folder);
+ public void load(IFolder folder, IPath runtimeBaseDirectory, IProgressMonitor monitor) throws CoreException
+ {
+ try
+ {
+ monitor = ProgressUtil.getMonitorFor(monitor);
+ monitor.beginTask(Messages.loadingTask,800);
- // Load jetty.xml files
- List<PathFileConfig> jettyXMLConfiFiles = startIniConfig
- .getJettyXMLFiles();
- List<Server> servers = new ArrayList<Server>();
- Server server = null;
- File file = null;
- IPath jettyPath = null;
- if (jettyXMLConfiFiles.size() > 0) {
- for (PathFileConfig jettyXMLConfig : jettyXMLConfiFiles) {
- file = jettyXMLConfig.getFile();
- jettyPath = jettyXMLConfig.getPath();
- serverFactory = new Factory();
- serverFactory
- .setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.server");
- server = (Server) serverFactory
- .loadDocument(new FileInputStream(file));
- server.setFile(file);
- server.setPath(jettyPath);
- servers.add(server);
- }
- }
- // check for catalina.policy to verify that this is a v4.0 config
- // InputStream in = new
- // FileInputStream(path.append("catalina.policy").toFile());
- // in.read();
- // in.close();
- monitor.worked(1);
+ Factory serverFactory = null;
- WebApp webApp = null;
- PathFileConfig pathFileConfig = startIniConfig.getWebdefaultXMLConfig();
- if (pathFileConfig != null) {
- File webAppFile = pathFileConfig.getFile();
- IPath webAppPath = pathFileConfig.getPath();
-
- Factory webdefaultFactory = new Factory();
- webdefaultFactory
- .setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.server");
- webApp = (WebApp) webdefaultFactory.loadDocument(new FileInputStream(webAppFile));
- webApp.setFile(webAppFile);
- webApp.setPath(webAppPath);
- }
- // server = (Server) serverFactory.loadDocument(new FileInputStream(
- // path.append("jetty.xml").toFile()));
- serverInstance = new ServerInstance(servers, webApp, runtimeBaseDirectory);
- // check for catalina.policy to verify that this is a v4.0 config
- // IFile file = folder.getFile("catalina.policy");
- // if (!file.exists())
- // throw new CoreException(new Status(IStatus.WARNING,
- // JettyPlugin.PLUGIN_ID, 0,
- // NLS.bind(Messages.errorCouldNotLoadConfiguration,
- // folder.getFullPath().toOSString()), null));
+ // Load config.ini
+ this.startIniConfig = new StartIni(folder);
- // load server.xml
- // IFile file = folder.getFile("jetty.xml");
- // InputStream in = file.getContents();
- // serverFactory = new Factory();
- // serverFactory.setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.server70");
- // server = (Server) serverFactory.loadDocument(in);
- // serverInstance = new ServerInstance(server);
- // monitor.worked(200);
- //
- // // load web.xml
- // file = folder.getFile("webdefault.xml");
- // webAppDocument = new WebAppDocument(file);
- // monitor.worked(200);
+ // Load jetty.xml files
+ List<PathFileConfig> jettyXMLConfiFiles = startIniConfig.getJettyXMLFiles();
+ List<Server> servers = new ArrayList<Server>();
+ Server server = null;
+ File file = null;
+ IPath jettyPath = null;
+ if (jettyXMLConfiFiles.size() > 0)
+ {
+ for (PathFileConfig jettyXMLConfig : jettyXMLConfiFiles)
+ {
+ file = jettyXMLConfig.getFile();
+ jettyPath = jettyXMLConfig.getPath();
+ serverFactory = new Factory();
+ serverFactory.setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.server");
+ server = (Server)serverFactory.loadDocument(new FileInputStream(file));
+ server.setFile(file);
+ server.setPath(jettyPath);
+ servers.add(server);
+ }
+ }
+ // check for catalina.policy to verify that this is a v4.0 config
+ // InputStream in = new
+ // FileInputStream(path.append("catalina.policy").toFile());
+ // in.read();
+ // in.close();
+ monitor.worked(1);
- // load jetty-users.xml
- // file = folder.getFile("jetty-users.xml");
- // in = file.getContents();
+ WebApp webApp = null;
+ PathFileConfig pathFileConfig = startIniConfig.getWebdefaultXMLConfig();
+ if (pathFileConfig != null)
+ {
+ File webAppFile = pathFileConfig.getFile();
+ IPath webAppPath = pathFileConfig.getPath();
- // jettyUsersDocument = XMLUtil.getDocumentBuilder().parse(new
- // InputSource(in));
- monitor.worked(200);
+ Factory webdefaultFactory = new Factory();
+ webdefaultFactory.setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.server");
+ webApp = (WebApp)webdefaultFactory.loadDocument(new FileInputStream(webAppFile));
+ webApp.setFile(webAppFile);
+ webApp.setPath(webAppPath);
+ }
+ // server = (Server) serverFactory.loadDocument(new FileInputStream(
+ // path.append("jetty.xml").toFile()));
+ serverInstance = new ServerInstance(servers,webApp,runtimeBaseDirectory);
+ // check for catalina.policy to verify that this is a v4.0 config
+ // IFile file = folder.getFile("catalina.policy");
+ // if (!file.exists())
+ // throw new CoreException(new Status(IStatus.WARNING,
+ // JettyPlugin.PLUGIN_ID, 0,
+ // NLS.bind(Messages.errorCouldNotLoadConfiguration,
+ // folder.getFullPath().toOSString()), null));
- // load catalina.policy
- // file = folder.getFile("catalina.policy");
- // in = file.getContents();
- // policyFile = JettyVersionHelper.getFileContents(in);
- monitor.worked(200);
+ // load server.xml
+ // IFile file = folder.getFile("jetty.xml");
+ // InputStream in = file.getContents();
+ // serverFactory = new Factory();
+ // serverFactory.setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.server70");
+ // server = (Server) serverFactory.loadDocument(in);
+ // serverInstance = new ServerInstance(server);
+ // monitor.worked(200);
+ //
+ // // load web.xml
+ // file = folder.getFile("webdefault.xml");
+ // webAppDocument = new WebAppDocument(file);
+ // monitor.worked(200);
- if (monitor.isCanceled())
- throw new Exception("Cancelled");
- monitor.done();
- } catch (Exception e) {
- Trace.trace(
- Trace.WARNING,
- "Could not reload Jetty v7.0 configuration from: "
- + folder.getFullPath() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR,
- JettyPlugin.PLUGIN_ID, 0, NLS.bind(
- Messages.errorCouldNotLoadConfiguration, folder
- .getFullPath().toOSString()), e));
- }
+ // load jetty-users.xml
+ // file = folder.getFile("jetty-users.xml");
+ // in = file.getContents();
- }
+ // jettyUsersDocument = XMLUtil.getDocumentBuilder().parse(new
+ // InputSource(in));
+ monitor.worked(200);
- /**
- * Save the information held by this object to the given directory.
- *
- * @param folder
- * a folder
- * @param monitor
- * a progress monitor
- * @throws CoreException
- */
- public void save(IFolder folder, IProgressMonitor monitor)
- throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 1200);
- if (monitor.isCanceled())
- return;
+ // load catalina.policy
+ // file = folder.getFile("catalina.policy");
+ // in = file.getContents();
+ // policyFile = JettyVersionHelper.getFileContents(in);
+ monitor.worked(200);
- startIniConfig.save(folder.getFile(START_INI), monitor);
- serverInstance.save(folder, monitor);
+ if (monitor.isCanceled())
+ throw new Exception("Cancelled");
+ monitor.done();
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.WARNING,"Could not reload Jetty v7.0 configuration from: " + folder.getFullPath() + ": " + e.getMessage());
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorCouldNotLoadConfiguration,folder.getFullPath()
+ .toOSString()),e));
+ }
- // get etc/realm.properties
- // get etc/webdefault.xml
+ }
- InputStream in = null;
- IFolder newFolder = folder;
- IPath path = null;
- String filename = null;
- List<PathFileConfig> otherConfigs = startIniConfig
- .getOtherConfigs();
- for (PathFileConfig pathFileConfig : otherConfigs) {
- path = pathFileConfig.getPath();
- if (path.segmentCount() > 1) {
- newFolder = folder.getFolder(path.removeLastSegments(1));
- IOUtils.createFolder(newFolder, monitor);
- }
- filename = pathFileConfig.getFile().getName();
- in = new FileInputStream(pathFileConfig.getFile());
- IFile file = newFolder.getFile(filename);
- if (file.exists()) {
- // if (isServerDirty)
- file.setContents(in, true, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- // else
- // monitor.worked(200);
- } else
- file.create(in, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- }
+ /**
+ * Save the information held by this object to the given directory.
+ *
+ * @param folder
+ * a folder
+ * @param monitor
+ * a progress monitor
+ * @throws CoreException
+ */
+ public void save(IFolder folder, IProgressMonitor monitor) throws CoreException
+ {
+ try
+ {
+ monitor = ProgressUtil.getMonitorFor(monitor);
+ monitor.beginTask(Messages.savingTask,1200);
+ if (monitor.isCanceled())
+ return;
- // start.config from start.jar
- PathFileConfig startConfig = startIniConfig.getStartConfig();
- if (startConfig != null) {
- File startJARFile = startConfig.getFile();
- InputStream stream = StartConfig.getInputStream(startJARFile);
- IFile file = folder.getFile("start.config");
- if (file.exists()) {
- // if (isServerDirty)
- file.setContents(stream, true, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- // else
- // monitor.worked(200);
- } else
- file.create(stream, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
+ startIniConfig.save(folder.getFile(START_INI),monitor);
+ serverInstance.save(folder,monitor);
- }
+ // get etc/realm.properties
+ // get etc/webdefault.xml
- monitor.done();
- } catch (Exception e) {
- Trace.trace(
- Trace.SEVERE,
- "Could not save Jetty v7.0 configuration to "
- + folder.toString(), e);
- throw new CoreException(new Status(IStatus.ERROR,
- JettyPlugin.PLUGIN_ID, 0, NLS.bind(
- Messages.errorCouldNotSaveConfiguration,
- new String[] { e.getLocalizedMessage() }), e));
- }
- }
+ InputStream in = null;
+ IFolder newFolder = folder;
+ IPath path = null;
+ String filename = null;
+ List<PathFileConfig> otherConfigs = startIniConfig.getOtherConfigs();
+ for (PathFileConfig pathFileConfig : otherConfigs)
+ {
+ path = pathFileConfig.getPath();
+ if (path.segmentCount() > 1)
+ {
+ newFolder = folder.getFolder(path.removeLastSegments(1));
+ IOUtils.createFolder(newFolder,monitor);
+ }
+ filename = pathFileConfig.getFile().getName();
+ in = new FileInputStream(pathFileConfig.getFile());
+ IFile file = newFolder.getFile(filename);
+ if (file.exists())
+ {
+ // if (isServerDirty)
+ file.setContents(in,true,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ // else
+ // monitor.worked(200);
+ }
+ else
+ file.create(in,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ }
- public void importFromPath(IPath path, IPath runtimeBaseDirectory,
- boolean isTestEnv, IProgressMonitor monitor) throws CoreException {
- load(path, runtimeBaseDirectory, monitor);
+ // start.config from start.jar
+ PathFileConfig startConfig = startIniConfig.getStartConfig();
+ if (startConfig != null)
+ {
+ File startJARFile = startConfig.getFile();
+ InputStream stream = StartConfig.getInputStream(startJARFile);
+ IFile file = folder.getFile("start.config");
+ if (file.exists())
+ {
+ // if (isServerDirty)
+ file.setContents(stream,true,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ // else
+ // monitor.worked(200);
+ }
+ else
+ file.create(stream,true,ProgressUtil.getSubMonitorFor(monitor,200));
- // for test environment, remove existing contexts since a separate
- // catalina.base will be used
- if (isTestEnv) {
- while (serverInstance.removeContext(0)) {
- // no-op
- }
- }
- }
+ }
- /**
- * Modify the port with the given id.
- *
- * @param id
- * java.lang.String
- * @param port
- * int
- */
- public void modifyServerPort(String id, int port) {
- try {
- if ("server".equals(id)) {
- serverInstance.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(
- port));
- return;
- }
+ monitor.done();
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Could not save Jetty v7.0 configuration to " + folder.toString(),e);
+ throw new CoreException(new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,NLS.bind(Messages.errorCouldNotSaveConfiguration,new String[]
+ { e.getLocalizedMessage() }),e));
+ }
+ }
- // int i = id.indexOf("/");
- // // If a connector in the instance Service
- // if (i < 0) {
- // int connNum = Integer.parseInt(id);
- // Connector connector = serverInstance.getConnector(connNum);
- // if (connector != null) {
- // connector.setPort(port + "");
- // isServerDirty = true;
- // firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new
- // Integer(port));
- // }
- // }
- // // Else a connector in another Service
- // else {
- // int servNum = Integer.parseInt(id.substring(0, i));
- // int connNum = Integer.parseInt(id.substring(i + 1));
- //
- // Service service = server.getService(servNum);
- // Connector connector = service.getConnector(connNum);
- // connector.setPort(port + "");
- // isServerDirty = true;
- // firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new
- // Integer(port));
- // }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
+ public void importFromPath(IPath path, IPath runtimeBaseDirectory, boolean isTestEnv, IProgressMonitor monitor) throws CoreException
+ {
+ load(path,runtimeBaseDirectory,monitor);
- /**
- * Change a web module.
- *
- * @param index
- * int
- * @param docBase
- * java.lang.String
- * @param path
- * java.lang.String
- * @param reloadable
- * boolean
- */
- public void modifyWebModule(int index, String docBase, String path,
- boolean reloadable) {
- try {
- WebAppContext context = serverInstance.getContext(index);
- if (context != null) {
- context.setContextPath(path);
- context.save();
- isServerDirty = true;
- WebModule module = new WebModule(path, docBase, null,
- reloadable);
- firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY,
- new Integer(index), module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
- }
- }
+ // for test environment, remove existing contexts since a separate
+ // catalina.base will be used
+ if (isTestEnv)
+ {
+ while (serverInstance.removeContext(0))
+ {
+ // no-op
+ }
+ }
+ }
+
+ /**
+ * Modify the port with the given id.
+ *
+ * @param id
+ * java.lang.String
+ * @param port
+ * int
+ */
+ public void modifyServerPort(String id, int port)
+ {
+ try
+ {
+ if ("server".equals(id))
+ {
+ serverInstance.setPort(port + "");
+ isServerDirty = true;
+ firePropertyChangeEvent(MODIFY_PORT_PROPERTY,id,new Integer(port));
+ return;
+ }
+
+ // int i = id.indexOf("/");
+ // // If a connector in the instance Service
+ // if (i < 0) {
+ // int connNum = Integer.parseInt(id);
+ // Connector connector = serverInstance.getConnector(connNum);
+ // if (connector != null) {
+ // connector.setPort(port + "");
+ // isServerDirty = true;
+ // firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new
+ // Integer(port));
+ // }
+ // }
+ // // Else a connector in another Service
+ // else {
+ // int servNum = Integer.parseInt(id.substring(0, i));
+ // int connNum = Integer.parseInt(id.substring(i + 1));
+ //
+ // Service service = server.getService(servNum);
+ // Connector connector = service.getConnector(connNum);
+ // connector.setPort(port + "");
+ // isServerDirty = true;
+ // firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new
+ // Integer(port));
+ // }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error modifying server port " + id,e);
+ }
+ }
+
+ /**
+ * Change a web module.
+ *
+ * @param index
+ * int
+ * @param docBase
+ * java.lang.String
+ * @param path
+ * java.lang.String
+ * @param reloadable
+ * boolean
+ */
+ public void modifyWebModule(int index, String docBase, String path, boolean reloadable)
+ {
+ try
+ {
+ WebAppContext context = serverInstance.getContext(index);
+ if (context != null)
+ {
+ context.setContextPath(path);
+ context.save();
+ isServerDirty = true;
+ WebModule module = new WebModule(path,docBase,null,reloadable);
+ firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY,new Integer(index),module);
+ }
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error modifying web module " + index,e);
+ }
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Handler.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Handler.java
index d6d72e8..59c4f7a 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Handler.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Handler.java
@@ -22,76 +22,78 @@
import org.eclipse.jst.server.jetty.core.internal.util.JettyVersionHelper;
import org.eclipse.wst.server.core.IModule;
-public class Jetty70Handler extends JettyHandler {
+public class Jetty70Handler extends JettyHandler
+{
- protected static final IStatus startJarRequiredInstallDirStatus = new Status(
- IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- Messages.startJarRequiredInstallDirStatus, null);
+ protected static final IStatus startJarRequiredInstallDirStatus = new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,
+ Messages.startJarRequiredInstallDirStatus,null);
- public IStatus verifyInstallPath(IPath installPath) {
- IStatus result = JettyVersionHelper.checkJettyVersion(installPath);
- if (result.getSeverity() == IStatus.CANCEL) {
- // TODO : search in a folder.
- return startJarRequiredInstallDirStatus;
- }
+ public IStatus verifyInstallPath(IPath installPath)
+ {
+ IStatus result = JettyVersionHelper.checkJettyVersion(installPath);
+ if (result.getSeverity() == IStatus.CANCEL)
+ {
+ // TODO : search in a folder.
+ return startJarRequiredInstallDirStatus;
+ }
- return result;
- }
+ return result;
+ }
- public IStatus validate(IPath path, IVMInstall vmInstall) {
- // TODO : validate JVM
- return null;
- }
+ public IStatus validate(IPath path, IVMInstall vmInstall)
+ {
+ // TODO : validate JVM
+ return null;
+ }
- /**
- * @see IJettyVersionHandler#canAddModule(IModule)
- */
- public IStatus canAddModule(IModule module) {
- String version = module.getModuleType().getVersion();
- if ("2.2".equals(version) || "2.3".equals(version)
- || "2.4".equals(version) || "2.5".equals(version))
- return Status.OK_STATUS;
+ /**
+ * @see IJettyVersionHandler#canAddModule(IModule)
+ */
+ public IStatus canAddModule(IModule module)
+ {
+ String version = module.getModuleType().getVersion();
+ if ("2.2".equals(version) || "2.3".equals(version) || "2.4".equals(version) || "2.5".equals(version))
+ return Status.OK_STATUS;
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- Messages.errorSpec70, null);
- }
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,Messages.errorSpec70,null);
+ }
- public IPath getRuntimeBaseDirectory(JettyServer server) {
- return JettyVersionHelper.getStandardBaseDirectory(server);
- }
+ public IPath getRuntimeBaseDirectory(JettyServer server)
+ {
+ return JettyVersionHelper.getStandardBaseDirectory(server);
+ }
- /**
- * @see IJettyVersionHandler#getRuntimeVMArguments(IPath, IPath, IPath,
- * boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath,
- IPath deployPath, boolean isTestEnv) {
- return JettyVersionHelper.getJettyVMArguments(installPath, configPath,
- deployPath, getEndorsedDirectories(installPath), isTestEnv);
- }
+ /**
+ * @see IJettyVersionHandler#getRuntimeVMArguments(IPath, IPath, IPath, boolean)
+ */
+ public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv)
+ {
+ return JettyVersionHelper.getJettyVMArguments(installPath,configPath,deployPath,getEndorsedDirectories(installPath),isTestEnv);
+ }
- public String getEndorsedDirectories(IPath installPath) {
- return installPath.append("endorsed").toOSString();
- }
+ public String getEndorsedDirectories(IPath installPath)
+ {
+ return installPath.append("endorsed").toOSString();
+ }
- public String getRuntimePolicyFile(IPath configPath) {
- return configPath.append("lib").append("policy").append("jetty.policy")
- .toOSString();
- }
+ public String getRuntimePolicyFile(IPath configPath)
+ {
+ return configPath.append("lib").append("policy").append("jetty.policy").toOSString();
+ }
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug,
- boolean starting) {
- return JettyVersionHelper.getJettyProgramArguments(configPath, debug,
- starting);
- }
+ public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting)
+ {
+ return JettyVersionHelper.getJettyProgramArguments(configPath,debug,starting);
+ }
- public String[] getExcludedRuntimeProgramArguments(boolean debug,
- boolean starting) {
- // TODO Auto-generated method stub
- return null;
- }
+ public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
- public boolean supportsServeModulesWithoutPublish() {
- return true;
- }
+ public boolean supportsServeModulesWithoutPublish()
+ {
+ return true;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Provider.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Provider.java
index 802758b..38c6494 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Provider.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty70/Jetty70Provider.java
@@ -15,16 +15,20 @@
import org.eclipse.jst.server.jetty.core.internal.IJettyVersionHandler;
import org.eclipse.jst.server.jetty.core.internal.IJettyVersionProvider;
-public class Jetty70Provider implements IJettyVersionProvider {
+public class Jetty70Provider implements IJettyVersionProvider
+{
- public static final IJettyVersionProvider INSTANCE = new Jetty70Provider();
+ public static final IJettyVersionProvider INSTANCE = new Jetty70Provider();
- private IJettyVersionHandler versionHandler = new Jetty70Handler();
-
- public IJettyVersionHandler getJettyVersionHandler() {
- return versionHandler;
- }
- public IJettyConfiguration createJettyConfiguration(IFolder path) {
- return new Jetty70Configuration(path);
- }
+ private IJettyVersionHandler versionHandler = new Jetty70Handler();
+
+ public IJettyVersionHandler getJettyVersionHandler()
+ {
+ return versionHandler;
+ }
+
+ public IJettyConfiguration createJettyConfiguration(IFolder path)
+ {
+ return new Jetty70Configuration(path);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty80/Jetty80Handler.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty80/Jetty80Handler.java
index d300307..89cd3e9 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty80/Jetty80Handler.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty80/Jetty80Handler.java
@@ -18,19 +18,18 @@
import org.eclipse.jst.server.jetty.core.internal.jetty70.Jetty70Handler;
import org.eclipse.wst.server.core.IModule;
-public class Jetty80Handler extends Jetty70Handler {
+public class Jetty80Handler extends Jetty70Handler
+{
- /**
- * @see IJettyVersionHandler#canAddModule(IModule)
- */
- public IStatus canAddModule(IModule module) {
- String version = module.getModuleType().getVersion();
- if ("2.2".equals(version) || "2.3".equals(version)
- || "2.4".equals(version) || "2.5".equals(version)
- || "3.0".equals(version))
- return Status.OK_STATUS;
+ /**
+ * @see IJettyVersionHandler#canAddModule(IModule)
+ */
+ public IStatus canAddModule(IModule module)
+ {
+ String version = module.getModuleType().getVersion();
+ if ("2.2".equals(version) || "2.3".equals(version) || "2.4".equals(version) || "2.5".equals(version) || "3.0".equals(version))
+ return Status.OK_STATUS;
- return new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, 0,
- Messages.errorSpec70, null);
- }
+ return new Status(IStatus.ERROR,JettyPlugin.PLUGIN_ID,0,Messages.errorSpec70,null);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty80/Jetty80Provider.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty80/Jetty80Provider.java
index 918c166..9940ba3 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty80/Jetty80Provider.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/jetty80/Jetty80Provider.java
@@ -16,17 +16,20 @@
import org.eclipse.jst.server.jetty.core.internal.IJettyVersionProvider;
import org.eclipse.jst.server.jetty.core.internal.jetty70.Jetty70Configuration;
-public class Jetty80Provider implements IJettyVersionProvider {
+public class Jetty80Provider implements IJettyVersionProvider
+{
- public static final IJettyVersionProvider INSTANCE = new Jetty80Provider();
+ public static final IJettyVersionProvider INSTANCE = new Jetty80Provider();
- private IJettyVersionHandler versionHandler = new Jetty80Handler();
+ private IJettyVersionHandler versionHandler = new Jetty80Handler();
- public IJettyVersionHandler getJettyVersionHandler() {
- return versionHandler;
- }
+ public IJettyVersionHandler getJettyVersionHandler()
+ {
+ return versionHandler;
+ }
- public IJettyConfiguration createJettyConfiguration(IFolder path) {
- return new Jetty70Configuration(path);
- }
+ public IJettyConfiguration createJettyConfiguration(IFolder path)
+ {
+ return new Jetty70Configuration(path);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/IOUtils.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/IOUtils.java
index 4bebb02..4be2135 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/IOUtils.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/IOUtils.java
@@ -34,100 +34,101 @@
* I/O Utilities.
*
*/
-public class IOUtils {
+public class IOUtils
+{
- private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
+ private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
- /**
- * Converts the given URI to a local file. Use the existing file if the uri
- * is on the local file system. Otherwise fetch it. Returns null if unable
- * to fetch it.
- *
- * @param uri
- * @param monitor
- * @return
- * @throws CoreException
- */
- public static File toLocalFile(URI uri, IProgressMonitor monitor)
- throws CoreException {
- IFileStore fileStore = EFS.getStore(uri);
- File localFile = fileStore.toLocalFile(EFS.NONE, monitor);
- if (localFile == null)
- // non local file system
- localFile = fileStore.toLocalFile(EFS.CACHE, monitor);
- return localFile;
- }
+ /**
+ * Converts the given URI to a local file. Use the existing file if the uri is on the local file system. Otherwise fetch it. Returns null if unable to fetch
+ * it.
+ *
+ * @param uri
+ * @param monitor
+ * @return
+ * @throws CoreException
+ */
+ public static File toLocalFile(URI uri, IProgressMonitor monitor) throws CoreException
+ {
+ IFileStore fileStore = EFS.getStore(uri);
+ File localFile = fileStore.toLocalFile(EFS.NONE,monitor);
+ if (localFile == null)
+ // non local file system
+ localFile = fileStore.toLocalFile(EFS.CACHE,monitor);
+ return localFile;
+ }
- public static File toLocalFile(IFile file, IProgressMonitor monitor)
- throws CoreException {
- return toLocalFile(file.getLocationURI(), monitor);
- }
+ public static File toLocalFile(IFile file, IProgressMonitor monitor) throws CoreException
+ {
+ return toLocalFile(file.getLocationURI(),monitor);
+ }
- /**
- * Create Eclipse {@link IFolder}.
- *
- * @param folderHandle
- * @param monitor
- * @throws CoreException
- */
- public static void createFolder(IFolder folderHandle,
- IProgressMonitor monitor) throws CoreException {
- if (folderHandle.exists())
- return;
+ /**
+ * Create Eclipse {@link IFolder}.
+ *
+ * @param folderHandle
+ * @param monitor
+ * @throws CoreException
+ */
+ public static void createFolder(IFolder folderHandle, IProgressMonitor monitor) throws CoreException
+ {
+ if (folderHandle.exists())
+ return;
- IPath path = folderHandle.getFullPath();
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- int numSegments = path.segmentCount();
- if (numSegments > 2
- && !root.getFolder(path.removeLastSegments(1)).exists()) {
- // If the direct parent of the path doesn't exist, try
- // to create the
- // necessary directories.
- for (int i = numSegments - 2; i > 0; i--) {
- IFolder folder = root.getFolder(path.removeLastSegments(i));
- if (!folder.exists()) {
- folder.create(false, true, monitor);
- }
- }
- }
- folderHandle.create(false, true, monitor);
- }
+ IPath path = folderHandle.getFullPath();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ int numSegments = path.segmentCount();
+ if (numSegments > 2 && !root.getFolder(path.removeLastSegments(1)).exists())
+ {
+ // If the direct parent of the path doesn't exist, try
+ // to create the
+ // necessary directories.
+ for (int i = numSegments - 2; i > 0; i--)
+ {
+ IFolder folder = root.getFolder(path.removeLastSegments(i));
+ if (!folder.exists())
+ {
+ folder.create(false,true,monitor);
+ }
+ }
+ }
+ folderHandle.create(false,true,monitor);
+ }
- public static InputStream getInputStream(File jarFile, String fileName)
- throws ZipException, IOException {
- ZipFile zipFile = new ZipFile(jarFile);
- ZipEntry zipEntry = zipFile.getEntry(fileName);
- return zipFile.getInputStream(zipEntry);
- }
+ public static InputStream getInputStream(File jarFile, String fileName) throws ZipException, IOException
+ {
+ ZipFile zipFile = new ZipFile(jarFile);
+ ZipEntry zipEntry = zipFile.getEntry(fileName);
+ return zipFile.getInputStream(zipEntry);
+ }
- /**
- * Copy bytes from an <code>InputStream</code> to an
- * <code>OutputStream</code>.
- *
- * @param input
- * the <code>InputStream</code> to read from
- * @param output
- * the <code>OutputStream</code> to write to
- * @return the number of bytes copied
- * @throws IOException
- * In case of an I/O problem
- */
- public static int copy(InputStream input, OutputStream output)
- throws IOException {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
- int count = 0;
- int n = 0;
- while (-1 != (n = input.read(buffer))) {
- output.write(buffer, 0, n);
- count += n;
- }
- return count;
- }
+ /**
+ * Copy bytes from an <code>InputStream</code> to an <code>OutputStream</code>.
+ *
+ * @param input
+ * the <code>InputStream</code> to read from
+ * @param output
+ * the <code>OutputStream</code> to write to
+ * @return the number of bytes copied
+ * @throws IOException
+ * In case of an I/O problem
+ */
+ public static int copy(InputStream input, OutputStream output) throws IOException
+ {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+ int count = 0;
+ int n = 0;
+ while (-1 != (n = input.read(buffer)))
+ {
+ output.write(buffer,0,n);
+ count += n;
+ }
+ return count;
+ }
- public static InputStream toInputStream(String input, String encoding)
- throws IOException {
- byte bytes[] = encoding == null ? input.getBytes() : input
- .getBytes(encoding);
- return new ByteArrayInputStream(bytes);
- }
+ public static InputStream toInputStream(String input, String encoding) throws IOException
+ {
+ byte bytes[] = encoding == null?input.getBytes():input.getBytes(encoding);
+ return new ByteArrayInputStream(bytes);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/JettyVersionHelper.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/JettyVersionHelper.java
index 7009feb..c011bb5 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/JettyVersionHelper.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/JettyVersionHelper.java
@@ -24,142 +24,145 @@
import org.eclipse.jst.server.jetty.core.internal.JettyServerBehaviour;
import org.eclipse.jst.server.jetty.core.internal.Trace;
-public class JettyVersionHelper implements JettyConstants {
+public class JettyVersionHelper implements JettyConstants
+{
- public static IStatus checkJettyVersion(IPath installPath) {
- // Search start.jar
- IPath startJarPath = installPath.append(START_JAR);
- File jarFile = null;
- jarFile = startJarPath.toFile();
- // If jar is not at expected location, try alternate location
- if (!jarFile.exists()) {
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- }
+ public static IStatus checkJettyVersion(IPath installPath)
+ {
+ // Search start.jar
+ IPath startJarPath = installPath.append(START_JAR);
+ File jarFile = null;
+ jarFile = startJarPath.toFile();
+ // If jar is not at expected location, try alternate location
+ if (!jarFile.exists())
+ {
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
- /**
- * Gets the base directory for this server. This directory is used as the
- * "base" property for the server.
- *
- * @param ts
- * JettyServer from which to derive the base directory directory.
- * Only used to get the temp directory if needed.
- * @return path to base directory
- */
- public static IPath getStandardBaseDirectory(JettyServer ts) {
- if (ts.isTestEnvironment()) {
- String baseDir = ts.getInstanceDirectory();
- // If test mode and no instance directory specified, use temporary
- // directory
- if (baseDir == null) {
- JettyServerBehaviour tsb = (JettyServerBehaviour) ts
- .getServer().loadAdapter(JettyServerBehaviour.class,
- null);
- if (tsb == null) {
- return null;
- }
- return tsb.getTempDirectory();
- }
- IPath path = new Path(baseDir);
- if (!path.isAbsolute()) {
- IPath rootPath = ResourcesPlugin.getWorkspace().getRoot()
- .getLocation();
- path = rootPath.append(path);
- }
- // Return specified instance directory
- return path;
- }
- // Return runtime path
- return ts.getServer().getRuntime().getLocation();
- }
+ /**
+ * Gets the base directory for this server. This directory is used as the "base" property for the server.
+ *
+ * @param ts
+ * JettyServer from which to derive the base directory directory. Only used to get the temp directory if needed.
+ * @return path to base directory
+ */
+ public static IPath getStandardBaseDirectory(JettyServer ts)
+ {
+ if (ts.isTestEnvironment())
+ {
+ String baseDir = ts.getInstanceDirectory();
+ // If test mode and no instance directory specified, use temporary
+ // directory
+ if (baseDir == null)
+ {
+ JettyServerBehaviour tsb = (JettyServerBehaviour)ts.getServer().loadAdapter(JettyServerBehaviour.class,null);
+ if (tsb == null)
+ {
+ return null;
+ }
+ return tsb.getTempDirectory();
+ }
+ IPath path = new Path(baseDir);
+ if (!path.isAbsolute())
+ {
+ IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ path = rootPath.append(path);
+ }
+ // Return specified instance directory
+ return path;
+ }
+ // Return runtime path
+ return ts.getServer().getRuntime().getLocation();
+ }
- /**
- * Gets the startup VM arguments for the Jetty server.
- *
- * @param installPath
- * installation path for the server
- * @param instancePath
- * instance path for the server
- * @param deployPath
- * deploy path for the server
- * @param isTestEnv
- * test environment flag
- * @return array of strings containing VM arguments
- */
- public static String[] getJettyVMArguments(IPath installPath,
- IPath instancePath, IPath deployPath, String endorsedDirs,
- boolean isTestEnv) {
- List list = new ArrayList();
- if (isTestEnv) {
- list.add("-Djetty.home=\"" + instancePath.toOSString() + "\"");
- list.add("-DSTART=\"" + instancePath.toOSString()
- + "/start.config\"");
- list.add("-Dinstall.jetty.home=\"" + installPath.toOSString()
- + "\"");
- } else
- list.add("-Djetty.home=\"" + installPath.toOSString() + "\"");
- // if (isTestEnv)
- // list.add("-Djetty.base=\"" + instancePath.toOSString() + "\"");
- // else
- // list.add("-Djetty.base=\"" + installPath.toOSString() + "\"");
- // list.add("-Djetty.home=\"" + installPath.toOSString() + "\"");
- // Include a system property for the configurable deploy location
- // list.add("-Dwtp.deploy=\"" + deployPath.toOSString() + "\"");
- // list.add("-Djava.endorsed.dirs=\"" + endorsedDirs + "\"");
+ /**
+ * Gets the startup VM arguments for the Jetty server.
+ *
+ * @param installPath
+ * installation path for the server
+ * @param instancePath
+ * instance path for the server
+ * @param deployPath
+ * deploy path for the server
+ * @param isTestEnv
+ * test environment flag
+ * @return array of strings containing VM arguments
+ */
+ public static String[] getJettyVMArguments(IPath installPath, IPath instancePath, IPath deployPath, String endorsedDirs, boolean isTestEnv)
+ {
+ List<String> list = new ArrayList<String>();
+ if (isTestEnv)
+ {
+ list.add("-Djetty.home=\"" + instancePath.toOSString() + "\"");
+ list.add("-DSTART=\"" + instancePath.toOSString() + "/start.config\"");
+ list.add("-Dinstall.jetty.home=\"" + installPath.toOSString() + "\"");
+ }
+ else
+ list.add("-Djetty.home=\"" + installPath.toOSString() + "\"");
+ // if (isTestEnv)
+ // list.add("-Djetty.base=\"" + instancePath.toOSString() + "\"");
+ // else
+ // list.add("-Djetty.base=\"" + installPath.toOSString() + "\"");
+ // list.add("-Djetty.home=\"" + installPath.toOSString() + "\"");
+ // Include a system property for the configurable deploy location
+ // list.add("-Dwtp.deploy=\"" + deployPath.toOSString() + "\"");
+ // list.add("-Djava.endorsed.dirs=\"" + endorsedDirs + "\"");
- list.add("-DVERBOSE");
- // list.add("-Djetty.port=8081");
- // list.add("-Djetty.port=8081");
- list.add("-DSTOP.PORT=8082");
- list.add("-DSTOP.KEY=secret");
+ list.add("-DVERBOSE");
+ // list.add("-Djetty.port=8081");
+ // list.add("-Djetty.port=8081");
+ list.add("-DSTOP.PORT=8082");
+ list.add("-DSTOP.KEY=secret");
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
+ String[] s = new String[list.size()];
+ list.toArray(s);
+ return s;
+ }
- public static String[] getJettyProgramArguments(IPath configPath,
- boolean debug, boolean starting) {
- List list = new ArrayList();
+ public static String[] getJettyProgramArguments(IPath configPath, boolean debug, boolean starting)
+ {
+ List<String> list = new ArrayList<String>();
- if (starting) {
- // list.add(configPath.toOSString() + "/etc/jetty.xml");
- // list.add(configPath.toOSString() + "/etc/jetty-deploy.xml");
- } else
- list.add("--stop");
+ if (starting)
+ {
+ // list.add(configPath.toOSString() + "/etc/jetty.xml");
+ // list.add(configPath.toOSString() + "/etc/jetty-deploy.xml");
+ }
+ else
+ list.add("--stop");
- String[] temp = new String[list.size()];
- list.toArray(temp);
- return temp;
- }
+ String[] temp = new String[list.size()];
+ list.toArray(temp);
+ return temp;
+ }
- /**
- * Creates a Jetty instance directory at the specified path. This
- * involves creating the set of subdirectories uses by a Jetty instance.
- *
- * @param baseDir
- * directory at which to create Jetty instance directories.
- * @return result status of the operation
- */
- public static IStatus createJettyInstanceDirectory(IPath baseDir) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER,
- "Creating runtime directory at " + baseDir.toOSString());
- File temp = baseDir.append("contexts").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = baseDir.append("etc").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = baseDir.append("resources").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = baseDir.append("webapps").toFile();
- if (!temp.exists())
- temp.mkdirs();
+ /**
+ * Creates a Jetty instance directory at the specified path. This involves creating the set of subdirectories uses by a Jetty instance.
+ *
+ * @param baseDir
+ * directory at which to create Jetty instance directories.
+ * @return result status of the operation
+ */
+ public static IStatus createJettyInstanceDirectory(IPath baseDir)
+ {
+ if (Trace.isTraceEnabled())
+ Trace.trace(Trace.FINER,"Creating runtime directory at " + baseDir.toOSString());
+ File temp = baseDir.append("contexts").toFile();
+ if (!temp.exists())
+ temp.mkdirs();
+ temp = baseDir.append("etc").toFile();
+ if (!temp.exists())
+ temp.mkdirs();
+ temp = baseDir.append("resources").toFile();
+ if (!temp.exists())
+ temp.mkdirs();
+ temp = baseDir.append("webapps").toFile();
+ if (!temp.exists())
+ temp.mkdirs();
- return Status.OK_STATUS;
- }
-
+ return Status.OK_STATUS;
+ }
+
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/StringUtils.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/StringUtils.java
index 2dd0307..e5c2752 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/StringUtils.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/util/StringUtils.java
@@ -10,12 +10,14 @@
*******************************************************************************/
package org.eclipse.jst.server.jetty.core.internal.util;
-public class StringUtils {
+public class StringUtils
+{
- public static final String TRUE = "true";
- public static final String FALSE = "false";
+ public static final String TRUE = "true";
+ public static final String FALSE = "false";
- public static boolean isTrue(String s) {
- return TRUE.equals(s);
- }
+ public static boolean isTrue(String s)
+ {
+ return TRUE.equals(s);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/wst/IModuleVisitor.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/wst/IModuleVisitor.java
index d1cc535..ca340fc 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/wst/IModuleVisitor.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/wst/IModuleVisitor.java
@@ -18,61 +18,83 @@
/**
* Visitor interface to process module components
*/
-public interface IModuleVisitor {
+public interface IModuleVisitor
+{
- /**
- * Process web component
- * @param component web component to process
- * @throws CoreException
- */
- void visitWebComponent(IVirtualComponent component) throws CoreException;
+ /**
+ * Process web component
+ *
+ * @param component
+ * web component to process
+ * @throws CoreException
+ */
+ void visitWebComponent(IVirtualComponent component) throws CoreException;
- /**
- * Post process web component
- * @param component web component to process
- * @throws CoreException
- */
- void endVisitWebComponent(IVirtualComponent component) throws CoreException;
+ /**
+ * Post process web component
+ *
+ * @param component
+ * web component to process
+ * @throws CoreException
+ */
+ void endVisitWebComponent(IVirtualComponent component) throws CoreException;
- /**
- * Process archive component.
- * @param runtimePath path for component at runtime
- * @param workspacePath path to component in workspace
- */
- void visitArchiveComponent(IPath runtimePath, IPath workspacePath);
+ /**
+ * Process archive component.
+ *
+ * @param runtimePath
+ * path for component at runtime
+ * @param workspacePath
+ * path to component in workspace
+ */
+ void visitArchiveComponent(IPath runtimePath, IPath workspacePath);
- /**
- * Process dependent component.
- * @param runtimePath path for component at runtime
- * @param workspacePath path to component in workspace
- */
- void visitDependentComponent(IPath runtimePath, IPath workspacePath);
+ /**
+ * Process dependent component.
+ *
+ * @param runtimePath
+ * path for component at runtime
+ * @param workspacePath
+ * path to component in workspace
+ */
+ void visitDependentComponent(IPath runtimePath, IPath workspacePath);
- /**
- * Process web resource.
- * @param runtimePath path for resource at runtime
- * @param workspacePath path to resource in workspace
- */
- void visitWebResource(IPath runtimePath, IPath workspacePath);
+ /**
+ * Process web resource.
+ *
+ * @param runtimePath
+ * path for resource at runtime
+ * @param workspacePath
+ * path to resource in workspace
+ */
+ void visitWebResource(IPath runtimePath, IPath workspacePath);
- /**
- * Process a content resource from dependent component.
- * @param runtimePath path for resource at runtime
- * @param workspacePath path to resource in workspace
- */
- void visitDependentContentResource(IPath runtimePath, IPath workspacePath);
+ /**
+ * Process a content resource from dependent component.
+ *
+ * @param runtimePath
+ * path for resource at runtime
+ * @param workspacePath
+ * path to resource in workspace
+ */
+ void visitDependentContentResource(IPath runtimePath, IPath workspacePath);
- /**
- * Process EAR resource.
- * @param runtimePath path for resource at runtime
- * @param workspacePath path to resource in workspace
- */
- void visitEarResource(IPath runtimePath, IPath workspacePath);
+ /**
+ * Process EAR resource.
+ *
+ * @param runtimePath
+ * path for resource at runtime
+ * @param workspacePath
+ * path to resource in workspace
+ */
+ void visitEarResource(IPath runtimePath, IPath workspacePath);
- /**
- * Post process EAR resource.
- * @param component EAR component to process
- * @throws CoreException
- */
- void endVisitEarComponent(IVirtualComponent component) throws CoreException;
+ /**
+ * Post process EAR resource.
+ *
+ * @param component
+ * EAR component to process
+ * @throws CoreException
+ */
+ void endVisitEarComponent(IVirtualComponent component) throws CoreException;
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/wst/ModuleTraverser.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/wst/ModuleTraverser.java
index bf851f4..1d7ae74 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/wst/ModuleTraverser.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/wst/ModuleTraverser.java
@@ -52,11 +52,12 @@
/**
* Temporary solution for https://bugs.eclipse.org/bugs/show_bug.cgi?id=103888
*/
-public class ModuleTraverser {
+public class ModuleTraverser
+{
- /**
- * Facet type for EAR modules
- */
+ /**
+ * Facet type for EAR modules
+ */
public static final String EAR_MODULE = IModuleConstants.JST_EAR_MODULE;
/**
@@ -70,208 +71,221 @@
public static final String UTILITY_MODULE = IModuleConstants.JST_UTILITY_MODULE;
/**
- * Name of the custom Java classpath entry attribute that is used to flag entries
- * which should be exposed as module dependencies via the virtual component API.
+ * Name of the custom Java classpath entry attribute that is used to flag entries which should be exposed as module dependencies via the virtual component
+ * API.
*/
- public static final String CLASSPATH_COMPONENT_DEPENDENCY = "org.eclipse.jst.component.dependency"; //$NON-NLS-1
-
- /**
- * Name of the custom Java classpath entry attribute that is used to flag
- * the resolved entries of classpath containers that should not be exposed
- * via the virtual component API.
- */
- public static final String CLASSPATH_COMPONENT_NON_DEPENDENCY = "org.eclipse.jst.component.nondependency"; //$NON-NLS-1
-
- /**
- * Argument values that are used to select component dependency attribute type.
- */
- private static final int DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY = 0;
- private static final int DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY = 1;
- private static final int DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_NONDEPENDENCY = 2;
+ public static final String CLASSPATH_COMPONENT_DEPENDENCY = "org.eclipse.jst.component.dependency"; //$NON-NLS-1
- /**
+ /**
+ * Name of the custom Java classpath entry attribute that is used to flag the resolved entries of classpath containers that should not be exposed via the
+ * virtual component API.
+ */
+ public static final String CLASSPATH_COMPONENT_NON_DEPENDENCY = "org.eclipse.jst.component.nondependency"; //$NON-NLS-1
+
+ /**
+ * Argument values that are used to select component dependency attribute type.
+ */
+ private static final int DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY = 0;
+ private static final int DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY = 1;
+ private static final int DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_NONDEPENDENCY = 2;
+
+ /**
* Scans the module using the specified visitor.
*
- * @param module module to traverse
- * @param visitor visitor to handle resources
- * @param monitor a progress monitor
+ * @param module
+ * module to traverse
+ * @param visitor
+ * visitor to handle resources
+ * @param monitor
+ * a progress monitor
* @throws CoreException
*/
- public static void traverse(IModule module, IModuleVisitor visitor,
- IProgressMonitor monitor) throws CoreException {
+ public static void traverse(IModule module, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException
+ {
if (module == null || module.getModuleType() == null)
return;
String typeId = module.getModuleType().getId();
IVirtualComponent component = ComponentCore.createComponent(module.getProject());
- if (component == null) {
+ if (component == null)
+ {
// can happen if project has been closed
- Trace.trace(Trace.WARNING, "Unable to create component for module "
- + module.getName());
+ Trace.trace(Trace.WARNING,"Unable to create component for module " + module.getName());
return;
}
- if (EAR_MODULE.equals(typeId)) {
- traverseEarComponent(component, visitor, monitor);
- } else if (WEB_MODULE.equals(typeId)) {
- traverseWebComponent(component, visitor, monitor);
+ if (EAR_MODULE.equals(typeId))
+ {
+ traverseEarComponent(component,visitor,monitor);
+ }
+ else if (WEB_MODULE.equals(typeId))
+ {
+ traverseWebComponent(component,visitor,monitor);
}
}
- private static void traverseEarComponent(IVirtualComponent component,
- IModuleVisitor visitor, IProgressMonitor monitor)
- throws CoreException {
- // Currently the JST Server portion of WTP may not depend on the JST Enterprise portion of WTP
-/* EARArtifactEdit earEdit = EARArtifactEdit
- .getEARArtifactEditForRead(component);
- if (earEdit != null) {
- IVirtualReference[] j2eeComponents = earEdit.getJ2EEModuleReferences();
- for (int i = 0; i < j2eeComponents.length; i++) {
- traverseWebComponent(
- j2eeComponents[i].getReferencedComponent(), visitor,
- monitor);
- }
- IVirtualReference[] jarComponents = earEdit.getUtilityModuleReferences();
- for (int i = 0; i < jarComponents.length; i++) {
- IVirtualReference jarReference = jarComponents[i];
- IVirtualComponent jarComponent = jarReference
- .getReferencedComponent();
- IProject dependentProject = jarComponent.getProject();
- if (!dependentProject.hasNature(JavaCore.NATURE_ID))
- continue;
- IJavaProject project = JavaCore.create(dependentProject);
- IClasspathEntry cpe = getClasspathEntry(project, jarComponent
- .getRootFolder().getProjectRelativePath());
- visitor.visitEarResource(null, getOSPath(dependentProject,
- project, cpe.getOutputLocation()));
- }
- }*/
+ private static void traverseEarComponent(IVirtualComponent component, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException
+ {
+ // Currently the JST Server portion of WTP may not depend on the JST Enterprise portion of WTP
+ /*
+ * EARArtifactEdit earEdit = EARArtifactEdit .getEARArtifactEditForRead(component); if (earEdit != null) { IVirtualReference[] j2eeComponents =
+ * earEdit.getJ2EEModuleReferences(); for (int i = 0; i < j2eeComponents.length; i++) { traverseWebComponent(
+ * j2eeComponents[i].getReferencedComponent(), visitor, monitor); } IVirtualReference[] jarComponents = earEdit.getUtilityModuleReferences(); for (int i
+ * = 0; i < jarComponents.length; i++) { IVirtualReference jarReference = jarComponents[i]; IVirtualComponent jarComponent = jarReference
+ * .getReferencedComponent(); IProject dependentProject = jarComponent.getProject(); if (!dependentProject.hasNature(JavaCore.NATURE_ID)) continue;
+ * IJavaProject project = JavaCore.create(dependentProject); IClasspathEntry cpe = getClasspathEntry(project, jarComponent
+ * .getRootFolder().getProjectRelativePath()); visitor.visitEarResource(null, getOSPath(dependentProject, project, cpe.getOutputLocation())); } }
+ */
visitor.endVisitEarComponent(component);
}
- private static void traverseWebComponent(IVirtualComponent component,
- IModuleVisitor visitor, IProgressMonitor monitor)
- throws CoreException {
+ private static void traverseWebComponent(IVirtualComponent component, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException
+ {
visitor.visitWebComponent(component);
IProject proj = component.getProject();
StructureEdit warStruct = StructureEdit.getStructureEditForRead(proj);
- try {
+ try
+ {
WorkbenchComponent comp = warStruct.getComponent();
- if (comp == null) {
- Trace.trace(Trace.SEVERE,
- "Error getting WorkbenchComponent from war project. IProject=\""
- + proj + "\" StructureEdit=\"" + warStruct
- + "\" WorkbenchComponent=\"" + comp + "\"");
+ if (comp == null)
+ {
+ Trace.trace(Trace.SEVERE,"Error getting WorkbenchComponent from war project. IProject=\"" + proj + "\" StructureEdit=\"" + warStruct
+ + "\" WorkbenchComponent=\"" + comp + "\"");
return;
}
- traverseWebComponentLocalEntries(comp, visitor, monitor);
+ traverseWebComponentLocalEntries(comp,visitor,monitor);
// traverse referenced components
List children = comp.getReferencedComponents();
- for (Iterator itor = children.iterator(); itor.hasNext();) {
- ReferencedComponent childRef = (ReferencedComponent) itor.next();
+ for (Iterator itor = children.iterator(); itor.hasNext();)
+ {
+ ReferencedComponent childRef = (ReferencedComponent)itor.next();
IPath rtFolder = childRef.getRuntimePath();
URI refHandle = childRef.getHandle();
- if (PlatformURLModuleConnection.CLASSPATH.equals(
- refHandle.segment(ModuleURIUtil.ModuleURI.SUB_PROTOCOL_INDX))) {
+ if (PlatformURLModuleConnection.CLASSPATH.equals(refHandle.segment(ModuleURIUtil.ModuleURI.SUB_PROTOCOL_INDX)))
+ {
IPath refPath = getResolvedPathForArchiveComponent(refHandle);
// If an archive component, add to list
- if (refPath != null) {
- if (!refPath.isAbsolute()) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(refPath);
- IPath refPath2 = file.getLocation();
- if (refPath2 != null) {
- visitor.visitArchiveComponent(rtFolder, refPath2);
- }
- else {
- Trace.trace(Trace.WARNING, NLS.bind(
- "Could not get the location of a referenced component. It may not exist. Project={0}, Parent Component={1}, Referenced Component Path={2}",
- new Object[] { proj.getName(), comp.getName(), refPath}));
- }
- }
- else {
- visitor.visitArchiveComponent(rtFolder, refPath);
- }
+ if (refPath != null)
+ {
+ if (!refPath.isAbsolute())
+ {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(refPath);
+ IPath refPath2 = file.getLocation();
+ if (refPath2 != null)
+ {
+ visitor.visitArchiveComponent(rtFolder,refPath2);
+ }
+ else
+ {
+ Trace.trace(
+ Trace.WARNING,
+ NLS.bind(
+ "Could not get the location of a referenced component. It may not exist. Project={0}, Parent Component={1}, Referenced Component Path={2}",
+ new Object[]
+ { proj.getName(), comp.getName(), refPath }));
+ }
+ }
+ else
+ {
+ visitor.visitArchiveComponent(rtFolder,refPath);
+ }
}
- else {
- // TODO Determine if any use case would arrive here.
+ else
+ {
+ // TODO Determine if any use case would arrive here.
}
- } else {
- try {
+ }
+ else
+ {
+ try
+ {
WorkbenchComponent childCom = warStruct.findComponentByURI(refHandle);
- if (childCom == null) {
+ if (childCom == null)
+ {
continue;
}
- traverseDependentEntries(visitor, rtFolder, childCom,
- monitor);
- } catch (UnresolveableURIException e) {
+ traverseDependentEntries(visitor,rtFolder,childCom,monitor);
+ }
+ catch (UnresolveableURIException e)
+ {
JettyPlugin.log(e);
}
}
}
- } finally {
+ }
+ finally
+ {
warStruct.dispose();
}
visitor.endVisitWebComponent(component);
}
- private static void traverseWebComponentLocalEntries(
- WorkbenchComponent comp, IModuleVisitor visitor,
- IProgressMonitor monitor) throws CoreException {
+ private static void traverseWebComponentLocalEntries(WorkbenchComponent comp, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException
+ {
IProject warProject = StructureEdit.getContainingProject(comp);
- if (warProject == null || !warProject.hasNature(JavaCore.NATURE_ID)) {
+ if (warProject == null || !warProject.hasNature(JavaCore.NATURE_ID))
+ {
return;
}
IJavaProject project = JavaCore.create(warProject);
List res = comp.getResources();
- for (Iterator itorRes = res.iterator(); itorRes.hasNext();) {
- ComponentResource childComp = (ComponentResource) itorRes.next();
- IClasspathEntry cpe = getClasspathEntry(project, childComp.getSourcePath());
+ for (Iterator itorRes = res.iterator(); itorRes.hasNext();)
+ {
+ ComponentResource childComp = (ComponentResource)itorRes.next();
+ IClasspathEntry cpe = getClasspathEntry(project,childComp.getSourcePath());
if (cpe == null)
continue;
- visitor.visitWebResource(childComp.getRuntimePath(), getOSPath(
- warProject, project, cpe.getOutputLocation()));
+ visitor.visitWebResource(childComp.getRuntimePath(),getOSPath(warProject,project,cpe.getOutputLocation()));
}
// Include tagged classpath entries
- Map classpathDeps = getComponentClasspathDependencies(project, true);
- for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext();) {
- IClasspathEntry entry = (IClasspathEntry)iterator.next();
- IClasspathAttribute attrib = (IClasspathAttribute)classpathDeps.get(entry);
- boolean isClassFolder = isClassFolderEntry(entry);
- String rtFolder = attrib.getValue();
- if (rtFolder == null) {
- if (isClassFolder) {
- rtFolder = "/WEB-INF/classes";
- } else {
- rtFolder = "/WEB-INF/lib";
- }
- }
- IPath entryPath = entry.getPath();
- IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
- if (entryRes != null) {
- entryPath = entryRes.getLocation();
- }
- // TODO Determine if different handling is needed for some use cases
- if (isClassFolder) {
- visitor.visitWebResource(new Path(rtFolder),
- getOSPath(warProject, project, entry.getPath()));
- } else {
- visitor.visitArchiveComponent(new Path(rtFolder), entryPath);
- }
- }
+ Map classpathDeps = getComponentClasspathDependencies(project,true);
+ for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext();)
+ {
+ IClasspathEntry entry = (IClasspathEntry)iterator.next();
+ IClasspathAttribute attrib = (IClasspathAttribute)classpathDeps.get(entry);
+ boolean isClassFolder = isClassFolderEntry(entry);
+ String rtFolder = attrib.getValue();
+ if (rtFolder == null)
+ {
+ if (isClassFolder)
+ {
+ rtFolder = "/WEB-INF/classes";
+ }
+ else
+ {
+ rtFolder = "/WEB-INF/lib";
+ }
+ }
+ IPath entryPath = entry.getPath();
+ IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
+ if (entryRes != null)
+ {
+ entryPath = entryRes.getLocation();
+ }
+ // TODO Determine if different handling is needed for some use cases
+ if (isClassFolder)
+ {
+ visitor.visitWebResource(new Path(rtFolder),getOSPath(warProject,project,entry.getPath()));
+ }
+ else
+ {
+ visitor.visitArchiveComponent(new Path(rtFolder),entryPath);
+ }
+ }
}
- private static void traverseDependentEntries(IModuleVisitor visitor,
- IPath runtimeFolder, WorkbenchComponent component,
- IProgressMonitor monitor) throws CoreException {
+ private static void traverseDependentEntries(IModuleVisitor visitor, IPath runtimeFolder, WorkbenchComponent component, IProgressMonitor monitor)
+ throws CoreException
+ {
IProject dependentProject = StructureEdit.getContainingProject(component);
if (!dependentProject.hasNature(JavaCore.NATURE_ID))
return;
@@ -281,320 +295,373 @@
// go thru all entries
List res = component.getResources();
- for (Iterator itorRes = res.iterator(); itorRes.hasNext();) {
- ComponentResource childComp = (ComponentResource) itorRes.next();
+ for (Iterator itorRes = res.iterator(); itorRes.hasNext();)
+ {
+ ComponentResource childComp = (ComponentResource)itorRes.next();
IPath rtPath = childComp.getRuntimePath();
IPath srcPath = childComp.getSourcePath();
- IClasspathEntry cpe = getClasspathEntry(project, srcPath);
- if (cpe != null) {
- visitor.visitDependentComponent(runtimeFolder.append(rtPath)
- .append(name + ".jar"), getOSPath(dependentProject,
- project, cpe.getOutputLocation()));
+ IClasspathEntry cpe = getClasspathEntry(project,srcPath);
+ if (cpe != null)
+ {
+ visitor.visitDependentComponent(runtimeFolder.append(rtPath).append(name + ".jar"),getOSPath(dependentProject,project,cpe.getOutputLocation()));
}
// Handle META-INF/resources
- String path = rtPath.toString();
- IFolder resFolder = null;
- String targetPath = "";
- if ("/".equals(path)) {
- resFolder = dependentProject.getFolder(srcPath.append("META-INF/resources"));
- }
- else if ("/META-INF".equals(path)) {
- resFolder = dependentProject.getFolder(srcPath.append("resources"));
- }
- else if ("/META-INF/resources".equals(path)) {
- resFolder = dependentProject.getFolder(srcPath);
- }
- else if (path.startsWith("/META-INF/resources/")) {
- resFolder = dependentProject.getFolder(srcPath);
- targetPath = path.substring("/META-INF/resources".length());
- }
- if (resFolder != null && resFolder.exists()) {
- visitor.visitDependentContentResource(new Path(targetPath), resFolder.getLocation());
- }
+ String path = rtPath.toString();
+ IFolder resFolder = null;
+ String targetPath = "";
+ if ("/".equals(path))
+ {
+ resFolder = dependentProject.getFolder(srcPath.append("META-INF/resources"));
+ }
+ else if ("/META-INF".equals(path))
+ {
+ resFolder = dependentProject.getFolder(srcPath.append("resources"));
+ }
+ else if ("/META-INF/resources".equals(path))
+ {
+ resFolder = dependentProject.getFolder(srcPath);
+ }
+ else if (path.startsWith("/META-INF/resources/"))
+ {
+ resFolder = dependentProject.getFolder(srcPath);
+ targetPath = path.substring("/META-INF/resources".length());
+ }
+ if (resFolder != null && resFolder.exists())
+ {
+ visitor.visitDependentContentResource(new Path(targetPath),resFolder.getLocation());
+ }
}
// Include tagged classpath entries
- Map classpathDeps = getComponentClasspathDependencies(project, false);
- for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext();) {
- IClasspathEntry entry = (IClasspathEntry)iterator.next();
- boolean isClassFolder = isClassFolderEntry(entry);
- String rtFolder = null;
- if (isClassFolder) {
- rtFolder = "/";
- } else {
- rtFolder = "/WEB-INF/lib";
- }
- IPath entryPath = entry.getPath();
- IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
- if (entryRes != null) {
- entryPath = entryRes.getLocation();
- }
- // TODO Determine if different handling is needed for some use cases
- if (isClassFolder) {
- visitor.visitDependentComponent(runtimeFolder.append(rtFolder)
- .append(name + ".jar"), getOSPath(dependentProject,
- project, entry.getPath()));
- } else {
- visitor.visitArchiveComponent(new Path(rtFolder), entryPath);
- }
- }
+ Map classpathDeps = getComponentClasspathDependencies(project,false);
+ for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext();)
+ {
+ IClasspathEntry entry = (IClasspathEntry)iterator.next();
+ boolean isClassFolder = isClassFolderEntry(entry);
+ String rtFolder = null;
+ if (isClassFolder)
+ {
+ rtFolder = "/";
+ }
+ else
+ {
+ rtFolder = "/WEB-INF/lib";
+ }
+ IPath entryPath = entry.getPath();
+ IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
+ if (entryRes != null)
+ {
+ entryPath = entryRes.getLocation();
+ }
+ // TODO Determine if different handling is needed for some use cases
+ if (isClassFolder)
+ {
+ visitor.visitDependentComponent(runtimeFolder.append(rtFolder).append(name + ".jar"),getOSPath(dependentProject,project,entry.getPath()));
+ }
+ else
+ {
+ visitor.visitArchiveComponent(new Path(rtFolder),entryPath);
+ }
+ }
}
- private static IClasspathEntry getClasspathEntry(IJavaProject project,
- IPath sourcePath) throws JavaModelException {
+ private static IClasspathEntry getClasspathEntry(IJavaProject project, IPath sourcePath) throws JavaModelException
+ {
sourcePath = project.getPath().append(sourcePath);
IClasspathEntry[] cp = project.getRawClasspath();
- for (int i = 0; i < cp.length; i++) {
+ for (int i = 0; i < cp.length; i++)
+ {
if (sourcePath.equals(cp[i].getPath()))
return JavaCore.getResolvedClasspathEntry(cp[i]);
}
return null;
}
- private static IPath getOSPath(IProject project, IJavaProject javaProject,
- IPath outputPath) throws JavaModelException {
+ private static IPath getOSPath(IProject project, IJavaProject javaProject, IPath outputPath) throws JavaModelException
+ {
if (outputPath == null)
outputPath = javaProject.getOutputLocation();
// If we have the root of a project, return project location
- if (outputPath.segmentCount() == 1) {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(outputPath.lastSegment())
- .getLocation();
+ if (outputPath.segmentCount() == 1)
+ {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(outputPath.lastSegment()).getLocation();
}
// Otherwise return project folder location
- return ResourcesPlugin.getWorkspace().getRoot().getFolder(outputPath)
- .getLocation();
+ return ResourcesPlugin.getWorkspace().getRoot().getFolder(outputPath).getLocation();
}
/*
* Derived from J2EEProjectUtilities.getResolvedPathForArchiveComponent()
*/
- private static IPath getResolvedPathForArchiveComponent(URI uri) {
+ private static IPath getResolvedPathForArchiveComponent(URI uri)
+ {
- String resourceType = uri.segment(1);
- URI contenturi = ModuleURIUtil.trimToRelativePath(uri, 2);
- String contentName = contenturi.toString();
+ String resourceType = uri.segment(1);
+ URI contenturi = ModuleURIUtil.trimToRelativePath(uri,2);
+ String contentName = contenturi.toString();
- if (resourceType.equals("lib")) { //$NON-NLS-1$
- // module:/classpath/lib/D:/foo/foo.jar
- return Path.fromOSString(contentName);
+ if (resourceType.equals("lib")) { //$NON-NLS-1$
+ // module:/classpath/lib/D:/foo/foo.jar
+ return Path.fromOSString(contentName);
- } else if (resourceType.equals("var")) { //$NON-NLS-1$
+ }
+ else if (resourceType.equals("var")) { //$NON-NLS-1$
- // module:/classpath/var/<CLASSPATHVAR>/foo.jar
- String classpathVar = contenturi.segment(0);
- URI remainingPathuri = ModuleURIUtil.trimToRelativePath(contenturi, 1);
- String remainingPath = remainingPathuri.toString();
+ // module:/classpath/var/<CLASSPATHVAR>/foo.jar
+ String classpathVar = contenturi.segment(0);
+ URI remainingPathuri = ModuleURIUtil.trimToRelativePath(contenturi,1);
+ String remainingPath = remainingPathuri.toString();
- String[] classpathvars = JavaCore.getClasspathVariableNames();
- boolean found = false;
- for (int i = 0; i < classpathvars.length; i++) {
- if (classpathVar.equals(classpathvars[i])) {
- found = true;
- break;
- }
- }
- if (found) {
- IPath path = JavaCore.getClasspathVariable(classpathVar);
- if (path != null) {
- URI finaluri = URI.createURI(path.toOSString() + IPath.SEPARATOR + remainingPath);
- return Path.fromOSString(finaluri.toString());
- }
- }
- Trace.trace(Trace.WARNING,
- NLS.bind("Jetty publishing could not resolve dependency URI \"{0}\". A value for classpath variable {1} was not found.", uri, classpathVar));
- }
- return null;
- }
+ String[] classpathvars = JavaCore.getClasspathVariableNames();
+ boolean found = false;
+ for (int i = 0; i < classpathvars.length; i++)
+ {
+ if (classpathVar.equals(classpathvars[i]))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ {
+ IPath path = JavaCore.getClasspathVariable(classpathVar);
+ if (path != null)
+ {
+ URI finaluri = URI.createURI(path.toOSString() + IPath.SEPARATOR + remainingPath);
+ return Path.fromOSString(finaluri.toString());
+ }
+ }
+ Trace.trace(Trace.WARNING,
+ NLS.bind("Jetty publishing could not resolve dependency URI \"{0}\". A value for classpath variable {1} was not found.",uri,classpathVar));
+ }
+ return null;
+ }
- /*
- * Derived from ClasspathDependencyUtil.getComponentClasspathDependencies()
- */
- private static Map getComponentClasspathDependencies(final IJavaProject javaProject, final boolean isWebApp) throws CoreException {
+ /*
+ * Derived from ClasspathDependencyUtil.getComponentClasspathDependencies()
+ */
+ private static Map getComponentClasspathDependencies(final IJavaProject javaProject, final boolean isWebApp) throws CoreException
+ {
- // get the raw entries
- final Map referencedRawEntries = getRawComponentClasspathDependencies(javaProject);
- final Map validRawEntries = new HashMap();
+ // get the raw entries
+ final Map referencedRawEntries = getRawComponentClasspathDependencies(javaProject);
+ final Map validRawEntries = new HashMap();
- // filter out non-valid referenced raw entries
- final Iterator i = referencedRawEntries.keySet().iterator();
- while (i.hasNext()) {
- final IClasspathEntry entry = (IClasspathEntry) i.next();
- final IClasspathAttribute attrib = (IClasspathAttribute) referencedRawEntries.get(entry);
- if (isValid(entry, attrib, isWebApp, javaProject.getProject())) {
- validRawEntries.put(entry, attrib);
- }
- }
+ // filter out non-valid referenced raw entries
+ final Iterator i = referencedRawEntries.keySet().iterator();
+ while (i.hasNext())
+ {
+ final IClasspathEntry entry = (IClasspathEntry)i.next();
+ final IClasspathAttribute attrib = (IClasspathAttribute)referencedRawEntries.get(entry);
+ if (isValid(entry,attrib,isWebApp,javaProject.getProject()))
+ {
+ validRawEntries.put(entry,attrib);
+ }
+ }
- // if we have no valid raw entries, return empty map
- if (validRawEntries.isEmpty()) {
- return Collections.EMPTY_MAP;
- }
+ // if we have no valid raw entries, return empty map
+ if (validRawEntries.isEmpty())
+ {
+ return Collections.EMPTY_MAP;
+ }
- // XXX Would like to replace the code below with use of a public JDT API that returns
- // the raw IClasspathEntry for a given resolved IClasspathEntry (see see https://bugs.eclipse.org/bugs/show_bug.cgi?id=183995)
- // The code must currently leverage IPackageFragmentRoot to determine this
- // mapping and, because IPackageFragmentRoots do not maintain IClasspathEntry data, a prior
- // call is needed to getResolvedClasspath() and the resolved IClasspathEntries have to be stored in a Map from IPath-to-IClasspathEntry to
- // support retrieval using the resolved IPackageFragmentRoot
-
- // retrieve the resolved classpath
- final IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
- final Map pathToResolvedEntry = new HashMap();
-
- // store in a map from path to entry
- for (int j = 0; j < entries.length; j++) {
- pathToResolvedEntry.put(entries[j].getPath(), entries[j]);
- }
+ // XXX Would like to replace the code below with use of a public JDT API that returns
+ // the raw IClasspathEntry for a given resolved IClasspathEntry (see see https://bugs.eclipse.org/bugs/show_bug.cgi?id=183995)
+ // The code must currently leverage IPackageFragmentRoot to determine this
+ // mapping and, because IPackageFragmentRoots do not maintain IClasspathEntry data, a prior
+ // call is needed to getResolvedClasspath() and the resolved IClasspathEntries have to be stored in a Map from IPath-to-IClasspathEntry to
+ // support retrieval using the resolved IPackageFragmentRoot
- final Map referencedEntries = new LinkedHashMap();
-
- // grab all IPackageFragmentRoots
- final IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
- for (int j = 0; j < roots.length; j++) {
- final IPackageFragmentRoot root = roots[j];
- final IClasspathEntry rawEntry = root.getRawClasspathEntry();
-
- // is the raw entry valid?
- IClasspathAttribute attrib = (IClasspathAttribute) validRawEntries.get(rawEntry);
- if (attrib == null) {
- continue;
- }
-
- final IPath pkgFragPath = root.getPath();
- final IClasspathEntry resolvedEntry = (IClasspathEntry) pathToResolvedEntry.get(pkgFragPath);
- final IClasspathAttribute resolvedAttrib = checkForComponentDependencyAttribute(resolvedEntry,
- DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY);
- // attribute for the resolved entry must either be unspecified or it must be the
- // dependency attribute for it to be included
- if (resolvedAttrib == null || resolvedAttrib.getName().equals(CLASSPATH_COMPONENT_DEPENDENCY)) {
- // filter out resolved entry if it doesn't pass the validation rules
- if (isValid(resolvedEntry, resolvedAttrib != null ? resolvedAttrib : attrib, isWebApp, javaProject.getProject())) {
- if (resolvedAttrib != null) {
- // if there is an attribute on the sub-entry, use that
- attrib = resolvedAttrib;
- }
- referencedEntries.put(resolvedEntry, attrib);
- }
- }
- }
-
+ // retrieve the resolved classpath
+ final IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
+ final Map pathToResolvedEntry = new HashMap();
+
+ // store in a map from path to entry
+ for (int j = 0; j < entries.length; j++)
+ {
+ pathToResolvedEntry.put(entries[j].getPath(),entries[j]);
+ }
+
+ final Map referencedEntries = new LinkedHashMap();
+
+ // grab all IPackageFragmentRoots
+ final IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
+ for (int j = 0; j < roots.length; j++)
+ {
+ final IPackageFragmentRoot root = roots[j];
+ final IClasspathEntry rawEntry = root.getRawClasspathEntry();
+
+ // is the raw entry valid?
+ IClasspathAttribute attrib = (IClasspathAttribute)validRawEntries.get(rawEntry);
+ if (attrib == null)
+ {
+ continue;
+ }
+
+ final IPath pkgFragPath = root.getPath();
+ final IClasspathEntry resolvedEntry = (IClasspathEntry)pathToResolvedEntry.get(pkgFragPath);
+ final IClasspathAttribute resolvedAttrib = checkForComponentDependencyAttribute(resolvedEntry,DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY);
+ // attribute for the resolved entry must either be unspecified or it must be the
+ // dependency attribute for it to be included
+ if (resolvedAttrib == null || resolvedAttrib.getName().equals(CLASSPATH_COMPONENT_DEPENDENCY))
+ {
+ // filter out resolved entry if it doesn't pass the validation rules
+ if (isValid(resolvedEntry,resolvedAttrib != null?resolvedAttrib:attrib,isWebApp,javaProject.getProject()))
+ {
+ if (resolvedAttrib != null)
+ {
+ // if there is an attribute on the sub-entry, use that
+ attrib = resolvedAttrib;
+ }
+ referencedEntries.put(resolvedEntry,attrib);
+ }
+ }
+ }
+
return referencedEntries;
- }
+ }
- /*
- * Derived from ClasspathDependencyUtil.getRawComponentClasspathDependencies()
- */
- private static Map getRawComponentClasspathDependencies(final IJavaProject javaProject) throws CoreException {
- if (javaProject == null) {
- return Collections.EMPTY_MAP;
- }
- final Map referencedRawEntries = new HashMap();
- final IClasspathEntry[] entries = javaProject.getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
+ /*
+ * Derived from ClasspathDependencyUtil.getRawComponentClasspathDependencies()
+ */
+ private static Map getRawComponentClasspathDependencies(final IJavaProject javaProject) throws CoreException
+ {
+ if (javaProject == null)
+ {
+ return Collections.EMPTY_MAP;
+ }
+ final Map referencedRawEntries = new HashMap();
+ final IClasspathEntry[] entries = javaProject.getRawClasspath();
+ for (int i = 0; i < entries.length; i++)
+ {
final IClasspathEntry entry = entries[i];
- final IClasspathAttribute attrib = checkForComponentDependencyAttribute(entry,
- DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY);
- if (attrib != null) {
- referencedRawEntries.put(entry, attrib);
+ final IClasspathAttribute attrib = checkForComponentDependencyAttribute(entry,DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY);
+ if (attrib != null)
+ {
+ referencedRawEntries.put(entry,attrib);
}
}
return referencedRawEntries;
- }
+ }
- /*
- * Derived from ClasspathDependencyUtil.checkForComponentDependencyAttribute()
- */
- private static IClasspathAttribute checkForComponentDependencyAttribute(final IClasspathEntry entry, final int attributeType) {
- if (entry == null) {
- return null;
- }
- final IClasspathAttribute[] attributes = entry.getExtraAttributes();
- for (int i = 0; i < attributes.length; i++) {
- final IClasspathAttribute attribute = attributes[i];
- final String name = attribute.getName();
- if (name.equals(CLASSPATH_COMPONENT_DEPENDENCY)) {
- if (attributeType == DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY
- || attributeType == DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY) {
- return attribute;
- }
- } else if (name.equals(CLASSPATH_COMPONENT_NON_DEPENDENCY)) {
- if (attributeType == DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY
- || attributeType == DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_NONDEPENDENCY) {
- return attribute;
- }
- }
- }
- return null;
- }
+ /*
+ * Derived from ClasspathDependencyUtil.checkForComponentDependencyAttribute()
+ */
+ private static IClasspathAttribute checkForComponentDependencyAttribute(final IClasspathEntry entry, final int attributeType)
+ {
+ if (entry == null)
+ {
+ return null;
+ }
+ final IClasspathAttribute[] attributes = entry.getExtraAttributes();
+ for (int i = 0; i < attributes.length; i++)
+ {
+ final IClasspathAttribute attribute = attributes[i];
+ final String name = attribute.getName();
+ if (name.equals(CLASSPATH_COMPONENT_DEPENDENCY))
+ {
+ if (attributeType == DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY
+ || attributeType == DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY)
+ {
+ return attribute;
+ }
+ }
+ else if (name.equals(CLASSPATH_COMPONENT_NON_DEPENDENCY))
+ {
+ if (attributeType == DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY
+ || attributeType == DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_NONDEPENDENCY)
+ {
+ return attribute;
+ }
+ }
+ }
+ return null;
+ }
- /*
- * Derived from ClasspathDependencyValidator.validateVirtualComponentEntry()
- */
- private static boolean isValid(final IClasspathEntry entry, final IClasspathAttribute attrib, boolean isWebApp, final IProject project) {
- int kind = entry.getEntryKind();
- boolean isClassFolder = isClassFolderEntry(entry);
-
- if (kind == IClasspathEntry.CPE_PROJECT || kind == IClasspathEntry.CPE_SOURCE) {
- return false;
- }
+ /*
+ * Derived from ClasspathDependencyValidator.validateVirtualComponentEntry()
+ */
+ private static boolean isValid(final IClasspathEntry entry, final IClasspathAttribute attrib, boolean isWebApp, final IProject project)
+ {
+ int kind = entry.getEntryKind();
+ boolean isClassFolder = isClassFolderEntry(entry);
- String runtimePath = getRuntimePath(attrib, isWebApp, isClassFolder);
- if (!isWebApp) {
- if (!runtimePath.equals("../") && !runtimePath.equals("/")) {
- return false;
- }
- if (isClassFolder && !runtimePath.equals("/")) {
- return false;
- }
- }
- else {
- if (runtimePath != null && !runtimePath.equals("/WEB-INF/lib")
- && !runtimePath.equals("/WEB-INF/classes")
- && !runtimePath.equals("../")) {
- return false;
- }
- if (isClassFolder && !runtimePath.equals("/WEB-INF/classes")) {
- return false;
- }
- }
- return true;
- }
-
- /*
- * Derived from ClasspathDependencyUtil.isClassFolderEntry()
- */
- private static boolean isClassFolderEntry(final IClasspathEntry entry) {
- if (entry == null || entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY) {
- return false;
- }
- // does the path refer to a file or a folder?
- final IPath entryPath = entry.getPath();
- IPath entryLocation = entryPath;
- final IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
- if (resource != null) {
- entryLocation = resource.getLocation();
- }
- boolean isFile = true; // by default, assume a jar file
- if (entryLocation.toFile().isDirectory()) {
- isFile = false;
- }
- return !isFile;
- }
-
- /*
- * Derived from ClasspathDependencyUtil.getRuntimePath()
- */
- private static String getRuntimePath(final IClasspathAttribute attrib, final boolean isWebApp, final boolean isClassFolder) {
- if (attrib != null && !attrib.getName().equals(CLASSPATH_COMPONENT_DEPENDENCY)) {
- return null;
- }
- if (attrib == null || attrib.getValue()== null || attrib.getValue().length() == 0) {
- if (isWebApp) {
- return isClassFolder ? "/WEB_INF/classes" : "WEB-INF/lib";
- } else {
- return isClassFolder ? "/" : "../";
- }
- }
- return attrib.getValue();
- }
+ if (kind == IClasspathEntry.CPE_PROJECT || kind == IClasspathEntry.CPE_SOURCE)
+ {
+ return false;
+ }
+
+ String runtimePath = getRuntimePath(attrib,isWebApp,isClassFolder);
+ if (!isWebApp)
+ {
+ if (!runtimePath.equals("../") && !runtimePath.equals("/"))
+ {
+ return false;
+ }
+ if (isClassFolder && !runtimePath.equals("/"))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (runtimePath != null && !runtimePath.equals("/WEB-INF/lib") && !runtimePath.equals("/WEB-INF/classes") && !runtimePath.equals("../"))
+ {
+ return false;
+ }
+ if (isClassFolder && !runtimePath.equals("/WEB-INF/classes"))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * Derived from ClasspathDependencyUtil.isClassFolderEntry()
+ */
+ private static boolean isClassFolderEntry(final IClasspathEntry entry)
+ {
+ if (entry == null || entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY)
+ {
+ return false;
+ }
+ // does the path refer to a file or a folder?
+ final IPath entryPath = entry.getPath();
+ IPath entryLocation = entryPath;
+ final IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
+ if (resource != null)
+ {
+ entryLocation = resource.getLocation();
+ }
+ boolean isFile = true; // by default, assume a jar file
+ if (entryLocation.toFile().isDirectory())
+ {
+ isFile = false;
+ }
+ return !isFile;
+ }
+
+ /*
+ * Derived from ClasspathDependencyUtil.getRuntimePath()
+ */
+ private static String getRuntimePath(final IClasspathAttribute attrib, final boolean isWebApp, final boolean isClassFolder)
+ {
+ if (attrib != null && !attrib.getName().equals(CLASSPATH_COMPONENT_DEPENDENCY))
+ {
+ return null;
+ }
+ if (attrib == null || attrib.getValue() == null || attrib.getValue().length() == 0)
+ {
+ if (isWebApp)
+ {
+ return isClassFolder?"/WEB_INF/classes":"WEB-INF/lib";
+ }
+ else
+ {
+ return isClassFolder?"/":"../";
+ }
+ }
+ return attrib.getValue();
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/Factory.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/Factory.java
index 0b675f8..fa2105f 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/Factory.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/Factory.java
@@ -21,131 +21,160 @@
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+
/**
* Factory for reading and writing from XML files.
*/
-public class Factory {
- protected String packageName;
- protected Document document;
+public class Factory
+{
+ protected String packageName;
+ protected Document document;
- public Factory() {
- // do nothing
- }
-
- protected Attr createAttribute(String s, Element element) {
- Attr attr = document.createAttribute(s);
- element.setAttributeNode(attr);
- return attr;
- }
-
- protected XMLElement createElement(int index, String s, Node node) {
- if (index < 0)
- return createElement(s, node);
-
- Element element = document.createElement(s);
- try {
- Node child = node.getFirstChild();
- while (child != null && !s.equals(child.getNodeName())) {
- child = child.getNextSibling();
- }
- for (int i = 0; child != null && i < index; i++) {
- child = child.getNextSibling();
- while (child != null && !s.equals(child.getNodeName())) {
- child = child.getNextSibling();
- }
- }
- // TODO Try to improve formating, maybe dup an appropriate text node
- if (child != null)
- node.insertBefore(element, child);
- else
- node.appendChild(element);
- } catch (Exception e) {
- node.appendChild(element);
- }
- return newInstance(element);
- }
-
- protected XMLElement createElement(String s, Node node) {
- Element element = document.createElement(s);
- node.appendChild(element);
- return newInstance(element);
- }
-
- public byte[] getContents() throws IOException {
- return XMLUtil.getContents(document);
- }
-
- /**
- *
- * @return org.w3c.dom.Document
- */
- public Document getDocument() {
- return document;
- }
+ public Factory()
+ {
+ // do nothing
+ }
- public String getPackageName() {
- return packageName;
- }
+ protected Attr createAttribute(String s, Element element)
+ {
+ Attr attr = document.createAttribute(s);
+ element.setAttributeNode(attr);
+ return attr;
+ }
- public XMLElement loadDocument(InputStream in) throws IOException, SAXException {
- try {
- document = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- Element element = document.getDocumentElement();
- return newInstance(element);
- } catch (IllegalArgumentException exception) {
- Trace.trace(Trace.WARNING, "Error loading document", exception);
- throw new IOException("Could not load document");
- }
- }
+ protected XMLElement createElement(int index, String s, Node node)
+ {
+ if (index < 0)
+ return createElement(s,node);
- protected XMLElement newInstance(Element element) {
- //String s = element.getNodeName();
-
- String s = element.getAttribute("class");
- if (s.length() < 1) {
- s = element.getNodeName();
- }
- int index = s.lastIndexOf('.');
- s = s.substring(index+1, s.length());
-
- try {
- // change "web-app:test" to "WebAppTest"
- s = s.substring(0, 1).toUpperCase() + s.substring(1);
- int i = s.indexOf("-");
- while (i >= 0) {
- s = s.substring(0, i) + s.substring(i+1, i+2).toUpperCase() + s.substring(i+2);
- i = s.indexOf("-");
- }
- i = s.indexOf(":");
- while (i >= 0) {
- s = s.substring(0, i) + s.substring(i+1, i+2).toUpperCase() + s.substring(i+2);
- i = s.indexOf(":");
- }
-
- // add package name
- if (packageName != null)
- s = packageName + "." + s;
- Class class1 = Class.forName(s);
-
- XMLElement xmlElement = (XMLElement) class1.newInstance();
- xmlElement.setElement(element);
- xmlElement.setFactory(this);
- return xmlElement;
- } catch (Exception exception) {
- // ignore
- }
- return null;
- }
-
- public void save(String filename) throws IOException {
- XMLUtil.save(filename, document);
- }
-
- public void setDocument(Document d) {
- document = d;
- }
-
- public void setPackageName(String s) {
- packageName = s;
- }
+ Element element = document.createElement(s);
+ try
+ {
+ Node child = node.getFirstChild();
+ while (child != null && !s.equals(child.getNodeName()))
+ {
+ child = child.getNextSibling();
+ }
+ for (int i = 0; child != null && i < index; i++)
+ {
+ child = child.getNextSibling();
+ while (child != null && !s.equals(child.getNodeName()))
+ {
+ child = child.getNextSibling();
+ }
+ }
+ // TODO Try to improve formating, maybe dup an appropriate text node
+ if (child != null)
+ node.insertBefore(element,child);
+ else
+ node.appendChild(element);
+ }
+ catch (Exception e)
+ {
+ node.appendChild(element);
+ }
+ return newInstance(element);
+ }
+
+ protected XMLElement createElement(String s, Node node)
+ {
+ Element element = document.createElement(s);
+ node.appendChild(element);
+ return newInstance(element);
+ }
+
+ public byte[] getContents() throws IOException
+ {
+ return XMLUtil.getContents(document);
+ }
+
+ /**
+ *
+ * @return org.w3c.dom.Document
+ */
+ public Document getDocument()
+ {
+ return document;
+ }
+
+ public String getPackageName()
+ {
+ return packageName;
+ }
+
+ public XMLElement loadDocument(InputStream in) throws IOException, SAXException
+ {
+ try
+ {
+ document = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
+ Element element = document.getDocumentElement();
+ return newInstance(element);
+ }
+ catch (IllegalArgumentException exception)
+ {
+ Trace.trace(Trace.WARNING,"Error loading document",exception);
+ throw new IOException("Could not load document");
+ }
+ }
+
+ protected XMLElement newInstance(Element element)
+ {
+ // String s = element.getNodeName();
+
+ String s = element.getAttribute("class");
+ if (s.length() < 1)
+ {
+ s = element.getNodeName();
+ }
+ int index = s.lastIndexOf('.');
+ s = s.substring(index + 1,s.length());
+
+ try
+ {
+ // change "web-app:test" to "WebAppTest"
+ s = s.substring(0,1).toUpperCase() + s.substring(1);
+ int i = s.indexOf("-");
+ while (i >= 0)
+ {
+ s = s.substring(0,i) + s.substring(i + 1,i + 2).toUpperCase() + s.substring(i + 2);
+ i = s.indexOf("-");
+ }
+ i = s.indexOf(":");
+ while (i >= 0)
+ {
+ s = s.substring(0,i) + s.substring(i + 1,i + 2).toUpperCase() + s.substring(i + 2);
+ i = s.indexOf(":");
+ }
+
+ // add package name
+ if (packageName != null)
+ s = packageName + "." + s;
+ Class class1 = Class.forName(s);
+
+ XMLElement xmlElement = (XMLElement)class1.newInstance();
+ xmlElement.setElement(element);
+ xmlElement.setFactory(this);
+ return xmlElement;
+ }
+ catch (Exception exception)
+ {
+ // ignore
+ }
+ return null;
+ }
+
+ public void save(String filename) throws IOException
+ {
+ XMLUtil.save(filename,document);
+ }
+
+ public void setDocument(Document d)
+ {
+ document = d;
+ }
+
+ public void setPackageName(String s)
+ {
+ packageName = s;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/XMLElement.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/XMLElement.java
index 4a3856c..98ff17b 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/XMLElement.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/XMLElement.java
@@ -25,412 +25,484 @@
/**
* An XML element.
*/
-public class XMLElement {
- private Element xmlElement;
- protected Factory factory;
+public class XMLElement
+{
+ private Element xmlElement;
+ protected Factory factory;
- public XMLElement() {
- // do nothing
- }
+ public XMLElement()
+ {
+ // do nothing
+ }
- public void setText(String textContent) {
- xmlElement.setTextContent(textContent);
- }
+ public void setText(String textContent)
+ {
+ xmlElement.setTextContent(textContent);
+ }
- public Element getElementNode() {
- return xmlElement;
- }
+ public Element getElementNode()
+ {
+ return xmlElement;
+ }
- public Attr addAttribute(String s, String s1) {
- Attr attr = factory.createAttribute(s, xmlElement);
- attr.setValue(s1);
- return attr;
- }
+ public Attr addAttribute(String s, String s1)
+ {
+ Attr attr = factory.createAttribute(s,xmlElement);
+ attr.setValue(s1);
+ return attr;
+ }
- public XMLElement createElement(int index, String s) {
- return factory.createElement(index, s, xmlElement);
- }
+ public XMLElement createElement(int index, String s)
+ {
+ return factory.createElement(index,s,xmlElement);
+ }
- public XMLElement createElement(String s) {
- return factory.createElement(s, xmlElement);
- }
+ public XMLElement createElement(String s)
+ {
+ return factory.createElement(s,xmlElement);
+ }
- public XMLElement findElement(String s) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int i = nodelist == null ? 0 : nodelist.getLength();
- for (int j = 0; j < i; j++) {
- Node node = nodelist.item(j);
- String s1 = node.getNodeName().trim();
- if (s1.equals(s))
- return factory.newInstance((Element) node);
- }
+ public XMLElement findElement(String s)
+ {
+ NodeList nodelist = xmlElement.getElementsByTagName(s);
+ int i = nodelist == null?0:nodelist.getLength();
+ for (int j = 0; j < i; j++)
+ {
+ Node node = nodelist.item(j);
+ String s1 = node.getNodeName().trim();
+ if (s1.equals(s))
+ return factory.newInstance((Element)node);
+ }
- return createElement(s);
- }
+ return createElement(s);
+ }
- public XMLElement findElement(String s, int i) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int j = nodelist == null ? 0 : nodelist.getLength();
- for (int k = 0; k < j; k++) {
- Node node = nodelist.item(k);
- String s1 = node.getNodeName().trim();
- if (s1.equals(s) && k == i)
- return factory.newInstance((Element) node);
- }
+ public XMLElement findElement(String s, int i)
+ {
+ NodeList nodelist = xmlElement.getElementsByTagName(s);
+ int j = nodelist == null?0:nodelist.getLength();
+ for (int k = 0; k < j; k++)
+ {
+ Node node = nodelist.item(k);
+ String s1 = node.getNodeName().trim();
+ if (s1.equals(s) && k == i)
+ return factory.newInstance((Element)node);
+ }
- return createElement(s);
- }
+ return createElement(s);
+ }
- public Element findElement(String s, String attrName) {
- return findElement(xmlElement, s, attrName);
- }
-
- public Element findElement(Element element, String s, String attrName) {
- NodeList nodelist = element.getElementsByTagName(s);
- int j = nodelist == null ? 0 : nodelist.getLength();
- for (int k = 0; k < j; k++) {
- Element node = (Element) nodelist.item(k);
- if (hasAttribute(node, attrName)) {
- return node;
- }
- }
- Element newElement = element.getOwnerDocument().createElement(s);
- element.getOwnerDocument().getDocumentElement()
- .appendChild(newElement);
- return newElement;
- }
+ public Element findElement(String s, String attrName)
+ {
+ return findElement(xmlElement,s,attrName);
+ }
- public boolean hasAttribute(Element node, String attrName) {
- NamedNodeMap attributes = node.getAttributes();
- int length = attributes.getLength();
- for (int i = 0; i < length; i++) {
- Node n = attributes.item(i);
- if (attrName.equals(n.getNodeValue())) {
- return true;
- }
- }
- return false;
- }
+ public Element findElement(Element element, String s, String attrName)
+ {
+ NodeList nodelist = element.getElementsByTagName(s);
+ int j = nodelist == null?0:nodelist.getLength();
+ for (int k = 0; k < j; k++)
+ {
+ Element node = (Element)nodelist.item(k);
+ if (hasAttribute(node,attrName))
+ {
+ return node;
+ }
+ }
+ Element newElement = element.getOwnerDocument().createElement(s);
+ element.getOwnerDocument().getDocumentElement().appendChild(newElement);
+ return newElement;
+ }
- public String getAttributeValue(String s) {
- Attr attr = xmlElement.getAttributeNode(s);
- if (attr != null)
- return attr.getValue();
+ public boolean hasAttribute(Element node, String attrName)
+ {
+ NamedNodeMap attributes = node.getAttributes();
+ int length = attributes.getLength();
+ for (int i = 0; i < length; i++)
+ {
+ Node n = attributes.item(i);
+ if (attrName.equals(n.getNodeValue()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- return null;
- }
+ public String getAttributeValue(String s)
+ {
+ Attr attr = xmlElement.getAttributeNode(s);
+ if (attr != null)
+ return attr.getValue();
- public Map getAttributes() {
- Map attributes = new LinkedHashMap();
- NamedNodeMap attrs = xmlElement.getAttributes();
- if (null != attrs) {
- for (int i = 0; i < attrs.getLength(); i++) {
- Node attr = attrs.item(i);
- String name = attr.getNodeName();
- String value = attr.getNodeValue();
- attributes.put(name, value);
- }
- }
- return attributes;
- }
+ return null;
+ }
- public String getElementName() {
- return xmlElement.getNodeName();
- }
+ public Map getAttributes()
+ {
+ Map attributes = new LinkedHashMap();
+ NamedNodeMap attrs = xmlElement.getAttributes();
+ if (null != attrs)
+ {
+ for (int i = 0; i < attrs.getLength(); i++)
+ {
+ Node attr = attrs.item(i);
+ String name = attr.getNodeName();
+ String value = attr.getNodeValue();
+ attributes.put(name,value);
+ }
+ }
+ return attributes;
+ }
- public String getElementValue() {
- return getElementValue(xmlElement);
- }
+ public String getElementName()
+ {
+ return xmlElement.getNodeName();
+ }
- protected static String getElementValue(Element element) {
- String s = element.getNodeValue();
- if (s != null)
- return s;
- NodeList nodelist = element.getChildNodes();
- for (int i = 0; i < nodelist.getLength(); i++)
- if (nodelist.item(i) instanceof Text)
- return ((Text) nodelist.item(i)).getData();
+ public String getElementValue()
+ {
+ return getElementValue(xmlElement);
+ }
- return null;
- }
+ protected static String getElementValue(Element element)
+ {
+ String s = element.getNodeValue();
+ if (s != null)
+ return s;
+ NodeList nodelist = element.getChildNodes();
+ for (int i = 0; i < nodelist.getLength(); i++)
+ if (nodelist.item(i) instanceof Text)
+ return ((Text)nodelist.item(i)).getData();
- public Element getSubElement(String s) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int i = nodelist == null ? 0 : nodelist.getLength();
- for (int j = 0; j < i; j++) {
- Node node = nodelist.item(j);
- String s1 = node.getNodeName().trim();
- if (s1.equals(s))
- return (Element) node;
- }
+ return null;
+ }
- return null;
- }
+ public Element getSubElement(String s)
+ {
+ NodeList nodelist = xmlElement.getElementsByTagName(s);
+ int i = nodelist == null?0:nodelist.getLength();
+ for (int j = 0; j < i; j++)
+ {
+ Node node = nodelist.item(j);
+ String s1 = node.getNodeName().trim();
+ if (s1.equals(s))
+ return (Element)node;
+ }
- public String getSubElementValue(String s) {
- Element element = getSubElement(s);
- if (element == null)
- return null;
+ return null;
+ }
- String value = getElementValue(element);
- if (value == null)
- return null;
+ public String getSubElementValue(String s)
+ {
+ Element element = getSubElement(s);
+ if (element == null)
+ return null;
- return value.trim();
- }
+ String value = getElementValue(element);
+ if (value == null)
+ return null;
- public boolean removeAttribute(String s) {
- try {
- xmlElement.removeAttribute(s);
- return true;
- } catch (Exception ex) {
- return false;
- }
- }
+ return value.trim();
+ }
- public boolean removeElement(String s, int i) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int j = nodelist == null ? 0 : nodelist.getLength();
- for (int k = 0; k < j; k++) {
- Node node = nodelist.item(k);
- String s1 = node.getNodeName().trim();
- if (s1.equals(s) && k == i) {
- xmlElement.removeChild(node);
- return true;
- }
- }
+ public boolean removeAttribute(String s)
+ {
+ try
+ {
+ xmlElement.removeAttribute(s);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
- return false;
- }
+ public boolean removeElement(String s, int i)
+ {
+ NodeList nodelist = xmlElement.getElementsByTagName(s);
+ int j = nodelist == null?0:nodelist.getLength();
+ for (int k = 0; k < j; k++)
+ {
+ Node node = nodelist.item(k);
+ String s1 = node.getNodeName().trim();
+ if (s1.equals(s) && k == i)
+ {
+ xmlElement.removeChild(node);
+ return true;
+ }
+ }
- public void setAttributeValue(String s, String s1) {
- Attr attr = xmlElement.getAttributeNode(s);
- if (attr == null)
- attr = addAttribute(s, s1);
- else
- attr.setValue(s1);
- }
+ return false;
+ }
- void setElement(Element element) {
- xmlElement = element;
- }
+ public void setAttributeValue(String s, String s1)
+ {
+ Attr attr = xmlElement.getAttributeNode(s);
+ if (attr == null)
+ attr = addAttribute(s,s1);
+ else
+ attr.setValue(s1);
+ }
- protected static void setElementValue(Element element, String value) {
- String s = element.getNodeValue();
- if (s != null) {
- element.setNodeValue(value);
- return;
- }
- NodeList nodelist = element.getChildNodes();
- for (int i = 0; i < nodelist.getLength(); i++)
- if (nodelist.item(i) instanceof Text) {
- Text text = (Text) nodelist.item(i);
- text.setData(value);
- return;
- }
+ void setElement(Element element)
+ {
+ xmlElement = element;
+ }
- return;
- }
+ protected static void setElementValue(Element element, String value)
+ {
+ String s = element.getNodeValue();
+ if (s != null)
+ {
+ element.setNodeValue(value);
+ return;
+ }
+ NodeList nodelist = element.getChildNodes();
+ for (int i = 0; i < nodelist.getLength(); i++)
+ if (nodelist.item(i) instanceof Text)
+ {
+ Text text = (Text)nodelist.item(i);
+ text.setData(value);
+ return;
+ }
- void setFactory(Factory factory1) {
- factory = factory1;
- }
+ return;
+ }
- public Factory getFactory() {
- return factory;
- }
+ void setFactory(Factory factory1)
+ {
+ factory = factory1;
+ }
- public void setSubElementValue(String s, String value) {
- Element element = getSubElement(s);
- if (element == null) {
- element = factory.document.createElement(s);
- element.appendChild(factory.document.createTextNode("temp"));
- xmlElement.appendChild(element);
- }
- setElementValue(element, value);
- }
+ public Factory getFactory()
+ {
+ return factory;
+ }
- public int sizeOfElement(String s) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int i = nodelist == null ? 0 : nodelist.getLength();
- return i;
- }
+ public void setSubElementValue(String s, String value)
+ {
+ Element element = getSubElement(s);
+ if (element == null)
+ {
+ element = factory.document.createElement(s);
+ element.appendChild(factory.document.createTextNode("temp"));
+ xmlElement.appendChild(element);
+ }
+ setElementValue(element,value);
+ }
- public void updateElementValue(String s) {
- try {
- xmlElement.setNodeValue(s);
- } catch (DOMException ex) {
- NodeList nodelist = xmlElement.getChildNodes();
- int i = nodelist == null ? 0 : nodelist.getLength();
- if (i > 0) {
- for (int j = 0; j < i; j++)
- if (nodelist.item(j) instanceof Text) {
- ((Text) nodelist.item(j)).setData(s);
- return;
- }
- } else {
- xmlElement.appendChild(factory.document.createTextNode(s));
- }
- }
- }
+ public int sizeOfElement(String s)
+ {
+ NodeList nodelist = xmlElement.getElementsByTagName(s);
+ int i = nodelist == null?0:nodelist.getLength();
+ return i;
+ }
- public boolean hasChildNodes() {
- return xmlElement.hasChildNodes();
- }
+ public void updateElementValue(String s)
+ {
+ try
+ {
+ xmlElement.setNodeValue(s);
+ }
+ catch (DOMException ex)
+ {
+ NodeList nodelist = xmlElement.getChildNodes();
+ int i = nodelist == null?0:nodelist.getLength();
+ if (i > 0)
+ {
+ for (int j = 0; j < i; j++)
+ if (nodelist.item(j) instanceof Text)
+ {
+ ((Text)nodelist.item(j)).setData(s);
+ return;
+ }
+ }
+ else
+ {
+ xmlElement.appendChild(factory.document.createTextNode(s));
+ }
+ }
+ }
- public void removeChildren() {
- while (xmlElement.hasChildNodes()) {
- xmlElement.removeChild(xmlElement.getFirstChild());
- }
- }
+ public boolean hasChildNodes()
+ {
+ return xmlElement.hasChildNodes();
+ }
- public void copyChildrenTo(XMLElement destination) {
- NodeList nodelist = xmlElement.getChildNodes();
- int len = nodelist == null ? 0 : nodelist.getLength();
- for (int i = 0; i < len; i++) {
- Node node = nodelist.item(i);
- destination.importNode(node, true);
- }
- }
+ public void removeChildren()
+ {
+ while (xmlElement.hasChildNodes())
+ {
+ xmlElement.removeChild(xmlElement.getFirstChild());
+ }
+ }
- public void importNode(Node node, boolean deep) {
- xmlElement.appendChild(xmlElement.getOwnerDocument().importNode(node,
- deep));
- }
+ public void copyChildrenTo(XMLElement destination)
+ {
+ NodeList nodelist = xmlElement.getChildNodes();
+ int len = nodelist == null?0:nodelist.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node node = nodelist.item(i);
+ destination.importNode(node,true);
+ }
+ }
- /**
- * This method tries to compare two XMLElements for equivalence. Due to the
- * lack of normalization, they aren't compared for equality. Elements are
- * required to have the same attributes or the same node value if attributes
- * aren't present. Attributes and node value are assumed to be mutually
- * exclusive for Jetty configuration XML files. The same non-text child
- * nodes are required to be present in an element and appear in the same
- * order. If a node type other than element or comment is encountered, this
- * method punts and returns false.
- *
- * @param obj
- * XMLElement to compare
- * @return true if the elements are equivalent
- */
- public boolean isEquivalent(XMLElement obj) {
- if (obj != null) {
- try {
- return elementsAreEquivalent(xmlElement, obj.getElementNode());
- } catch (Exception e) {
- // Catch and ignore just to be safe
- }
- }
- return false;
- }
+ public void importNode(Node node, boolean deep)
+ {
+ xmlElement.appendChild(xmlElement.getOwnerDocument().importNode(node,deep));
+ }
- /**
- * Same as isEquivalent() but doesn't ignore exceptions for test purposes.
- * This avoids hiding an expected mismatch behind an unexpected exception.
- *
- * @param obj
- * XMLElement to compare
- * @return true if the elements are equivalent
- */
- public boolean isEquivalentTest(XMLElement obj) {
- if (obj != null) {
- return elementsAreEquivalent(xmlElement, obj.getElementNode());
- }
- return false;
- }
+ /**
+ * This method tries to compare two XMLElements for equivalence. Due to the lack of normalization, they aren't compared for equality. Elements are required
+ * to have the same attributes or the same node value if attributes aren't present. Attributes and node value are assumed to be mutually exclusive for Jetty
+ * configuration XML files. The same non-text child nodes are required to be present in an element and appear in the same order. If a node type other than
+ * element or comment is encountered, this method punts and returns false.
+ *
+ * @param obj
+ * XMLElement to compare
+ * @return true if the elements are equivalent
+ */
+ public boolean isEquivalent(XMLElement obj)
+ {
+ if (obj != null)
+ {
+ try
+ {
+ return elementsAreEquivalent(xmlElement,obj.getElementNode());
+ }
+ catch (Exception e)
+ {
+ // Catch and ignore just to be safe
+ }
+ }
+ return false;
+ }
- private static boolean elementsAreEquivalent(Element element,
- Element otherElement) {
- if (element == otherElement)
- return true;
+ /**
+ * Same as isEquivalent() but doesn't ignore exceptions for test purposes. This avoids hiding an expected mismatch behind an unexpected exception.
+ *
+ * @param obj
+ * XMLElement to compare
+ * @return true if the elements are equivalent
+ */
+ public boolean isEquivalentTest(XMLElement obj)
+ {
+ if (obj != null)
+ {
+ return elementsAreEquivalent(xmlElement,obj.getElementNode());
+ }
+ return false;
+ }
- if (!element.getNodeName().equals(otherElement.getNodeName()))
- return false;
+ private static boolean elementsAreEquivalent(Element element, Element otherElement)
+ {
+ if (element == otherElement)
+ return true;
- if (element.hasChildNodes()) {
- if (otherElement.hasChildNodes()
- && attributesAreEqual(element, otherElement)) {
- // Compare child nodes
- NodeList nodelist = element.getChildNodes();
- NodeList otherNodelist = otherElement.getChildNodes();
- if (nodelist.getLength() == otherNodelist.getLength()) {
- Node node = nextNonTextNode(element.getFirstChild());
- Node otherNode = nextNonTextNode(otherElement
- .getFirstChild());
- while (node != null) {
- if (otherNode == null)
- return false;
- short nextNodeType = node.getNodeType();
- if (nextNodeType != otherNode.getNodeType())
- return false;
- // If elements, compare
- if (nextNodeType == Node.ELEMENT_NODE) {
- if (!elementsAreEquivalent((Element) node,
- (Element) otherNode))
- return false;
- }
- // Else if comment, compare
- else if (nextNodeType == Node.COMMENT_NODE) {
- if (!nodeValuesAreEqual(node, otherNode))
- return false;
- }
- // Else punt on other node types
- else {
- return false;
- }
- node = nextNonTextNode(node.getNextSibling());
- otherNode = nextNonTextNode(otherNode.getNextSibling());
- }
- // If also at end of other children, return equal
- if (otherNode == null)
- return true;
- }
- }
- } else if (!otherElement.hasChildNodes()) {
- return attributesAreEqual(element, otherElement);
- }
- return false;
- }
+ if (!element.getNodeName().equals(otherElement.getNodeName()))
+ return false;
- private static Node nextNonTextNode(Node node) {
- while (node != null && node.getNodeType() == Node.TEXT_NODE)
- node = node.getNextSibling();
- return node;
- }
+ if (element.hasChildNodes())
+ {
+ if (otherElement.hasChildNodes() && attributesAreEqual(element,otherElement))
+ {
+ // Compare child nodes
+ NodeList nodelist = element.getChildNodes();
+ NodeList otherNodelist = otherElement.getChildNodes();
+ if (nodelist.getLength() == otherNodelist.getLength())
+ {
+ Node node = nextNonTextNode(element.getFirstChild());
+ Node otherNode = nextNonTextNode(otherElement.getFirstChild());
+ while (node != null)
+ {
+ if (otherNode == null)
+ return false;
+ short nextNodeType = node.getNodeType();
+ if (nextNodeType != otherNode.getNodeType())
+ return false;
+ // If elements, compare
+ if (nextNodeType == Node.ELEMENT_NODE)
+ {
+ if (!elementsAreEquivalent((Element)node,(Element)otherNode))
+ return false;
+ }
+ // Else if comment, compare
+ else if (nextNodeType == Node.COMMENT_NODE)
+ {
+ if (!nodeValuesAreEqual(node,otherNode))
+ return false;
+ }
+ // Else punt on other node types
+ else
+ {
+ return false;
+ }
+ node = nextNonTextNode(node.getNextSibling());
+ otherNode = nextNonTextNode(otherNode.getNextSibling());
+ }
+ // If also at end of other children, return equal
+ if (otherNode == null)
+ return true;
+ }
+ }
+ }
+ else if (!otherElement.hasChildNodes())
+ {
+ return attributesAreEqual(element,otherElement);
+ }
+ return false;
+ }
- private static boolean attributesAreEqual(Element element,
- Element otherElement) {
- NamedNodeMap attrs = element.getAttributes();
- NamedNodeMap otherAttrs = otherElement.getAttributes();
- if (attrs == null && otherAttrs == null) {
- // Return comparison of element values if there are no attributes
- return nodeValuesAreEqual(element, otherElement);
- }
+ private static Node nextNonTextNode(Node node)
+ {
+ while (node != null && node.getNodeType() == Node.TEXT_NODE)
+ node = node.getNextSibling();
+ return node;
+ }
- if (attrs.getLength() == otherAttrs.getLength()) {
- if (attrs.getLength() == 0)
- // Return comparison of element values if there are no
- // attributes
- return nodeValuesAreEqual(element, otherElement);
+ private static boolean attributesAreEqual(Element element, Element otherElement)
+ {
+ NamedNodeMap attrs = element.getAttributes();
+ NamedNodeMap otherAttrs = otherElement.getAttributes();
+ if (attrs == null && otherAttrs == null)
+ {
+ // Return comparison of element values if there are no attributes
+ return nodeValuesAreEqual(element,otherElement);
+ }
- for (int i = 0; i < attrs.getLength(); i++) {
- Node attr = attrs.item(i);
- Node otherAttr = otherAttrs.getNamedItem(attr.getNodeName());
- if (!nodeValuesAreEqual(attr, otherAttr))
- return false;
- }
- return true;
- }
- return false;
- }
+ if (attrs.getLength() == otherAttrs.getLength())
+ {
+ if (attrs.getLength() == 0)
+ // Return comparison of element values if there are no
+ // attributes
+ return nodeValuesAreEqual(element,otherElement);
- private static boolean nodeValuesAreEqual(Node node, Node otherNode) {
- String value = node.getNodeValue();
- String otherValue = otherNode.getNodeValue();
- if (value != null && otherValue != null) {
- if (value.equals(otherValue))
- return true;
- } else if (value == null && otherValue == null)
- return true;
- return false;
- }
+ for (int i = 0; i < attrs.getLength(); i++)
+ {
+ Node attr = attrs.item(i);
+ Node otherAttr = otherAttrs.getNamedItem(attr.getNodeName());
+ if (!nodeValuesAreEqual(attr,otherAttr))
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private static boolean nodeValuesAreEqual(Node node, Node otherNode)
+ {
+ String value = node.getNodeValue();
+ String otherValue = otherNode.getNodeValue();
+ if (value != null && otherValue != null)
+ {
+ if (value.equals(otherValue))
+ return true;
+ }
+ else if (value == null && otherValue == null)
+ return true;
+ return false;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/XMLUtil.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/XMLUtil.java
index defb7d6..7e3767d 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/XMLUtil.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/XMLUtil.java
@@ -37,394 +37,496 @@
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+
/**
* Utility class to create and read XML documents.
*/
-public class XMLUtil {
- private static DocumentBuilder documentBuilder;
+public class XMLUtil
+{
+ private static DocumentBuilder documentBuilder;
- /**
- * XMLUtil constructor comment.
- */
- public XMLUtil() {
- super();
- }
-
- public static DocumentBuilder getDocumentBuilder() {
- if (documentBuilder == null)
- try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(false);
- factory.setExpandEntityReferences(false);
- // In case we happen to have a Xerces parser, try to set the feature that allows Java encodings to be used
- try {
- factory.setFeature("http://apache.org/xml/features/allow-java-encodings", true);
- }
- catch (ParserConfigurationException e) {
- // Ignore if feature isn't supported
- }
- //factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd", new Boolean(false));
- documentBuilder = factory.newDocumentBuilder();
- documentBuilder.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- return new InputSource(new ByteArrayInputStream(new byte[0]));
- }
- });
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error creating document builder");
- }
+ /**
+ * XMLUtil constructor comment.
+ */
+ public XMLUtil()
+ {
+ super();
+ }
- return documentBuilder;
- }
+ public static DocumentBuilder getDocumentBuilder()
+ {
+ if (documentBuilder == null)
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(false);
+ factory.setExpandEntityReferences(false);
+ // In case we happen to have a Xerces parser, try to set the feature that allows Java encodings to be used
+ try
+ {
+ factory.setFeature("http://apache.org/xml/features/allow-java-encodings",true);
+ }
+ catch (ParserConfigurationException e)
+ {
+ // Ignore if feature isn't supported
+ }
+ // factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd", new Boolean(false));
+ documentBuilder = factory.newDocumentBuilder();
+ documentBuilder.setEntityResolver(new EntityResolver()
+ {
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ return new InputSource(new ByteArrayInputStream(new byte[0]));
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ Trace.trace(Trace.SEVERE,"Error creating document builder");
+ }
- /**
- * Create a child of the given node at the given index.
- *
- * @param doc a document
- * @param element an element
- * @param index an index
- * @param nodeName a node name
- * @return org.w3c.dom.Element
- */
- public static Element createChildElement(Document doc, Element element, int index, String nodeName) {
- Element element2 = doc.createElement(nodeName);
- try {
- NodeList childList = element.getElementsByTagName(nodeName);
- Node child = childList.item(index);
- element.insertBefore(element2, child);
- } catch (Exception e) {
- element.appendChild(element2);
- }
- return element2;
- }
+ return documentBuilder;
+ }
- /**
- * Create a child of the given node.
- *
- * @param doc a document
- * @param node a node
- * @param nodeName a node name
- * @return org.w3c.dom.Element
- */
- public static Element createChildElement(Document doc, Node node, String nodeName) {
- Element element = doc.createElement(nodeName);
- node.appendChild(element);
- return element;
- }
+ /**
+ * Create a child of the given node at the given index.
+ *
+ * @param doc
+ * a document
+ * @param element
+ * an element
+ * @param index
+ * an index
+ * @param nodeName
+ * a node name
+ * @return org.w3c.dom.Element
+ */
+ public static Element createChildElement(Document doc, Element element, int index, String nodeName)
+ {
+ Element element2 = doc.createElement(nodeName);
+ try
+ {
+ NodeList childList = element.getElementsByTagName(nodeName);
+ Node child = childList.item(index);
+ element.insertBefore(element2,child);
+ }
+ catch (Exception e)
+ {
+ element.appendChild(element2);
+ }
+ return element2;
+ }
- /*
- * Set the value of the given node to the given text.
- */
- public static void createTextChildElement(Document doc, Node node, String name, String value) {
- Element element = createChildElement(doc, node, name);
- element.appendChild(doc.createTextNode(value));
- }
+ /**
+ * Create a child of the given node.
+ *
+ * @param doc
+ * a document
+ * @param node
+ * a node
+ * @param nodeName
+ * a node name
+ * @return org.w3c.dom.Element
+ */
+ public static Element createChildElement(Document doc, Node node, String nodeName)
+ {
+ Element element = doc.createElement(nodeName);
+ node.appendChild(element);
+ return element;
+ }
- /**
- * Return the attribute value.
- * @return java.lang.String
- * @param element org.w3c.dom.Element
- * @param attr java.lang.String
- */
- public static String getAttributeValue(Element element, String attr) {
- return element.getAttributeNode(attr).getValue();
- }
+ /*
+ * Set the value of the given node to the given text.
+ */
+ public static void createTextChildElement(Document doc, Node node, String name, String value)
+ {
+ Element element = createChildElement(doc,node,name);
+ element.appendChild(doc.createTextNode(value));
+ }
- public static byte[] getContents(Document document) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try {
- print(new PrintStream(out, true, "UTF-8"), document);
- return out.toByteArray();
- } catch (Exception ex) {
- throw new IOException(ex.getLocalizedMessage());
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
+ /**
+ * Return the attribute value.
+ *
+ * @return java.lang.String
+ * @param element
+ * org.w3c.dom.Element
+ * @param attr
+ * java.lang.String
+ */
+ public static String getAttributeValue(Element element, String attr)
+ {
+ return element.getAttributeNode(attr).getValue();
+ }
- protected static String getDocumentTypeData(DocumentType doctype) {
- String data = doctype.getName();
- if (doctype.getPublicId() != null) {
- data += " PUBLIC \"" + doctype.getPublicId() + "\"";
- String systemId = doctype.getSystemId();
- if (systemId == null)
- systemId = "";
- data += " \"" + systemId + "\"";
- } else
- data += " SYSTEM \"" + doctype.getSystemId() + "\"";
-
- return data;
- }
+ public static byte[] getContents(Document document) throws IOException
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ try
+ {
+ print(new PrintStream(out,true,"UTF-8"),document);
+ return out.toByteArray();
+ }
+ catch (Exception ex)
+ {
+ throw new IOException(ex.getLocalizedMessage());
+ }
+ finally
+ {
+ if (out != null)
+ try
+ {
+ out.close();
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ }
+ }
- /**
- * Return an iterator for the subelements.
- * @return java.util.Iterator
- * @param element org.w3c.dom.Element
- * @param name java.lang.String
- */
- public static Iterator getNodeIterator(Element element, String name) {
- List list = new ArrayList();
- NodeList nodeList = element.getElementsByTagName(name);
-
- int length = nodeList.getLength();
- for (int i = 0; i < length; i++)
- list.add(nodeList.item(i));
-
- return list.iterator();
- }
+ protected static String getDocumentTypeData(DocumentType doctype)
+ {
+ String data = doctype.getName();
+ if (doctype.getPublicId() != null)
+ {
+ data += " PUBLIC \"" + doctype.getPublicId() + "\"";
+ String systemId = doctype.getSystemId();
+ if (systemId == null)
+ systemId = "";
+ data += " \"" + systemId + "\"";
+ }
+ else
+ data += " SYSTEM \"" + doctype.getSystemId() + "\"";
- /**
- * Get the value of this node. Will return "" instead of null.
- * @return java.lang.String
- * @param node org.w3c.dom.Node
- */
- public static String getNodeValue(Node node) {
- NodeList nodeList = node.getChildNodes();
-
- int length = nodeList.getLength();
- for (int i = 0; i < length; i++) {
- Node n = nodeList.item(i);
- if (n instanceof Text) {
- Text t = (Text) n;
- return t.getNodeValue();
- }
- }
- return "";
- }
+ return data;
+ }
- /*
- * Get the value of a subnode.
+ /**
+ * Return an iterator for the subelements.
+ *
+ * @return java.util.Iterator
+ * @param element
+ * org.w3c.dom.Element
+ * @param name
+ * java.lang.String
+ */
+ public static Iterator<Node> getNodeIterator(Element element, String name)
+ {
+ List<Node> list = new ArrayList<Node>();
+ NodeList nodeList = element.getElementsByTagName(name);
- * @return java.lang.String
- */
- public static String getSubNodeValue(Element element, String name) {
- NodeList nodeList = element.getElementsByTagName(name);
- return getNodeValue(nodeList.item(0)).trim();
- }
+ int length = nodeList.getLength();
+ for (int i = 0; i < length; i++)
+ list.add(nodeList.item(i));
- /*
- * Insert the given text.
- */
- public static void insertText(Document doc, Node node, String text) {
- node.appendChild(doc.createCDATASection(text));
- }
+ return list.iterator();
+ }
- protected static String normalize(String s) {
- StringBuffer stringbuffer = new StringBuffer();
- int i = s == null ? 0 : s.length();
- for (int j = 0; j < i; j++) {
- char c = s.charAt(j);
- switch (c) {
- case 60 : /* '<' */
- stringbuffer.append("<");
- break;
-
- case 62 : /* '>' */
- stringbuffer.append(">");
- break;
-
- case 38 : /* '&' */
- stringbuffer.append("&");
- break;
-
- case 34 : /* '"' */
- stringbuffer.append(""");
- break;
-
- case 10 : /* '\n' */
- case 13 : /* '\r' */
- default :
- stringbuffer.append(c);
- break;
-
- }
- }
-
- return stringbuffer.toString();
- }
+ /**
+ * Get the value of this node. Will return "" instead of null.
+ *
+ * @return java.lang.String
+ * @param node
+ * org.w3c.dom.Node
+ */
+ public static String getNodeValue(Node node)
+ {
+ NodeList nodeList = node.getChildNodes();
- protected static void print(PrintStream out, Node node) {
- if (node == null)
- return;
- short type = node.getNodeType();
- switch (type) {
- case Node.DOCUMENT_NODE: {
- out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- //out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
- NodeList nodelist = node.getChildNodes();
- int size = nodelist.getLength();
- for (int i = 0; i < size; i++)
- print(out, nodelist.item(i));
- break;
- }
-
- case Node.DOCUMENT_TYPE_NODE: {
- DocumentType docType = (DocumentType) node;
- out.print("<!DOCTYPE " + getDocumentTypeData(docType) + ">\n");
- break;
- }
-
- case Node.ELEMENT_NODE: {
- out.print('<');
- out.print(node.getNodeName());
- NamedNodeMap map = node.getAttributes();
- if (map != null) {
- int size = map.getLength();
- for (int i = 0; i < size; i++) {
- Attr attr = (Attr) map.item(i);
- out.print(' ');
- out.print(attr.getNodeName());
- out.print("=\"");
- out.print(normalize(attr.getNodeValue()));
- out.print('"');
- }
- }
-
- if (!node.hasChildNodes())
- out.print("/>");
- else {
- out.print('>');
- NodeList nodelist = node.getChildNodes();
- int numChildren = nodelist.getLength();
- for (int i = 0; i < numChildren; i++)
- print(out, nodelist.item(i));
-
- out.print("</");
- out.print(node.getNodeName());
- out.print('>');
- }
- break;
- }
-
- case Node.ENTITY_REFERENCE_NODE: {
- NodeList nodelist = node.getChildNodes();
- if (nodelist != null) {
- int size = nodelist.getLength();
- for (int i = 0; i < size; i++)
- print(out, nodelist.item(i));
-
- }
- break;
- }
-
- case Node.CDATA_SECTION_NODE: {
- out.print(normalize(node.getNodeValue()));
- break;
- }
-
- case Node.TEXT_NODE: {
- out.print(normalize(node.getNodeValue()));
- break;
- }
-
- case Node.PROCESSING_INSTRUCTION_NODE: {
- out.print("<?");
- out.print(node.getNodeName());
- String s = node.getNodeValue();
- if (s != null && s.length() > 0) {
- out.print(' ');
- out.print(s);
- }
- out.print("?>");
- break;
- }
-
- case Node.COMMENT_NODE: {
- out.print("<!--");
- out.print(node.getNodeValue());
- out.print("-->");
- break;
- }
-
- default: {
- out.print(normalize(node.getNodeValue()));
- break;
- }
- }
- out.flush();
- }
+ int length = nodeList.getLength();
+ for (int i = 0; i < length; i++)
+ {
+ Node n = nodeList.item(i);
+ if (n instanceof Text)
+ {
+ Text t = (Text)n;
+ return t.getNodeValue();
+ }
+ }
+ return "";
+ }
- public static void save(String filename, Document document) throws IOException {
- PrintStream out = null;
- try {
- out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)), true, "UTF-8");
- //traceNode(document, "");
- print(out, document);
- } catch (Exception ex) {
- throw new IOException(ex.getLocalizedMessage());
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
+ /*
+ * Get the value of a subnode.
+ *
+ * @return java.lang.String
+ */
+ public static String getSubNodeValue(Element element, String name)
+ {
+ NodeList nodeList = element.getElementsByTagName(name);
+ return getNodeValue(nodeList.item(0)).trim();
+ }
- public static void save(String filename, Node node) throws IOException {
- PrintStream out = null;
- try {
- out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)), true, "UTF-8");
- print(out, node);
- } catch (Exception ex) {
- throw new IOException(ex.getLocalizedMessage());
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
+ /*
+ * Insert the given text.
+ */
+ public static void insertText(Document doc, Node node, String text)
+ {
+ node.appendChild(doc.createCDATASection(text));
+ }
- /*
- * Set the value of the subnode
- *
- * @param name java.lang.String
- * @param value java.lang.String
- */
- public static void setNodeValue(Node node, String name, String value) {
- String s = node.getNodeValue();
- if (s != null) {
- node.setNodeValue(value);
- return;
- }
- NodeList nodelist = node.getChildNodes();
- for (int i = 0; i < nodelist.getLength(); i++) {
- if (nodelist.item(i) instanceof Text) {
- Text text = (Text) nodelist.item(i);
- text.setData(value);
- return;
- }
- }
- return;
- }
+ protected static String normalize(String s)
+ {
+ StringBuffer stringbuffer = new StringBuffer();
+ int i = s == null?0:s.length();
+ for (int j = 0; j < i; j++)
+ {
+ char c = s.charAt(j);
+ switch (c)
+ {
+ case 60: /* '<' */
+ stringbuffer.append("<");
+ break;
- public static String toString(Document document) {
- PrintStream out = null;
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
- out = new PrintStream(baos);
- print(out, document);
- return new String(baos.toByteArray(), "UTF-8");
- } catch (Exception ex) {
- // ignore
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- return null;
- }
+ case 62: /* '>' */
+ stringbuffer.append(">");
+ break;
+
+ case 38: /* '&' */
+ stringbuffer.append("&");
+ break;
+
+ case 34: /* '"' */
+ stringbuffer.append(""");
+ break;
+
+ case 10: /* '\n' */
+ case 13: /* '\r' */
+ default:
+ stringbuffer.append(c);
+ break;
+
+ }
+ }
+
+ return stringbuffer.toString();
+ }
+
+ protected static void print(PrintStream out, Node node)
+ {
+ if (node == null)
+ return;
+ short type = node.getNodeType();
+ switch (type)
+ {
+ case Node.DOCUMENT_NODE:
+ {
+ out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ // out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
+ NodeList nodelist = node.getChildNodes();
+ int size = nodelist.getLength();
+ for (int i = 0; i < size; i++)
+ print(out,nodelist.item(i));
+ break;
+ }
+
+ case Node.DOCUMENT_TYPE_NODE:
+ {
+ DocumentType docType = (DocumentType)node;
+ out.print("<!DOCTYPE " + getDocumentTypeData(docType) + ">\n");
+ break;
+ }
+
+ case Node.ELEMENT_NODE:
+ {
+ out.print('<');
+ out.print(node.getNodeName());
+ NamedNodeMap map = node.getAttributes();
+ if (map != null)
+ {
+ int size = map.getLength();
+ for (int i = 0; i < size; i++)
+ {
+ Attr attr = (Attr)map.item(i);
+ out.print(' ');
+ out.print(attr.getNodeName());
+ out.print("=\"");
+ out.print(normalize(attr.getNodeValue()));
+ out.print('"');
+ }
+ }
+
+ if (!node.hasChildNodes())
+ out.print("/>");
+ else
+ {
+ out.print('>');
+ NodeList nodelist = node.getChildNodes();
+ int numChildren = nodelist.getLength();
+ for (int i = 0; i < numChildren; i++)
+ print(out,nodelist.item(i));
+
+ out.print("</");
+ out.print(node.getNodeName());
+ out.print('>');
+ }
+ break;
+ }
+
+ case Node.ENTITY_REFERENCE_NODE:
+ {
+ NodeList nodelist = node.getChildNodes();
+ if (nodelist != null)
+ {
+ int size = nodelist.getLength();
+ for (int i = 0; i < size; i++)
+ print(out,nodelist.item(i));
+
+ }
+ break;
+ }
+
+ case Node.CDATA_SECTION_NODE:
+ {
+ out.print(normalize(node.getNodeValue()));
+ break;
+ }
+
+ case Node.TEXT_NODE:
+ {
+ out.print(normalize(node.getNodeValue()));
+ break;
+ }
+
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ {
+ out.print("<?");
+ out.print(node.getNodeName());
+ String s = node.getNodeValue();
+ if (s != null && s.length() > 0)
+ {
+ out.print(' ');
+ out.print(s);
+ }
+ out.print("?>");
+ break;
+ }
+
+ case Node.COMMENT_NODE:
+ {
+ out.print("<!--");
+ out.print(node.getNodeValue());
+ out.print("-->");
+ break;
+ }
+
+ default:
+ {
+ out.print(normalize(node.getNodeValue()));
+ break;
+ }
+ }
+ out.flush();
+ }
+
+ public static void save(String filename, Document document) throws IOException
+ {
+ PrintStream out = null;
+ try
+ {
+ out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)),true,"UTF-8");
+ // traceNode(document, "");
+ print(out,document);
+ }
+ catch (Exception ex)
+ {
+ throw new IOException(ex.getLocalizedMessage());
+ }
+ finally
+ {
+ if (out != null)
+ try
+ {
+ out.close();
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ }
+ }
+
+ public static void save(String filename, Node node) throws IOException
+ {
+ PrintStream out = null;
+ try
+ {
+ out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)),true,"UTF-8");
+ print(out,node);
+ }
+ catch (Exception ex)
+ {
+ throw new IOException(ex.getLocalizedMessage());
+ }
+ finally
+ {
+ if (out != null)
+ try
+ {
+ out.close();
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ }
+ }
+
+ /*
+ * Set the value of the subnode
+ *
+ * @param name java.lang.String
+ *
+ * @param value java.lang.String
+ */
+ public static void setNodeValue(Node node, String name, String value)
+ {
+ String s = node.getNodeValue();
+ if (s != null)
+ {
+ node.setNodeValue(value);
+ return;
+ }
+ NodeList nodelist = node.getChildNodes();
+ for (int i = 0; i < nodelist.getLength(); i++)
+ {
+ if (nodelist.item(i) instanceof Text)
+ {
+ Text text = (Text)nodelist.item(i);
+ text.setData(value);
+ return;
+ }
+ }
+ return;
+ }
+
+ public static String toString(Document document)
+ {
+ PrintStream out = null;
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
+ out = new PrintStream(baos);
+ print(out,document);
+ return new String(baos.toByteArray(),"UTF-8");
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ finally
+ {
+ if (out != null)
+ try
+ {
+ out.close();
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/ServerInstance.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/ServerInstance.java
index bbacc98..a1790be 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/ServerInstance.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/ServerInstance.java
@@ -33,213 +33,245 @@
import org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.webapp.WebAppContext;
import org.xml.sax.SAXException;
-public class ServerInstance {
+public class ServerInstance
+{
- private List<Server> jettyServers;
- private IPath runtimeBaseDirectory;
- private boolean contextsLoaded = false;
- private List<WebAppContext> webAppContexts = new ArrayList<WebAppContext>();
- private WebApp webApp = null;
+ private List<Server> jettyServers;
+ private IPath runtimeBaseDirectory;
+ private boolean contextsLoaded = false;
+ private List<WebAppContext> webAppContexts = new ArrayList<WebAppContext>();
+ private WebApp webApp = null;
- public ServerInstance(List<Server> jettyServers, WebApp webApp,
- IPath runtimeBaseDirectory) {
- if (jettyServers == null)
- throw new IllegalArgumentException(
- "Jetty Server argument may not be null.");
- this.jettyServers = jettyServers;
- this.runtimeBaseDirectory = runtimeBaseDirectory;
- this.webApp = webApp;
- }
+ public ServerInstance(List<Server> jettyServers, WebApp webApp, IPath runtimeBaseDirectory)
+ {
+ if (jettyServers == null)
+ throw new IllegalArgumentException("Jetty Server argument may not be null.");
+ this.jettyServers = jettyServers;
+ this.runtimeBaseDirectory = runtimeBaseDirectory;
+ this.webApp = webApp;
+ }
- public List<Connector> getConnectors() {
- List<Connector> allConnectors = null;
- List<Connector> serverConnectors = null;
- for (Server server : jettyServers) {
- serverConnectors = server.getConnectors();
- if (serverConnectors != null) {
- if (allConnectors == null) {
- allConnectors = new ArrayList<Connector>();
- }
- allConnectors.addAll(serverConnectors);
- }
- }
- return allConnectors;
- }
+ public List<Connector> getConnectors()
+ {
+ List<Connector> allConnectors = null;
+ List<Connector> serverConnectors = null;
+ for (Server server : jettyServers)
+ {
+ serverConnectors = server.getConnectors();
+ if (serverConnectors != null)
+ {
+ if (allConnectors == null)
+ {
+ allConnectors = new ArrayList<Connector>();
+ }
+ allConnectors.addAll(serverConnectors);
+ }
+ }
+ return allConnectors;
+ }
- public boolean removeContext(int index) {
- if (index >= webAppContexts.size())
- return false;
- WebAppContext webAppContext = webAppContexts.remove(index);
- if (webAppContext != null) {
- IPath contextFilePath = getXMLContextFilePath(webAppContext
- .getContextPath());
- File contextFile = contextFilePath.toFile();
- if (contextFile.exists()) {
- contextFile.delete();
- }
- }
- return (webAppContext != null);
- }
+ public boolean removeContext(int index)
+ {
+ if (index >= webAppContexts.size())
+ return false;
+ WebAppContext webAppContext = webAppContexts.remove(index);
+ if (webAppContext != null)
+ {
+ IPath contextFilePath = getXMLContextFilePath(webAppContext.getContextPath());
+ File contextFile = contextFilePath.toFile();
+ if (contextFile.exists())
+ {
+ contextFile.delete();
+ }
+ }
+ return (webAppContext != null);
+ }
- public List<Server> getJettyServers() {
- return jettyServers;
- }
+ public List<Server> getJettyServers()
+ {
+ return jettyServers;
+ }
- public void save(final IFolder folder, IProgressMonitor monitor)
- throws IOException, CoreException {
- IPath path = null;
- String filename = null;
- byte[] data = null;
- InputStream in = null;
- IFolder newFolder = folder;
- for (Server jettyServer : jettyServers) {
- path = jettyServer.getPath();
- if (path.segmentCount() > 1) {
- newFolder = folder.getFolder(path.removeLastSegments(1));
- IOUtils.createFolder(newFolder, monitor);
- }
+ public void save(final IFolder folder, IProgressMonitor monitor) throws IOException, CoreException
+ {
+ IPath path = null;
+ String filename = null;
+ byte[] data = null;
+ InputStream in = null;
+ IFolder newFolder = folder;
+ for (Server jettyServer : jettyServers)
+ {
+ path = jettyServer.getPath();
+ if (path.segmentCount() > 1)
+ {
+ newFolder = folder.getFolder(path.removeLastSegments(1));
+ IOUtils.createFolder(newFolder,monitor);
+ }
- filename = jettyServer.getFile().getName();
- data = jettyServer.getFactory().getContents();
- in = new ByteArrayInputStream(data);
- IFile file = newFolder.getFile(filename);
- if (file.exists()) {
- // if (isServerDirty)
- file.setContents(in, true, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- // else
- // monitor.worked(200);
- } else
- file.create(in, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- }
- if (webApp != null) {
- path = webApp.getPath();
- if (path.segmentCount() > 1) {
- newFolder = folder.getFolder(path.removeLastSegments(1));
- IOUtils.createFolder(newFolder, monitor);
- }
+ filename = jettyServer.getFile().getName();
+ data = jettyServer.getFactory().getContents();
+ in = new ByteArrayInputStream(data);
+ IFile file = newFolder.getFile(filename);
+ if (file.exists())
+ {
+ // if (isServerDirty)
+ file.setContents(in,true,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ // else
+ // monitor.worked(200);
+ }
+ else
+ file.create(in,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ }
+ if (webApp != null)
+ {
+ path = webApp.getPath();
+ if (path.segmentCount() > 1)
+ {
+ newFolder = folder.getFolder(path.removeLastSegments(1));
+ IOUtils.createFolder(newFolder,monitor);
+ }
- filename = webApp.getFile().getName();
- data = webApp.getFactory().getContents();
- in = new ByteArrayInputStream(data);
- IFile file = newFolder.getFile(filename);
- if (file.exists()) {
- // if (isServerDirty)
- file.setContents(in, true, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- // else
- // monitor.worked(200);
- } else
- file.create(in, true,
- ProgressUtil.getSubMonitorFor(monitor, 200));
- }
+ filename = webApp.getFile().getName();
+ data = webApp.getFactory().getContents();
+ in = new ByteArrayInputStream(data);
+ IFile file = newFolder.getFile(filename);
+ if (file.exists())
+ {
+ // if (isServerDirty)
+ file.setContents(in,true,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ // else
+ // monitor.worked(200);
+ }
+ else
+ file.create(in,true,ProgressUtil.getSubMonitorFor(monitor,200));
+ }
- }
+ }
- public WebAppContext createContext(String documentBase, String memento,
- String path) throws IOException, SAXException {
- loadContextsIfNeeded();
- String pathWithoutSlash = path;
- if (pathWithoutSlash.startsWith("/")) {
- pathWithoutSlash = pathWithoutSlash.substring(1,
- pathWithoutSlash.length());
- }
- WebAppContext context = createContext(WebAppContext.class
- .getResourceAsStream("WebAppContext.xml"));
- context.setContextPath(pathWithoutSlash);
+ public WebAppContext createContext(String documentBase, String memento, String path) throws IOException, SAXException
+ {
+ loadContextsIfNeeded();
+ String pathWithoutSlash = path;
+ if (pathWithoutSlash.startsWith("/"))
+ {
+ pathWithoutSlash = pathWithoutSlash.substring(1,pathWithoutSlash.length());
+ }
+ WebAppContext context = createContext(WebAppContext.class.getResourceAsStream("WebAppContext.xml"));
+ context.setContextPath(pathWithoutSlash);
- File f = new File(documentBase);
- if (f.exists()) {
- context.setWar(documentBase, true);
- } else {
- context.setWar("/wtpwebapps/" + pathWithoutSlash, false);
- }
+ File f = new File(documentBase);
+ if (f.exists())
+ {
+ context.setWar(documentBase,true);
+ }
+ else
+ {
+ context.setWar("/wtpwebapps/" + pathWithoutSlash,false);
+ }
- IPath contextFilePath = getXMLContextFilePath(pathWithoutSlash);
- context.setSaveFile(contextFilePath.toFile());
- context.save();
- return context;
- }
+ IPath contextFilePath = getXMLContextFilePath(pathWithoutSlash);
+ context.setSaveFile(contextFilePath.toFile());
+ context.save();
+ return context;
+ }
- private IPath getXMLContextFilePath(String path) {
- String pathWithoutSlash = path;
- if (pathWithoutSlash.startsWith("/")) {
- pathWithoutSlash = pathWithoutSlash.substring(1,
- pathWithoutSlash.length());
- }
- // Save it as file in the WTP /contexts
- String fileName = pathWithoutSlash + ".xml";
- IPath contextFolderPath = runtimeBaseDirectory.append("contexts");
- File folder = contextFolderPath.toFile();
- if (!folder.exists()) {
- folder.mkdirs();
- }
- return contextFolderPath.append(fileName);
- }
+ private IPath getXMLContextFilePath(String path)
+ {
+ String pathWithoutSlash = path;
+ if (pathWithoutSlash.startsWith("/"))
+ {
+ pathWithoutSlash = pathWithoutSlash.substring(1,pathWithoutSlash.length());
+ }
+ // Save it as file in the WTP /contexts
+ String fileName = pathWithoutSlash + ".xml";
+ IPath contextFolderPath = runtimeBaseDirectory.append("contexts");
+ File folder = contextFolderPath.toFile();
+ if (!folder.exists())
+ {
+ folder.mkdirs();
+ }
+ return contextFolderPath.append(fileName);
+ }
- private WebAppContext createContext(InputStream stream) throws IOException,
- SAXException {
- Factory webAppContextFactory = new Factory();
- webAppContextFactory
- .setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.webapp");
- WebAppContext context = (WebAppContext) webAppContextFactory
- .loadDocument(stream);
- webAppContexts.add(context);
- return context;
- }
+ private WebAppContext createContext(InputStream stream) throws IOException, SAXException
+ {
+ Factory webAppContextFactory = new Factory();
+ webAppContextFactory.setPackageName("org.eclipse.jst.server.jetty.core.internal.xml.jetyy70.webapp");
+ WebAppContext context = (WebAppContext)webAppContextFactory.loadDocument(stream);
+ webAppContexts.add(context);
+ return context;
+ }
- private void loadContextsIfNeeded() {
- if (contextsLoaded)
- return;
- try {
- WebAppContext context = null;
- IPath contexts = runtimeBaseDirectory.append("contexts");
- File contextsFolder = contexts.toFile();
- if (contextsFolder.exists()) {
- InputStream stream = null;
- File f = null;
- File[] files = contextsFolder.listFiles();
- for (int i = 0; i < files.length; i++) {
- f = files[i];
- try {
- stream = new FileInputStream(f);
- context = createContext(stream);
- context.setSaveFile(f);
- } catch (Throwable e) {
- e.printStackTrace();
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
- } finally {
- contextsLoaded = true;
- }
- }
+ private void loadContextsIfNeeded()
+ {
+ if (contextsLoaded)
+ return;
+ try
+ {
+ WebAppContext context = null;
+ IPath contexts = runtimeBaseDirectory.append("contexts");
+ File contextsFolder = contexts.toFile();
+ if (contextsFolder.exists())
+ {
+ InputStream stream = null;
+ File f = null;
+ File[] files = contextsFolder.listFiles();
+ for (int i = 0; i < files.length; i++)
+ {
+ f = files[i];
+ try
+ {
+ stream = new FileInputStream(f);
+ context = createContext(stream);
+ context.setSaveFile(f);
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (stream != null)
+ {
+ try
+ {
+ stream.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ contextsLoaded = true;
+ }
+ }
- public Collection<WebAppContext> getContexts() {
- loadContextsIfNeeded();
- return webAppContexts;
- }
+ public Collection<WebAppContext> getContexts()
+ {
+ loadContextsIfNeeded();
+ return webAppContexts;
+ }
- public void setPort(String port) {
- List<Connector> connectors = getConnectors();
- if (connectors != null && connectors.size() > 0) {
- Connector connector = connectors.get(0);
- connector.setPort(port);
- }
+ public void setPort(String port)
+ {
+ List<Connector> connectors = getConnectors();
+ if (connectors != null && connectors.size() > 0)
+ {
+ Connector connector = connectors.get(0);
+ connector.setPort(port);
+ }
- }
+ }
- public WebAppContext getContext(int index) {
- return webAppContexts.get(index);
- }
+ public WebAppContext getContext(int index)
+ {
+ return webAppContexts.get(index);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/Connector.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/Connector.java
index 85594fe..b37504a 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/Connector.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/Connector.java
@@ -13,28 +13,34 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-public class Connector {
+public class Connector
+{
- private Element portElement;
-
- public Connector(Element portElement) {
- this.portElement = portElement;
- }
-
- public String getPort() {
- Node firstChild = portElement.getFirstChild();
- if (firstChild.getNodeType() == Node.ELEMENT_NODE) {
- // SystemProperty default=""
- return ((Element)firstChild).getAttribute("default");
-
- }
- else {
- return portElement.getTextContent();
- }
- }
-
- public void setPort(String port) {
- portElement.setTextContent(port);
- }
+ private Element portElement;
+
+ public Connector(Element portElement)
+ {
+ this.portElement = portElement;
+ }
+
+ public String getPort()
+ {
+ Node firstChild = portElement.getFirstChild();
+ if (firstChild.getNodeType() == Node.ELEMENT_NODE)
+ {
+ // SystemProperty default=""
+ return ((Element)firstChild).getAttribute("default");
+
+ }
+ else
+ {
+ return portElement.getTextContent();
+ }
+ }
+
+ public void setPort(String port)
+ {
+ portElement.setTextContent(port);
+ }
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/Server.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/Server.java
index aa6d789..aad7737 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/Server.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/Server.java
@@ -19,48 +19,56 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-public class Server extends XMLElement {
+public class Server extends XMLElement
+{
- private File file;
- private IPath path;
-
- public List<Connector> getConnectors() {
- List<Connector> connectors = null;
- NodeList callNodes = getElementNode().getElementsByTagName("Call");
- int length = callNodes.getLength();
- Element node = null;
- for (int i = 0; i < length; i++) {
- node = (Element)callNodes.item(i);
- if (hasAttribute(node, "addConnector")) {
- Element portElement = super.findElement(node, "Set", "port");
- if (portElement != null) {
- Connector connector = new Connector(portElement);
- if (connectors == null) {
- connectors = new ArrayList<Connector>();
- }
- connectors.add(connector);
- }
- }
- }
- return connectors;
- }
+ private File file;
+ private IPath path;
- public void setFile(File jettyXMLFile) {
- this.file = jettyXMLFile;
- }
-
- public File getFile() {
- return file;
- }
+ public List<Connector> getConnectors()
+ {
+ List<Connector> connectors = null;
+ NodeList callNodes = getElementNode().getElementsByTagName("Call");
+ int length = callNodes.getLength();
+ Element node = null;
+ for (int i = 0; i < length; i++)
+ {
+ node = (Element)callNodes.item(i);
+ if (hasAttribute(node,"addConnector"))
+ {
+ Element portElement = super.findElement(node,"Set","port");
+ if (portElement != null)
+ {
+ Connector connector = new Connector(portElement);
+ if (connectors == null)
+ {
+ connectors = new ArrayList<Connector>();
+ }
+ connectors.add(connector);
+ }
+ }
+ }
+ return connectors;
+ }
- public IPath getPath() {
- return path;
- }
+ public void setFile(File jettyXMLFile)
+ {
+ this.file = jettyXMLFile;
+ }
- public void setPath(IPath path) {
- this.path = path;
- }
+ public File getFile()
+ {
+ return file;
+ }
-
-
+ public IPath getPath()
+ {
+ return path;
+ }
+
+ public void setPath(IPath path)
+ {
+ this.path = path;
+ }
+
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/WebApp.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/WebApp.java
index e15a71b..80ec428 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/WebApp.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/server/WebApp.java
@@ -15,22 +15,30 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jst.server.jetty.core.internal.xml.XMLElement;
-public class WebApp extends XMLElement {
+public class WebApp extends XMLElement
+{
- private File file;
- private IPath path;
- public File getFile() {
- return file;
- }
- public void setFile(File file) {
- this.file = file;
- }
- public IPath getPath() {
- return path;
- }
- public void setPath(IPath path) {
- this.path = path;
- }
-
-
+ private File file;
+ private IPath path;
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public void setFile(File file)
+ {
+ this.file = file;
+ }
+
+ public IPath getPath()
+ {
+ return path;
+ }
+
+ public void setPath(IPath path)
+ {
+ this.path = path;
+ }
+
}
diff --git a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/webapp/WebAppContext.java b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/webapp/WebAppContext.java
index 26f3884..f476d74 100644
--- a/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/webapp/WebAppContext.java
+++ b/org.eclipse.jst.server.jetty.core/src/org/eclipse/jst/server/jetty/core/internal/xml/jetyy70/webapp/WebAppContext.java
@@ -19,84 +19,103 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-public class WebAppContext extends XMLElement {
+public class WebAppContext extends XMLElement
+{
- private File saveFile;
- private String memento;
- private String documentBase;
+ private File saveFile;
+ private String memento;
+ private String documentBase;
- public void setContextPath(String contextPath) {
- Element element = super.findElement("Set", "contextPath");
- if (contextPath.startsWith("/")) {
- element.setTextContent(contextPath);
- } else {
- element.setTextContent("/" + contextPath);
- }
+ public void setContextPath(String contextPath)
+ {
+ Element element = super.findElement("Set","contextPath");
+ if (contextPath.startsWith("/"))
+ {
+ element.setTextContent(contextPath);
+ }
+ else
+ {
+ element.setTextContent("/" + contextPath);
+ }
- }
+ }
- public void setWar(String war, boolean isExternal) {
- Element element = super.findElement("Set", "war");
- element.setTextContent(war);
- if (!isExternal) {
- Document document = element.getOwnerDocument();
- Element systemProperty = document.createElement("SystemProperty");
- systemProperty.setAttribute("name", "jetty.home");
- systemProperty.setAttribute("default", ".");
- Node firstChild = element.getFirstChild();
- element.insertBefore(systemProperty, firstChild);
- }
- }
+ public void setWar(String war, boolean isExternal)
+ {
+ Element element = super.findElement("Set","war");
+ element.setTextContent(war);
+ if (!isExternal)
+ {
+ Document document = element.getOwnerDocument();
+ Element systemProperty = document.createElement("SystemProperty");
+ systemProperty.setAttribute("name","jetty.home");
+ systemProperty.setAttribute("default",".");
+ Node firstChild = element.getFirstChild();
+ element.insertBefore(systemProperty,firstChild);
+ }
+ }
- public String getContextPath() {
- Element element = super.findElement("Set", "contextPath");
- return element.getTextContent();
- }
+ public String getContextPath()
+ {
+ Element element = super.findElement("Set","contextPath");
+ return element.getTextContent();
+ }
- public String getWar() {
- Element element = super.findElement("Set", "war");
- return element.getTextContent();
- }
+ public String getWar()
+ {
+ Element element = super.findElement("Set","war");
+ return element.getTextContent();
+ }
- public void save() throws IOException {
- XMLUtil.save(saveFile.getCanonicalPath(), getElementNode()
- .getOwnerDocument());
- }
+ public void save() throws IOException
+ {
+ XMLUtil.save(saveFile.getCanonicalPath(),getElementNode().getOwnerDocument());
+ }
- public void setSaveFile(File saveFile) {
- this.saveFile = saveFile;
- String war = getWar();
- File warFile = new File(war);
- if (war != null && warFile.exists()) {
- try {
- this.documentBase = warFile.getCanonicalPath();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- this.documentBase = saveFile.getName();
- int index = documentBase.lastIndexOf('.');
- if (index != -1) {
- documentBase = documentBase.substring(0, index);
- }
- this.memento = "org.eclipse.jst.jee.server:" + documentBase;
- }
- }
+ public void setSaveFile(File saveFile)
+ {
+ this.saveFile = saveFile;
+ String war = getWar();
+ File warFile = new File(war);
+ if (war != null && warFile.exists())
+ {
+ try
+ {
+ this.documentBase = warFile.getCanonicalPath();
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ this.documentBase = saveFile.getName();
+ int index = documentBase.lastIndexOf('.');
+ if (index != -1)
+ {
+ documentBase = documentBase.substring(0,index);
+ }
+ this.memento = "org.eclipse.jst.jee.server:" + documentBase;
+ }
+ }
- public String getMemento() {
- return memento;
- }
+ public String getMemento()
+ {
+ return memento;
+ }
- // public void setMemento(String memento) {
- // this.memento = memento;
- // }
+ // public void setMemento(String memento) {
+ // this.memento = memento;
+ // }
- public String getDocumentBase() {
- return documentBase;
- }
+ public String getDocumentBase()
+ {
+ return documentBase;
+ }
- // public void setDocumentBase(String documentBase) {
- // this.documentBase = documentBase;
- // }
+ // public void setDocumentBase(String documentBase) {
+ // this.documentBase = documentBase;
+ // }
}
diff --git a/org.eclipse.jst.server.jetty.ui.websocket/src/org/eclipse/jst/server/jetty/ui/websocket/internal/wizard/AddWebSocketWizardPage.java b/org.eclipse.jst.server.jetty.ui.websocket/src/org/eclipse/jst/server/jetty/ui/websocket/internal/wizard/AddWebSocketWizardPage.java
index f17ad50..c533826 100644
--- a/org.eclipse.jst.server.jetty.ui.websocket/src/org/eclipse/jst/server/jetty/ui/websocket/internal/wizard/AddWebSocketWizardPage.java
+++ b/org.eclipse.jst.server.jetty.ui.websocket/src/org/eclipse/jst/server/jetty/ui/websocket/internal/wizard/AddWebSocketWizardPage.java
@@ -114,7 +114,7 @@
String text = displayNameText.getText();
// Set default URL Pattern
- List input = new ArrayList();
+ List<String[]> input = new ArrayList<String[]>();
input.add(new String[]
{ "/" + text }); //$NON-NLS-1$
if (urlSection != null)
@@ -158,7 +158,7 @@
{
String text = displayNameText.getText();
// Set default URL Pattern
- List input = new ArrayList();
+ List<String[]> input = new ArrayList<String[]>();
input.add(new String[]
{ "/" + text }); //$NON-NLS-1$
if (urlSection != null)
diff --git a/org.eclipse.jst.server.jetty.ui/src/org/eclipse/jst/server/jetty/ui/internal/JettyRuntimeComposite.java b/org.eclipse.jst.server.jetty.ui/src/org/eclipse/jst/server/jetty/ui/internal/JettyRuntimeComposite.java
index b7fad41..d80a1e1 100644
--- a/org.eclipse.jst.server.jetty.ui/src/org/eclipse/jst/server/jetty/ui/internal/JettyRuntimeComposite.java
+++ b/org.eclipse.jst.server.jetty.ui/src/org/eclipse/jst/server/jetty/ui/internal/JettyRuntimeComposite.java
@@ -74,7 +74,7 @@
protected Text installDir;
protected Text name;
protected Combo combo;
- protected List installedJREs;
+ protected List<IVMInstall> installedJREs;
protected String[] jreNames;
protected IInstallableRuntime ir;
protected Job installRuntimeJob;
@@ -356,7 +356,7 @@
protected void updateJREs()
{
// get all installed JVMs
- installedJREs = new ArrayList();
+ installedJREs = new ArrayList<IVMInstall>();
IVMInstallType[] vmInstallTypes = JavaRuntime.getVMInstallTypes();
int size = vmInstallTypes.length;
for (int i = 0; i < size; i++)