diff options
Diffstat (limited to 'plugins')
112 files changed, 1927 insertions, 1730 deletions
diff --git a/plugins/org.eclipse.jst.server.core/plugin.xml b/plugins/org.eclipse.jst.server.core/plugin.xml index e4282698f..4808fd6a3 100644 --- a/plugins/org.eclipse.jst.server.core/plugin.xml +++ b/plugins/org.eclipse.jst.server.core/plugin.xml @@ -8,11 +8,11 @@ class="org.eclipse.jst.server.core.internal.JavaServerPlugin"> <requires> - <import plugin="org.eclipse.core.resources" /> - <import plugin="org.eclipse.debug.core" /> - <import plugin="org.eclipse.wst.server.core" /> - <import plugin="org.eclipse.jdt.core" /> - <import plugin="org.eclipse.jdt.launching" /> + <import plugin="org.eclipse.core.resources"/> + <import plugin="org.eclipse.debug.core"/> + <import plugin="org.eclipse.wst.server.core"/> + <import plugin="org.eclipse.jdt.core"/> + <import plugin="org.eclipse.jdt.launching"/> <import plugin="org.eclipse.core.runtime"/> </requires> diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java index b043f81b9..6bf5ae7a9 100644 --- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java +++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java @@ -36,7 +36,7 @@ public class RuntimeClasspathContainerInitializer extends ClasspathContainerInit if (handler != null) crth = (ClasspathRuntimeTargetHandler) handler.getAdapter(ClasspathRuntimeTargetHandler.class); String runtimeId = containerPath.segment(2); - runtime = ServerCore.getRuntime(runtimeId); + runtime = ServerCore.findRuntime(runtimeId); if (containerPath.segmentCount() > 3) id = containerPath.segment(3); } diff --git a/plugins/org.eclipse.jst.server.tomcat.core/plugin.xml b/plugins/org.eclipse.jst.server.tomcat.core/plugin.xml index beca95f69..51a6c5b7c 100644 --- a/plugins/org.eclipse.jst.server.tomcat.core/plugin.xml +++ b/plugins/org.eclipse.jst.server.tomcat.core/plugin.xml @@ -14,14 +14,13 @@ </runtime> <requires> - <import plugin="org.eclipse.core.runtime" /> - <import plugin="org.eclipse.core.resources" /> - <import plugin="org.eclipse.debug.core" /> - <import plugin="org.eclipse.jdt.core" /> - <import plugin="org.eclipse.jdt.debug" /> - <import plugin="org.eclipse.jdt.launching" /> - <import plugin="org.eclipse.wst.server.core" /> - <import plugin="org.eclipse.jst.server.core" /> + <import plugin="org.eclipse.core.runtime"/> + <import plugin="org.eclipse.core.resources"/> + <import plugin="org.eclipse.debug.core"/> + <import plugin="org.eclipse.jdt.core"/> + <import plugin="org.eclipse.jdt.launching"/> + <import plugin="org.eclipse.wst.server.core"/> + <import plugin="org.eclipse.jst.server.core"/> </requires> <extension point="org.eclipse.wst.server.core.runtimeTypes"> @@ -118,13 +117,12 @@ order="50" startTimeout="45000" stopTimeout="15000" - monitorable="true" initialState="stopped" configurationTypeId="org.eclipse.jst.server.tomcat.32" launchConfigId="org.eclipse.jst.server.tomcat.core.launchConfigurationType" - runtimeTypeId="org.eclipse.jst.server.tomcat.32.runtime" + runtimeTypeId="org.eclipse.jst.server.tomcat.runtime.32" class="org.eclipse.jst.server.tomcat.core.internal.TomcatServer" - workingCopyClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerWorkingCopy"> + behaviourClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour"> </serverType> <serverType id="org.eclipse.jst.server.tomcat.40" @@ -135,13 +133,12 @@ order="52" startTimeout="45000" stopTimeout="15000" - monitorable="true" initialState="stopped" configurationTypeId="org.eclipse.jst.server.tomcat.40" launchConfigId="org.eclipse.jst.server.tomcat.core.launchConfigurationType" - runtimeTypeId="org.eclipse.jst.server.tomcat.40.runtime" + runtimeTypeId="org.eclipse.jst.server.tomcat.runtime.40" class="org.eclipse.jst.server.tomcat.core.internal.TomcatServer" - workingCopyClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerWorkingCopy"> + behaviourClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour"> </serverType> <serverType id="org.eclipse.jst.server.tomcat.41" @@ -152,13 +149,12 @@ order="54" startTimeout="45000" stopTimeout="15000" - monitorable="true" initialState="stopped" configurationTypeId="org.eclipse.jst.server.tomcat.41" launchConfigId="org.eclipse.jst.server.tomcat.core.launchConfigurationType" - runtimeTypeId="org.eclipse.jst.server.tomcat.41.runtime" + runtimeTypeId="org.eclipse.jst.server.tomcat.runtime.41" class="org.eclipse.jst.server.tomcat.core.internal.TomcatServer" - workingCopyClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerWorkingCopy"> + behaviourClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour"> </serverType> <serverType id="org.eclipse.jst.server.tomcat.50" @@ -169,13 +165,12 @@ order="56" startTimeout="45000" stopTimeout="15000" - monitorable="true" initialState="stopped" configurationTypeId="org.eclipse.jst.server.tomcat.50" launchConfigId="org.eclipse.jst.server.tomcat.core.launchConfigurationType" - runtimeTypeId="org.eclipse.jst.server.tomcat.50.runtime" + runtimeTypeId="org.eclipse.jst.server.tomcat.runtime.50" class="org.eclipse.jst.server.tomcat.core.internal.TomcatServer" - workingCopyClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerWorkingCopy"> + behaviourClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour"> </serverType> <serverType id="org.eclipse.jst.server.tomcat.55" @@ -186,13 +181,12 @@ order="58" startTimeout="45000" stopTimeout="15000" - monitorable="true" initialState="stopped" configurationTypeId="org.eclipse.jst.server.tomcat.55" launchConfigId="org.eclipse.jst.server.tomcat.core.launchConfigurationType" - runtimeTypeId="org.eclipse.jst.server.tomcat.55.runtime" + runtimeTypeId="org.eclipse.jst.server.tomcat.runtime.55" class="org.eclipse.jst.server.tomcat.core.internal.TomcatServer" - workingCopyClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerWorkingCopy"> + behaviourClass="org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour"> </serverType> </extension> diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/ITomcatServer.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/ITomcatServer.java index 0ad623f95..fa18f8431 100644 --- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/ITomcatServer.java +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/ITomcatServer.java @@ -10,11 +10,6 @@ **********************************************************************/ package org.eclipse.jst.server.tomcat.core; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IProcess; - import org.eclipse.wst.server.core.model.IURLProvider; /** * @@ -54,22 +49,4 @@ public interface ITomcatServer extends IURLProvider { * @return */ public String getRuntimeClass(); - - /** - * Set the process that is monitored for Tomcat startup and shutdown. - * Warning: Do not call this method unless you know what you're doing; - * it should only be used in rare cases. - * - * @param newProcess - */ - public void setProcess(IProcess newProcess); - - /** - * Setup for starting the server. - * - * @param launch ILaunch - * @param launchMode String - * @param monitor IProgressMonitor - */ - public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException; }
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/ITomcatServerBehaviour.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/ITomcatServerBehaviour.java new file mode 100644 index 000000000..2320590b7 --- /dev/null +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/ITomcatServerBehaviour.java @@ -0,0 +1,47 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.jst.server.tomcat.core; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IProcess; + +import org.eclipse.wst.server.core.model.IURLProvider; +/** + * + */ +public interface ITomcatServerBehaviour extends IURLProvider { + /** + * Returns the main class that is used to launch the Tomcat server. + * + * @return + */ + public String getRuntimeClass(); + + /** + * Set the process that is monitored for Tomcat startup and shutdown. + * Warning: Do not call this method unless you know what you're doing; + * it should only be used in rare cases. + * + * @param newProcess + */ + public void setProcess(IProcess newProcess); + + /** + * Setup for starting the server. + * + * @param launch ILaunch + * @param launchMode String + * @param monitor IProgressMonitor + */ + public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException; +}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchConfigurationDelegate.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchConfigurationDelegate.java index 1ee62a352..9abaa1cb1 100644 --- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchConfigurationDelegate.java +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchConfigurationDelegate.java @@ -32,14 +32,14 @@ public class TomcatLaunchConfigurationDelegate extends AbstractJavaLaunchConfigu public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { String serverId = configuration.getAttribute(IServer.ATTR_SERVER_ID, (String) null); - IServer server = ServerCore.getServer(serverId); + IServer server = ServerCore.findServer(serverId); if (server == null) { Trace.trace(Trace.FINEST, "Launch configuration could not find server"); // throw CoreException(); return; } - TomcatServer tomcatServer = (TomcatServer) server.getAdapter(TomcatServer.class); + TomcatServerBehaviour tomcatServer = (TomcatServerBehaviour) server.getAdapter(TomcatServerBehaviour.class); tomcatServer.setupLaunch(launch, mode, monitor); String mainTypeName = tomcatServer.getRuntimeClass(); diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeLocator.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeLocator.java index df05a935b..a28611021 100644 --- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeLocator.java +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeLocator.java @@ -87,7 +87,7 @@ public class TomcatRuntimeLocator extends RuntimeLocatorDelegate { protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir, IProgressMonitor monitor) { for (int i = 0; i < runtimeTypes.length; i++) { try { - IRuntimeType runtimeType = ServerCore.getRuntimeType(runtimeTypes[i]); + IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypes[i]); IRuntimeWorkingCopy runtime = runtimeType.createRuntime(dir.getAbsolutePath(), monitor); runtime.setName(dir.getName()); runtime.setLocation(new Path(dir.getAbsolutePath())); diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java index 2ce6cfc0e..6d419c391 100644 --- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java @@ -10,7 +10,6 @@ **********************************************************************/ package org.eclipse.jst.server.tomcat.core.internal; -import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.Iterator; @@ -25,21 +24,19 @@ import org.eclipse.jdt.launching.IVMInstall; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jst.server.j2ee.IWebModule; import org.eclipse.jst.server.tomcat.core.ITomcatConfiguration; +import org.eclipse.jst.server.tomcat.core.ITomcatConfigurationWorkingCopy; import org.eclipse.jst.server.tomcat.core.ITomcatRuntime; import org.eclipse.jst.server.tomcat.core.ITomcatServer; +import org.eclipse.jst.server.tomcat.core.ITomcatServerWorkingCopy; import org.eclipse.jst.server.tomcat.core.WebModule; import org.eclipse.wst.server.core.*; import org.eclipse.wst.server.core.model.*; -import org.eclipse.wst.server.core.util.FileUtil; import org.eclipse.wst.server.core.util.PingThread; -import org.eclipse.wst.server.core.util.SocketUtil; /** * Generic Tomcat server. */ -public class TomcatServer extends ServerDelegate implements ITomcatServer { - private static final String ATTR_STOP = "stop-server"; - +public class TomcatServer extends ServerDelegate implements ITomcatServer, ITomcatServerWorkingCopy { protected transient IPath tempDirectory; // the thread used to ping the server to check for startup @@ -196,158 +193,6 @@ public class TomcatServer extends ServerDelegate implements ITomcatServer { return buf.toString(); } - public void setProcess(final IProcess newProcess) { - if (process != null) - return; - - process = newProcess; - processListener = new IDebugEventSetListener() { - public void handleDebugEvents(DebugEvent[] events) { - if (events != null) { - int size = events.length; - for (int i = 0; i < size; i++) { - if (process.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) { - DebugPlugin.getDefault().removeDebugEventListener(this); - stopImpl(); - } - } - } - } - }; - DebugPlugin.getDefault().addDebugEventListener(processListener); - } - - protected void stopImpl() { - if (ping != null) { - ping.stopPinging(); - ping = null; - } - if (process != null) { - process = null; - DebugPlugin.getDefault().removeDebugEventListener(processListener); - processListener = null; - } - setServerState(IServer.STATE_STOPPED); - } - - public void publishServer(IProgressMonitor monitor) throws CoreException { - IPath confDir = null; - if (isTestEnvironment()) { - confDir = getTempDirectory(); - File temp = confDir.append("conf").toFile(); - if (!temp.exists()) - temp.mkdirs(); - } else - confDir = getServer().getRuntime().getLocation(); - IStatus status = getTomcatConfiguration().backupAndPublish(confDir, !isTestEnvironment(), monitor); - if (status != null && !status.isOK()) - throw new CoreException(status); - - setServerPublishState(IServer.PUBLISH_STATE_NONE); - } - - /** - * Returns the project publisher that can be used to - * publish the given project. - */ - public void publishModule(IModule[] parents, IModule module, IProgressMonitor monitor) { - if (isTestEnvironment()) - return; - - // TODO - publish! - IWebModule webModule = (IWebModule) module; - IPath from = webModule.getLocation(); - IPath to = getServer().getRuntime().getLocation().append("webapps").append(webModule.getContextRoot()); - FileUtil.smartCopyDirectory(from.toOSString(), to.toOSString(), monitor); - } - - /** - * Setup for starting the server. - * - * @param launch ILaunch - * @param launchMode String - * @param monitor IProgressMonitor - */ - public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException { - if ("true".equals(launch.getLaunchConfiguration().getAttribute(ATTR_STOP, "false"))) - return; - IStatus status = getTomcatRuntime().validate(); - if (status != null && !status.isOK()) - throw new CoreException(status); - - //setRestartNeeded(false); - TomcatConfiguration configuration = getTomcatConfiguration(); - - // check that ports are free - Iterator iterator = configuration.getServerPorts().iterator(); - while (iterator.hasNext()) { - IServerPort sp = (IServerPort) iterator.next(); - if (SocketUtil.isPortInUse(sp.getPort(), 5)) - throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorPortInUse", new String[] {sp.getPort() + "", sp.getName()}), null)); - } - - setServerState(IServer.STATE_STARTING); - - // ping server to check for startup - try { - String url = "http://localhost"; - int port = configuration.getMainPort().getPort(); - if (port != 80) - url += ":" + port; - ping = new PingThread(getServer(), this, url); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Can't ping for Tomcat startup."); - } - } - - /** - * Cleanly shuts down and terminates the server. - */ - public void stop() { - int state = getServer().getServerState(); - if (state == IServer.STATE_STOPPED) - return; - else if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) { - terminate(); - return; - } - - try { - Trace.trace(Trace.FINER, "Stopping Tomcat"); - if (state != IServer.STATE_STOPPED) - setServerState(IServer.STATE_STOPPING); - - ILaunchConfiguration launchConfig = getServer().getLaunchConfiguration(true, null); - ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy(); - - String args = renderCommandLine(getRuntimeProgramArguments(false), " "); - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args); - wc.setAttribute(ATTR_STOP, "true"); - wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error stopping Tomcat", e); - } - } - - /** - * Terminates the server. - */ - public void terminate() { - if (getServer().getServerState() == IServer.STATE_STOPPED) - return; - - try { - setServerState(IServer.STATE_STOPPING); - Trace.trace(Trace.FINER, "Killing the Tomcat process"); - if (process != null && !process.isTerminated()) { - process.terminate(); - stopImpl(); - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error killing the process", e); - } - } - /** * Return a string representation of this object. * @return java.lang.String @@ -526,4 +371,87 @@ public class TomcatServer extends ServerDelegate implements ITomcatServer { list.toArray(sp); return sp; } + + public void setDefaults() { + setTestEnvironment(true); + } + + /** + * Sets this process to debug mode. This feature only works + * with Tomcat 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 server to test environment mode. + * + * @param b boolean + */ + public void setTestEnvironment(boolean b) { + setAttribute(PROPERTY_TEST_ENVIRONMENT, b); + } + + /** + * Add the given project to this configuration. The project + * has already been verified using isSupportedProject() and + * does not already exist in the configuration. + * + * @param ref java.lang.String + */ + 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); + + IServerConfigurationWorkingCopy scwc = getServer().getServerConfiguration().createWorkingCopy(); + // TODO + ITomcatConfigurationWorkingCopy wc = (ITomcatConfigurationWorkingCopy) scwc.getAdapter(ITomcatConfigurationWorkingCopy.class); + boolean change = false; + + if (add != null) { + int size = add.length; + for (int i = 0; i < size; i++) { + IModule module3 = add[i]; + IWebModule module = (IWebModule) module3.getAdapter(IWebModule.class); + String contextRoot = module.getContextRoot(); + if (contextRoot != null && !contextRoot.startsWith("/")) + contextRoot = "/" + contextRoot; + WebModule module2 = new WebModule(contextRoot, + module.getLocation().toOSString(), module3.getId(), true); + wc.addWebModule(-1, module2); + change = true; + } + } + + if (remove != null) { + int size2 = remove.length; + for (int j = 0; j < size2; j++) { + IModule module3 = remove[j]; + String memento = module3.getId(); + List modules = getTomcatConfiguration().getWebModules(); + int size = modules.size(); + for (int i = 0; i < size; i++) { + WebModule module = (WebModule) modules.get(i); + if (memento.equals(module.getMemento())) { + wc.removeWebModule(i); + change = true; + } + } + } + } + if (change) + scwc.save(false, monitor); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java new file mode 100644 index 000000000..0eec0f99d --- /dev/null +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java @@ -0,0 +1,400 @@ +/********************************************************************** + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.jst.server.tomcat.core.internal; + +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.runtime.*; +import org.eclipse.debug.core.*; +import org.eclipse.debug.core.model.IProcess; +import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; +import org.eclipse.jdt.launching.IRuntimeClasspathEntry; +import org.eclipse.jdt.launching.IVMInstall; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jst.server.j2ee.IWebModule; +import org.eclipse.jst.server.tomcat.core.ITomcatRuntime; +import org.eclipse.jst.server.tomcat.core.ITomcatServerBehaviour; + +import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.model.*; +import org.eclipse.wst.server.core.util.FileUtil; +import org.eclipse.wst.server.core.util.PingThread; +import org.eclipse.wst.server.core.util.SocketUtil; +/** + * Generic Tomcat server. + */ +public class TomcatServerBehaviour extends ServerBehaviourDelegate implements ITomcatServerBehaviour { + private static final String ATTR_STOP = "stop-server"; + + protected transient IPath tempDirectory; + + // the thread used to ping the server to check for startup + protected transient PingThread ping = null; + protected transient IProcess process; + protected transient IDebugEventSetListener processListener; + + /** + * TomcatServer. + */ + public TomcatServerBehaviour() { + super(); + } + + public TomcatRuntime getTomcatRuntime() { + if (getServer().getRuntime() == null) + return null; + + return (TomcatRuntime) getServer().getAdapter(TomcatRuntime.class); + } + + public ITomcatVersionHandler getTomcatVersionHandler() { + if (getServer().getRuntime() == null) + return null; + + return getTomcatRuntime().getVersionHandler(); + } + + public TomcatConfiguration getTomcatConfiguration() { + IServerConfiguration configuration = getServer().getServerConfiguration(); + if (configuration == null) + return null; + + return (TomcatConfiguration) configuration.getAdapter(TomcatConfiguration.class); + } + + public TomcatServer getTomcatServer() { + return null; // TODO + } + + /** + * Return the root URL of this module. + * @param module org.eclipse.wst.server.core.model.IModule + * @return java.net.URL + */ + public URL getModuleRootURL(IModule module) { + try { + if (module == null || !(module instanceof IWebModule)) + return null; + + IServerConfiguration serverConfig = getServer().getServerConfiguration(); + if (serverConfig == null) + return null; + + TomcatConfiguration config = (TomcatConfiguration) serverConfig.getAdapter(TomcatConfiguration.class); + if (config == null) + return null; + + String url = "http://localhost"; + int port = config.getMainPort().getPort(); + port = ServerCore.getServerMonitorManager().getMonitoredPort(getServer(), port, "web"); + if (port != 80) + url += ":" + port; + + url += config.getWebModuleURL(module); + + if (!url.endsWith("/")) + url += "/"; + + return new URL(url); + } catch (Exception e) { + Trace.trace("Could not get root URL", e); + return null; + } + } + + /** + * Return the runtime class name. + * + * @return java.lang.String + */ + public String getRuntimeClass() { + return getTomcatVersionHandler().getRuntimeClass(); + } + + /** + * Return the program's runtime arguments to start or stop. + * + * @param boolean starting + * @return java.lang.String + */ + protected String[] getRuntimeProgramArguments(boolean starting) { + IPath configPath = null; + if (getTomcatServer().isTestEnvironment()) + configPath = getTempDirectory(); + return getTomcatVersionHandler().getRuntimeProgramArguments(configPath, getTomcatServer().isDebug(), starting); + } + + /** + * Return the runtime (VM) arguments. + * + * @return java.lang.String + */ + protected String[] getRuntimeVMArguments() { + IPath configPath = null; + if (getTomcatServer().isTestEnvironment()) + configPath = getTempDirectory(); + return getTomcatVersionHandler().getRuntimeVMArguments(getServer().getRuntime().getLocation(), configPath, getTomcatServer().isSecure()); + } + + /** + * Obtain a temporary directory if this server doesn't + * already have one. Otherwise, return the existing one. + * @return java.io.File + */ + public IPath getTempDirectory() { + if (tempDirectory == null) + tempDirectory = getServer().getTempDirectory(); + return tempDirectory; + } + + 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(); + } + + public void setProcess(final IProcess newProcess) { + if (process != null) + return; + + process = newProcess; + processListener = new IDebugEventSetListener() { + public void handleDebugEvents(DebugEvent[] events) { + if (events != null) { + int size = events.length; + for (int i = 0; i < size; i++) { + if (process.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) { + DebugPlugin.getDefault().removeDebugEventListener(this); + stopImpl(); + } + } + } + } + }; + DebugPlugin.getDefault().addDebugEventListener(processListener); + } + + protected void stopImpl() { + if (ping != null) { + ping.stopPinging(); + ping = null; + } + if (process != null) { + process = null; + DebugPlugin.getDefault().removeDebugEventListener(processListener); + processListener = null; + } + setServerState(IServer.STATE_STOPPED); + } + + public void publishServer(IProgressMonitor monitor) throws CoreException { + IPath confDir = null; + if (getTomcatServer().isTestEnvironment()) { + confDir = getTempDirectory(); + File temp = confDir.append("conf").toFile(); + if (!temp.exists()) + temp.mkdirs(); + } else + confDir = getServer().getRuntime().getLocation(); + IStatus status = getTomcatConfiguration().backupAndPublish(confDir, !getTomcatServer().isTestEnvironment(), monitor); + if (status != null && !status.isOK()) + throw new CoreException(status); + + setServerPublishState(IServer.PUBLISH_STATE_NONE); + } + + /** + * Returns the project publisher that can be used to + * publish the given project. + */ + public void publishModule(IModule[] parents, IModule module, IProgressMonitor monitor) { + if (getTomcatServer().isTestEnvironment()) + return; + + IWebModule webModule = (IWebModule) module; + IPath from = webModule.getLocation(); + IPath to = getServer().getRuntime().getLocation().append("webapps").append(webModule.getContextRoot()); + FileUtil.smartCopyDirectory(from.toOSString(), to.toOSString(), monitor); + } + + /** + * Setup for starting the server. + * + * @param launch ILaunch + * @param launchMode String + * @param monitor IProgressMonitor + */ + public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException { + if ("true".equals(launch.getLaunchConfiguration().getAttribute(ATTR_STOP, "false"))) + return; + IStatus status = getTomcatRuntime().validate(); + if (status != null && !status.isOK()) + throw new CoreException(status); + + //setRestartNeeded(false); + TomcatConfiguration configuration = getTomcatConfiguration(); + + // check that ports are free + Iterator iterator = configuration.getServerPorts().iterator(); + while (iterator.hasNext()) { + IServerPort sp = (IServerPort) iterator.next(); + if (SocketUtil.isPortInUse(sp.getPort(), 5)) + throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorPortInUse", new String[] {sp.getPort() + "", sp.getName()}), null)); + } + + setServerState(IServer.STATE_STARTING); + + // ping server to check for startup + try { + String url = "http://localhost"; + int port = configuration.getMainPort().getPort(); + if (port != 80) + url += ":" + port; + ping = new PingThread(getServer(), this, url); + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Can't ping for Tomcat startup."); + } + } + + /** + * Cleanly shuts down and terminates the server. + */ + public void stop(boolean force) { + if (force) { + terminate(); + return; + } + int state = getServer().getServerState(); + if (state == IServer.STATE_STOPPED) + return; + else if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) { + terminate(); + return; + } + + try { + Trace.trace(Trace.FINER, "Stopping Tomcat"); + if (state != IServer.STATE_STOPPED) + setServerState(IServer.STATE_STOPPING); + + ILaunchConfiguration launchConfig = getServer().getLaunchConfiguration(true, null); + ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy(); + + String args = renderCommandLine(getRuntimeProgramArguments(false), " "); + wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args); + wc.setAttribute(ATTR_STOP, "true"); + wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Error stopping Tomcat", e); + } + } + + /** + * Terminates the server. + */ + protected void terminate() { + if (getServer().getServerState() == IServer.STATE_STOPPED) + return; + + try { + setServerState(IServer.STATE_STOPPING); + Trace.trace(Trace.FINER, "Killing the Tomcat process"); + if (process != null && !process.isTerminated()) { + process.terminate(); + stopImpl(); + } + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Error killing the process", e); + } + } + + /** + * Return a string representation of this object. + * @return java.lang.String + */ + public String toString() { + return "TomcatServer"; + } + + /** + * Update the given configuration in the server. + * (i.e. publish any changes to the server, and restart if necessary) + * @param config org.eclipse.wst.server.core.model.IServerConfiguration + */ + /*public void updateConfiguration() { + Trace.trace(Trace.FINEST, "Configuration updated " + this); + //setConfigurationSyncState(SYNC_STATE_DIRTY); + //setRestartNeeded(true); + }*/ + + /** + * Respond to updates within the project tree. + */ + //public void updateModule(final IModule module, IModuleResourceDelta delta) { } + + public void setLaunchDefaults(ILaunchConfigurationWorkingCopy workingCopy) { + ITomcatRuntime runtime = getTomcatRuntime(); + IVMInstall vmInstall = runtime.getVMInstall(); + if (vmInstall != null) { + workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, vmInstall.getVMInstallType().getId()); + workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, vmInstall.getName()); + } + + String[] args = getRuntimeProgramArguments(true); + String args2 = renderCommandLine(args, " "); + workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args2); + + args = getRuntimeVMArguments(); + args2 = renderCommandLine(args, " "); + workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, args2); + + List cp = runtime.getRuntimeClasspath(); + + // add tools.jar to the path + if (vmInstall != null) { + try { + cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(new Path(JavaRuntime.JRE_CONTAINER).append("org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType").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()) { + cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(toolsPath)); + } + } + } + + Iterator cpi = cp.iterator(); + List list = new ArrayList(); + while (cpi.hasNext()) { + IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) cpi.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); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerLocator.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerLocator.java index db3913c04..ef50fc3ed 100644 --- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerLocator.java +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerLocator.java @@ -20,12 +20,12 @@ import org.eclipse.wst.server.core.model.ServerLocatorDelegate; public class TomcatServerLocator extends ServerLocatorDelegate { public void searchForServers(String host, final IServerLocator.Listener listener, final IProgressMonitor monitor) { IRuntimeLocator.Listener listener2 = new IRuntimeLocator.Listener() { - public void runtimeFound(IRuntime runtime) { + public void runtimeFound(IRuntimeWorkingCopy runtime) { String runtimeTypeId = runtime.getRuntimeType().getId(); String serverTypeId = runtimeTypeId.substring(0, runtimeTypeId.length() - 8); - IServerType serverType = ServerCore.getServerType(serverTypeId); + IServerType serverType = ServerCore.findServerType(serverTypeId); try { - IServer server = serverType.createServer(serverTypeId, null, runtime, monitor); + IServerWorkingCopy server = serverType.createServer(serverTypeId, null, runtime, monitor); listener.serverFound(server); } catch (Exception e) { Trace.trace(Trace.WARNING, "Could not create Tomcat server", e); diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerWorkingCopy.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerWorkingCopy.java deleted file mode 100644 index 3d2d01a81..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerWorkingCopy.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.eclipse.jst.server.tomcat.core.internal; -/********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - **********************************************************************/ -import java.util.List; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.server.j2ee.IWebModule; -import org.eclipse.jst.server.tomcat.core.ITomcatConfigurationWorkingCopy; -import org.eclipse.jst.server.tomcat.core.ITomcatServerWorkingCopy; -import org.eclipse.jst.server.tomcat.core.WebModule; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerConfigurationWorkingCopy; -import org.eclipse.wst.server.core.IServerWorkingCopy; -/** - * - */ -public class TomcatServerWorkingCopy extends TomcatServer implements ITomcatServerWorkingCopy { - protected IServerWorkingCopy workingCopy; - - public TomcatServerWorkingCopy() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ServerWorkingCopyDelegate#initializeWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) - */ - public void initialize(IServerWorkingCopy workingCopy2) { - this.workingCopy = workingCopy2; - } - - public void setDefaults() { - setTestEnvironment(true); - } - - /** - * Sets this process to debug mode. This feature only works - * with Tomcat 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) { - //workingCopy.setAttribute(PROPERTY_SECURE, b); - } - - /** - * Sets this server to test environment mode. - * - * @param b boolean - */ - public void setTestEnvironment(boolean b) { - //workingCopy.setAttribute(PROPERTY_TEST_ENVIRONMENT, b); - } - - /** - * Add the given project to this configuration. The project - * has already been verified using isSupportedProject() and - * does not already exist in the configuration. - * - * @param ref java.lang.String - */ - 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); - - IServerConfigurationWorkingCopy scwc = getServer().getServerConfiguration().createWorkingCopy(); - // TODO - ITomcatConfigurationWorkingCopy wc = (ITomcatConfigurationWorkingCopy) scwc.getAdapter(ITomcatConfigurationWorkingCopy.class); - boolean change = false; - - if (add != null) { - int size = add.length; - for (int i = 0; i < size; i++) { - IModule module3 = add[i]; - IWebModule module = (IWebModule) module3.getAdapter(IWebModule.class); - String contextRoot = module.getContextRoot(); - if (contextRoot != null && !contextRoot.startsWith("/")) - contextRoot = "/" + contextRoot; - WebModule module2 = new WebModule(contextRoot, - module.getLocation().toOSString(), module3.getId(), true); - wc.addWebModule(-1, module2); - change = true; - } - } - - if (remove != null) { - int size2 = remove.length; - for (int j = 0; j < size2; j++) { - IModule module3 = remove[j]; - String memento = module3.getId(); - List modules = getTomcatConfiguration().getWebModules(); - int size = modules.size(); - for (int i = 0; i < size; i++) { - WebModule module = (WebModule) modules.get(i); - if (memento.equals(module.getMemento())) { - wc.removeWebModule(i); - change = true; - } - } - } - } - if (change) - scwc.save(false, monitor); - setServerPublishState(IServer.PUBLISH_STATE_FULL); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java index d76fb1265..0f4ff3cc8 100644 --- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java @@ -39,7 +39,7 @@ public class TomcatSourcePathComputerDelegate implements ISourcePathComputerDele String serverId = configuration.getAttribute(IServer.ATTR_SERVER_ID, (String) null); - IServer server = ServerCore.getServer(serverId); + IServer server = ServerCore.findServer(serverId); if (server != null) { List list = new ArrayList(); List pathList = new ArrayList(); diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/plugin.xml b/plugins/org.eclipse.jst.server.tomcat.ui/plugin.xml index fedacc9b7..9a3565e18 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/plugin.xml +++ b/plugins/org.eclipse.jst.server.tomcat.ui/plugin.xml @@ -15,21 +15,15 @@ <requires> <import plugin="org.eclipse.core.runtime"/> - <import plugin="org.eclipse.core.resources"/> <import plugin="org.eclipse.ui"/> <import plugin="org.eclipse.ui.ide"/> - <import plugin="org.eclipse.ui.editors"/> <import plugin="org.eclipse.ui.forms"/> - <import plugin="org.eclipse.debug.core"/> <import plugin="org.eclipse.debug.ui"/> - <import plugin="org.eclipse.jdt.core"/> - <import plugin="org.eclipse.jdt.debug"/> <import plugin="org.eclipse.jdt.debug.ui"/> <import plugin="org.eclipse.jdt.launching"/> <import plugin="org.eclipse.wst.server.core"/> <import plugin="org.eclipse.wst.server.ui"/> <import plugin="org.eclipse.jst.server.core"/> - <import plugin="org.eclipse.jst.server.ui"/> <import plugin="org.eclipse.jst.server.tomcat.core"/> </requires> diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSection.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSection.java index dbf024da2..a2d823c84 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSection.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSection.java @@ -38,7 +38,7 @@ import org.eclipse.ui.help.WorkbenchHelp; /** * Tomcat configuration mime editor section. */ -public class ConfigurationMimeEditorSection extends ServerResourceEditorSection { +public class ConfigurationMimeEditorSection extends ServerEditorSection { protected ITomcatConfigurationWorkingCopy tomcatConfiguration; protected boolean updating; diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSectionFactory.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSectionFactory.java index 019ba247f..26536c36e 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSectionFactory.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSectionFactory.java @@ -10,7 +10,7 @@ **********************************************************************/ package org.eclipse.jst.server.tomcat.ui.internal.editor; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.editor.*; /** * @@ -19,7 +19,7 @@ public class ConfigurationMimeEditorSectionFactory extends ServerEditorPageSecti /* * @see ServerEditorPartFactoryDelegate#shouldDisplay(IServer) */ - public boolean shouldCreateSection(IServer server) { + public boolean shouldCreateSection(IServerWorkingCopy server) { return (server.getServerConfiguration() != null); } diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSection.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSection.java index 79fa9fc96..0384087c8 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSection.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSection.java @@ -38,7 +38,7 @@ import org.eclipse.ui.help.WorkbenchHelp; /** * Tomcat configuration port editor page. */ -public class ConfigurationPortEditorSection extends ServerResourceEditorSection { +public class ConfigurationPortEditorSection extends ServerEditorSection { protected ITomcatConfigurationWorkingCopy tomcatConfiguration; protected boolean updating; diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSectionFactory.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSectionFactory.java index 13453308a..5fb8e1e22 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSectionFactory.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSectionFactory.java @@ -10,7 +10,7 @@ **********************************************************************/ package org.eclipse.jst.server.tomcat.ui.internal.editor; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.editor.*; /** * @@ -19,7 +19,7 @@ public class ConfigurationPortEditorSectionFactory extends ServerEditorPageSecti /* * @see ServerEditorPartFactoryDelegate#shouldDisplay(IServer) */ - public boolean shouldCreateSection(IServer server) { + public boolean shouldCreateSection(IServerWorkingCopy server) { return (server.getServerConfiguration() != null); } diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorFactory.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorFactory.java index 6edeef435..bf88255bd 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorFactory.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorFactory.java @@ -12,7 +12,7 @@ package org.eclipse.jst.server.tomcat.ui.internal.editor; import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.editor.ServerEditorPartFactoryDelegate; /** * @@ -21,7 +21,7 @@ public class ConfigurationWebModuleEditorFactory extends ServerEditorPartFactory /* * @see ServerEditorPartFactoryDelegate#shouldDisplay(IServer) */ - public boolean shouldCreatePage(IServer server) { + public boolean shouldCreatePage(IServerWorkingCopy server) { return (server.getServerConfiguration() != null); } diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java index bdf4a7679..bbc06a525 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java @@ -51,11 +51,11 @@ import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.ServerUtil; import org.eclipse.wst.server.ui.ServerUICore; import org.eclipse.wst.server.ui.editor.ICommandManager; -import org.eclipse.wst.server.ui.editor.ServerResourceEditorPart; +import org.eclipse.wst.server.ui.editor.ServerEditorPart; /** * Tomcat configuration web module editor page. */ -public class ConfigurationWebModuleEditorPart extends ServerResourceEditorPart { +public class ConfigurationWebModuleEditorPart extends ServerEditorPart { protected ITomcatServerWorkingCopy server2; protected ITomcatConfigurationWorkingCopy configuration; diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java index 5e0de762b..eb8865c1c 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java @@ -38,7 +38,7 @@ import org.eclipse.wst.server.ui.editor.*; /** * Tomcat server general editor page. */ -public class ServerGeneralEditorSection extends ServerResourceEditorSection { +public class ServerGeneralEditorSection extends ServerEditorSection { protected ITomcatServerWorkingCopy tomcatServer; protected Button secure; diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSectionFactory.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSectionFactory.java index 2eccd056d..011fc5ac7 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSectionFactory.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSectionFactory.java @@ -10,7 +10,7 @@ **********************************************************************/ package org.eclipse.jst.server.tomcat.ui.internal.editor; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.editor.*; /** * @@ -19,7 +19,7 @@ public class ServerGeneralEditorSectionFactory extends ServerEditorPageSectionFa /* * @see ServerEditorPartFactoryDelegate#shouldDisplay(IServer) */ - public boolean shouldCreateSection(IServer server) { + public boolean shouldCreateSection(IServerWorkingCopy server) { return (server != null && server.getServerType().getId().indexOf("tomcat") >= 0); } diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java index 47a6a084f..5908ff525 100644 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java +++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java @@ -39,7 +39,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerAttributes; import org.eclipse.wst.server.core.ServerUtil; import org.eclipse.wst.server.ui.ServerUICore; /** @@ -50,7 +50,7 @@ public class WebModuleDialog extends Dialog { protected boolean isEdit; protected boolean isProject; protected Text docBase; - protected IServer server2; + protected IServerAttributes server2; protected ITomcatServer server; protected ITomcatConfiguration config; @@ -60,7 +60,7 @@ public class WebModuleDialog extends Dialog { * WebModuleDialog constructor comment. * @param parentShell org.eclipse.swt.widgets.Shell */ - protected WebModuleDialog(Shell parentShell, IServer server2, ITomcatServer server, ITomcatConfiguration config, WebModule module) { + protected WebModuleDialog(Shell parentShell, IServerAttributes server2, ITomcatServer server, ITomcatConfiguration config, WebModule module) { super(parentShell); this.module = module; this.server2 = server2; @@ -73,7 +73,7 @@ public class WebModuleDialog extends Dialog { * WebModuleDialog constructor comment. * @param parentShell org.eclipse.swt.widgets.Shell */ - protected WebModuleDialog(Shell parentShell, IServer server2, ITomcatServer server, ITomcatConfiguration config, boolean isProject) { + protected WebModuleDialog(Shell parentShell, IServerAttributes server2, ITomcatServer server, ITomcatConfiguration config, boolean isProject) { this(parentShell, server2, server, config, new WebModule("/", "", null, true)); isEdit = false; this.isProject = isProject; diff --git a/plugins/org.eclipse.jst.server.ui/plugin.xml b/plugins/org.eclipse.jst.server.ui/plugin.xml index fc6f5b228..8a9540bc5 100644 --- a/plugins/org.eclipse.jst.server.ui/plugin.xml +++ b/plugins/org.eclipse.jst.server.ui/plugin.xml @@ -9,11 +9,7 @@ <requires> <import plugin="org.eclipse.core.runtime"/> - <import plugin="org.eclipse.core.resources"/> <import plugin="org.eclipse.ui"/> - <import plugin="org.eclipse.ui.ide"/> - <import plugin="org.eclipse.ui.views"/> - <import plugin="org.eclipse.ui.editors"/> <import plugin="org.eclipse.jdt.core"/> <import plugin="org.eclipse.jdt.launching"/> <import plugin="org.eclipse.wst.server.core"/> diff --git a/plugins/org.eclipse.wst.server.core/schema/serverTypes.exsd b/plugins/org.eclipse.wst.server.core/schema/serverTypes.exsd index 67035d67e..caaf75fac 100644 --- a/plugins/org.eclipse.wst.server.core/schema/serverTypes.exsd +++ b/plugins/org.eclipse.wst.server.core/schema/serverTypes.exsd @@ -50,13 +50,6 @@ </documentation>
</annotation>
</attribute>
- <attribute name="runtimeTypeId" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
@@ -79,7 +72,7 @@ Server instances of this type will delegate to instances of this class. </documentation>
</annotation>
</attribute>
- <attribute name="workingCopyClass" type="string">
+ <attribute name="behaviourClass" type="string">
<annotation>
<documentation>
specifies the fully qualified name of the Java class that implements <samp>IServerWorkingCopyDelegate</samp>. @@ -94,6 +87,13 @@ Server instances of this type will delegate to instances of this class. </documentation>
</annotation>
</attribute>
+ <attribute name="runtimeTypeId" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
<attribute name="startable" type="string">
<annotation>
<documentation>
@@ -129,13 +129,6 @@ Server instances of this type will delegate to instances of this class. </documentation>
</annotation>
</attribute>
- <attribute name="monitorable" type="boolean">
- <annotation>
- <documentation>
- "true" if the class implements IMonitorableServer, and "false" otherwise
- </documentation>
- </annotation>
- </attribute>
<attribute name="launchModes" type="string">
<annotation>
<documentation>
@@ -143,13 +136,6 @@ Server instances of this type will delegate to instances of this class. </documentation>
</annotation>
</attribute>
- <attribute name="testEnvironment" type="string">
- <annotation>
- <documentation>
- "true" if this server should not be creatable unless there is an existing runtime with the test environment flag set to true, "false" otherwise
- </documentation>
- </annotation>
- </attribute>
<attribute name="initialState" type="string">
<annotation>
<documentation>
@@ -216,7 +202,7 @@ Server instances of this type will delegate to instances of this class. <meta.section type="apiInfo"/>
</appInfo>
<documentation>
- Value of the attribute <b>class</b> must be a fully qualified name of a Java class that implements the interface <b>org.eclipse.wst.server.core.model.ServerDelegate</b>.
+ Value of the attribute <b>class</b> must be a fully qualified name of a Java class that extends the abstract class <b>org.eclipse.wst.server.core.model.ServerDelegate</b> and has a public 0-arg constructor.
</documentation>
</annotation>
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOptionalTask.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOptionalTask.java index a7302030f..0bab31bc9 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOptionalTask.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOptionalTask.java @@ -12,7 +12,7 @@ package org.eclipse.wst.server.core; /** * An optional task. */ -public interface IOptionalTask extends ITask, IOrdered { +public interface IOptionalTask extends ITask { public static final int TASK_UNNECESSARY = 0; public static final int TASK_COMPLETED = 1; public static final int TASK_READY = 2; @@ -25,4 +25,11 @@ public interface IOptionalTask extends ITask, IOrdered { * @return byte */ public int getStatus(); + + /** + * Returns the order (index/priority). + * + * @return int + */ + public int getOrder(); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntime.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntime.java index 780dc79c7..b471d7471 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntime.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntime.java @@ -25,8 +25,10 @@ import org.eclipse.core.runtime.*; * </p> * <p> * IRuntime implements IAdaptable to allow users to obtain a runtime-type-specific - * class that can be used to set fields. getAdapter() may involve plugin loading, - * and should not be called from popup menus and the like. + * class. By casting the runtime extension to the type prescribed in the API + * documentation for that particular runtime type, the client can access + * runtime-type-specific properties and methods. getAdapter() may involve plugin + * loading, and should not be called from popup menus, etc. * </p> * <p> * [issue: As mentioned in an issue on IRuntimeType, the term "runtime" @@ -35,11 +37,13 @@ import org.eclipse.core.runtime.*; * better choice.] * </p> * <p> - * The resource manager maintains a global list of all known runtime instances - * ({@link IResourceManager#getRuntimes()}). + * The server framework maintains a global list of all known runtime instances + * ({@link ServerCore#getRuntimes()}). * </p> * <p> - * [issue: Equality/identify for runtimes?] + * All runtimes have a unique id. Two runtimes (or more likely a runtime and it's + * working copy) with the same id are equal, and two runtimes with different ids + * are never equal. * </p> * * <p>This interface is not intended to be implemented by clients.</p> @@ -59,18 +63,6 @@ public interface IRuntime extends IElement, IAdaptable { public IRuntimeType getRuntimeType(); /** - * Returns the extension for this runtime. - * The runtime extension is a runtime-type-specific object. - * By casting the runtime extension to the type prescribed in - * the API documentation for that particular runtime type, - * the client can access runtime-type-specific properties and - * methods. - * - * @return the runtime extension, or <code>null</code> if none - */ - //public IServerExtension getExtension(IProgressMonitor monitor); - - /** * Returns a runtime working copy for modifying this runtime instance. * If this instance is already a working copy, it is returned. * If this instance is not a working copy, a new runtime working copy @@ -108,20 +100,6 @@ public interface IRuntime extends IElement, IAdaptable { public IPath getLocation(); /** - * Returns whether this runtime can be used as a test environment. - * <p> - * [issue: How does one explain what a "test environment" is? - * How does this property of runtime square with - * IServerType.isTestEnvironment(), a *type-generic* - * property of a server type?] - * </p> - * - * @return <code>true</code> if this runtime can be use as a - * test environment, and <code>false</code> if it cannot - */ - public boolean isTestEnvironment(); - - /** * Returns whether this runtime is a stub (used for compilation only) or a full runtime. * * @return <code>true</code> if this runtime is a stub, and <code>false</code> otherwise diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLocator.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLocator.java index 10d966ba0..7f3008329 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLocator.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLocator.java @@ -28,7 +28,7 @@ public interface IRuntimeLocator { * * @param runtime the runtime that was found. */ - public void runtimeFound(IRuntime runtime); + public void runtimeFound(IRuntimeWorkingCopy runtime); } /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeTargetHandler.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeTargetHandler.java index 2fe43a23e..e94fdc8d7 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeTargetHandler.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeTargetHandler.java @@ -15,22 +15,32 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; /** + * A runtime target handler is used to apply some properties to a project + * this is being targeted to a given runtime. For instance, the handler + * might update the classpath of a Java project to include the runtime's + * classes, add validation for the given runtime, or restrict the type of + * resources that can be created. * * <p>This interface is not intended to be implemented by clients.</p> */ -public interface IRuntimeTargetHandler extends IOrdered, IAdaptable { +public interface IRuntimeTargetHandler extends IAdaptable { /** + * Returns the id of this runtime target handler. + * Each known runtime target handler has a distinct id. + * Ids are intended to be used internally as keys; they are not + * intended to be shown to end users. * - * @return + * @return the runtime target handler id */ public String getId(); /** - * Returns true if this runtime target handler supports (can work with) the - * given runtime. + * Returns <code>true</code> if this runtime target handler supports + * (can work with) the given runtime. * - * @param runtimeType - * @return + * @param runtimeType a runtime type + * @return <code>true</code> if the handler can accept the given runtime type, + * and <code>false</code> otherwise */ public boolean supportsRuntimeType(IRuntimeType runtimeType); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeType.java index 453bbf93f..6f921c4a6 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeType.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeType.java @@ -42,14 +42,6 @@ import org.eclipse.core.runtime.IProgressMonitor; * be tied to the particular servers involved.] * </p> * <p> - * [issue: It is notoriously difficult to place any kind of - * useful order on objects that are contributed independently by - * non-collaborating parties. The IOrdered mechanism is weak, and - * can't really solve the problem. Issues of presentation are usually - * best left to the UI, which can sort objects based on arbitrary - * properties.] - * </p> - * <p> * [issue: Equality/identify for runtime types? Are IRuntimeType * instances guaranteed to be canonical (client can use ==), * or is it possible for there to be non-identical IRuntimeType @@ -63,7 +55,7 @@ import org.eclipse.core.runtime.IProgressMonitor; * * @since 1.0 */ -public interface IRuntimeType extends IOrdered { +public interface IRuntimeType { /** * Returns the id of this runtime type. * Each known server runtime type has a distinct id. diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeWorkingCopy.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeWorkingCopy.java index 451a79371..0d8dd61ac 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeWorkingCopy.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeWorkingCopy.java @@ -15,7 +15,9 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; /** * A working copy runtime object used for formulating changes - * to a runtime instance ({@link IRuntime}). + * to a runtime instance ({@link IRuntime}). Changes made on a + * working copy do not occur (and are not persisted) until a + * save() is performed. * <p> * [issue: The default value of location and test environment * should be specified here (or in IServerType.createRuntime). @@ -42,6 +44,7 @@ import org.eclipse.core.runtime.IProgressMonitor; * likely to change significantly before the initial release.</it> * </p> * + * @see IRuntime * @since 1.0 */ public interface IRuntimeWorkingCopy extends IRuntime, IElementWorkingCopy { @@ -86,20 +89,12 @@ public interface IRuntimeWorkingCopy extends IRuntime, IElementWorkingCopy { * Commits the changes made in this working copy. If there is * no extant runtime instance with a matching id and runtime * type, this will create a runtime instance with attributes - * taken from this working copy. If there an existing runtime - * instance with a matching id and runtime type, this will - * change the runtime instance accordingly. + * taken from this working copy, and return that object. * <p> - * [issue: What is relationship to - * this.getOriginal() and the IRuntime returned by this.save()? - * The answer should be: they're the same runtime, for an - * appropriate notion of "same". As currently implemented, they - * are different IRuntime instances but have the same runtime - * id and same runtime types. Client that are hanging on to - * the old runtime instance will not see the changes. - * If IRuntime were some kind of handle object as elsewhere in - * Eclipse Platform, this kind of change could be done much - * more smoothly.] + * If there an existing runtime instance with a matching id and + * runtime type, this will change the runtime instance accordingly. + * The returned runtime will be the same runtime this is returned + * from getOriginal(), after the changes have been applied. * </p> * <p> * [issue: What is lifecycle for RuntimeWorkingCopyDelegate @@ -109,16 +104,7 @@ public interface IRuntimeWorkingCopy extends IRuntime, IElementWorkingCopy { * @param monitor a progress monitor, or <code>null</code> if progress * reporting and cancellation are not desired * @return a new runtime instance - * @throws CoreException [missing] + * @throws CoreException thrown if the save could not be completed */ public IRuntime save(boolean force, IProgressMonitor monitor) throws CoreException; - - /** - * Sets whether this runtime can be used as a test environment. - * - * @param b <code>true</code> if this runtime can be use as a - * test environment, and <code>false</code> if it cannot - * @see IRuntime#isTestEnvironment() - */ - public void setTestEnvironment(boolean b); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java index 663f5af66..cae8cc7d0 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java @@ -10,7 +10,6 @@ **********************************************************************/ package org.eclipse.wst.server.core; -import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.*; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; @@ -46,8 +45,8 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; * stop, and restart it. * </p> * <p> - * The resource manager maintains a global list of all known server instances - * ({@link IResourceManager#getServers()}). + * The server framework maintains a global list of all known server instances + * ({@link ServerCore#getServers()}). * </p> * <p> * [rough notes: @@ -82,8 +81,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; * * @since 1.0 */ -public interface IServer extends IElement, IAdaptable { - +public interface IServer extends IServerAttributes, IAdaptable { /** * File extension (value "server") for serialized representation of * server instances. @@ -224,77 +222,6 @@ public interface IServer extends IElement, IAdaptable { * @return */ public int getModulePublishState(IModule module); - - /** - * Returns the host for the server. - * The format of the host can be either a qualified or unqualified hostname, - * or an IP address and must conform to RFC 2732. - * - * @return a host string conforming to RFC 2732 - * @see java.net.URL.getHost() - */ - public String getHost(); - - /** - * Returns the file where this server instance is serialized. - * - * @return the file in the workspace where the server instance - * is serialized, or <code>null</code> if the information is - * instead to be persisted with the workspace but not with any - * particular workspace resource - */ - public IFile getFile(); - - /** - * Returns the runtime associated with this server. - * <p> - * Note: The runtime of a server working copy may or may not - * be a working copy. For a server instance that is not a - * working copy, the runtime instance is not a working copy - * either. - * </p> - * <p> - * [issue: According to serverType extension point, - * runtimeTypeId is a mandatory attribute. It seems odd - * then to have server runtime instance being an - * optional property of server instance. What does it mean - * for a server to not have a runtime?] - * </p> - * - * @return the runtime, or <code>null</code> if none - */ - public IRuntime getRuntime(); - - /** - * Returns the type of this server. - * - * @return the server type - */ - public IServerType getServerType(); - - /** - * Returns the server configuration associated with this server. - * <p> - * Note: The server configuration of a server working copy may - * or may not be a working copy. For a server instance that is - * not a working copy, the server configuration instance is not - * a working copy either. - * </p> - * <p> - * [issue: According to serverType extension point, - * configurationTypeId is an optional attribute. If a server type - * has no server configuration type, then it seems reasonable to - * expect this method to return null for all instances of that server - * type. But what about a server type that explicitly specifies - * a server configuration type. Does that mean that all server - * instances of that server type must have a server configuration - * instance of that server configuration type, and that this method - * never returns null in those cases?] - * </p> - * - * @return the server configuration, or <code>null</code> if none - */ - public IServerConfiguration getServerConfiguration(); /** * Returns the server extension for this server. @@ -339,29 +266,6 @@ public interface IServer extends IElement, IAdaptable { * @return a new working copy */ public IServerWorkingCopy createWorkingCopy(); - - /** - * Returns whether the given server configuration can be used with - * this server. - * <p> - * [issue: This seems to be just a convenience method. Given that it's - * straightforward enought for a client to compare - * this.getServerType().getServerConfiguration() - * to configuration.getServerConfigurationType(), - * it's not clear that there is a great need for this method.] - * </p> - * <p> - * [issue: It does not make sense to allow a null configuration.] - * </p> - * - * Returns true if this is a configuration that is - * applicable to (can be used with) this server. - * - * @param configuration the server configuration - * @return <code>true</code> if this server supports the given server - * configuration, and <code>false/code> otherwise - */ - public boolean isSupportedConfiguration(IServerConfiguration configuration); /** * Returns an array of the modules that have not been published @@ -598,13 +502,20 @@ public interface IServer extends IElement, IAdaptable { * nothing if this server cannot be stopped ({@link #canStop()} * returns <code>false</code>. * <p> + * If force is <code>false</code>, it will attempt to stop the server + * normally/gracefully. If force is <code>true</code>, then the server + * process will be terminated any way that it can. + * </p> + * <p> * [issue: There is no way to communicate failure to the * client. Given that this operation can go awry, there probably * should be a mechanism that allows failing asynch operations * to be diagnosed.] * </p> + * @param force <code>true</code> to kill the server, or <code>false</code> + * to stop normally */ - public void stop(); + public void stop(boolean force); /** * Stops this server and waits until the server has completely stopped. @@ -617,21 +528,6 @@ public interface IServer extends IElement, IAdaptable { public void synchronousStop(); /** - * Terminates the server process(es). This method should only be - * used as a last resort after the stop() method fails to work. - * The server should return from this method quickly and - * use the server listener to notify shutdown progress. - * It MUST terminate the server completely and return it to - * the stopped state. - * <p> - * [issue: Since IServer already has stop(), it's hard to explain - * in what way this method is truely different. Given that stop() - * did not do the trick, why would terminate() have better luck.] - * </p> - */ - public void terminate(); - - /** * Returns whether the given module can be restarted. * <p> * [issue: It's unclear whether this operations is guaranteed to be fast @@ -705,63 +601,6 @@ public interface IServer extends IElement, IAdaptable { public void synchronousRestartModule(IModule module, IProgressMonitor monitor) throws CoreException; /** - * Returns a temporary directory that the requestor can use - * throughout it's lifecycle. This is primary to be used by - * servers for working directories, server specific - * files, etc. - * - * <p>As long as the same key is used to call this method on - * each use of the workbench, this method directory will return - * the same directory. If the directory is not requested over a - * period of time, the directory may be deleted and a new one - * will be assigned on the next request. For this reason, a - * server should request the temp directory on startup - * if it wants to store files there. In all cases, the server - * should have a backup plan to refill the directory - * in case it has been deleted since last use.</p> - * - * @return org.eclipse.core.runtime.IPath - */ - public IPath getTempDirectory(); - - /** - * Returns whether the specified module modifications could be made to this - * server at this time. - * <p> - * This method may decide based on the type of module - * or refuse simply due to reaching a maximum number of - * modules or other criteria. - * </p> - * <p> - * [issue: This seems odd to have a pre-flight method. - * I should expect that the client can propose making - * any set of module changes they desire (via a server - * working copy). If the server doesn't like it, the operation - * should fail.] - * </p> - * - * @param add a possibly-empty list of modules to add - * @param remove a possibly-empty list of modules to remove - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @return <code>true</code> if the proposed modifications - * look feasible, and <code>false</code> otherwise - */ - public IStatus canModifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor); - - /** - * Returns an array of modules that are associated with - * this server. - * <p> - * [issue: Clarify that these are root modules, not ones parented - * by some other module.] - * </p> - * - * @return a possibly-empty array of modules - */ - public IModule[] getModules(IProgressMonitor monitor); - - /** * Returns the current state of the given module on this server. * Returns <code>STATE_UNKNOWN</code> if the module * is not among the ones associated with this server. @@ -771,50 +610,4 @@ public interface IServer extends IElement, IAdaptable { * constants declared on {@link IServer} */ public int getModuleState(IModule module); - - /** - * Returns the child module(s) of this module. If this - * module contains other modules, it should list those - * modules. If not, it should return an empty list. - * - * <p>This method should only return the direct children. - * To obtain the full module tree, this method may be - * recursively called on the children.</p> - * - * @param module org.eclipse.wst.server.core.IModule - * @return array - */ - public IModule[] getChildModules(IModule module, IProgressMonitor monitor); - - /** - * Returns the parent module(s) of this module. When - * determining if a given project can run on a server - * configuration, this method will be used to find the - * actual module(s) that may be run on the server. For - * instance, a Web module may return a list of Ear - * modules that it is contained in if the server only - * supports configuring Ear modules. - * - * <p>If the module type is not supported, this method - * may return null. If the type is normally supported but there - * is a configuration problem or missing parent, etc., this - * method may fire a CoreException that may then be presented - * to the user.</p> - * - * <p>If it does return valid parent(s), this method should - * always return the topmost parent module(s), even if - * there are a few levels (a heirarchy) of modules.</p> - * - * @param module org.eclipse.wst.server.core.IModule - * @return array - * @throws org.eclipse.core.runtime.CoreException - */ - public IModule[] getParentModules(IModule module, IProgressMonitor monitor) throws CoreException; - - /** - * Returns an array of IServerPorts that this server has. - * - * @return - */ - public IServerPort[] getServerPorts(); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerAttributes.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerAttributes.java new file mode 100644 index 000000000..87f92bd8f --- /dev/null +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerAttributes.java @@ -0,0 +1,349 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - Initial API and implementation + **********************************************************************/ +package org.eclipse.wst.server.core; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.*; +/** + * Represents a server instance. Every server is an instance of a + * particular, fixed server type. + * <p> + * Not surprisingly, the notion of <b>server</b> is central in the web tools + * server infrastructure. In this context, understand that a server is + * a web server of some ilk. It could be a simple web server lacking Java + * support, or an J2EE based server, or perhaps even some kind of database + * server. A more exact definition is not required for the purposes of this API. + * From a tool-centric point of view, a server + * is something that the developer is writing "content" for. + * The unit of content is termed a module. + * In a sense, the server exists, but lacks useful content. The + * development task is to provide that content. The content can include + * anything from simple, static HTML web pages to complex, highly dynamic + * web applications. + * In the course of writing and debugging this content, + * the developer will want to test their content on a web server, to see how it + * gets served up. For this they will need to launch a server process running on + * some host machine (often the local host on which the IDE is running), or + * attach to a server that's already running on a remote (or local) host. + * The newly developed content sitting in the developer's workspace needs to + * end up in a location and format that the running server can use for its + * serving purposes. + * </p> + * <p> + * In this picture, an <code>IServer</code> object is a proxy for the real web + * server. Through this proxy, a client can configure the server, and start, + * stop, and restart it. + * </p> + * <p> + * The server framework maintains a global list of all known server instances + * ({@link ServerCore#getServers()}). + * </p> + * <p> + * [rough notes: + * Server has a state. + * Server can be started, stopped, and restarted. + * To modify server attributes, get a working copy, modify it, and then save it + * to commit the changes. + * Server attributes. Serialization. + * Chained working copies for runtime, server configuration. + * Server has a set of root modules. + * Modules have state wrt a server. + * Restarting modules. + * ] + * </p> + * <p> + * [issue: The information actually stored in the (.server) file is: + * server id and name, server type id, runtime id, server configuration id, + * and test-environment. It's unclear what's gained by storing this + * information in a workspace file. Is it so that this information + * can be shared between users via a repository? Or is it just so that + * there would be something to open in the resource navigator view?] + * </p> + * <p> + * [issue: Equality/identify for servers?] + * </p> + * + * <p>This interface is not intended to be implemented by clients.</p> + * <p> + * <it>Caveat: The server core API is still in an early form, and is + * likely to change significantly before the initial release.</it> + * </p> + * + * @since 1.0 + */ +public interface IServerAttributes extends IElement, IAdaptable { + /** + * File extension (value "server") for serialized representation of + * server instances. + * <p> + * [issue: What is relationship between this file extension and + * the file passed to IServerType.create(...) or returned by + * IServer.getFile()? That is, are server files expected to end + * in ".server", or is this just a default? If the former + * (as I suspect), then IServerType.create needs to say so, + * and the implementation should enforce the restriction.] + * </p> + */ + public static final String FILE_EXTENSION = "server"; + + /** + * Server id attribute (value "server-id") of launch configurations. + * This attribute is used to tag a launch configuration with th + * id of the corresponding server. + * <p> + * [issue: This feels like an implementation detail. If it is to + * remain API, need to explain how a client uses this attribute.] + * </p> + * @see ILaunchConfiguration + */ + public static final String ATTR_SERVER_ID = "server-id"; + + /** + * Returns the host for the server. + * The format of the host can be either a qualified or unqualified hostname, + * or an IP address and must conform to RFC 2732. + * + * @return a host string conforming to RFC 2732 + * @see java.net.URL.getHost() + */ + public String getHost(); + + /** + * Returns the file where this server instance is serialized. + * + * @return the file in the workspace where the server instance + * is serialized, or <code>null</code> if the information is + * instead to be persisted with the workspace but not with any + * particular workspace resource + */ + public IFile getFile(); + + /** + * Returns the runtime associated with this server. + * <p> + * Note: The runtime of a server working copy may or may not + * be a working copy. For a server instance that is not a + * working copy, the runtime instance is not a working copy + * either. + * </p> + * <p> + * [issue: According to serverType extension point, + * runtimeTypeId is a mandatory attribute. It seems odd + * then to have server runtime instance being an + * optional property of server instance. What does it mean + * for a server to not have a runtime?] + * </p> + * + * @return the runtime, or <code>null</code> if none + */ + public IRuntime getRuntime(); + + /** + * Returns the type of this server. + * + * @return the server type + */ + public IServerType getServerType(); + + /** + * Returns the server configuration associated with this server. + * <p> + * Note: The server configuration of a server working copy may + * or may not be a working copy. For a server instance that is + * not a working copy, the server configuration instance is not + * a working copy either. + * </p> + * <p> + * [issue: According to serverType extension point, + * configurationTypeId is an optional attribute. If a server type + * has no server configuration type, then it seems reasonable to + * expect this method to return null for all instances of that server + * type. But what about a server type that explicitly specifies + * a server configuration type. Does that mean that all server + * instances of that server type must have a server configuration + * instance of that server configuration type, and that this method + * never returns null in those cases?] + * </p> + * + * @return the server configuration, or <code>null</code> if none + */ + public IServerConfiguration getServerConfiguration(); + + /** + * Returns the server extension for this server. + * The server extension is a server-type-specific object. + * By casting the server extension to the type prescribed in + * the API documentation for that particular server type, + * the client can access server-type-specific properties and + * methods. + * + * @return the server extension + */ + //public IServerExtension getExtension(IProgressMonitor monitor); + + /** + * Returns a server working copy for modifying this server instance. + * If this instance is already a working copy, it is returned. + * If this instance is not a working copy, a new server working copy + * is created with the same id and attributes. + * Clients are responsible for saving or releasing the working copy when + * they are done with it. + * <p> + * The server working copy is related to this server instance + * in the following ways: + * <pre> + * this.getWorkingCopy().getId() == this.getId() + * this.getWorkingCopy().getFile() == this.getFile() + * this.getWorkingCopy().getOriginal() == this + * this.getWorkingCopy().getRuntime() == this.getRuntime() + * this.getWorkingCopy().getServerConfiguration() == this.getServerConfiguration() + * </pre> + * </p> + * <p> + * [issue: IServerWorkingCopy extends IServer. + * Server.getWorkingCopy() create a new working copy; + * ServerWorkingCopy.getWorkingCopy() returns this. + * This may be convenient in code that is ignorant of + * whether they are dealing with a working copy or not. + * However, it is hard for clients to manage working copies + * with this design.] + * </p> + * + * @return a new working copy + */ + public IServerWorkingCopy createWorkingCopy(); + + /** + * Returns whether the given server configuration can be used with + * this server. + * <p> + * [issue: This seems to be just a convenience method. Given that it's + * straightforward enought for a client to compare + * this.getServerType().getServerConfiguration() + * to configuration.getServerConfigurationType(), + * it's not clear that there is a great need for this method.] + * </p> + * <p> + * [issue: It does not make sense to allow a null configuration.] + * </p> + * + * Returns true if this is a configuration that is + * applicable to (can be used with) this server. + * + * @param configuration the server configuration + * @return <code>true</code> if this server supports the given server + * configuration, and <code>false/code> otherwise + */ + public boolean isSupportedConfiguration(IServerConfiguration configuration); + + /** + * Returns a temporary directory that the requestor can use + * throughout it's lifecycle. This is primary to be used by + * servers for working directories, server specific + * files, etc. + * + * <p>As long as the same key is used to call this method on + * each use of the workbench, this method directory will return + * the same directory. If the directory is not requested over a + * period of time, the directory may be deleted and a new one + * will be assigned on the next request. For this reason, a + * server should request the temp directory on startup + * if it wants to store files there. In all cases, the server + * should have a backup plan to refill the directory + * in case it has been deleted since last use.</p> + * + * @return org.eclipse.core.runtime.IPath + */ + public IPath getTempDirectory(); + + /** + * Returns an array of modules that are associated with + * this server. + * <p> + * [issue: Clarify that these are root modules, not ones parented + * by some other module.] + * </p> + * + * @return a possibly-empty array of modules + */ + public IModule[] getModules(IProgressMonitor monitor); + + /** + * Returns whether the specified module modifications could be made to this + * server at this time. + * <p> + * This method may decide based on the type of module + * or refuse simply due to reaching a maximum number of + * modules or other criteria. + * </p> + * <p> + * [issue: This seems odd to have a pre-flight method. + * I should expect that the client can propose making + * any set of module changes they desire (via a server + * working copy). If the server doesn't like it, the operation + * should fail.] + * </p> + * + * @param add a possibly-empty list of modules to add + * @param remove a possibly-empty list of modules to remove + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @return <code>true</code> if the proposed modifications + * look feasible, and <code>false</code> otherwise + */ + public IStatus canModifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor); + + /** + * Returns the child module(s) of this module. If this + * module contains other modules, it should list those + * modules. If not, it should return an empty list. + * + * <p>This method should only return the direct children. + * To obtain the full module tree, this method may be + * recursively called on the children.</p> + * + * @param module org.eclipse.wst.server.core.IModule + * @return array + */ + public IModule[] getChildModules(IModule module, IProgressMonitor monitor); + + /** + * Returns the parent module(s) of this module. When + * determining if a given project can run on a server + * configuration, this method will be used to find the + * actual module(s) that may be run on the server. For + * instance, a Web module may return a list of Ear + * modules that it is contained in if the server only + * supports configuring Ear modules. + * + * <p>If the module type is not supported, this method + * may return null. If the type is normally supported but there + * is a configuration problem or missing parent, etc., this + * method may fire a CoreException that may then be presented + * to the user.</p> + * + * <p>If it does return valid parent(s), this method should + * always return the topmost parent module(s), even if + * there are a few levels (a heirarchy) of modules.</p> + * + * @param module org.eclipse.wst.server.core.IModule + * @return array + * @throws org.eclipse.core.runtime.CoreException + */ + public IModule[] getParentModules(IModule module, IProgressMonitor monitor) throws CoreException; + + /** + * Returns an array of IServerPorts that this server has. + * + * @return + */ + public IServerPort[] getServerPorts(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerConfiguration.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerConfiguration.java index 2831bd414..1ae48aed6 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerConfiguration.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerConfiguration.java @@ -32,8 +32,8 @@ import org.eclipse.core.runtime.IPath; * configurations between several servers of the same type (e.g., a local test * server and a remote server running on another host). * </p> * <p> - * The resource manager maintains a global list of all known server - * configuration instances ({@link IResourceManager#getServerConfigurations()}). + * The server framework maintains a global list of all known server + * configuration instances ({@link ServerCore#getServerConfigurations()}). * </p> * <p> * [issue: The information actually stored in the (.config) file is: diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerConfigurationType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerConfigurationType.java index f123a3af6..2126df384 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerConfigurationType.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerConfigurationType.java @@ -30,14 +30,6 @@ import org.eclipse.core.runtime.IProgressMonitor; * This interface is not intended to be implemented by clients. * </p> * <p> - * [issue: It is notoriously difficult to place any kind of - * useful order on objects that are contributed independently by - * non-collaborating parties. The IOrdered mechanism is weak, and - * can't really solve the problem. Issues of presentation are usually - * best left to the UI, which can sort objects based on arbitrary - * properties.] - * </p> - * <p> * [issue: Equality/identify for server types? Are IServerConfigurationType * instances guaranteed to be canonical (client can use ==), * or is it possible for there to be non-identical IServerConfigurationType @@ -51,7 +43,7 @@ import org.eclipse.core.runtime.IProgressMonitor; * * @since 1.0 */ -public interface IServerConfigurationType extends IOrdered { +public interface IServerConfigurationType { /** * Returns the id of this server configuration type. diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLocator.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLocator.java index 8930850c0..7dbcfa5ea 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLocator.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLocator.java @@ -28,7 +28,7 @@ public interface IServerLocator { * * @param server the runtime that was found. */ - public void serverFound(IServer server); + public void serverFound(IServerWorkingCopy server); } /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerMonitorManager.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerMonitorManager.java index 75c99c9f2..a130e74e8 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerMonitorManager.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerMonitorManager.java @@ -11,7 +11,6 @@ package org.eclipse.wst.server.core; import org.eclipse.core.runtime.CoreException; - /** * * <p>This interface is not intended to be implemented by clients.</p> @@ -22,7 +21,7 @@ public interface IServerMonitorManager { * * @return */ - public IServerMonitor getCurrentServerMonitor(); + //public IServerMonitor getCurrentServerMonitor(); /** * Switch to use a different server monitor. All existing monitors will be @@ -31,7 +30,7 @@ public interface IServerMonitorManager { * @param newMonitor * @throws CoreException */ - public void setServerMonitor(IServerMonitor newMonitor) throws CoreException; + //public void setServerMonitor(IServerMonitor newMonitor) throws CoreException; /** * Returns the array of ports that are currently being monitored. diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java index f806bb7df..e32b15db8 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java @@ -28,14 +28,6 @@ import org.eclipse.core.runtime.IProgressMonitor; * This interface is not intended to be implemented by clients. * </p> * <p> - * [issue: It is notoriously difficult to place any kind of - * useful order on objects that are contributed independently by - * non-collaborating parties. The IOrdered mechanism is weak, and - * can't really solve the problem. Issues of presentation are usually - * best left to the UI, which can sort objects based on arbitrary - * properties.] - * </p> - * <p> * [issue: Equality/identify for server types? Are IServerType * instances guaranteed to be canonical (client can use ==), * or is it possible for there to be non-identical IServerType @@ -49,7 +41,7 @@ import org.eclipse.core.runtime.IProgressMonitor; * * @since 1.0 */ -public interface IServerType extends IOrdered { +public interface IServerType { /** * Constant (value 0) indicating that a type of server that can be * directly started and stopped. @@ -275,55 +267,6 @@ public interface IServerType extends IOrdered { public boolean supportsRemoteHosts(); /** - * Returns whether this type of server can be monitored. - * <p> - * For instances of server types that can be monitored, - * the corresponding server delegate implements - * {@link org.eclipse.wst.server.core.model.IMonitorableServer}. - * </p> - * <p> - * [issue: Again, it seems odd to me that this is something - * hard-wired to a server type. Without loss of generality, - * the notion of "monitorable" need only show up at the - * server instance level. All that would be required - * would be to have the server delegate implement - * IMonitorableServer.] - * </p> - * <p> - * [issue: It's not clear how much of this is a client concern. - * If it is a client concern, care should be taken to do - * it in such a way that the server delegate does not need to be - * exposed to ordinary clients.] - * </p> - * - * @return <code>true</code> if this type of server can be monitored, - * and <code>false</code> if it cannot - */ - public boolean isMonitorable(); - - /** - * Returns whether this type of server can be used as a - * test environment. - * <p> - * [issue: How does one explain what a "test environment" is? - * How does this property of server types square with - * IRuntime.isTestEnvironment(), an *instance-specific* - * property of a server runtime (it's not on IRuntimeType)?] - * </p> - * <p> - * [issue: The old spec read: - * "Returns true if the "testEnvironment" attribute is set. If true, this - * server can only be created when there is an existing runtime that has - * the property "testEnvironment" set to true." - * ] - * </p> - * - * @return <code>true</code> if this type of server can be use as a - * test environment, and <code>false</code> if it cannot - */ - public boolean isTestEnvironment(); - - /** * Creates an working copy instance of this server type. * After setting various properties of the working copy, * the client should call {@link IServerWorkingCopy#save(IProgressMonitor)} @@ -339,6 +282,10 @@ public interface IServerType extends IOrdered { * Consider combining the method with the other.] * </p> * <p> + * The server returned from this method will have it's + * host set to "localhost". + * </p> + * <p> * [issue: This method is declared as throwing CoreException. * From a clients's point of view, what are the circumstances that * cause this operation to fail?] @@ -368,6 +315,10 @@ public interface IServerType extends IOrdered { * of a progress monitor.] * </p> * <p> + * The server returned from this method will have it's + * host set to "localhost". + * </p> + * <p> * [issue: The implementation of this method creates a server * config working copy, whereas the other one does not!? * Consider combining the method with the other.] @@ -379,7 +330,7 @@ public interface IServerType extends IOrdered { * </p> * * @param id the id to assign to the server instance; a generated - * id is used if id is <code>null</code> or an empty string + * id is used if id is <code>null</code> or an empty string * @param file the file in the workspace where the server instance * is to be serialized, or <code>null</code> if the information is * instead to be persisted with the workspace but not with any @@ -390,20 +341,20 @@ public interface IServerType extends IOrdered { * @throws CoreException [missing] */ public IServerWorkingCopy createServer(String id, IFile file, IProgressMonitor monitor) throws CoreException; - + /** * Return the timeout (in ms) that should be used to wait for the server to start. * Returns -1 if there is no timeout. * - * @return + * @return the server startup timeout */ public int getStartTimeout(); /** * Return the timeout (in ms) to wait before assuming that the server * has failed to stop. Returns -1 if there is no timeout. - * - * @return + * + * @return the server shutdown timeout */ public int getStopTimeout(); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerWorkingCopy.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerWorkingCopy.java index e194b34bd..784d4fd1b 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerWorkingCopy.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerWorkingCopy.java @@ -17,13 +17,6 @@ import org.eclipse.core.runtime.IProgressMonitor; * A working copy server object used for formulating changes * to a server instance ({@link IServer}). * <p> - * [issue: The default value of host name should be specified - * here (or in IServerType.createServer). If the initial value is null (or - * something simularly unsuitable for actual use), then IServer.getHost - * needs to be spec'd to allow null return, and save needs to deal with the - * case where the client forgets to initialize this property.] - * </p> - * <p> * [issue: The default value of runtime should be specified * here (or in IServerType.createServer). If the initial value is null (or * something simularly unsuitable for actual use), then IServer.getRuntime @@ -66,7 +59,7 @@ import org.eclipse.core.runtime.IProgressMonitor; * * @since 1.0 */ -public interface IServerWorkingCopy extends IServer, IElementWorkingCopy { +public interface IServerWorkingCopy extends IServerAttributes, IElementWorkingCopy { /** * Sets the server configuration associated with this server working copy. * <p> diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java index 42bc6b663..c298c79e0 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java @@ -97,7 +97,7 @@ public class ServerCore { /** * Returns the resource manager. * - * @return org.eclipse.wst.server.core.IResourceManager + * @return org.eclipse.wst.server.core.internal.ResourceManager */ private static ResourceManager getResourceManager() { return ResourceManager.getInstance(); @@ -155,16 +155,12 @@ public class ServerCore { * if none. This convenience method searches the list of known * runtime types ({@link #getRuntimeTypes()}) for the one with a matching * runtime type id ({@link IRuntimeType#getId()}). The id may not be null. - * <p> - * [issue: Consider renaming this method findRuntimeType to make - * it clear that it is searching.] - * </p> * * @param the runtime type id * @return the runtime type, or <code>null</code> if there is no runtime type * with the given id */ - public static IRuntimeType getRuntimeType(String id) { + public static IRuntimeType findRuntimeType(String id) { if (id == null) throw new IllegalArgumentException(); @@ -250,16 +246,12 @@ public class ServerCore { * if none. This convenience method searches the list of known * server types ({@link #getServerTypes()}) for the one with a matching * server type id ({@link IServerType#getId()}). The id may not be null. - * <p> - * [issue: Consider renaming this method findServerType to make - * it clear that it is searching.] - * </p> * * @param the server type id * @return the server type, or <code>null</code> if there is no server type * with the given id */ - public static IServerType getServerType(String id) { + public static IServerType findServerType(String id) { if (id == null) throw new IllegalArgumentException(); @@ -299,16 +291,12 @@ public class ServerCore { * ({@link #getServerConfigurationTypes()}) for the one a matching * server id ({@link IServerConfigurationType#getId()}). The id may not * be null. - * <p> - * [issue: Consider renaming this method findServerConfigurationType - * to make it clear that it is searching.] - * </p> * * @param the server configuration type id * @return the server configuration type, or <code>null</code> if * there is no server configuration type with the given id */ - public static IServerConfigurationType getServerConfigurationType(String id) { + public static IServerConfigurationType findServerConfigurationType(String id) { if (id == null) throw new IllegalArgumentException(); @@ -329,11 +317,6 @@ public class ServerCore { * <p> * A new array is returned on each call, so clients may store or modify the result. * </p> - * <p> - * [issue: Are module factories SPI-side objects or do - * normal clients need access to them? If they are only SPI, - * this method should be moved to the SPI package.] - * </p> * * @return the array of module factories {@link IModuleFactory} */ @@ -351,21 +334,12 @@ public class ServerCore { * if none. This convenience method searches the list of known * module factories ({@link #getModuleFactories()}) for the one a matching * module factory id ({@link IModuleFactory#getId()}). The id may not be null. - * <p> - * [issue: Consider renaming this method findModuleFactory - * to make it clear that it is searching.] - * </p> - * <p> - * [issue: Are module factories SPI-side objects or do - * normal clients need access to them? If they are only SPI, - * this method should be moved to the SPI package.] - * </p> * * @param the module factory id * @return the module factory, or <code>null</code> if there is no module factory * with the given id */ - /*public static IModuleFactory getModuleFactory(String id) { + /*public static IModuleFactory findModuleFactory(String id) { if (id == null) throw new IllegalArgumentException(); @@ -494,7 +468,7 @@ public class ServerCore { Trace.trace(Trace.SEVERE, " Could not load runtimeType: " + cf[i].getAttribute("id"), t); } } - ServerUtil.sortOrderedList(runtimeTypes); + sortOrderedList(runtimeTypes); Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .runtimeTypes extension point -<-"); } @@ -545,7 +519,7 @@ public class ServerCore { Trace.trace(Trace.SEVERE, " Could not load runtimeTargetHandler: " + cf[i].getAttribute("id"), t); } } - ServerUtil.sortOrderedList(runtimeTargetHandlers); + sortOrderedList(runtimeTargetHandlers); Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .runtimeTargetHandlers extension point -<-"); } @@ -571,7 +545,7 @@ public class ServerCore { Trace.trace(Trace.SEVERE, " Could not load serverType: " + cf[i].getAttribute("id"), t); } } - ServerUtil.sortOrderedList(serverTypes); + sortOrderedList(serverTypes); Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .serverTypes extension point -<-"); } @@ -597,7 +571,7 @@ public class ServerCore { Trace.trace(Trace.SEVERE, " Could not load serverConfigurationType: " + cf[i].getAttribute("id"), t); } } - ServerUtil.sortOrderedList(serverConfigurationTypes); + sortOrderedList(serverConfigurationTypes); Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .serverConfigurationTypes extension point -<-"); } @@ -622,7 +596,8 @@ public class ServerCore { Trace.trace(Trace.SEVERE, " Could not load moduleFactories: " + cf[i].getAttribute("id"), t); } } - ServerUtil.sortOrderedList(moduleFactories); + sortOrderedList(moduleFactories); + Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .moduleFactories extension point -<-"); } @@ -716,7 +691,8 @@ public class ServerCore { } } - ServerUtil.sortOrderedList(serverTasks); + sortOrderedList(serverTasks); + Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .serverTasks extension point -<-"); } @@ -749,16 +725,12 @@ public class ServerCore { * if none. This convenience method searches the list of known * runtimes ({@link #getRuntimes()}) for the one with a matching * runtime id ({@link IRuntime#getId()}). The id may not be null. - * <p> - * [issue: Consider renaming this method findRuntime to make - * it clear that it is searching.] - * </p> * * @param the runtime id * @return the runtime instance, or <code>null</code> if there is no runtime * with the given id */ - public static IRuntime getRuntime(String id) { + public static IRuntime findRuntime(String id) { return getResourceManager().getRuntime(id); } @@ -780,16 +752,12 @@ public class ServerCore { * if none. This convenience method searches the list of known * servers ({@link #getServers()}) for the one with a matching * server id ({@link IServer#getId()}). The id must not be null. - * <p> - * [issue: Consider renaming this method findServer to make - * it clear that it is searching.] - * </p> * * @param the server id * @return the server instance, or <code>null</code> if there is no server * with the given id */ - public static IServer getServer(String id) { + public static IServer findServer(String id) { return getResourceManager().getServer(id); } @@ -799,16 +767,12 @@ public class ServerCore { * server configurations ({@link #getServerConfigurations()}) for the one * with a matching server configuration id * ({@link IServerConfiguration#getId()}). The id must not be null. - * <p> - * [issue: Consider renaming this method findServerConfiguration to make - * it clear that it is searching.] - * </p> * * @param the server configuration id * @return the server configuration instance, or <code>null</code> if * there is no server configuration with the given id */ - public static IServerConfiguration getServerConfiguration(String id) { + public static IServerConfiguration findServerConfiguration(String id) { return getResourceManager().getServerConfiguration(id); } @@ -943,4 +907,30 @@ public class ServerCore { public static void removeModuleEventsListener(IModuleEventsListener listener) { getResourceManager().removeModuleEventsListener(listener); } + + /** + * Sort the given list of IOrdered items into indexed order. This method + * modifies the original list, but returns the value for convenience. + * + * @param list java.util.List + * @return java.util.List + */ + private static List sortOrderedList(List list) { + if (list == null) + return null; + + int size = list.size(); + for (int i = 0; i < size - 1; i++) { + for (int j = i + 1; j < size; j++) { + IOrdered a = (IOrdered) list.get(i); + IOrdered b = (IOrdered) list.get(j); + if (a.getOrder() > b.getOrder()) { + Object temp = a; + list.set(i, b); + list.set(j, temp); + } + } + } + return list; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java index 7f3ee916c..3db808f6f 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java @@ -633,7 +633,7 @@ public class ServerUtil { /** * Visit all the modules in the server configuration. */ - public static void visit(IServer server, IModuleVisitor visitor, IProgressMonitor monitor) { + public static void visit(IServerAttributes server, IModuleVisitor visitor, IProgressMonitor monitor) { if (server == null) return; @@ -650,7 +650,7 @@ public class ServerUtil { /** * Returns true to keep visiting, and false to stop. */ - private static boolean visitModule(IServer server, IModule[] parents, IModule module, IModuleVisitor visitor, IProgressMonitor monitor) { + private static boolean visitModule(IServerAttributes server, IModule[] parents, IModule module, IModuleVisitor visitor, IProgressMonitor monitor) { if (server == null || module == null || parents == null) return true; @@ -845,58 +845,6 @@ public class ServerUtil { } return name; } - - /** - * Sort the given list of IOrdered items into indexed order. This method - * modifies the original list, but returns the value for convenience. - * - * @param list java.util.List - * @return java.util.List - */ - public static List sortOrderedList(List list) { - if (list == null) - return null; - - int size = list.size(); - for (int i = 0; i < size - 1; i++) { - for (int j = i + 1; j < size; j++) { - IOrdered a = (IOrdered) list.get(i); - IOrdered b = (IOrdered) list.get(j); - if (a.getOrder() > b.getOrder()) { - Object temp = a; - list.set(i, b); - list.set(j, temp); - } - } - } - return list; - } - - /** - * Sort the given list of IOrdered items into reverse indexed order. This method - * modifies the original list, but returns the value for convenience. - * - * @param list java.util.List - * @return java.util.List - */ - public static List sortOrderedListReverse(List list) { - if (list == null) - return null; - - int size = list.size(); - for (int i = 0; i < size - 1; i++) { - for (int j = i + 1; j < size; j++) { - IOrdered a = (IOrdered) list.get(i); - IOrdered b = (IOrdered) list.get(j); - if (a.getOrder() < b.getOrder()) { - Object temp = a; - list.set(i, b); - list.set(j, temp); - } - } - } - return list; - } /** * Return a list of all runtime targets that match the given type and version. diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Base.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Base.java index 005d3e8d4..ca24fde5c 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Base.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Base.java @@ -158,7 +158,6 @@ public abstract class Base { saveList(child, key, list); } else if (obj instanceof Map) { Map vMap = (Map) obj; - //FIXME: ASSUMPTION MAP STORES STRINGS ONLY saveMap(child,key,vMap); } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IOrdered.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IOrdered.java new file mode 100644 index 000000000..3afa850fd --- /dev/null +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IOrdered.java @@ -0,0 +1,33 @@ +/********************************************************************** + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - Initial API and implementation + **********************************************************************/ +package org.eclipse.wst.server.core.internal; +/** + * An object that has an absolute ordering, and can be ordered against other objects. + * + * <p> + * [issue: It is notoriously difficult to place any kind of + * useful order on objects that are contributed independently by + * non-collaborating parties. The IOrdered mechanism is weak, and + * can't really solve the problem. Issues of presentation are usually + * best left to the UI, which can sort objects based on arbitrary + * properties.] + * </p> + * + * <p>This interface is not intended to be implemented by clients.</p> + */ +public interface IOrdered { + /** + * Returns the order (index/priority). + * + * @return int + */ + public int getOrder(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerMonitor.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IServerMonitor.java index c42494570..25165ee6e 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerMonitor.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IServerMonitor.java @@ -8,10 +8,7 @@ * Contributors: * IBM Corporation - Initial API and implementation **********************************************************************/ -package org.eclipse.wst.server.core; - -import org.eclipse.core.runtime.CoreException; - +package org.eclipse.wst.server.core.internal; /** * An interface to a TCP/IP monitor. * @@ -47,12 +44,12 @@ public interface IServerMonitor { * @param port * @return */ - public int startMonitoring(IServer server, IServerPort port, int monitorPort) throws CoreException; + //public int startMonitoring(IServer server, IServerPort port, int monitorPort) throws CoreException; /** * Stop monitoring the given port. * * @param port */ - public void stopMonitoring(IServer server, IServerPort port); -} + //public void stopMonitoring(IServer server, IServerPort port); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java index 22ee6dd20..d5556de66 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java @@ -77,10 +77,10 @@ public class Module implements IModule { return name; } - public ModuleDelegate getDelegate(IProgressMonitor monitor) { + protected ModuleDelegate getDelegate() { if (delegate == null) { try { - delegate = null; // TODO + delegate = factory.getDelegate().getModuleDelegate(this); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Could not create delegate" + toString() + ": " + e.getMessage()); } @@ -95,7 +95,7 @@ public class Module implements IModule { */ public IModule[] getChildModules(IProgressMonitor monitor) { try { - return getDelegate(monitor).getChildModules(); + return getDelegate().getChildModules(); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate getChildModules() " + toString(), e); return null; @@ -109,7 +109,7 @@ public class Module implements IModule { */ public IStatus validate(IProgressMonitor monitor) { try { - return getDelegate(monitor).validate(); + return getDelegate().validate(); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate validate() " + toString(), e); return null; @@ -173,7 +173,7 @@ public class Module implements IModule { * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter(Class adapter) { - ModuleDelegate delegate2 = getDelegate(null); + ModuleDelegate delegate2 = getDelegate(); if (adapter.isInstance(delegate2)) return delegate; return null; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java index 0ebbaf2a9..75ddfd556 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. + * Copyright (c) 2003, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -18,13 +18,12 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.IOrdered; import org.eclipse.wst.server.core.model.ModuleFactoryDelegate; import org.eclipse.wst.server.core.model.IModuleFactoryListener; /** * */ -public class ModuleFactory implements IOrdered { +public class ModuleFactory { private IConfigurationElement element; private ModuleFactoryDelegate delegate; private List moduleTypes; @@ -174,4 +173,4 @@ public class ModuleFactory implements IOrdered { public String toString() { return "ModuleFactory[" + getId() + "]"; } -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ProjectProperties.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ProjectProperties.java index 8f5dd02a9..7b1ca44fb 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ProjectProperties.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ProjectProperties.java @@ -135,7 +135,7 @@ public class ProjectProperties implements IProjectProperties { if (serverId == null || serverId.length() == 0) return null; - IServer server = ServerCore.getServer(serverId); + IServer server = ServerCore.findServer(serverId); /*if (server != null && ServerUtil.containsModule(server, module)) return server; else @@ -178,7 +178,7 @@ public class ProjectProperties implements IProjectProperties { loadPreferences(); if (runtimeId == null) return null; - return ServerCore.getRuntime(runtimeId); + return ServerCore.findRuntime(runtimeId); } /** @@ -189,7 +189,7 @@ public class ProjectProperties implements IProjectProperties { */ public void setRuntimeTarget(IRuntime runtime, IProgressMonitor monitor) throws CoreException { loadPreferences(); - IRuntime oldRuntime = ServerCore.getRuntime(runtimeId); + IRuntime oldRuntime = ServerCore.findRuntime(runtimeId); setRuntimeTarget(oldRuntime, runtime, true, monitor); } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java index 55a3ba221..d1cbc142c 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java @@ -456,17 +456,6 @@ public class ResourceManager { return; Trace.trace(Trace.RESOURCES, "Deregistering server: " + server.getName()); - - // terminate server if it is being deleted! - // TODO - should we be doing this? - /*int state = server.getServerState(); - if (state != IServer.STATE_STOPPED && state != IServer.STATE_STOPPING && - state != IServer.STATE_UNKNOWN) { - IServerExtension extension = server.getExtension(null); - if (extension instanceof IStartableServer) { - ((IStartableServer) extension).terminate(); - } - }*/ ((Server) server).deleteLaunchConfigurations(); ServerPlugin.getInstance().removeTempDirectory(server.getId(), new NullProgressMonitor()); @@ -823,7 +812,7 @@ public class ResourceManager { IRuntime a = (IRuntime) list.get(i); IRuntime b = (IRuntime) list.get(j); if (a.getRuntimeType() != null && b.getRuntimeType() != null && - a.getRuntimeType().getOrder() < b.getRuntimeType().getOrder()) { + ((RuntimeType)a.getRuntimeType()).getOrder() < ((RuntimeType)b.getRuntimeType()).getOrder()) { Object temp = a; list.set(i, b); list.set(j, temp); @@ -840,7 +829,7 @@ public class ResourceManager { list.toArray(r); return r; } - + /** * Returns the runtime with the given id. * diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Runtime.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Runtime.java index a1ad833cd..247ccdcd1 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Runtime.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Runtime.java @@ -149,7 +149,7 @@ public class Runtime extends Base implements IRuntime { protected void loadState(IMemento memento) { String runtimeTypeId = memento.getString(PROP_RUNTIME_TYPE_ID); - runtimeType = ServerCore.getRuntimeType(runtimeTypeId); + runtimeType = ServerCore.findRuntimeType(runtimeTypeId); } protected void saveState(IMemento memento) { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/RuntimeType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/RuntimeType.java index e0c67d068..818074206 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/RuntimeType.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/RuntimeType.java @@ -18,7 +18,7 @@ import org.eclipse.wst.server.core.*; /** * */ -public class RuntimeType implements IRuntimeType { +public class RuntimeType implements IRuntimeType, IOrdered { private IConfigurationElement element; private List moduleTypes; @@ -54,7 +54,7 @@ public class RuntimeType implements IRuntimeType { public String getDescription() { return element.getAttribute("description"); } - + /** * Returns the order. * diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java index 5ec287d42..796144f9f 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java @@ -34,6 +34,7 @@ public class Server extends Base implements IServer { protected IServerType serverType; protected ServerDelegate delegate; + protected ServerBehaviourDelegate behaviourDelegate; protected IRuntime runtime; protected IServerConfiguration configuration; @@ -117,7 +118,7 @@ public class Server extends Base implements IServer { return configuration; } - public ServerDelegate getDelegate(IProgressMonitor monitor) { + protected ServerDelegate getDelegate() { if (delegate != null) return delegate; @@ -139,6 +140,28 @@ public class Server extends Base implements IServer { return delegate; } + protected ServerBehaviourDelegate getBehaviourDelegate() { + if (behaviourDelegate != null) + return behaviourDelegate; + + if (serverType != null) { + synchronized (this) { + if (behaviourDelegate == null) { + try { + long time = System.currentTimeMillis(); + IConfigurationElement element = ((ServerType) serverType).getElement(); + behaviourDelegate = (ServerBehaviourDelegate) element.createExecutableExtension("behaviourClass"); + behaviourDelegate.initialize(this); + Trace.trace(Trace.PERFORMANCE, "Server.getDelegate(): <" + (System.currentTimeMillis() - time) + "> " + getServerType().getId()); + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Could not create delegate " + toString(), e); + } + } + } + } + return behaviourDelegate; + } + /** * Returns true if the delegate has been loaded. * @@ -380,7 +403,7 @@ public class Server extends Base implements IServer { deployableDelta[i] = moduleProjects[i].getModuleResourceDelta(delta); if (deployableDelta[i] != null) { - // TODO updateDeployable(module, deployableDelta[i]); + // updateDeployable(module, deployableDelta[i]); PublishControl control = PublishInfo.getPublishInfo().getPublishControl(Server.this, parents, module); if (control.isDirty()) @@ -736,28 +759,31 @@ public class Server extends Base implements IServer { multi.add(taskStatus); if (monitor.isCanceled()) - return null; // TODO + return new Status(IStatus.INFO, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%publishingCancelled"), null); // start publishing Trace.trace(Trace.FINEST, "Opening connection to the remote server"); firePublishStarted(); //boolean connectionOpen = false; try { - getDelegate(monitor).publishStart(ProgressUtil.getSubMonitorFor(monitor, 1000)); + getBehaviourDelegate().publishStart(ProgressUtil.getSubMonitorFor(monitor, 1000)); } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Error starting publish to " + toString(), ce); - Status ps = new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%xxx"), null); // TODO - firePublishFinished(ps); + Trace.trace(Trace.INFO, "CoreException publishing to " + toString(), ce); + firePublishFinished(ce.getStatus()); return ce.getStatus(); } - // publish the configuration + // publish the server try { if (!monitor.isCanceled() && serverType.hasServerConfiguration()) { - delegate.publishServer(ProgressUtil.getSubMonitorFor(monitor, 1000)); + getBehaviourDelegate().publishServer(ProgressUtil.getSubMonitorFor(monitor, 1000)); } + } catch (CoreException ce) { + Trace.trace(Trace.INFO, "CoreException publishing to " + toString(), ce); + multi.add(ce.getStatus()); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error publishing configuration to " + toString(), e); + multi.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorPublishing"), e)); } // remove old modules @@ -770,14 +796,17 @@ public class Server extends Base implements IServer { // end the publishing Trace.trace(Trace.FINEST, "Closing connection with the remote server"); try { - delegate.publishStop(ProgressUtil.getSubMonitorFor(monitor, 500)); + getBehaviourDelegate().publishFinish(ProgressUtil.getSubMonitorFor(monitor, 500)); } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Error stopping publish to " + toString(), ce); - // TODO + Trace.trace(Trace.INFO, "CoreException publishing to " + toString(), ce); + multi.add(ce.getStatus()); + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Error stopping publish to " + toString(), e); + multi.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorPublishing"), e)); } - + if (monitor.isCanceled()) { - IStatus status = new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%publishingCancelled"), null); + IStatus status = new Status(IStatus.INFO, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%publishingCancelled"), null); multi.add(status); } @@ -805,7 +834,7 @@ public class Server extends Base implements IServer { Status multi = new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%publishingProject", module.getName()), null); try { - getDelegate(monitor).publishModule(parents, module, monitor); + getBehaviourDelegate().publishModule(parents, module, monitor); } catch (CoreException ce) { // ignore } @@ -867,11 +896,37 @@ public class Server extends Base implements IServer { } } - ServerUtil.sortOrderedList(tasks); + sortOrderedList(tasks); return tasks; } + /** + * Sort the given list of IOrdered items into indexed order. This method + * modifies the original list, but returns the value for convenience. + * + * @param list java.util.List + * @return java.util.List + */ + private static List sortOrderedList(List list) { + if (list == null) + return null; + + int size = list.size(); + for (int i = 0; i < size - 1; i++) { + for (int j = i + 1; j < size; j++) { + IOrdered a = (IOrdered) list.get(i); + IOrdered b = (IOrdered) list.get(j); + if (a.getOrder() > b.getOrder()) { + Object temp = a; + list.set(i, b); + list.set(j, temp); + } + } + } + return list; + } + protected IStatus performTasks(List tasks, IProgressMonitor monitor) { Trace.trace(Trace.FINEST, "Performing tasks: " + tasks.size()); @@ -909,9 +964,12 @@ public class Server extends Base implements IServer { * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter(Class adapter) { - ServerDelegate delegate2 = getDelegate(null); + ServerDelegate delegate2 = getDelegate(); if (adapter.isInstance(delegate2)) - return delegate; + return delegate2; + ServerBehaviourDelegate delegate3 = getBehaviourDelegate(); + if (adapter.isInstance(delegate3)) + return delegate3; return null; } @@ -962,7 +1020,7 @@ public class Server extends Base implements IServer { public void setLaunchDefaults(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) { try { - getDelegate(monitor).setLaunchDefaults(workingCopy); + getBehaviourDelegate().setLaunchDefaults(workingCopy); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate setLaunchDefaults() " + toString(), e); } @@ -1107,7 +1165,7 @@ public class Server extends Base implements IServer { try { try { - getDelegate(null).restart(mode2); + getBehaviourDelegate().restart(mode2); return; } catch (CoreException ce) { Trace.trace(Trace.SEVERE, "Error calling delegate restart() " + toString()); @@ -1143,7 +1201,7 @@ public class Server extends Base implements IServer { }); // stop the server - stop(); + stop(false); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error restarting server", e); } @@ -1166,34 +1224,18 @@ public class Server extends Base implements IServer { /** * Stop the server if it is running. */ - public void stop() { + public void stop(boolean force) { if (getServerState() == STATE_STOPPED) return; Trace.trace(Trace.FINEST, "Stopping server: " + toString()); try { - getDelegate(null).stop(); + getBehaviourDelegate().stop(force); } catch (Throwable t) { Trace.trace(Trace.SEVERE, "Error calling delegate stop() " + toString(), t); } } - - /** - * Terminate the server process(es). This method should only be - * used as a last resort after the stop() method fails to work. - * The server should return from this method quickly and - * use the server listener to notify shutdown progress. - * It MUST terminate the server completely and return it to - * the stopped state. - */ - public void terminate() { - try { - getDelegate(null).terminate(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate terminate() " + toString(), e); - } - } /** * Start the server in the given start mode and waits until the server @@ -1346,7 +1388,7 @@ public class Server extends Base implements IServer { thread.start(); // stop the server - stop(); + stop(false); // wait for it! wait for it! synchronized (mutex) { @@ -1432,7 +1474,7 @@ public class Server extends Base implements IServer { // restart the module try { - getDelegate(monitor).restartModule(module, monitor); + getBehaviourDelegate().restartModule(module, monitor); } catch (CoreException e) { removeServerListener(listener); throw e; @@ -1483,15 +1525,15 @@ public class Server extends Base implements IServer { protected void resolve() { IServerType oldServerType = serverType; String serverTypeId = getAttribute("server-type-id", (String)null); - serverType = ServerCore.getServerType(serverTypeId); + serverType = ServerCore.findServerType(serverTypeId); if (serverType != null && !serverType.equals(oldServerType)) serverState = ((ServerType)serverType).getInitialState(); String runtimeId = getAttribute(RUNTIME_ID, (String)null); - runtime = ServerCore.getRuntime(runtimeId); + runtime = ServerCore.findRuntime(runtimeId); String configurationId = getAttribute(CONFIGURATION_ID, (String)null); - configuration = ServerCore.getServerConfiguration(configurationId); + configuration = ServerCore.findServerConfiguration(configurationId); } protected void setInternal(ServerWorkingCopy wc) { @@ -1535,7 +1577,7 @@ public class Server extends Base implements IServer { */ public IStatus canModifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor) { try { - return getDelegate(monitor).canModifyModules(add, remove); + return getDelegate().canModifyModules(add, remove); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate canModifyModules() " + toString(), e); return null; @@ -1547,7 +1589,7 @@ public class Server extends Base implements IServer { */ public IModule[] getModules(IProgressMonitor monitor) { try { - return getDelegate(monitor).getModules(); + return getDelegate().getModules(); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate getModules() " + toString(), e); return new IModule[0]; @@ -1587,7 +1629,7 @@ public class Server extends Base implements IServer { */ public IModule[] getChildModules(IModule module, IProgressMonitor monitor) { try { - return getDelegate(monitor).getChildModules(module); + return getDelegate().getChildModules(module); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate getChildModules() " + toString(), e); return null; @@ -1599,7 +1641,7 @@ public class Server extends Base implements IServer { */ public IModule[] getParentModules(IModule module, IProgressMonitor monitor) throws CoreException { try { - return getDelegate(monitor).getParentModules(module); + return getDelegate().getParentModules(module); } catch (CoreException se) { //Trace.trace(Trace.FINER, "CoreException calling delegate getParentModules() " + toString() + ": " + se.getMessage()); throw se; @@ -1630,7 +1672,7 @@ public class Server extends Base implements IServer { */ public boolean canRestartModule(IModule module) { try { - return getDelegate(null).canRestartModule(module); + return getBehaviourDelegate().canRestartModule(module); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate canRestartRuntime() " + toString(), e); return false; @@ -1661,7 +1703,7 @@ public class Server extends Base implements IServer { */ public void restartModule(IModule module, IProgressMonitor monitor) throws CoreException { try { - getDelegate(monitor).restartModule(module, monitor); + getBehaviourDelegate().restartModule(module, monitor); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate restartModule() " + toString(), e); } @@ -1674,7 +1716,7 @@ public class Server extends Base implements IServer { */ public IServerPort[] getServerPorts() { try { - return getDelegate(null).getServerPorts(); + return getDelegate().getServerPorts(); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate getServerPorts() " + toString(), e); return null; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerConfiguration.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerConfiguration.java index eb25cfcf7..4b31f6971 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerConfiguration.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerConfiguration.java @@ -229,7 +229,7 @@ public class ServerConfiguration extends Base implements IServerConfiguration { protected void loadState(IMemento memento) { String serverTypeId = memento.getString("server-configuration-type-id"); - configurationType = ServerCore.getServerConfigurationType(serverTypeId); + configurationType = ServerCore.findServerConfigurationType(serverTypeId); } protected void saveState(IMemento memento) { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerConfigurationType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerConfigurationType.java index bdab75747..4baa00166 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerConfigurationType.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerConfigurationType.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. + * Copyright (c) 2003, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -20,7 +20,7 @@ import org.eclipse.wst.server.core.*; /** * */ -public class ServerConfigurationType implements IServerConfigurationType { +public class ServerConfigurationType implements IServerConfigurationType, IOrdered { protected IConfigurationElement element; /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitor.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitor.java index f4d73daf8..77b1e35cf 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitor.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitor.java @@ -14,7 +14,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerMonitor; import org.eclipse.wst.server.core.IServerPort; import org.eclipse.wst.server.core.model.ServerMonitorDelegate; /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitorManager.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitorManager.java index 5fc06888c..4130ec699 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitorManager.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitorManager.java @@ -26,7 +26,7 @@ public class ServerMonitorManager implements IServerMonitorManager { protected static ServerMonitorManager instance; protected List ports = new ArrayList(); - protected IServerMonitor monitor; + protected ServerMonitor monitor; class MonitoredPort implements IMonitoredServerPort { protected IServer server; @@ -124,7 +124,7 @@ public class ServerMonitorManager implements IServerMonitorManager { protected void load(IMemento memento, IProgressMonitor monitor2) { String serverId = memento.getString("serverId"); - server = ServerCore.getServer(serverId); + server = ServerCore.findServer(serverId); if (server == null) throw new RuntimeException("Server could not be found: " + serverId + " " + server); String newPortStr = memento.getString("port"); @@ -163,7 +163,7 @@ public class ServerMonitorManager implements IServerMonitorManager { public ServerMonitorManager() { IServerMonitor[] monitors = ServerCore.getServerMonitors(); if (monitors != null && monitors.length > 0) - monitor = monitors[0]; + monitor = (ServerMonitor) monitors[0]; instance = this; loadMonitors(); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java index 78d666d2f..adf5e1acd 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java @@ -22,7 +22,7 @@ import org.eclipse.wst.server.core.*; /** * */ -public class ServerType implements IServerType { +public class ServerType implements IServerType, IOrdered { protected IConfigurationElement element; /** @@ -55,7 +55,7 @@ public class ServerType implements IServerType { } public IRuntimeType getRuntimeType() { - return ServerCore.getRuntimeType(element.getAttribute("runtimeTypeId")); + return ServerCore.findRuntimeType(element.getAttribute("runtimeTypeId")); } public boolean hasRuntime() { @@ -106,7 +106,7 @@ public class ServerType implements IServerType { public IServerConfigurationType getServerConfigurationType() { String configurationTypeId = element.getAttribute("configurationTypeId"); - return ServerCore.getServerConfigurationType(configurationTypeId); + return ServerCore.findServerConfigurationType(configurationTypeId); } public boolean supportsRemoteHosts() { @@ -142,14 +142,6 @@ public class ServerType implements IServerType { return configurationTypeId != null && configurationTypeId.length() > 0; } - public boolean isMonitorable() { - return "true".equalsIgnoreCase(element.getAttribute("monitorable")); - } - - public boolean isTestEnvironment() { - return "true".equalsIgnoreCase(element.getAttribute("testEnvironment")); - } - public IServerWorkingCopy createServer(String id, IFile file, IRuntime runtime, IProgressMonitor monitor) { if (id == null || id.length() == 0) id = ServerPlugin.generateId(); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerWorkingCopy.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerWorkingCopy.java index 32ea6f3bc..8e09e5521 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerWorkingCopy.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerWorkingCopy.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. + * Copyright (c) 2003, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -18,7 +18,7 @@ import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.*; import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.model.*; +import org.eclipse.wst.server.core.model.ServerDelegate; /** * */ @@ -26,7 +26,7 @@ public class ServerWorkingCopy extends Server implements IServerWorkingCopy { protected Server server; protected WorkingCopyHelper wch; - protected ServerWorkingCopyDelegate workingCopyDelegate; + protected ServerDelegate workingCopyDelegate; // working copy public ServerWorkingCopy(Server server) { @@ -130,7 +130,7 @@ public class ServerWorkingCopy extends Server implements IServerWorkingCopy { return wch.isDirty(); } - public ServerWorkingCopyDelegate getWorkingCopyDelegate(IProgressMonitor monitor) { + public ServerDelegate getWorkingCopyDelegate(IProgressMonitor monitor) { // make sure that the regular delegate is loaded //getDelegate(); @@ -143,7 +143,7 @@ public class ServerWorkingCopy extends Server implements IServerWorkingCopy { try { long time = System.currentTimeMillis(); IConfigurationElement element = ((ServerType) serverType).getElement(); - workingCopyDelegate = (ServerWorkingCopyDelegate) element.createExecutableExtension("workingCopyClass"); + workingCopyDelegate = (ServerDelegate) element.createExecutableExtension("class"); workingCopyDelegate.initialize(this); Trace.trace(Trace.PERFORMANCE, "ServerWorkingCopy.getWorkingCopyDelegate(): <" + (System.currentTimeMillis() - time) + "> " + getServerType().getId()); } catch (Exception e) { @@ -178,7 +178,6 @@ public class ServerWorkingCopy extends Server implements IServerWorkingCopy { server.setInternal(this); server.doSave(monitor); wch.setDirty(false); - getWorkingCopyDelegate(monitor).handleSave(monitor); return server; } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServer.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServer.java index 1d3d44d14..d79a11ebe 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServer.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServer.java @@ -17,10 +17,15 @@ import org.eclipse.core.runtime.IStatus; public interface IServer { /** * + */ + public boolean canOperate(IServerOperation[] operations); + + /** + * * @param operation * @param state * @param synchronous * @return */ - public IStatus operate(IServerOperation[] operation, ServerState state, boolean synchronous); + public IStatus operate(IServerOperation[] operations, ServerState state, boolean synchronous); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ServerState.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ServerState.java index 8b94c4391..3de9c9b26 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ServerState.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ServerState.java @@ -12,7 +12,6 @@ package org.eclipse.wst.server.core.internal.operations; import java.util.ArrayList; import java.util.List; - /** * A server state. */ diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StopServerOperation.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StopServerOperation.java new file mode 100644 index 000000000..762dc8847 --- /dev/null +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StopServerOperation.java @@ -0,0 +1,23 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.wst.server.core.internal.operations; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +/** + * Start server operation. + */ +public class StopServerOperation implements IServerOperation { + public IStatus execute(IProgressMonitor monitor) throws CoreException { + return null; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java index 5b3158f33..72750d1a3 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java @@ -27,16 +27,6 @@ import org.eclipse.wst.server.core.util.ModuleFactoryEvent; * constructor. * </p> * <p> - * [issue: 2 differences from server delegate. - * (1) module factory delegate is associated with the module factory - * itself (server delegates are associated with each server instance - * (2) the module factory delegate has no backpoint to its IModuleFactory. - * The first is ok; the second is problematic because there is - * protocol on IModuleFactory that the delegate might need, such - * as the module factory id. Should add an initialize(IModuleFactory) - * method and spec that initialize is called at creation time.] - * </p> - * <p> * Module factory delegates may keep state in instance fields, but that state is * transient and will not be persisted across workbench sessions. * </p> @@ -56,6 +46,16 @@ public abstract class ModuleFactoryDelegate { private ModuleFactory factory; + /** + * Initializes this module factory delegate with its life-long module + * factory instance. + * <p> + * This method is called by the server core framework. + * Clients should never call this method. + * </p> + * + * @param newFactory the module factory instance + */ public final void initialize(ModuleFactory newFactory) { factory = newFactory; } @@ -64,7 +64,7 @@ public abstract class ModuleFactoryDelegate { return factory.getId(); } - protected IModule createModule(String type) { + public IModule createModule(String type) { return null; } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeDelegate.java index edb614b16..e5c6b534c 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeDelegate.java @@ -37,15 +37,8 @@ import org.eclipse.wst.server.core.internal.ServerPlugin; * </p> * <p> * Runtime delegates may keep state in instance fields, but that state is - * transient and will not be persisted across workbench sessions. - * </p> - * <p> - * [issue: Runtime delegates can read runtime attributes via - * IRuntime; runtime working copy delegates can also set them - * via IRuntimeWorkingCopy. However, current implementation does - * not serialize any attributes other than the ones server core - * knows about. So it's unclear whether there is any intent - * to support attributes that are runtime-type-specific.] + * transient and will not be persisted across workbench sessions. To save state + * across workbench sessions, it must be persisted using the attributes. * </p> * <p> * This abstract class is intended to be extended only by clients @@ -57,6 +50,7 @@ import org.eclipse.wst.server.core.internal.ServerPlugin; * </p> * * @see IRuntime + * @see IRuntimeWorkingCopy * @since 1.0 */ public abstract class RuntimeDelegate { @@ -68,18 +62,21 @@ public abstract class RuntimeDelegate { } /** + * Initialize this runtime delegate. + */ + public void initialize() { + // do nothing + } + + /** * Initializes this runtime delegate with its life-long runtime instance. * <p> - * This method is called by the web server core framework. + * This method is called by the server core framework. * Clients should never call this method. * </p> * - * @param runtime the runtime instance + * @param server the runtime instance */ - public void initialize() { - // do nothing - } - public final void initialize(Runtime newRuntime) { runtime = newRuntime; if (runtime instanceof RuntimeWorkingCopy) @@ -227,10 +224,7 @@ public abstract class RuntimeDelegate { /** * Sets the value of the specified list-valued attribute of this - * element. The list may only contain Strings. - * <p> - * [issue: Serialization/deserialization] - * </p> + * element. The list may only contain String values. * * @param id the attribute id * @param value the value of the specified attribute @@ -241,10 +235,7 @@ public abstract class RuntimeDelegate { /** * Sets the value of the specified map-valued attribute of this - * element. - * <p> - * [issue: Serialization/deserialization] - * </p> + * element. The map may only contain String values. * * @param id the attribute id * @param value the value of the specified attribute diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerBehaviourDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerBehaviourDelegate.java new file mode 100644 index 000000000..4332325da --- /dev/null +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerBehaviourDelegate.java @@ -0,0 +1,341 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - Initial API and implementation + **********************************************************************/ +package org.eclipse.wst.server.core.model; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.wst.server.core.IModule; +import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.internal.Server; +/** + * A server delegate provides the implementation for various + * generic and server-type-specific operations for a specific type of server. + * A server delegate is specified by the + * <code>class</code> attribute of a <code>serverTypes</code> extension. + * <p> + * When the server instance needs to be given a delegate, the delegate class + * specified for the server type is instantiated with a 0-argument constructor + * and primed with <code>delegate.initialize(((IServerState)server)</code>, + * which it is expected to hang on to. Later, when + * <code>delegate.dispose()</code> is called as the server instance is + * being discarded, the delegate is expected to let go of the server instance. + * </p> + * <p> + * Server delegates may keep state in instance fields, but that state is + * transient and will not be persisted across workbench sessions. + * </p> + * <p> + * This abstract class is intended to be extended only by clients + * to extend the <code>serverTypes</code> extension point. + * </p> + * <p> + * <it>Caveat: The server core API is still in an early form, and is + * likely to change significantly before the initial release.</it> + * </p> + * + * @see IServer#getExtension() + * @since 1.0 + */ +public abstract class ServerBehaviourDelegate { + private Server server; + + public ServerBehaviourDelegate() { + // do nothing + } + + /** + * Initializes this server delegate with its life-long server instance. + * <p> + * This method is called by the server core framework. + * Clients should never call this method. + * </p> + * + * @param server the server instance + */ + public final void initialize(Server newServer) { + server = newServer; + initialize(); + } + + public void initialize() { + // do nothing + } + + public final IServer getServer() { + return server; + } + + /** + * Sets the current state of this server. + * + * @param state one of the server state (<code>STATE_XXX</code>) + * constants declared on {@link IServer} + * @see IServer#getServerState() + */ + public final void setServerState(int state) { + server.setServerState(state); + } + + public final void setMode(String mode) { + server.setMode(mode); + } + + /** + * Sets the server restart state. + * + * @param state boolean + */ + public final void setServerRestartState(boolean state) { + server.setServerRestartState(state); + } + + /** + * Sets the server publish state. + * + * @param state int + */ + public final void setServerPublishState(int state) { + server.setServerPublishState(state); + } + + /** + * Hook to fire an event when a module state changes. + * + * @param module + * @param state + */ + public final void setModuleState(IModule module, int state) { + server.setModuleState(module, state); + } + + /** + * Sets the module publish state. + * + * @param state int + */ + public final void setModulePublishState(IModule module, int state) { + server.setModulePublishState(module, state); + } + + /** + * Sets the module restart state. + * + * @param state int + */ + public final void setModuleRestartState(IModule module, boolean state) { + server.setModuleRestartState(module, state); + } + + /** + * Disposes of this server delegate. + * <p> + * This method is called by the web server core framework. + * Clients should never call this method. + * </p> + * <p> + * Implementations are expected to let go of the delegate's reference + * to the server, deregister listeners, etc. + * </p> + */ + public void dispose() { + // do nothing + } + + /** + * The server configuration has changed. This method should return + * quickly. If any republishing must occur, the relevant in-sync + * methods should return a new value. If the server must be restarted, + * the isRestartNeeded() method should return true. + * + * @see IServer#updateConfiguration() + */ + //public abstract void updateConfiguration(); + + /** + * A module resource has changed. This method should return + * quickly. If the server must be restarted to handle the + * change of this file, the isRestartNeeded() method should + * return true and the event should be fired. + * + * @param module org.eclipse.wst.server.core.IModule + * @param delta org.eclipse.wst.server.core.IModuleResourceDelta + */ + //public abstract void updateModule(IModule module, IModuleResourceDelta delta); + + /** + * Methods called to notify that publishing is about to begin. + * This allows the server to open a connection to the server + * or get any global information ready. + * <p> + * This method is called by the server core framework, + * in response to a call to <code>IServer.publish()</code>. + * Clients should never call this method. + * </p> + * + * @param monitor org.eclipse.core.runtime.IProgressMonitor + * @throws CoreException + */ + public void publishStart(IProgressMonitor monitor) throws CoreException { + // do nothing + } + + /** + * Publish the server. + * <p> + * This method is called by the server core framework, + * in response to a call to <code>IServer.publish()</code>. + * Clients should never call this method. + * </p> + * + * @param monitor + * @throws CoreException + */ + public abstract void publishServer(IProgressMonitor monitor) throws CoreException; + + /** + * Publish an individual module to the server. + * <p> + * This method is called by the server core framework, + * in response to a call to <code>IServer.publish()</code>. + * Clients should never call this method. + * </p> + * + * @param parents + * @param module + * @param monitor + * @throws CoreException + */ + public abstract void publishModule(IModule[] parents, IModule module, IProgressMonitor monitor) throws CoreException; + + /** + * Methods called to notify that publishing has finished. + * The server can close any open connections to the server + * and do any cleanup operations. + * <p> + * This method is called by the server core framework, + * in response to a call to <code>IServer.publish()</code>. + * Clients should never call this method. + * </p> + * + * @param monitor org.eclipse.core.runtime.IProgressMonitor + * @throws CoreException + */ + public void publishFinish(IProgressMonitor monitor) throws CoreException { + // do nothing + } + + /** + * + * @see IServer#setLaunchDefaults(ILaunchConfigurationWorkingCopy) + */ + public abstract void setLaunchDefaults(ILaunchConfigurationWorkingCopy workingCopy); + + /** + * Restart this server. The server should use the server + * listener to notify progress. It must use the same debug + * flags as was originally passed into the start() method. + * + * This method is used if there is a quick/better way to restart + * the server. If it throws a CoreException, the normal stop/start + * actions will be used. + */ + public void restart(String launchMode) throws CoreException { + throw new CoreException(null); + } + + /** + * Returns whether the given module can be restarted. + * <p> + * [issue: It's unclear whether this operations is guaranteed to be fast + * or whether it could involve communication with any actual + * server. If it is not fast, the method should take a progress + * monitor.] + * </p> + * + * @param module the module + * @return <code>true</code> if the given module can be + * restarted, and <code>false</code> otherwise + */ + public boolean canRestartModule(IModule module) { + return false; + } + + /** + * Check if the given module is in sync on the server. It should + * return true if the module should be restarted (is out of + * sync) or false if the module does not need to be restarted. + * + * @param module org.eclipse.wst.server.core.model.IModule + * @return boolean + */ + /*public boolean isModuleRestartNeeded(IModule module) { + return false; + }*/ + + /** + * Asynchronously restarts the given module on the server. + * See the specification of + * {@link IServer#synchronousRestartModule(IModule, IProgressMonitor)} + * for further details. + * <p> + * The implementation should update the module sync state and fire + * an event for the module. + * </p> + * <p> + * [issue: It should probably be spec'd to throw an exception error if the + * given module is not associated with the server.] + * </p> + * <p> + * [issue: Since this method is ascynchronous, is there + * any need for the progress monitor?] + * </p> + * <p> + * [issue: Since this method is ascynchronous, how can + * it return a meaningful IStatus? + * And IServer.synchronousModuleRestart throws CoreException + * if anything goes wrong.] + * </p> + * <p> + * [issue: If the module was just published to the server + * and had never been started, would is be ok to "start" + * the module using this method?] + * </p> + * + * @param module the module to be started + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @return status object + * @exception CoreException if an error occurs while trying to restart the module + */ + public void restartModule(IModule module, IProgressMonitor monitor) throws CoreException { + // do nothing + } + + /** + * Shuts down and stops this server. The server should return from this method + * quickly and use the server listener to notify shutdown progress. + * <p> + * If force is <code>false</code>, it will attempt to stop the server + * normally/gracefully. If force is <code>true</code>, then the server + * process will be terminated any way that it can. + * </p> + * <p> + * [issue: There is no way to communicate failure to the + * client. Given that this operation can go awry, there probably + * should be a mechanism that allows failing asynch operations + * to be diagnosed.] + * </p> + * @param force <code>true</code> to kill the server, or <code>false</code> + * to stop normally + */ + public abstract void stop(boolean force); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerDelegate.java index d7a91748f..bd5015a3f 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerDelegate.java @@ -16,11 +16,12 @@ import java.util.Map; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.IServer; import org.eclipse.wst.server.core.IServerPort; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.core.internal.Server; +import org.eclipse.wst.server.core.internal.ServerWorkingCopy; /** * A server delegate provides the implementation for various * generic and server-type-specific operations for a specific type of server. @@ -36,15 +37,9 @@ import org.eclipse.wst.server.core.internal.Server; * </p> * <p> * Server delegates may keep state in instance fields, but that state is - * transient and will not be persisted across workbench sessions. - * </p> - * <p> - * [issue: Server delegates can read server attributes via - * IServer; server working copy delegates can also set them - * via IServerWorkingCopy. However, current implementation does - * not serialize any attributes other than the ones server core - * knows about. So it's unclear whether there is any intent - * to support attributes that are server-type-specific.] + * transient and will not be persisted across workbench sessions. To save + * state across workbench sessions, it must be persisted using the + * attributes. * </p> * <p> * This abstract class is intended to be extended only by clients @@ -55,11 +50,13 @@ import org.eclipse.wst.server.core.internal.Server; * likely to change significantly before the initial release.</it> * </p> * - * @see IServer#getExtension() + * @see IServer + * @see IServerWorkingCopy * @since 1.0 */ public abstract class ServerDelegate { private Server server; + private ServerWorkingCopy serverWC; public ServerDelegate() { // do nothing @@ -71,86 +68,35 @@ public abstract class ServerDelegate { * This method is called by the server core framework. * Clients should never call this method. * </p> - * <p> - * [issue: The class attribute of the serverTypes extension point - * must stipulate that the class must have a public 0-arg constructor - * in addition to implementing ServerDelegate.] - * </p> * * @param server the server instance */ public final void initialize(Server newServer) { server = newServer; + if (newServer instanceof ServerWorkingCopy) + serverWC = (ServerWorkingCopy) newServer; initialize(); } - public void initialize() { - // do nothing - } - - public final IServer getServer() { - return server; - } - - /** - * Sets the current state of this server. - * - * @param state one of the server state (<code>STATE_XXX</code>) - * constants declared on {@link IServer} - * @see IServer#getServerState() - */ - public final void setServerState(int state) { - server.setServerState(state); - } - - public final void setMode(String mode) { - server.setMode(mode); - } - /** - * Sets the server restart state. - * - * @param state boolean - */ - public final void setServerRestartState(boolean state) { - server.setServerRestartState(state); - } - - /** - * Sets the server publish state. + * * - * @param state int */ - public final void setServerPublishState(int state) { - server.setServerPublishState(state); + public void initialize() { + // do nothing } /** - * Hook to fire an event when a module state changes. + * Returns the server that this server delegate corresponds to. * - * @param module - * @param state + * @return the server */ - public final void setModuleState(IModule module, int state) { - server.setModuleState(module, state); + public final IServer getServer() { + return server; } - /** - * Sets the module publish state. - * - * @param state int - */ - public final void setModulePublishState(IModule module, int state) { - server.setModulePublishState(module, state); - } - - /** - * Sets the module restart state. - * - * @param state int - */ - public final void setModuleRestartState(IModule module, boolean state) { - server.setModuleRestartState(module, state); + public final IServerWorkingCopy getServerWC() { + return serverWC; } public final int getAttribute(String attributeName, int defaultValue) { @@ -189,75 +135,6 @@ public abstract class ServerDelegate { } /** - * The server configuration has changed. This method should return - * quickly. If any republishing must occur, the relevant in-sync - * methods should return a new value. If the server must be restarted, - * the isRestartNeeded() method should return true. - * - * @see IServer#updateConfiguration() - */ - //public abstract void updateConfiguration(); - - /** - * A module resource has changed. This method should return - * quickly. If the server must be restarted to handle the - * change of this file, the isRestartNeeded() method should - * return true and the event should be fired. - * - * @param module org.eclipse.wst.server.core.IModule - * @param delta org.eclipse.wst.server.core.IModuleResourceDelta - */ - //public abstract void updateModule(IModule module, IModuleResourceDelta delta); - - /** - * Methods called to notify that publishing is about to begin. - * This allows the server to open a connection to the server - * or get any global information ready. - * - * <p>This method should not be called directly! Use the - * IServerControl to correctly publish to the server.</p> - * - * @param monitor org.eclipse.core.runtime.IProgressMonitor - * @return org.eclipse.core.runtime.IStatus - */ - public void publishStart(IProgressMonitor monitor) throws CoreException { - // do nothing - } - - /** - * Publish the configuration. - * - * @param monitor - * @return - */ - public abstract void publishServer(IProgressMonitor monitor) throws CoreException; - - /** - * Publish an individual module to the server. - * - * @param parents - * @param module - * @return - */ - public abstract void publishModule(IModule[] parents, IModule module, IProgressMonitor monitor) throws CoreException; - - /** - * Methods called to notify that publishing has finished. - * The server can close any open connections to the server - * and do any cleanup operations. - * - * <p>This method should not be called directly! Use the - * IServerControl to correctly publish to the - * server.</p> - * - * @param monitor org.eclipse.core.runtime.IProgressMonitor - * @return org.eclipse.core.runtime.IStatus - */ - public void publishStop(IProgressMonitor monitor) throws CoreException { - // do nothing - } - - /** * Returns whether the specified module modifications could be made to this * server at this time. See the specification of * {@link IServer#canModifyModules(IModule[], IModule[])} @@ -337,119 +214,99 @@ public abstract class ServerDelegate { public abstract IModule[] getParentModules(IModule module) throws CoreException; /** - * - * @see IServer#setLaunchDefaults(ILaunchConfigurationWorkingCopy) + * Returns an array of IServerPorts that this server has. + * + * @return the server's ports */ - public abstract void setLaunchDefaults(ILaunchConfigurationWorkingCopy workingCopy); + public IServerPort[] getServerPorts() { + return null; + } /** - * Restart this server. The server should use the server - * listener to notify progress. It must use the same debug - * flags as was originally passed into the start() method. - * - * This method is used if there is a quick/better way to restart - * the server. If it throws a CoreException, the normal stop/start - * actions will be used. + * Initializes this server with default values. This method is called when + * a new server is created so that the server can be initialized with + * meaningful values. */ - public void restart(String launchMode) throws CoreException { - throw new CoreException(null); + public void setDefaults() { + // do nothing } - + /** - * Returns whether the given module can be restarted. - * <p> - * [issue: It's unclear whether this operations is guaranteed to be fast - * or whether it could involve communication with any actual - * server. If it is not fast, the method should take a progress - * monitor.] - * </p> - * - * @param module the module - * @return <code>true</code> if the given module can be - * restarted, and <code>false</code> otherwise + * Sets the value of the specified integer-valued attribute of this + * element. + * + * @param id the attribute id + * @param value the value of the specified attribute + * @see getAttribute(String, int) */ - public boolean canRestartModule(IModule module) { - return false; + public final void setAttribute(String id, int value) { + serverWC.setAttribute(id, value); } /** - * Check if the given module is in sync on the server. It should - * return true if the module should be restarted (is out of - * sync) or false if the module does not need to be restarted. - * - * @param module org.eclipse.wst.server.core.model.IModule - * @return boolean + * Sets the value of the specified boolean-valued attribute of this + * element. + * + * @param id the attribute id + * @param value the value of the specified attribute + * @see getAttribute(String, boolean) */ - /*public boolean isModuleRestartNeeded(IModule module) { - return false; - }*/ + public final void setAttribute(String id, boolean value) { + serverWC.setAttribute(id, value); + } /** - * Asynchronously restarts the given module on the server. - * See the specification of - * {@link IServer#synchronousRestartModule(IModule, IProgressMonitor)} - * for further details. - * <p> - * The implementation should update the module sync state and fire - * an event for the module. - * </p> - * <p> - * [issue: It should probably be spec'd to throw an exception error if the - * given module is not associated with the server.] - * </p> - * <p> - * [issue: Since this method is ascynchronous, is there - * any need for the progress monitor?] - * </p> - * <p> - * [issue: Since this method is ascynchronous, how can - * it return a meaningful IStatus? - * And IServer.synchronousModuleRestart throws CoreException - * if anything goes wrong.] - * </p> - * <p> - * [issue: If the module was just published to the server - * and had never been started, would is be ok to "start" - * the module using this method?] - * </p> + * Sets the value of the specified string-valued attribute of this + * element. * - * @param module the module to be started - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @return status object - * @exception CoreException if an error occurs while trying to restart the module + * @param id the attribute id + * @param value the value of the specified attribute + * @see getAttribute(String, String) */ - public void restartModule(IModule module, IProgressMonitor monitor) throws CoreException { - // do nothing + public final void setAttribute(String id, String value) { + serverWC.setAttribute(id, value); } - + /** - * Cleanly shuts down and stops this server. The - * server should return from this method quickly and - * use the server listener to notify shutdown progress. - * - * <p>This method should not be called directly! Use the - * IServer to correctly start and register - * the server.</p> + * Sets the value of the specified list-valued attribute of this + * element. The list may only contain String values. + * + * @param id the attribute id + * @param value the value of the specified attribute + * @see getAttribute(String, List) */ - public abstract void stop(); + public final void setAttribute(String id, List value) { + serverWC.setAttribute(id, value); + } /** - * Terminate the server process(es). This method should only be - * used as a last resort after the stop() method fails to work. - * The server should return from this method quickly and - * use the server listener to notify shutdown progress. - * It MUST terminate the server completely and return it to - * the stopped state. + * Sets the value of the specified map-valued attribute of this + * element. The map may only contain String values. + * + * @param id the attribute id + * @param value the value of the specified attribute + * @see getAttribute(String, Map) */ - public abstract void terminate(); - + public final void setAttribute(String id, Map value) { + serverWC.setAttribute(id, value); + } + /** - * Returns an array of IServerPorts that this server has. + * Modifies the list of modules associated with the server. + * See the specification of + * {@link IServerWorkingCopy#modifyModules(IModule[], IModule[], IProgressMonitor)} + * for further details. + * <p> + * This method is called by the web server core framework, + * in response to a call to <code>IServerWorkingCopy.modifyModules</code>. + * Clients should never call this method. + * </p> * - * @return + * @param add a possibly-empty list of modules to add + * @param remove a possibly-empty list of modules to remove + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @throws CoreException [missing] */ - public IServerPort[] getServerPorts() { - return null; - } + public abstract void modifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor) throws CoreException; }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerWorkingCopyDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerWorkingCopyDelegate.java deleted file mode 100644 index f48f8548a..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerWorkingCopyDelegate.java +++ /dev/null @@ -1,245 +0,0 @@ -/********************************************************************** - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.core.model; - -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.wst.server.core.IElement; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -/** - * A server working copy delegate provides the implementation for various - * generic and server-type-specific operations on server working copies - * for a specific type of server. - * A server working copy delegate is specified by the - * <code>workingCopyClass</code> attribute of a <code>serverTypes</code> - * extension. - * <p> - * When the server working copy instance needs to be given a delegate, the - * working copy delegate class specified for the server type is instantiated - * with a 0-argument constructor and primed with - * <code>delegate.initialize(serverWorkingCopy)</code>, - * which it is expected to hang on to. - * Later, when <code>delegate.handleSave</code> is called, - * the working copy is expected to [TBD]. Finally, when - * <code>delegate.dispose()</code> is called as the server working copy is - * being discarded, the delegate is expected to let go of the server working - * copy. - * </p> - * <p> - * Server working copy delegates may keep state in instance fields, but that - * state is transient and will not be persisted across workbench sessions. - * </p> - * <p> - * [issue: Server delegates can read server attributes via - * IServer; server working copy delegates can also set them - * via IServerWorkingCopy. However, current implementation does - * not serialize any attributes other than the ones server core - * knows about. So it's unclear whether there is any intent - * to support attributes that are server-type-specific.] - * </p> - * <p> - * [issue: ServerWorkingCopyDelegate extending ServerDelegate has - * some undesirable properties: the type has 2 initialize methods - * public void initialize(IServerWorkingCopy workingCopy) - * public void initialize(IServerState server). - * It would be simpler if these types were unrelated. - * ] - * </p> - * <p> - * [issue: As mentioned on IServerWorkingCopy.getWorkingCopyDelegate(), - * exposing ServerWorkingCopyDelegate to clients of IServerWorkingCopy - * is confusing and dangerous. Instead, replace IServerWorkingCopy.getWorkingCopyDelegate() - * with something like IServerWorkingCopy.getServerWorkingCopyExtension() which - * returns an IServerWorkingCopyExtension. The implementation of - * IServerWorkingCopy.getServerWorkingCopyExtension() should forward to - * getServerWorkingCopyExtension() - * declared here. IServerWorkingCopyExtension is an * "marker" interface that - * server providers would implement or extend only if they want to expose - * additional API on working copies for their server type. That way - * ServerWorkingCopyDelegate can be kept entirely on the SPI side, - * out of view from clients.] - * </p> - * <p> - * This abstract class is intended to be extended only by clients - * to extend the <code>serverTypes</code> extension point. - * </p> - * <p> - * <it>Caveat: The server core API is still in an early form, and is - * likely to change significantly before the initial release.</it> - * </p> - * - * @see org.eclipse.wst.server.core.IServerWorkingCopy#getWorkingCopyExtension() - * @since 1.0 - */ -public abstract class ServerWorkingCopyDelegate { - private ServerWorkingCopy server; - - /** - * Initializes this server working copy delegate with its life-long server - * working copy. - * <p> - * This method is called by the web server core framework. - * Clients should never call this method. - * </p> - * <p> - * Implementations are expected to hang on to a reference to the - * server working copy. - * </p> - * <p> - * [issue: The workingCopyClass attribute of the serverTypes extension point - * must stipulate that the class must have a public 0-arg constructor - * in addition to implementing ServerWorkingCopyDelegate.] - * </p> - * - * @param workingCopy the server working copy - */ - public final void initialize(ServerWorkingCopy workingCopy) { - server = workingCopy; - initialize(); - } - - public void initialize() { - // do nothing - } - - /** - * Initializes this server with default values. This method is called when - * a new server is created so that the server can be initialized with - * meaningful values. - */ - public void setDefaults() { - // do nothing - } - - /** - * Sets the value of the specified integer-valued attribute of this - * element. - * - * @param id the attribute id - * @param value the value of the specified attribute - * @see IElement#getAttribute(String, int) - */ - public final void setAttribute(String id, int value) { - server.setAttribute(id, value); - } - - /** - * Sets the value of the specified boolean-valued attribute of this - * element. - * - * @param id the attribute id - * @param value the value of the specified attribute - * @see IElement#getAttribute(String, boolean) - */ - public final void setAttribute(String id, boolean value) { - server.setAttribute(id, value); - } - - /** - * Sets the value of the specified string-valued attribute of this - * element. - * - * @param id the attribute id - * @param value the value of the specified attribute - * @see IElement#getAttribute(String, String) - */ - public final void setAttribute(String id, String value) { - server.setAttribute(id, value); - } - - /** - * Sets the value of the specified list-valued attribute of this - * element. - * <p> - * [issue: Serialization/deserialization] - * </p> - * - * @param id the attribute id - * @param value the value of the specified attribute - * @see IElement#getAttribute(String, List) - */ - public final void setAttribute(String id, List value) { - server.setAttribute(id, value); - } - - /** - * Sets the value of the specified map-valued attribute of this - * element. - * <p> - * [issue: Serialization/deserialization] - * </p> - * - * @param id the attribute id - * @param value the value of the specified attribute - * @see IElement#getAttribute(String, Map) - */ - public final void setAttribute(String id, Map value) { - server.setAttribute(id, value); - } - - /** - * Modifies the list of modules associated with the server. - * See the specification of - * {@link IServerWorkingCopy#modifyModules(IModule[], IModule[], IProgressMonitor)} - * for further details. - * <p> - * This method is called by the web server core framework, - * in response to a call to <code>IServerWorkingCopy.modifyModules</code>. - * Clients should never call this method. - * </p> - * - * @param add a possibly-empty list of modules to add - * @param remove a possibly-empty list of modules to remove - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @throws CoreException [missing] - */ - public abstract void modifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor) throws CoreException; - - /** - * Handles a save of this server working copy. This method is called - * when the server working copy <code>save</code> method - * is invoked and can be used to resolve calculated fields or perform - * other operations related to the changes that are being made. - * <p> - * This method is called by the web server core framework. - * Clients should never call this method. - * </p> - * <p> - * [issue: It's unclear why this method is necessary.] - * </p> - * - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - */ - public abstract void handleSave(IProgressMonitor monitor); - - /** - * Disposes of this runtime delegate. - * <p> - * This method is called by the web server core framework. - * Clients should never call this method. - * </p> - * <p> - * Implementations are expected to let go of the delegate's reference - * to the runtime, deregister listeners, etc. - * </p> - */ - public void dispose() { - // do nothing - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PingThread.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PingThread.java index 674958c52..e3b5478c9 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PingThread.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PingThread.java @@ -17,7 +17,7 @@ import java.net.URLConnection; import org.eclipse.wst.server.core.IServer; import org.eclipse.wst.server.core.internal.Trace; -import org.eclipse.wst.server.core.model.ServerDelegate; +import org.eclipse.wst.server.core.model.ServerBehaviourDelegate; /** * Thread used to ping server to test when it is started. */ @@ -33,7 +33,7 @@ public class PingThread { private boolean stop = false; private String url; - private ServerDelegate server; + private ServerBehaviourDelegate server; private IServer server2; /** @@ -44,7 +44,7 @@ public class PingThread { * @param url * @param mode */ - public PingThread(IServer server2, ServerDelegate server, String url) { + public PingThread(IServer server2, ServerBehaviourDelegate server, String url) { super(); this.server = server; this.server2 = server2; @@ -72,7 +72,7 @@ public class PingThread { while (!stop) { try { if (count == MAX_PINGS) { - server2.stop(); + server2.stop(false); stop = true; break; } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModuleFactoryDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModuleFactoryDelegate.java index f9213093d..4345de8b4 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModuleFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModuleFactoryDelegate.java @@ -103,7 +103,7 @@ public abstract class ProjectModuleFactoryDelegate extends ModuleFactoryDelegate IResourceDelta delta = event.getDelta(); //if (delta.getFlags() == IResourceDelta.MARKERS || delta.getFlags() == IResourceDelta.NO_CHANGE) - // return; // TODO + // return; delta.accept(new IResourceDeltaVisitor() { public boolean visit(IResourceDelta visitorDelta) { diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml index 5c8663ddb..6870d8a93 100644 --- a/plugins/org.eclipse.wst.server.ui/plugin.xml +++ b/plugins/org.eclipse.wst.server.ui/plugin.xml @@ -13,8 +13,6 @@ <import plugin="org.eclipse.core.expressions"/> <import plugin="org.eclipse.ui"/> <import plugin="org.eclipse.ui.ide"/> - <import plugin="org.eclipse.ui.views"/> - <import plugin="org.eclipse.ui.editors"/> <import plugin="org.eclipse.ui.forms"/> <import plugin="org.eclipse.ui.workbench.texteditor"/> <import plugin="org.eclipse.debug.core"/> diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java index 47260b39d..8c4f0ce41 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java @@ -205,7 +205,7 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab try { String serverId = configuration.getAttribute(IServer.ATTR_SERVER_ID, ""); if (!serverId.equals("")) { - server = ServerCore.getServer(serverId); + server = ServerCore.findServer(serverId); if (server == null) { //server no longer exists setErrorMessage(ServerUIPlugin.getResource("%errorInvalidServer")); @@ -255,7 +255,7 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab try { String id = launchConfig.getAttribute(IServer.ATTR_SERVER_ID, ""); if (!id.equals("")) { - IServer server2 = ServerCore.getServer(id); + IServer server2 = ServerCore.findServer(id); if (server2 == null) return false; if (server2.getServerState() == IServer.STATE_STOPPED) diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java index 8082eacdf..7261f2455 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java @@ -218,7 +218,7 @@ public class ServerUIUtil { * @return */ public static boolean showNewRuntimeWizard(Shell shell, final String runtimeTypeId) { - IRuntimeType runtimeType = ServerCore.getRuntimeType(runtimeTypeId); + IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypeId); if (runtimeType != null) { try { final IRuntimeWorkingCopy runtime = runtimeType.createRuntime(null, null); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOrdered.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IOrdered.java index 751a89e5d..468bb8bda 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOrdered.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IOrdered.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - Initial API and implementation **********************************************************************/ -package org.eclipse.wst.server.core; +package org.eclipse.wst.server.ui.editor; /** * An object that has an absolute ordering, and can be ordered against other objects. * diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorActionFactoryDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorActionFactoryDelegate.java index 70d08c5ff..b044d579c 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorActionFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorActionFactoryDelegate.java @@ -13,7 +13,7 @@ package org.eclipse.wst.server.ui.editor; import org.eclipse.jface.action.IAction; import org.eclipse.ui.IEditorSite; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; /** * */ @@ -25,7 +25,7 @@ public abstract class ServerEditorActionFactoryDelegate { * * @param server */ - public abstract boolean shouldDisplay(IServer server); + public abstract boolean shouldDisplay(IServerWorkingCopy server); /** * Create the action. diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPageSectionFactoryDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPageSectionFactoryDelegate.java index 0988e2aa1..28baf5ed4 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPageSectionFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPageSectionFactoryDelegate.java @@ -10,7 +10,7 @@ **********************************************************************/ package org.eclipse.wst.server.ui.editor; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; /** * */ @@ -21,7 +21,7 @@ public abstract class ServerEditorPageSectionFactoryDelegate { * instance) complex configuration pages to only be shown when used * with non-unittest servers. */ - public abstract boolean shouldCreateSection(IServer server); + public abstract boolean shouldCreateSection(IServerWorkingCopy server); /** * Create the editor page section. diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerResourceEditorPart.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java index fd3bc4aa5..471f424cd 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerResourceEditorPart.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java @@ -23,6 +23,8 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.part.EditorPart; import org.eclipse.wst.server.core.IServerConfigurationWorkingCopy; import org.eclipse.wst.server.core.IServerWorkingCopy; +import org.eclipse.wst.server.ui.internal.editor.IServerEditorPageSectionFactory; +import org.eclipse.wst.server.ui.internal.editor.IServerEditorPartFactory; import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore; /** * An abstract server editor which implements the most common methods @@ -31,7 +33,7 @@ import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore; * This class also provides each editor page with an error message which * will be displayed on the status bar of the editor. */ -public abstract class ServerResourceEditorPart extends EditorPart { +public abstract class ServerEditorPart extends EditorPart { public static final int PROP_ERROR = 5; private String errorMessage = null; @@ -47,7 +49,7 @@ public abstract class ServerResourceEditorPart extends EditorPart { private FormToolkit toolkit; - public ServerResourceEditorPart() { + public ServerEditorPart() { super(); } @@ -174,8 +176,8 @@ public abstract class ServerResourceEditorPart extends EditorPart { (serverConfigurationTypeId != null && factory.supportsType(serverConfigurationTypeId))) && factory.shouldCreateSection(server)) { IServerEditorSection section = factory.createSection(); - if (section instanceof ServerResourceEditorSection) - ((ServerResourceEditorSection) section).setServerResourceEditorPart(this); + if (section instanceof ServerEditorSection) + ((ServerEditorSection) section).setServerResourceEditorPart(this); sections.add(section); sectionToInsertionId.put(section, insertionId); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPartFactoryDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPartFactoryDelegate.java index b8a62009c..0148c45de 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPartFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPartFactoryDelegate.java @@ -12,7 +12,7 @@ package org.eclipse.wst.server.ui.editor; import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; /** * */ @@ -23,7 +23,7 @@ public abstract class ServerEditorPartFactoryDelegate { * instance) complex configuration pages to only be shown when used * with non-unittest servers. */ - public abstract boolean shouldCreatePage(IServer server); + public abstract boolean shouldCreatePage(IServerWorkingCopy server); /** * Create the editor page. diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerResourceEditorSection.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java index fc50d84c0..2a1c0b9d7 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerResourceEditorSection.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java @@ -22,7 +22,7 @@ import org.eclipse.wst.server.core.IServerWorkingCopy; /** * */ -public abstract class ServerResourceEditorSection implements IServerEditorSection { +public abstract class ServerEditorSection implements IServerEditorSection { private String errorMessage = null; public IServerWorkingCopy server; @@ -30,7 +30,7 @@ public abstract class ServerResourceEditorSection implements IServerEditorSectio public ICommandManager commandManager; protected boolean readOnly; protected Composite parentComp; - protected ServerResourceEditorPart editor; + protected ServerEditorPart editor; /* (non-Javadoc) * @see org.eclipse.wst.server.ui.editor.IServerEditorSection#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) @@ -73,7 +73,7 @@ public abstract class ServerResourceEditorSection implements IServerEditorSectio return null; } - public void setServerResourceEditorPart(ServerResourceEditorPart editor) { + public void setServerResourceEditorPart(ServerEditorPart editor) { this.editor = editor; } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java index d3895b92d..f01fef55b 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java @@ -178,7 +178,7 @@ public class RuntimePreferencePage extends PreferencePage implements IWorkbenchP final List list = new ArrayList(); final IRuntimeLocator.Listener listener = new IRuntimeLocator.Listener() { - public void runtimeFound(final IRuntime runtime) { + public void runtimeFound(final IRuntimeWorkingCopy runtime) { dialog.getShell().getDisplay().syncExec(new Runnable() { public void run() { monitor.subTask(runtime.getName()); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTree.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTree.java index eb366a77a..81a7919fa 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTree.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTree.java @@ -1,15 +1,15 @@ -package org.eclipse.wst.server.ui.internal; /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM - Initial API and implementation - * **********************************************************************/ +package org.eclipse.wst.server.ui.internal; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -19,23 +19,13 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.wst.server.core.IElement; +import org.eclipse.jface.viewers.*; import org.eclipse.wst.server.core.IServer; import org.eclipse.wst.server.ui.actions.NewServerAction; -import org.eclipse.wst.server.ui.internal.view.servers.DeleteAction; -import org.eclipse.wst.server.ui.internal.view.servers.OpenAction; -import org.eclipse.wst.server.ui.internal.view.servers.PublishAction; -import org.eclipse.wst.server.ui.internal.view.servers.RestartAction; -import org.eclipse.wst.server.ui.internal.view.servers.StartAction; +import org.eclipse.wst.server.ui.internal.view.servers.*; import org.eclipse.wst.server.ui.internal.view.tree.ServerElementAdapter; import org.eclipse.wst.server.ui.internal.view.tree.ServerTreeAction; import org.eclipse.swt.widgets.Shell; - /** * */ @@ -329,7 +319,7 @@ public class ServerTree { return true; } else if (obj instanceof ServerElementAdapter) { ServerElementAdapter adapter = (ServerElementAdapter) obj; - IElement element = adapter.getServerResource(); + Object element = adapter.getObject(); if (element instanceof IServer) { Action open = new OpenAction((IServer) element); open.run(); @@ -347,13 +337,13 @@ public class ServerTree { while (iterator.hasNext()) { Object obj = iterator.next(); - if (obj instanceof IElement) + if (obj instanceof ServerElementAdapter) + list.add(((ServerElementAdapter) obj).getObject()); + else list.add(obj); - else if (obj instanceof ServerElementAdapter) - list.add(((ServerElementAdapter) obj).getServerResource()); } - IElement[] res = new IElement[list.size()]; + Object[] res = new Object[list.size()]; list.toArray(res); Action delete = new DeleteAction(shell, res); @@ -373,4 +363,4 @@ public class ServerTree { } return null; } -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTreeContentProvider.java index 8a728021c..76aee0d48 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTreeContentProvider.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTreeContentProvider.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. + * Copyright (c) 2003, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -17,13 +17,7 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.wst.server.core.IElement; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerConfiguration; -import org.eclipse.wst.server.core.IServerConfigurationLifecycleListener; -import org.eclipse.wst.server.core.IServerListener; -import org.eclipse.wst.server.core.IServerLifecycleListener; -import org.eclipse.wst.server.core.ServerCore; +import org.eclipse.wst.server.core.*; import org.eclipse.wst.server.core.model.IModuleEvent; import org.eclipse.wst.server.core.model.IModuleEventsListener; import org.eclipse.wst.server.core.model.IModuleFactoryEvent; @@ -283,9 +277,9 @@ public class ServerTreeContentProvider implements ITreeContentProvider { /** * Handles the add of a new server resource. * - * @param element org.eclipse.wst.server.core.model.IServerResource + * @param element */ - protected void handleServerResourceAdded(IElement element) { + protected void handleServerResourceAdded(Object element) { //Trace.trace("add: " + element); if (viewer == null) return; @@ -324,9 +318,9 @@ public class ServerTreeContentProvider implements ITreeContentProvider { /** * Updates an element in the tree. * - * @param element org.eclipse.wst.server.core.model.IServerResource + * @param element */ - protected void handleServerResourceChanged(IElement element) { + protected void handleServerResourceChanged(Object element) { //Trace.trace("change: " + element); if (viewer == null) return; @@ -366,9 +360,9 @@ public class ServerTreeContentProvider implements ITreeContentProvider { /** * Handles the removal of a server resource. * - * @param element org.eclipse.wst.server.core.model.IServerResource + * @param element */ - protected void handleServerResourceRemoved(IElement element) { + protected void handleServerResourceRemoved(Object element) { //Trace.trace("remove: " + element); if (viewer == null) return; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java index 035ba4b0e..fac1a0573 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java @@ -188,7 +188,7 @@ public class ServerUIPlugin extends AbstractUIPlugin { // only try calling terminate once. Also, make sure that it didn't stop while // the dialog was open if (server.getServerState() != IServer.STATE_STOPPED) - server.terminate(); + server.stop(true); alive = false; } } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/DeleteActionDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/DeleteActionDelegate.java index 48980dcad..62008d1f9 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/DeleteActionDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/DeleteActionDelegate.java @@ -81,7 +81,7 @@ public class DeleteActionDelegate implements IWorkbenchWindowActionDelegate { else if (obj instanceof IServerConfiguration) list.add(obj); else if (obj instanceof ServerElementAdapter) - list.add(((ServerElementAdapter) obj).getServerResource()); + list.add(((ServerElementAdapter) obj).getObject()); else { action.setEnabled(false); return; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/ServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/ServerAction.java index d9b039a1f..abb414a5f 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/ServerAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/ServerAction.java @@ -22,13 +22,13 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.wst.server.core.IOrdered; import org.eclipse.wst.server.core.IServer; import org.eclipse.wst.server.core.IServerConfiguration; -import org.eclipse.wst.server.core.ServerUtil; import org.eclipse.wst.server.ui.actions.IServerAction; +import org.eclipse.wst.server.ui.editor.IOrdered; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.Trace; +import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.plugin.AbstractUIPlugin; /** @@ -225,7 +225,7 @@ public class ServerAction implements IOrdered { } // sort actions - ServerUtil.sortOrderedList(serverActions); + ServerEditorCore.sortOrderedList(serverActions); Trace.trace(Trace.CONFIG, "-<- Done loading .serverActions extension point -<-"); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/GlobalCommandManager.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/GlobalCommandManager.java index 7bf57d252..d82bcd74e 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/GlobalCommandManager.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/GlobalCommandManager.java @@ -165,11 +165,11 @@ public class GlobalCommandManager { CommandManagerInfo info = new CommandManagerInfo(); info.count = 1; info.id = id; - IServer server = ServerCore.getServer(id); + IServer server = ServerCore.findServer(id); if (server != null) info.wc = server.createWorkingCopy(); else { - IServerConfiguration config = ServerCore.getServerConfiguration(id); + IServerConfiguration config = ServerCore.findServerConfiguration(id); if (config != null) info.wc = config.createWorkingCopy(); } @@ -210,11 +210,11 @@ public class GlobalCommandManager { try { CommandManagerInfo info = getExistingCommandManagerInfo(id); if (info != null) { - IServer server = ServerCore.getServer(id); + IServer server = ServerCore.findServer(id); if (server != null) info.wc = server.createWorkingCopy(); else { - IServerConfiguration config = ServerCore.getServerConfiguration(id); + IServerConfiguration config = ServerCore.findServerConfiguration(id); if (config != null) info.wc = config.createWorkingCopy(); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorActionFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorActionFactory.java index da18d1808..5b9bda94d 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorActionFactory.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorActionFactory.java @@ -8,13 +8,14 @@ * Contributors: * IBM - Initial API and implementation **********************************************************************/ -package org.eclipse.wst.server.ui.editor; +package org.eclipse.wst.server.ui.internal.editor; import org.eclipse.jface.action.IAction; import org.eclipse.ui.IEditorSite; -import org.eclipse.wst.server.core.IOrdered; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; +import org.eclipse.wst.server.ui.editor.IOrdered; +import org.eclipse.wst.server.ui.editor.IServerEditorPartInput; /** * */ @@ -43,7 +44,7 @@ public interface IServerEditorActionFactory extends IOrdered { * This allows (for instance) complex configuration pages to only be shown when used * with non-unittest servers. */ - public boolean shouldDisplay(IServer server); + public boolean shouldDisplay(IServerWorkingCopy server); /** * Create the action. diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPageSectionFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPageSectionFactory.java index 69d00e832..06ff73d3c 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPageSectionFactory.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPageSectionFactory.java @@ -8,10 +8,11 @@ * Contributors: * IBM - Initial API and implementation **********************************************************************/ -package org.eclipse.wst.server.ui.editor; +package org.eclipse.wst.server.ui.internal.editor; -import org.eclipse.wst.server.core.IOrdered; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; +import org.eclipse.wst.server.ui.editor.IOrdered; +import org.eclipse.wst.server.ui.editor.IServerEditorSection; /** * */ @@ -37,7 +38,7 @@ public interface IServerEditorPageSectionFactory extends IOrdered { * This allows (for instance) complex configuration pages to only be shown when used * with non-unittest servers. */ - public boolean shouldCreateSection(IServer server); + public boolean shouldCreateSection(IServerWorkingCopy server); /** * Create the editor page section. diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPartFactory.java index 55d72b27a..fc688c4cd 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartFactory.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPartFactory.java @@ -8,12 +8,12 @@ * Contributors: * IBM - Initial API and implementation **********************************************************************/ -package org.eclipse.wst.server.ui.editor; +package org.eclipse.wst.server.ui.internal.editor; import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.server.core.IOrdered; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; +import org.eclipse.wst.server.ui.editor.IOrdered; /** * */ @@ -44,7 +44,7 @@ public interface IServerEditorPartFactory extends IOrdered { * This allows (for instance) complex configuration pages to only be shown when used * with non-unittest servers. */ - public boolean shouldCreatePage(IServer server); + public boolean shouldCreatePage(IServerWorkingCopy server); /** * Create the editor page. diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorFactory.java index b7dfc3391..04c6802ac 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorFactory.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorFactory.java @@ -12,7 +12,7 @@ package org.eclipse.wst.server.ui.internal.editor; import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.editor.ServerEditorPartFactoryDelegate; /** * @@ -21,7 +21,7 @@ public class OverviewEditorFactory extends ServerEditorPartFactoryDelegate { /* * @see ServerEditorPartFactoryDelegate#shouldCreatePage(IServer, IServerConfiguration) */ - public boolean shouldCreatePage(IServer server) { + public boolean shouldCreatePage(IServerWorkingCopy server) { return true; } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java index ea7395b5c..aebf081e9 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java @@ -39,7 +39,7 @@ import org.eclipse.wst.server.ui.internal.command.SetServerRuntimeCommand; /** * Server general editor page. */ -public class OverviewEditorPart extends ServerResourceEditorPart { +public class OverviewEditorPart extends ServerEditorPart { protected Text serverName; protected Text serverConfigurationName; protected Text hostname; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java index 0be53f9d7..fa2800777 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java @@ -241,8 +241,8 @@ public class ServerEditor extends MultiPageEditorPart { Trace.trace(Trace.FINEST, "Adding page: " + factory.getId() + " " + editorPartInput); try { IEditorPart page = factory.createPage(); - if (page instanceof ServerResourceEditorPart) { - ServerResourceEditorPart srep = (ServerResourceEditorPart) page; + if (page instanceof ServerEditorPart) { + ServerEditorPart srep = (ServerEditorPart) page; srep.setPageFactory(factory); } index = addPage(page, editorPartInput); @@ -316,8 +316,8 @@ public class ServerEditor extends MultiPageEditorPart { int count = 0; while (iterator.hasNext()) { IEditorPart part = (IEditorPart) iterator.next(); - if (part instanceof ServerResourceEditorPart) { - IStatus[] status2 = ((ServerResourceEditorPart) part).getSaveStatus(); + if (part instanceof ServerEditorPart) { + IStatus[] status2 = ((ServerEditorPart) part).getSaveStatus(); if (status2 != null) { int size = status2.length; for (int i = 0; i < size; i++) @@ -403,7 +403,7 @@ public class ServerEditor extends MultiPageEditorPart { * @param i int */ protected void firePropertyChange(int i) { - if (i == ServerResourceEditorPart.PROP_ERROR) + if (i == ServerEditorPart.PROP_ERROR) updateStatusError(); super.firePropertyChange(i); } @@ -525,15 +525,15 @@ public class ServerEditor extends MultiPageEditorPart { String error = null; IEditorPart part = getActiveEditor(); - if (part instanceof ServerResourceEditorPart) - error = ((ServerResourceEditorPart) part).getErrorMessage(); + if (part instanceof ServerEditorPart) + error = ((ServerEditorPart) part).getErrorMessage(); Iterator iterator = serverPages.iterator(); int count = 0; while (error == null && iterator.hasNext()) { part = (IEditorPart) iterator.next(); - if (part instanceof ServerResourceEditorPart) { - error = ((ServerResourceEditorPart) part).getErrorMessage(); + if (part instanceof ServerEditorPart) { + error = ((ServerEditorPart) part).getErrorMessage(); if (error != null) error = "[" + getPageText(count) + "] " + error; } @@ -909,7 +909,7 @@ public class ServerEditor extends MultiPageEditorPart { /** * */ - protected void promptReloadServerFile(String id, IServer serverFile2) { + protected void promptReloadServerFile(String id, IServerWorkingCopy serverFile2) { String title = ServerUIPlugin.getResource("%editorResourceModifiedTitle"); String message = ServerUIPlugin.getResource("%editorServerModifiedMessage"); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionFactory.java index aa0fc0550..c5d34c10e 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionFactory.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionFactory.java @@ -1,7 +1,6 @@ -package org.eclipse.wst.server.ui.internal.editor; /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html @@ -9,19 +8,19 @@ package org.eclipse.wst.server.ui.internal.editor; * Contributors: * IBM - Initial API and implementation **********************************************************************/ +package org.eclipse.wst.server.ui.internal.editor; + import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.jface.action.IAction; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.editor.IServerEditorActionFactory; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.editor.ServerEditorActionFactoryDelegate; import org.eclipse.wst.server.ui.editor.IServerEditorPartInput; import org.eclipse.wst.server.ui.internal.Trace; import org.eclipse.ui.IEditorSite; - /** * A default server that can be created for a set of given * natures. @@ -147,7 +146,7 @@ public class ServerEditorActionFactory implements IServerEditorActionFactory { * instance) complex configuration pages to only be shown when used * with non-unittest servers. */ - public boolean shouldDisplay(IServer server) { + public boolean shouldDisplay(IServerWorkingCopy server) { try { return getDelegate().shouldDisplay(server); } catch (Exception e) { diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorCore.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorCore.java index 057b1da68..74ccd4171 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorCore.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorCore.java @@ -7,7 +7,6 @@ * * Contributors: * IBM - Initial API and implementation - * **********************************************************************/ package org.eclipse.wst.server.ui.internal.editor; @@ -17,7 +16,7 @@ import java.util.List; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.server.core.ServerUtil; +import org.eclipse.wst.server.ui.editor.IOrdered; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.Trace; /** @@ -71,7 +70,7 @@ public class ServerEditorCore { } // sort pages - ServerUtil.sortOrderedList(editorPageFactories); + sortOrderedList(editorPageFactories); Trace.trace(Trace.CONFIG, "-<- Done loading .editorPages extension point -<-"); } @@ -95,7 +94,7 @@ public class ServerEditorCore { } // sort sections - ServerUtil.sortOrderedList(editorPageSectionFactories); + sortOrderedList(editorPageSectionFactories); Trace.trace(Trace.CONFIG, "-<- Done loading .editorPageSections extension point -<-"); } @@ -130,7 +129,33 @@ public class ServerEditorCore { } // sort pages - ServerUtil.sortOrderedList(editorActionFactories); + sortOrderedList(editorActionFactories); Trace.trace(Trace.CONFIG, "-<- Done loading .editorActions extension point -<-"); } + + /** + * Sort the given list of IOrdered items into indexed order. This method + * modifies the original list, but returns the value for convenience. + * + * @param list java.util.List + * @return java.util.List + */ + public static List sortOrderedList(List list) { + if (list == null) + return null; + + int size = list.size(); + for (int i = 0; i < size - 1; i++) { + for (int j = i + 1; j < size; j++) { + IOrdered a = (IOrdered) list.get(i); + IOrdered b = (IOrdered) list.get(j); + if (a.getOrder() > b.getOrder()) { + Object temp = a; + list.set(i, b); + list.set(j, temp); + } + } + } + return list; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInput.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInput.java index 8f43a715c..fa8f6dff1 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInput.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInput.java @@ -103,9 +103,9 @@ public class ServerEditorInput implements IServerEditorInput, IPersistableElemen * otherwise */ public boolean exists() { - if (serverId != null && ServerCore.getServer(serverId) == null) + if (serverId != null && ServerCore.findServer(serverId) == null) return false; - else if (configurationId != null && ServerCore.getServerConfiguration(configurationId) == null) + else if (configurationId != null && ServerCore.findServerConfiguration(configurationId) == null) return false; else return true; @@ -154,12 +154,12 @@ public class ServerEditorInput implements IServerEditorInput, IPersistableElemen */ public String getName() { if (serverId != null) { - IServer server = ServerCore.getServer(serverId); + IServer server = ServerCore.findServer(serverId); if (server != null) return server.getName(); return serverId; } else if (configurationId != null) { - IServerConfiguration configuration = ServerCore.getServerConfiguration(configurationId); + IServerConfiguration configuration = ServerCore.findServerConfiguration(configurationId); if (configuration != null) return configuration.getName(); return configurationId; @@ -180,7 +180,7 @@ public class ServerEditorInput implements IServerEditorInput, IPersistableElemen public String getToolTipText() { String s = null; if (serverId != null) { - IServer server = ServerCore.getServer(serverId); + IServer server = ServerCore.findServer(serverId); if (server != null) { if (server.getFile() != null) { s = server.getFile().getFullPath().makeRelative().toString(); @@ -191,7 +191,7 @@ public class ServerEditorInput implements IServerEditorInput, IPersistableElemen } } if (s == null && configurationId != null) { - IServerConfiguration configuration = ServerCore.getServerConfiguration(configurationId); + IServerConfiguration configuration = ServerCore.findServerConfiguration(configurationId); if (configuration != null) { if (configuration.getFile() != null) { s = configuration.getFile().getFullPath().makeRelative().toString(); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPageSectionFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPageSectionFactory.java index eb0b9c764..8c862a714 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPageSectionFactory.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPageSectionFactory.java @@ -1,7 +1,6 @@ -package org.eclipse.wst.server.ui.internal.editor; /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html @@ -9,16 +8,17 @@ package org.eclipse.wst.server.ui.internal.editor; * Contributors: * IBM - Initial API and implementation **********************************************************************/ +package org.eclipse.wst.server.ui.internal.editor; + import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.editor.*; import org.eclipse.wst.server.ui.internal.Trace; - /** * */ @@ -146,7 +146,7 @@ public class ServerEditorPageSectionFactory implements IServerEditorPageSectionF * <p>If the instance or configuration is being opened by itself, the * other value (instance or configuration) will be null. */ - public boolean shouldCreateSection(IServer server) { + public boolean shouldCreateSection(IServerWorkingCopy server) { try { return getDelegate().shouldCreateSection(server); } catch (Exception e) { diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartFactory.java index ff20255ec..755be7d79 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartFactory.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartFactory.java @@ -1,7 +1,6 @@ -package org.eclipse.wst.server.ui.internal.editor; /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html @@ -9,13 +8,14 @@ package org.eclipse.wst.server.ui.internal.editor; * Contributors: * IBM - Initial API and implementation **********************************************************************/ +package org.eclipse.wst.server.ui.internal.editor; + import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.editor.IServerEditorPartFactory; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.editor.ServerEditorPartFactoryDelegate; import org.eclipse.wst.server.ui.internal.Trace; import org.eclipse.ui.IEditorPart; @@ -176,7 +176,7 @@ public class ServerEditorPartFactory implements IServerEditorPartFactory { * This allows (for instance) complex configuration pages to only be shown when used * with non-unittest servers. */ - public boolean shouldCreatePage(IServer server) { + public boolean shouldCreatePage(IServerWorkingCopy server) { try { return getDelegate().shouldCreatePage(server); } catch (Exception e) { diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java index 18eedb7b4..2d0aaa3e5 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java @@ -18,6 +18,7 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.wst.server.core.IElement; import org.eclipse.wst.server.core.IServer; import org.eclipse.wst.server.core.IServerConfiguration; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.core.ITask; import org.eclipse.wst.server.ui.editor.ICommandManager; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; @@ -92,7 +93,7 @@ public class ServerResourceCommandManager implements ICommandManager { IElement serverfile = commandManager.getServerResource(id); if (commandManager.hasChanged(id)) { if (serverfile instanceof IServer) - editor.promptReloadServerFile(id, (IServer) serverfile); + editor.promptReloadServerFile(id, (IServerWorkingCopy) serverfile); else editor.promptReloadServerConfigurationFile(id, (IServerConfiguration) serverfile); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/ModifyModulesTask.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/ModifyModulesTask.java index 59d27dfcc..4228ed1a0 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/ModifyModulesTask.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/ModifyModulesTask.java @@ -54,13 +54,14 @@ public class ModifyModulesTask extends Task { IRunningActionServer ras = (IRunningActionServer) workingCopy.getAdapter(IRunningActionServer.class); if (ras != null) { - int state = workingCopy.getServerState(); + IServer server = workingCopy.getOriginal(); + int state = server.getServerState(); if (state == IServer.STATE_STOPPED || state == IServer.STATE_UNKNOWN) { String mode = (String) getTaskModel().getObject(ITaskModel.TASK_LAUNCH_MODE); if (mode == null || mode.length() == 0) mode = ILaunchManager.DEBUG_MODE; - workingCopy.synchronousStart(mode, monitor); + server.synchronousStart(mode, monitor); } } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java index 887c377f6..aba64315d 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java @@ -44,7 +44,7 @@ public class ServerTableViewer extends TableViewer { protected IPublishListener publishListener; protected IServerListener serverListener; - protected static IElement deletedElement = null; + protected static Object deletedElement = null; // servers that are currently publishing and starting protected static List publishing = new ArrayList(); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java index 9511e7ee4..e74883896 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java @@ -331,7 +331,7 @@ public class ServersView extends ViewPart { } // monitor - if (server.getServerType() != null && server.getServerType().isMonitorable()) { + if (server.getServerType() != null) { final MenuManager menuManager = new MenuManager(ServerUIPlugin.getResource("%actionMonitor")); final IServer server2 = server; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java index 6baf2fe44..0f5e020de 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java @@ -61,7 +61,7 @@ public class StopAction extends AbstractServerAction { dialog.setBlockOnOpen(false); dialog.open(); - server.stop(); + server.stop(false); dialog.close(); } }); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/tree/ServerElementAdapter.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/tree/ServerElementAdapter.java index a9b931067..de5cbce83 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/tree/ServerElementAdapter.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/tree/ServerElementAdapter.java @@ -1,6 +1,6 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html @@ -14,7 +14,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.wst.server.core.IElement; import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.IServer; import org.eclipse.wst.server.core.IServerConfiguration; @@ -27,11 +26,11 @@ import org.eclipse.ui.model.IWorkbenchAdapter; public class ServerElementAdapter implements IAdaptable, IWorkbenchAdapter, IServerElementTag { private static final Object[] NO_CHILDREN = new Object[0]; - protected IElement resource; + protected Object resource; protected Object parent; protected byte flags; - public ServerElementAdapter(Object parent, IElement resource) { + public ServerElementAdapter(Object parent, Object resource) { this.parent = parent; this.resource = resource; } @@ -138,7 +137,7 @@ public class ServerElementAdapter implements IAdaptable, IWorkbenchAdapter, ISer return parent; } - public IElement getServerResource() { + public Object getObject() { return resource; } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/tree/TextResourceAdapter.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/tree/TextResourceAdapter.java index b7ed01547..d8cc747be 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/tree/TextResourceAdapter.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/tree/TextResourceAdapter.java @@ -15,7 +15,6 @@ import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.wst.server.core.IElement; import org.eclipse.wst.server.core.IServerConfiguration; import org.eclipse.wst.server.core.ServerCore; import org.eclipse.wst.server.ui.ServerImageResource; @@ -32,7 +31,7 @@ public class TextResourceAdapter implements IAdaptable, IWorkbenchAdapter, IServ protected Object parent; protected byte thisStyle; - public static IElement deleted; + public static Object deleted; public final static byte STYLE_SERVERS = 0; public final static byte STYLE_CONFIGURATIONS = 1; @@ -89,7 +88,7 @@ public class TextResourceAdapter implements IAdaptable, IWorkbenchAdapter, IServ new TextResourceAdapter(this, STYLE_CONFIGURATIONS) };*/ - IElement[] elements = null; + Object[] elements = null; if (thisStyle == STYLE_SERVERS) elements = ServerCore.getServers(); else if (thisStyle == STYLE_CONFIGURATIONS) diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java index 0fc89906d..26655c2fd 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java @@ -74,12 +74,7 @@ public class RuntimeTypeComposite extends AbstractTreeComposite { return super.compare(viewer, e1, e2); IRuntimeType r1 = (IRuntimeType) e1; IRuntimeType r2 = (IRuntimeType) e2; - if (r1.getOrder() > r2.getOrder()) - return -1; - else if (r1.getOrder() < r2.getOrder()) - return 1; - else - return super.compare(viewer, e1, e2); + return r1.getName().compareToIgnoreCase(r2.getName()); } }); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java index 43e1493eb..de80462da 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. + * Copyright (c) 2003, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -55,9 +55,10 @@ public class RuntimeTypeTreeContentProvider extends AbstractTreeContentProvider for (int i = 0; i < size; i++) { IRuntimeType runtimeType = runtimeTypes[i]; if (!creation || runtimeType.canCreate()) { - if (runtimeType.getOrder() > initialSelectionOrder) { + int order = getRuntimeOrder(runtimeType); + if (order > initialSelectionOrder) { initialSelection = runtimeType; - initialSelectionOrder = runtimeType.getOrder(); + initialSelectionOrder = order; } TreeElement ele = null; if (style == STYLE_VENDOR) { @@ -94,9 +95,10 @@ public class RuntimeTypeTreeContentProvider extends AbstractTreeContentProvider for (int i = 0; i < size; i++) { IRuntimeType runtimeType = runtimeTypes[i]; if (!creation || runtimeType.canCreate()) { - if (runtimeType.getOrder() > initialSelectionOrder) { + int order = getRuntimeOrder(runtimeType); + if (order > initialSelectionOrder) { initialSelection = runtimeType; - initialSelectionOrder = runtimeType.getOrder(); + initialSelectionOrder = order; } list.add(runtimeType); } @@ -105,4 +107,8 @@ public class RuntimeTypeTreeContentProvider extends AbstractTreeContentProvider } elements = list.toArray(); } + + private int getRuntimeOrder(IRuntimeType runtimeType) { + return 0; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java index 591b18cdf..4e9caeb9f 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2003 IBM Corporation and others. +/********************************************************************** + * Copyright (c) 2003, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -7,7 +7,7 @@ * * Contributors: * IBM - Initial API and implementation - */ + **********************************************************************/ package org.eclipse.wst.server.ui.internal.viewers; import java.util.ArrayList; @@ -64,9 +64,10 @@ public class ServerTreeContentProvider extends AbstractTreeContentProvider { if (acceptServer(servers[i])) { IServerType serverType = servers[i].getServerType(); IRuntimeType runtimeType = serverType.getRuntimeType(); - if (serverType.getOrder() > initialSelectionOrder) { + int order = getServerOrder(serverType); + if (order > initialSelectionOrder) { initialSelection = servers[i]; - initialSelectionOrder = serverType.getOrder(); + initialSelectionOrder = order; } TreeElement te = null; if (style == STYLE_HOST) { @@ -95,9 +96,10 @@ public class ServerTreeContentProvider extends AbstractTreeContentProvider { if (acceptServer(servers[i])) { IServerType serverType = servers[i].getServerType(); list.add(servers[i]); - if (serverType.getOrder() > initialSelectionOrder) { + int order = getServerOrder(serverType); + if (order > initialSelectionOrder) { initialSelection = servers[i]; - initialSelectionOrder = serverType.getOrder(); + initialSelectionOrder = order; } } } @@ -122,4 +124,8 @@ public class ServerTreeContentProvider extends AbstractTreeContentProvider { } return true; } + + private int getServerOrder(IServerType serverType) { + return 0; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java index 05b15386c..87ef314ec 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java @@ -1,6 +1,6 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html @@ -32,7 +32,6 @@ public class ServerTypeComposite extends AbstractTreeComposite { protected IModuleType moduleType; - protected boolean includeTestEnvironments = true; protected boolean isLocalhost; protected boolean includeIncompatibleVersions; @@ -106,15 +105,6 @@ public class ServerTypeComposite extends AbstractTreeComposite { //treeViewer.expandToLevel(2); treeViewer.setSelection(sel, true); } - - public void setIncludeTestEnvironments(boolean b) { - includeTestEnvironments = b; - ISelection sel = treeViewer.getSelection(); - contentProvider.setIncludeTestEnvironments(b); - treeViewer.refresh(); - treeViewer.setSelection(sel, true); - //treeViewer.expandToLevel(2); - } public void setIncludeIncompatibleVersions(boolean b) { includeIncompatibleVersions = b; @@ -142,7 +132,6 @@ public class ServerTypeComposite extends AbstractTreeComposite { ISelection sel = treeViewer.getSelection(); contentProvider = new ServerTypeTreeContentProvider(option, moduleType); contentProvider.setLocalhost(isLocalhost); - contentProvider.setIncludeTestEnvironments(includeTestEnvironments); contentProvider.setIncludeIncompatibleVersions(includeIncompatibleVersions); treeViewer.setContentProvider(contentProvider); treeViewer.setSelection(sel); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java index 3389e3dc4..5e8039ccc 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. + * Copyright (c) 2003, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -25,7 +25,6 @@ public class ServerTypeTreeContentProvider extends AbstractTreeContentProvider { public static final byte STYLE_TYPE = 4; // not used yet protected boolean localhost; - protected boolean includeTestEnvironments = true; protected IModuleType moduleType; protected boolean includeIncompatibleVersions; @@ -50,11 +49,12 @@ public class ServerTypeTreeContentProvider extends AbstractTreeContentProvider { if (serverTypes != null) { int size = serverTypes.length; for (int i = 0; i < size; i++) { - IServerType serverType = serverTypes[i]; + IServerType serverType = serverTypes[i]; if (include(serverType)) { - if (serverType.getOrder() > initialSelectionOrder) { + int order = getServerOrder(serverType); + if (order > initialSelectionOrder) { initialSelection = serverType; - initialSelectionOrder = serverType.getOrder(); + initialSelectionOrder = order; } if (style == STYLE_FLAT) { list.add(serverType); @@ -100,16 +100,18 @@ public class ServerTypeTreeContentProvider extends AbstractTreeContentProvider { IRuntimeType runtimeType = serverType.getRuntimeType(); if (runtimeType == null) return false; + + String moduleTypeId = null; + if (moduleType != null) + moduleTypeId = moduleType.getId(); if (includeIncompatibleVersions) { - if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleType.getId(), null)) + if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleTypeId, null)) return false; } else { - if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleType.getId(), moduleType.getVersion())) - return false; - } - - if (!includeTestEnvironments && serverType.isTestEnvironment()) { - if (!checkForTestEnvironmentRuntime(serverType)) + String moduleVersion = null; + if (moduleType != null) + moduleVersion = moduleType.getVersion(); + if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleTypeId, moduleVersion)) return false; } @@ -119,20 +121,6 @@ public class ServerTypeTreeContentProvider extends AbstractTreeContentProvider { return false; } - protected boolean checkForTestEnvironmentRuntime(IServerType serverType) { - IRuntimeType runtimeType = serverType.getRuntimeType(); - IRuntime[] runtimes = ServerUtil.getRuntimes(runtimeType); - if (runtimes == null || runtimes.length == 0) - return false; - - int size = runtimes.length; - for (int i = 0; i < size; i++) { - if (runtimes[i].isTestEnvironment()) - return true; - } - return false; - } - protected boolean checkForNonStubEnvironmentRuntime(IServerType serverType) { IRuntimeType runtimeType = serverType.getRuntimeType(); IRuntime[] runtimes = ServerUtil.getRuntimes(runtimeType); @@ -151,14 +139,13 @@ public class ServerTypeTreeContentProvider extends AbstractTreeContentProvider { localhost = local; fillTree(); } - - public void setIncludeTestEnvironments(boolean te) { - includeTestEnvironments = te; - fillTree(); - } - + public void setIncludeIncompatibleVersions(boolean b) { includeIncompatibleVersions = b; fillTree(); } + + private int getServerOrder(IServerType serverType) { + return 0; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java index 8fb72ae86..4caa05d84 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java @@ -1,7 +1,6 @@ -package org.eclipse.wst.server.ui.internal.wizard; /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html @@ -9,6 +8,8 @@ package org.eclipse.wst.server.ui.internal.wizard; * Contributors: * IBM - Initial API and implementation **********************************************************************/ +package org.eclipse.wst.server.ui.internal.wizard; + import java.util.List; import org.eclipse.wst.server.core.*; @@ -18,13 +19,12 @@ import org.eclipse.wst.server.ui.internal.wizard.fragment.ModifyModulesWizardFra import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment; import org.eclipse.wst.server.ui.wizard.TaskWizard; import org.eclipse.wst.server.ui.wizard.WizardFragment; - /** * A wizard used to add and remove modules. */ public class ModifyModulesWizard extends TaskWizard { static class ModifyModulesWizard2 extends WizardFragment { - protected IServer server; + protected IServerWorkingCopy server; public ModifyModulesWizard2(IServerWorkingCopy server) { this.server = server; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java index 132f479bd..083df8d28 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java @@ -166,7 +166,7 @@ public class NewServerWizardFragment extends WizardFragment { } } - public IServer getServer() { + public IServerWorkingCopy getServer() { if (comp == null) return null; return comp.getServer(); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java index bbba05648..946f52a80 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java @@ -1,6 +1,6 @@ /********************************************************************** - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2003, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html @@ -24,10 +24,12 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.wst.server.core.*; import org.eclipse.wst.server.core.util.Task; +import org.eclipse.wst.server.ui.editor.IOrdered; import org.eclipse.wst.server.ui.internal.EclipseUtil; import org.eclipse.wst.server.ui.internal.ProgressUtil; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.Trace; +import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore; import org.eclipse.wst.server.ui.internal.wizard.page.TasksComposite; import org.eclipse.wst.server.ui.wizard.IWizardHandle; import org.eclipse.wst.server.ui.wizard.WizardFragment; @@ -274,7 +276,7 @@ public class TasksWizardFragment extends WizardFragment { // begin task monitor.beginTask(ServerUIPlugin.getResource("%performingTasks"), performTasks.size() * 1000); - ServerUtil.sortOrderedList(performTasks); + ServerEditorCore.sortOrderedList(performTasks); Iterator iterator = performTasks.iterator(); while (iterator.hasNext()) { @@ -331,4 +333,4 @@ public class TasksWizardFragment extends WizardFragment { public boolean hasOptionalTasks() { return hasOptionalTasks; } -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java index fefca5483..002f29489 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java @@ -33,10 +33,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ITaskModel; -import org.eclipse.wst.server.core.ServerUtil; +import org.eclipse.wst.server.core.*; import org.eclipse.wst.server.ui.ServerUICore; import org.eclipse.wst.server.ui.internal.*; import org.eclipse.wst.server.ui.wizard.IWizardHandle; @@ -48,7 +45,7 @@ public class ModifyModulesComposite extends Composite { protected IWizardHandle wizard; - protected IServer server; + protected IServerAttributes server; protected Map childModuleMap = new HashMap(); protected Map parentTreeItemMap = new HashMap(); @@ -89,7 +86,7 @@ public class ModifyModulesComposite extends Composite { createControl(); } - public void setServer(IServer server) { + public void setServer(IServerAttributes server) { if (server == this.server) return; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewDetectServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewDetectServerComposite.java index 7f6b9252f..e14b673bc 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewDetectServerComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewDetectServerComposite.java @@ -17,6 +17,7 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.*; import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerAttributes; import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.ui.internal.SWTUtil; import org.eclipse.swt.SWT; @@ -48,7 +49,7 @@ public class NewDetectServerComposite extends Composite { protected Label hostLabel; public interface IServerSelectionListener { - public void serverSelected(IServer server); + public void serverSelected(IServerAttributes server); } public class ServerContentProvider implements IStructuredContentProvider { diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java index 70dca923f..e57e992b6 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java @@ -42,7 +42,7 @@ import org.eclipse.wst.server.ui.internal.viewers.ServerTypeComposite; */ public class NewManualServerComposite extends Composite { public interface ServerSelectionListener { - public void serverSelected(IServer server); + public void serverSelected(IServerAttributes server); } public interface IWizardHandle2 { @@ -115,7 +115,6 @@ public class NewManualServerComposite extends Composite { //WizardUtil.defaultSelect(parent, CreateServerWizardPage.this); } }); - serverTypeComposite.setIncludeTestEnvironments(false); serverTypeComposite.setIncludeIncompatibleVersions(true); GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); data.horizontalSpan = 2; @@ -233,9 +232,6 @@ public class NewManualServerComposite extends Composite { if (runtimes != null) { int size = runtimes.length; for (int i = 0; i < size; i++) { - if (runtimes[i].isTestEnvironment()) - return runtimes[i]; - if (!runtimes[i].isStub()) return runtime; } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java index 7e2e4e48a..d6fa853cb 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java @@ -33,6 +33,7 @@ import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.IModuleType; import org.eclipse.wst.server.core.IRuntime; import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerAttributes; import org.eclipse.wst.server.core.IServerType; import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.core.ITaskModel; @@ -298,7 +299,7 @@ public class NewServerComposite extends Composite { detectHostComp = createHostComposite(detectComp2); detectComp = new NewDetectServerComposite(detectComp2, new NewDetectServerComposite.IServerSelectionListener() { - public void serverSelected(IServer server) { + public void serverSelected(IServerAttributes server) { // do nothing } }); @@ -374,6 +375,9 @@ public class NewServerComposite extends Composite { manualComp2.setLayout(layout); manualHostComp = createHostComposite(manualComp2); + IModuleType mt = null; + if (module != null) + mt = module.getModuleType(); manualComp = new NewManualServerComposite(manualComp2, new NewManualServerComposite.IWizardHandle2() { public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException { @@ -385,8 +389,8 @@ public class NewServerComposite extends Composite { public void setMessage(String newMessage, int newType) { wizard.setMessage(newMessage, newType); } - }, module.getModuleType(), new NewManualServerComposite.ServerSelectionListener() { - public void serverSelected(IServer server) { + }, mt, new NewManualServerComposite.ServerSelectionListener() { + public void serverSelected(IServerAttributes server) { updateTaskModel(); } }); @@ -404,7 +408,7 @@ public class NewServerComposite extends Composite { protected void updateTaskModel() { if (taskModel != null) { - IServer server = getServer(); + IServerWorkingCopy server = getServer(); if (server != null) { taskModel.putObject(ITaskModel.TASK_SERVER, server); taskModel.putObject(ITaskModel.TASK_RUNTIME, server.getRuntime()); @@ -422,7 +426,7 @@ public class NewServerComposite extends Composite { updateTaskModel(); } - public IServer getServer() { + public IServerWorkingCopy getServer() { if (mode == MODE_EXISTING) return existingWC; //existingComp.getSelectedServer(); else if (mode == MODE_DETECT) |