Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org')
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ClassDetector.java30
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ContextPublishTaskDelegate.java58
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/FileUtil.java248
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/IMimeMapping.java29
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatConfiguration.java38
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatConfigurationWorkingCopy.java69
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntime.java35
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntimeWorkingCopy.java25
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServer.java26
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerBehaviour.java46
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerWorkingCopy.java22
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatVersionHandler.java60
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatWebModule.java43
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.java95
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.properties102
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/MimeMapping.java47
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PingThread.java125
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ProgressUtil.java69
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishOperation2.java110
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishTask.java39
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Configuration.java575
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Handler.java109
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java593
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Handler.java121
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java747
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Handler.java119
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java823
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Handler.java119
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java724
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Handler.java43
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java327
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchConfigurationDelegate.java81
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchableAdapterDelegate.java68
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPlugin.java295
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java234
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeClasspathProvider.java85
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeLocator.java117
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java356
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java819
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerLocator.java37
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerUtil.java86
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java101
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java98
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebAppDocument.java164
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebModule.java89
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddMimeMappingCommand.java46
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddModuleCommand.java60
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddWebModuleCommand.java48
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ConfigurationCommand.java53
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/FixModuleContextRootTask.java85
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyMimeMappingCommand.java51
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyPortCommand.java61
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyWebModuleCommand.java44
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveMimeMappingCommand.java48
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveModuleCommand.java59
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveWebModuleCommand.java48
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ServerCommand.java54
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetDebugModeCommand.java47
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetSecureCommand.java47
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetTestEnvironmentCommand.java47
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetWebModulePathCommand.java55
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java129
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLElement.java249
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java390
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Connector.java37
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Context.java77
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/ContextManager.java77
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Parameter.java37
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Server.java37
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Connector.java85
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Context.java61
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Engine.java65
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Host.java53
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Listener.java37
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Server.java69
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Service.java41
76 files changed, 0 insertions, 10543 deletions
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ClassDetector.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ClassDetector.java
deleted file mode 100644
index 2ff873714..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ClassDetector.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-/**
- * Utility class to check for the existence of a class given as an
- * argument.
- */
-public class ClassDetector {
- public static void main(String[] args) {
- if (args == null || args.length != 1) {
- System.out.println("Usage: ClassDetector [className]");
- return;
- }
-
- try {
- Class.forName(args[0]);
- System.out.println("true");
- } catch (Exception e) {
- System.out.println("false");
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ContextPublishTaskDelegate.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ContextPublishTaskDelegate.java
deleted file mode 100644
index 673a2dc39..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ContextPublishTaskDelegate.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.jst.server.tomcat.core.internal.command.FixModuleContextRootTask;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.PublishOperation;
-import org.eclipse.wst.server.core.model.PublishTaskDelegate;
-
-public class ContextPublishTaskDelegate extends PublishTaskDelegate {
- public PublishOperation[] getTasks(IServer server, List modules) {
- if (modules == null)
- return null;
-
- TomcatServer tomcatServer = (TomcatServer) server.loadAdapter(TomcatServer.class, null);
- TomcatConfiguration configuration = null;
- try {
- configuration = tomcatServer.getTomcatConfiguration();
- } catch (Exception e) {
- return null;
- }
-
- List tasks = new ArrayList();
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- IModule[] module = (IModule[]) modules.get(i);
- IModule m = module[module.length - 1];
- IWebModule webModule = (IWebModule) m.loadAdapter(IWebModule.class, null);
- WebModule webModule2 = configuration.getWebModule(m);
- if (webModule != null && webModule2 != null) {
- String contextRoot = webModule.getContextRoot();
- if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0)
- contextRoot = "/" + contextRoot;
- int kind = PublishOperation.OPTIONAL;
- if (!contextRoot.equals(webModule2.getPath()))
- kind = PublishOperation.PREFERRED;
-
- int index = configuration.getWebModules().indexOf(webModule2);
- FixModuleContextRootTask task = new FixModuleContextRootTask(m, index, webModule.getContextRoot(), kind);
- tasks.add(task);
- }
- }
-
- return (PublishOperation[]) tasks.toArray(new PublishOperation[tasks.size()]);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/FileUtil.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/FileUtil.java
deleted file mode 100644
index c1e063bae..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/FileUtil.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.*;
-import java.net.URL;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.core.PublishUtil;
-import org.eclipse.osgi.util.NLS;
-/**
- * Utility class with an assortment of useful file methods.
- */
-public class FileUtil {
- // size of the buffer
- private static final int BUFFER = 10240;
-
- // the buffer
- private static byte[] buf = new byte[BUFFER];
-
- /**
- * FileUtil cannot be created. Use static methods.
- */
- private FileUtil() {
- super();
- }
-
- /**
- * Copys a directory from a to b.
- *
- * @param from java.lang.String
- * @param to java.lang.String
- * @param monitor a progress monitor, or <code>null</code>
- */
- public static void copyDirectory(String from, String to, IProgressMonitor monitor) {
- try {
- File fromDir = new File(from);
- File toDir = new File(to);
-
- File[] files = fromDir.listFiles();
-
- toDir.mkdir();
-
- // cycle through files
- int size = files.length;
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(NLS.bind(Messages.copyingTask, new String[] {from, to}), size * 50);
-
- for (int i = 0; i < size; i++) {
- File current = files[i];
- String fromFile = current.getAbsolutePath();
- String toFile = to;
- if (!toFile.endsWith(File.separator))
- toFile += File.separator;
- toFile += current.getName();
- if (current.isFile()) {
- copyFile(fromFile, toFile);
- monitor.worked(50);
- } else if (current.isDirectory()) {
- monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {fromFile, toFile}));
- copyDirectory(fromFile, toFile, ProgressUtil.getSubMonitorFor(monitor, 50));
- }
- if (monitor.isCanceled())
- return;
- }
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error copying directory", e);
- }
- }
-
- /**
- * Copy a file from a to b. Closes the input stream after use.
- *
- * @param in java.io.InputStream
- * @param to java.lang.String
- * @return a status
- */
- public static IStatus copyFile(InputStream in, String to) {
- OutputStream out = null;
-
- try {
- out = new FileOutputStream(to);
-
- int avail = in.read(buf);
- while (avail > 0) {
- out.write(buf, 0, avail);
- avail = in.read(buf);
- }
- return Status.OK_STATUS;
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error copying file", e);
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (Exception ex) {
- // ignore
- }
- try {
- if (out != null)
- out.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- }
-
- /**
- * Copy a file from a to b.
- *
- * @param from java.lang.String
- * @param to java.lang.String
- * @return a status
- */
- public static IStatus copyFile(String from, String to) {
- try {
- return copyFile(new FileInputStream(from), to);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error copying file", e);
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
- }
- }
-
- /**
- * Copy a file from a to b.
- *
- * @param from java.net.URL
- * @param to java.lang.String
- * @return a status
- */
- public static IStatus copyFile(URL from, String to) {
- try {
- return copyFile(from.openStream(), to);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error copying file", e);
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
- }
- }
-
- /**
- * Copys a directory from a to b, only modifying as needed
- * and deleting old files and directories.
- *
- * @param from a directory
- * @param to a directory
- * @param monitor a progress monitor
- */
- public static void smartCopyDirectory(String from, String to, IProgressMonitor monitor) {
- try {
- File fromDir = new File(from);
- File toDir = new File(to);
-
- File[] fromFiles = fromDir.listFiles();
- int fromSize = fromFiles.length;
-
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(NLS.bind(Messages.copyingTask, new String[] {from, to}), 550);
-
- File[] toFiles = null;
-
- // delete old files and directories from this directory
- if (toDir.exists() && toDir.isDirectory()) {
- toFiles = toDir.listFiles();
- int toSize = toFiles.length;
-
- // check if this exact file exists in the new directory
- for (int i = 0; i < toSize; i++) {
- String name = toFiles[i].getName();
- boolean isDir = toFiles[i].isDirectory();
- boolean found = false;
- for (int j = 0; j < fromSize; j++) {
- if (name.equals(fromFiles[j].getName()) && isDir == fromFiles[j].isDirectory())
- found = true;
- }
-
- // delete file if it can't be found or isn't the correct type
- if (!found) {
- if (isDir)
- PublishUtil.deleteDirectory(toFiles[i], null);
- else
- toFiles[i].delete();
- }
- if (monitor.isCanceled())
- return;
- }
- } else {
- if (toDir.isFile())
- toDir.delete();
- toDir.mkdir();
- }
- monitor.worked(50);
-
- // cycle through files and only copy when it doesn't exist
- // or is newer
- toFiles = toDir.listFiles();
- int toSize = toFiles.length;
- int dw = 0;
- if (toSize > 0)
- dw = 500 / toSize;
-
- for (int i = 0; i < fromSize; i++) {
- File current = fromFiles[i];
-
- // check if this is a new or newer file
- boolean copy = true;
- if (!current.isDirectory()) {
- String name = current.getName();
- long mod = current.lastModified();
- for (int j = 0; j < toSize; j++) {
- if (name.equals(toFiles[j].getName()) && mod <= toFiles[j].lastModified())
- copy = false;
- }
- }
-
- if (copy) {
- String fromFile = current.getAbsolutePath();
- String toFile = to;
- if (!toFile.endsWith(File.separator))
- toFile += File.separator;
- toFile += current.getName();
- if (current.isFile()) {
- copyFile(fromFile, toFile);
- monitor.worked(dw);
- } else if (current.isDirectory()) {
- monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {fromFile, toFile}));
- smartCopyDirectory(fromFile, toFile, ProgressUtil.getSubMonitorFor(monitor, dw));
- }
- }
- if (monitor.isCanceled())
- return;
- }
- monitor.worked(500 - dw * toSize);
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error smart copying directory " + from + " - " + to, e);
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/IMimeMapping.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/IMimeMapping.java
deleted file mode 100644
index ee5946f17..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/IMimeMapping.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-/**
- *
- */
-public interface IMimeMapping {
- /**
- * Returns the extension.
- *
- * @return the extension
- */
- public String getExtension();
-
- /**
- * Returns the mime type.
- *
- * @return the mime type
- */
- public String getMimeType();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatConfiguration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatConfiguration.java
deleted file mode 100644
index b9bada112..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatConfiguration.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.List;
-/**
- *
- */
-public interface ITomcatConfiguration {
- /**
- * Returns a list of mime mappings.
- *
- * @return mime mappings
- */
- public List getMimeMappings();
-
- /**
- * Returns a list of ServerPorts that this configuration uses.
- *
- * @return the server ports
- */
- public List getServerPorts();
-
- /**
- * Return a list of the web modules in this server.
- *
- * @return the web modules
- */
- public List getWebModules();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatConfigurationWorkingCopy.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatConfigurationWorkingCopy.java
deleted file mode 100644
index 510d77e99..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatConfigurationWorkingCopy.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-public interface ITomcatConfigurationWorkingCopy extends ITomcatConfiguration {
- /**
- * Add a web module.
- *
- * @param index int
- * @param module org.eclipse.jst.server.tomcat.WebModule
- */
- public void addWebModule(int index, ITomcatWebModule module);
-
- /**
- * Change a web module.
- *
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable);
-
- /**
- * Remove a web module.
- *
- * @param index int
- */
- public void removeWebModule(int index);
-
- /**
- * Adds a mime mapping.
- *
- * @param index int
- * @param map MimeMapping
- */
- public void addMimeMapping(int index, IMimeMapping map);
-
- /**
- * Change a mime mapping.
- *
- * @param index int
- * @param map MimeMapping
- */
- public void modifyMimeMapping(int index, IMimeMapping map);
-
- /**
- * Modify the port with the given id.
- *
- * @param id java.lang.String
- * @param port int
- */
- public void modifyServerPort(String id, int port);
-
- /**
- * Remove a mime mapping.
- *
- * @param index int
- */
- public void removeMimeMapping(int index);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntime.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntime.java
deleted file mode 100644
index 865dad3b9..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntime.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.List;
-
-import org.eclipse.jst.server.core.IJavaRuntime;
-/**
- *
- */
-public interface ITomcatRuntime extends IJavaRuntime {
- /**
- * Returns <code>true</code> if this server is using the default JRE, and
- * <code>false</code> otherwise.
- *
- * @return <code>true</code> if this server is using the default JRE, and
- * <code>false</code> otherwise
- */
- public boolean isUsingDefaultJRE();
-
- /**
- * Returns the runtime classpath that is used by this runtime.
- *
- * @return the runtime classpath
- */
- public List getRuntimeClasspath();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntimeWorkingCopy.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntimeWorkingCopy.java
deleted file mode 100644
index faac3d271..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntimeWorkingCopy.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.jdt.launching.IVMInstall;
-/**
- *
- */
-public interface ITomcatRuntimeWorkingCopy extends ITomcatRuntime {
- /**
- * Set the VM install (installed JRE) that this runtime is using.
- * Use <code>null</code> to use the Eclipse default JRE.
- *
- * @param vmInstall the VM install to use
- */
- public void setVMInstall(IVMInstall vmInstall);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServer.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServer.java
deleted file mode 100644
index 7d380ed87..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.wst.server.core.model.IURLProvider;
-/**
- *
- */
-public interface ITomcatServer extends IURLProvider {
- public static final String PROPERTY_TEST_ENVIRONMENT = "testEnvironment";
- /**
- * Returns true if this is a test (publish and run code out of the
- * workbench) environment server.
- *
- * @return boolean
- */
- public boolean isTestEnvironment();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerBehaviour.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerBehaviour.java
deleted file mode 100644
index 63f96ed0b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerBehaviour.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-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;
-/**
- *
- */
-public interface ITomcatServerBehaviour {
- /**
- * Returns the main class that is used to launch the Tomcat server.
- *
- * @return the main runtime class
- */
- 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
- * @throws CoreException if anything goes wrong
- */
- 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/ITomcatServerWorkingCopy.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerWorkingCopy.java
deleted file mode 100644
index 73253741a..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerWorkingCopy.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-/**
- *
- */
-public interface ITomcatServerWorkingCopy extends ITomcatServer {
- /**
- * Sets this server to test environment mode.
- *
- * @param b boolean
- */
- public void setTestEnvironment(boolean b);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatVersionHandler.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatVersionHandler.java
deleted file mode 100644
index 897a28470..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatVersionHandler.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.wst.server.core.IModule;
-/**
- *
- */
-public interface ITomcatVersionHandler {
- public boolean verifyInstallPath(IPath installPath);
-
- public String getRuntimeClass();
-
- public List getRuntimeClasspath(IPath installPath);
-
- /**
- * Return the program's runtime arguments.
- *
- * @param configPath a config path
- * @param debug <code>true</code> if debug mode is on
- * @param starting <code>true</code> if the server is starting
- * @return a string array of program arguments
- */
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting);
-
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, boolean isTestEnv);
-
- public String getRuntimePolicyFile(IPath configPath);
-
- /**
- * Returns true if the given project is supported by this
- * server, and false otherwise.
- *
- * @param module a web module
- * @return the status
- */
- public IStatus canAddModule(IModule module);
-
- /**
- * Returns the runtime base path for relative paths in the server
- * configuration.
- *
- * @param serverBehaviour TomcatServerBehaviour instance from
- * which to determine the base path
- * @return the base path
- */
- public IPath getRuntimeBaseDirectory(TomcatServerBehaviour serverBehaviour);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatWebModule.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatWebModule.java
deleted file mode 100644
index 7cb88b803..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatWebModule.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-/**
- * A Web module deployed on Tomcat.
- */
-public interface ITomcatWebModule {
- /**
- * Get the document base.
- *
- * @return java.lang.String
- */
- public String getDocumentBase();
-
- /**
- * Return the path. (context root)
- *
- * @return java.lang.String
- */
- public String getPath();
-
- /**
- * Return the memento.
- *
- * @return java.lang.String
- */
- public String getMemento();
-
- /**
- * Return true if the web module is auto-reloadable.
- *
- * @return java.lang.String
- */
- public boolean isReloadable();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.java
deleted file mode 100644
index 643d752d8..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.osgi.util.NLS;
-/**
- * Translated messages.
- */
-public class Messages extends NLS {
- public static String copyingTask;
- public static String errorCopyingFile;
- public static String deletingTask;
- public static String errorInstallDir;
- public static String errorInstallDirTrailingSlash;
- public static String errorJRE;
- public static String warningJRE;
- public static String target32runtime;
- public static String target40runtime;
- public static String target41runtime;
- public static String target50runtime;
- public static String target55runtime;
- public static String portUnknown;
- public static String loadingTask;
- public static String errorCouldNotLoadConfiguration;
- public static String savingTask;
- public static String errorCouldNotSaveConfiguration;
- public static String updatingConfigurationTask;
- public static String canAddModule;
- public static String errorSpec32;
- public static String errorSpec40;
- public static String errorSpec41;
- public static String errorSpec50;
- public static String errorSpec55;
- public static String portServer;
- public static String runtimeDirPrepared;
- public static String publishConfigurationTask;
- public static String publishContextConfigTask;
- public static String savingContextConfigTask;
- public static String checkingContextTask;
- public static String serverPostProcessingComplete;
- public static String errorPublishConfiguration;
- public static String cleanupServerTask;
- public static String detectingRemovedProjects;
- public static String deletingContextFilesTask;
- public static String deletingContextFile;
- public static String deletedContextFile;
- public static String errorCouldNotDeleteContextFile;
- public static String errorCleanupServer;
- public static String publisherPublishTask;
- public static String errorNoConfiguration;
- public static String errorWebModulesOnly;
- public static String errorNoRuntime;
- public static String publishServerTask;
- public static String errorPortInvalid;
- public static String errorPortInUse;
- public static String errorPortsInUse;
- public static String errorDuplicateContextRoot;
- public static String errorCouldNotLoadContextXml;
- public static String configurationEditorActionModifyPortDescription;
- public static String configurationEditorActionModifyPort;
- public static String configurationEditorActionModifyMimeMappingDescription;
- public static String configurationEditorActionModifyMimeMapping;
- public static String configurationEditorActionAddMimeMappingDescription;
- public static String configurationEditorActionAddMimeMapping;
- public static String configurationEditorActionAddWebModuleDescription;
- public static String configurationEditorActionAddWebModule;
- public static String configurationEditorActionModifyWebModuleDescription;
- public static String configurationEditorActionModifyWebModule;
- public static String configurationEditorActionRemoveMimeMappingDescription;
- public static String configurationEditorActionRemoveMimeMapping;
- public static String configurationEditorActionRemoveWebModuleDescription;
- public static String configurationEditorActionRemoveWebModule;
- public static String serverEditorActionSetDebugModeDescription;
- public static String serverEditorActionSetDebugMode;
- public static String serverEditorActionSetSecureDescription;
- public static String serverEditorActionSetSecure;
- public static String serverEditorActionSetTestEnvironmentDescription;
- public static String serverEditorActionSetTestEnvironment;
- public static String configurationEditorActionEditWebModuleDescription;
- public static String configurationEditorActionEditWebModulePath;
- public static String fixModuleContextRootDescription;
- public static String fixModuleContextRoot;
-
- static {
- NLS.initializeMessages(TomcatPlugin.PLUGIN_ID + ".internal.Messages", Messages.class);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.properties b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.properties
deleted file mode 100644
index 46548e644..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.properties
+++ /dev/null
@@ -1,102 +0,0 @@
-###############################################################################
-# Copyright (c) 2004, 2005 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-# runtime target
-target32runtime=Tomcat v3.2 runtime
-target40runtime=Tomcat v4.0 runtime
-target41runtime=Tomcat v4.1 runtime
-target50runtime=Tomcat v5.0 runtime
-target55runtime=Tomcat v5.5 runtime
-
-# --------------- Tasks (progress monitors) ---------------
-savingTask=Saving...
-loadingTask=Loading...
-updatingConfigurationTask=Updating run-time configuration...
-publishServerTask=Publishing to server...
-publishConfigurationTask=Publishing the configuration...
-publisherPublishTask=Publishing {0}...
-fixModuleContextRoot=Update context root for Web module {0}
-fixModuleContextRootDescription=Update the context root of the Web module to match the current settings
-
-publishContextConfigTask=Publishing META-INF/context.xml configurations...
-checkingContextTask=Checking Context {0} for context.xml...
-savingContextConfigTask=Saving context configuration updates...
-serverPostProcessingComplete=Context configurations added.
-
-cleanupServerTask=Removing obsolete files from server...
-detectingRemovedProjects=Preparing list of removed projects...
-deletingContextFilesTask=Deleting obsolete context files from server...
-deletingContextFile=Deleting obsolete context file {0}...
-deletedContextFile=Context file {0} removed
-runtimeDirPrepared=Runtime directory prepared
-copyingTask=Copying from {0} to {1}
-deletingTask=Deleting {0}
-errorCopyingFile=Error copying file to {0}: {1}
-
-# Editor commands (used in undo/redo menus)
-configurationEditorActionAddMimeMapping=add MIME mapping
-configurationEditorActionAddMimeMappingDescription=Add a MIME mapping
-configurationEditorActionModifyMimeMapping=modify MIME mapping
-configurationEditorActionModifyMimeMappingDescription=Modify the MIME mapping
-configurationEditorActionRemoveMimeMapping=remove MIME mapping
-configurationEditorActionRemoveMimeMappingDescription=Remove a MIME mapping
-configurationEditorActionAddWebModule=add Web module
-configurationEditorActionAddWebModuleDescription=Add a Web module
-configurationEditorActionModifyWebModule=modify Web module
-configurationEditorActionModifyWebModuleDescription=Modify the Web module
-configurationEditorActionRemoveWebModule=remove Web module
-configurationEditorActionRemoveWebModuleDescription=Remove Web module {0}
-configurationEditorActionModifyPort=set port number
-configurationEditorActionModifyPortDescription=Set the port number
-configurationEditorActionEditWebModulePath=edit Web module path
-configurationEditorActionEditWebModuleDescription=Change Web module path from {0} to {1}
-
-# --------------- General ---------------
-canAddModule=Web module can be added to the server.
-portServer=Tomcat admin port
-portUnknown=unknown port
-
-# --------------- Errors and Info ---------------
-errorInstallDir=The Tomcat installation directory is not correct. It does not point to a valid Tomcat installation.
-errorInstallDirTrailingSlash=The Tomcat installation directory should not have a trailing slash.
-errorJRE=The JRE could not be found. Edit the server and change the JRE location.
-errorPortInvalid=The server cannot be started because one or more of the ports are invalid. Open the server editor and correct the invalid ports.
-errorPortInUse=Port {0} required by {1} is already in use. The server may already be running in another process, or a system process may be using the port. \
- To start this server you will need to stop the other process or change the port number(s).
-errorPortsInUse=Several ports ({0}) required by {1} are already in use. The server may already be running in another process, or a system process may be using the port. \
- To start this server you will need to stop the other process or change the port number(s).
-# the {0} in the following two lines will be replaced with a location (path) of the missing or corrupt server configuration
-errorNoConfiguration=The Tomcat server configuration at {0} is missing. Check the server for errors.
-errorCouldNotLoadConfiguration=Could not load the Tomcat server configuration at {0}. The configuration may be corrupt or incomplete.
-errorCouldNotSaveConfiguration=Could not save the Tomcat server configuration: {0}.
-errorPublishConfiguration=Could not publish server configuration: {0}.
-errorCouldNotDeleteContextFile=Could not delete obsolete context file: {0}
-errorCleanupServer=Could not clean server of obsolete files: {0}
-errorWebModulesOnly=Tomcat only supports running J2EE Web modules.
-errorNoRuntime=Cannot add modules because there is no runtime associated with the server.
-errorSpec32=Tomcat version 3.2 only supports J2EE 1.2 Web modules
-errorSpec40=Tomcat version 4.0 only supports J2EE 1.2 and 1.3 Web modules
-errorSpec41=Tomcat version 4.1 only supports J2EE 1.2 and 1.3 Web modules
-errorSpec50=Tomcat version 5.0 only supports J2EE 1.2, 1.3, and 1.4 Web modules
-errorSpec55=Tomcat version 5.5 only supports J2EE 1.2, 1.3, and 1.4 Web modules
-errorDuplicateContextRoot=Two or more Web modules defined in the configuration have the same context root ({0}). \
- To start this server you will need to remove the duplicate(s).
-errorCouldNotLoadContextXml=Could not load the context configuration for the {0} context due to a syntax error or other exception.
-
-warningJRE=Tomcat requires a Java SDK in order to compile JSP files. Ensure that the JRE preference settings point to an SDK install location.
-
-# Actions (used in undo/redo menus)
-serverEditorActionSetSecure=set security
-serverEditorActionSetSecureDescription=Set the Tomcat security
-serverEditorActionSetDebugMode=set Tomcat debug mode
-serverEditorActionSetDebugModeDescription=Set Tomcat in debug mode
-serverEditorActionSetTestEnvironment=run modules from workspace
-serverEditorActionSetTestEnvironmentDescription=Run modules from the workspace
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/MimeMapping.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/MimeMapping.java
deleted file mode 100644
index bd3fb2e69..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/MimeMapping.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-/**
- * A mime mapping.
- */
-public class MimeMapping implements IMimeMapping {
- private String extension;
- private String mimeType;
-
- /**
- * MimeMapping constructor comment.
- *
- * @param extension an extension
- * @param mimeType a mime type
- */
- public MimeMapping(String extension, String mimeType) {
- super();
- this.extension = extension;
- this.mimeType = mimeType;
- }
-
- /**
- * Returns the extension.
- * @return java.lang.String
- */
- public String getExtension() {
- return extension;
- }
-
- /**
- * Returns the mime type.
- * @return java.lang.String
- */
- public String getMimeType() {
- return mimeType;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PingThread.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PingThread.java
deleted file mode 100644
index ffb95a235..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PingThread.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.FileNotFoundException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.eclipse.wst.server.core.IServer;
-/**
- * Thread used to ping server to test when it is started.
- */
-public class PingThread {
- // delay before pinging starts
- private static final int PING_DELAY = 2000;
-
- // delay between pings
- private static final int PING_INTERVAL = 250;
-
- // maximum number of pings before giving up
- private int maxPings = 56; // total: 16 seconds + connection time
-
- private boolean stop = false;
- private String url;
- private IServer server;
- private TomcatServerBehaviour behaviour;
-
- /**
- * Create a new PingThread.
- *
- * @param server
- * @param url
- * @param maxPings
- * @param behaviour
- */
- public PingThread(IServer server, String url, int maxPings, TomcatServerBehaviour behaviour) {
- super();
- this.server = server;
- this.url = url;
- this.maxPings = maxPings;
- this.behaviour = behaviour;
- Thread t = new Thread("Tomcat Ping Thread") {
- public void run() {
- ping();
- }
- };
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * Ping the server until it is started. Then set the server
- * state to STATE_STARTED.
- */
- protected void ping() {
- int count = 0;
- try {
- Thread.sleep(PING_DELAY);
- } catch (Exception e) {
- // ignore
- }
- while (!stop) {
- try {
- if (count == maxPings) {
- try {
- server.stop(false);
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Ping: could not stop server");
- }
- stop = true;
- break;
- }
- count++;
-
- Trace.trace(Trace.FINEST, "Ping: pinging");
- URL pingUrl = new URL(url);
- URLConnection conn = pingUrl.openConnection();
- ((HttpURLConnection)conn).getResponseCode();
-
- // ping worked - server is up
- if (!stop) {
- Trace.trace(Trace.FINEST, "Ping: success");
- Thread.sleep(200);
- behaviour.setServerStarted();
- }
- stop = true;
- } catch (FileNotFoundException fe) {
- try {
- Thread.sleep(200);
- } catch (Exception e) {
- // ignore
- }
- behaviour.setServerStarted();
- stop = true;
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Ping: failed");
- // pinging failed
- if (!stop) {
- try {
- Thread.sleep(PING_INTERVAL);
- } catch (InterruptedException e2) {
- // ignore
- }
- }
- }
- }
- }
-
- /**
- * Tell the pinging to stop.
- */
- public void stop() {
- Trace.trace(Trace.FINEST, "Ping: stopping");
- stop = true;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ProgressUtil.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ProgressUtil.java
deleted file mode 100644
index aedadd57c..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ProgressUtil.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.core.runtime.*;
-/**
- * Progress Monitor utility.
- */
-public class ProgressUtil {
- /**
- * ProgressUtil constructor comment.
- */
- private ProgressUtil() {
- super();
- }
-
- /**
- * Return a valid progress monitor.
- *
- * @param monitor org.eclipse.core.runtime.IProgressMonitor
- * @return org.eclipse.core.runtime.IProgressMonitor
- */
- public static IProgressMonitor getMonitorFor(IProgressMonitor monitor) {
- if (monitor == null)
- return new NullProgressMonitor();
- return monitor;
- }
-
- /**
- * Return a sub-progress monitor with the given amount on the
- * current progress monitor.
- *
- * @param monitor org.eclipse.core.runtime.IProgressMonitor
- * @param ticks int
- * @return org.eclipse.core.runtime.IProgressMonitor
- */
- public static IProgressMonitor getSubMonitorFor(IProgressMonitor monitor, int ticks) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks);
- }
-
- /**
- * Return a sub-progress monitor with the given amount on the
- * current progress monitor.
- *
- * @param monitor org.eclipse.core.runtime.IProgressMonitor
- * @param ticks a number of ticks
- * @param style a style
- * @return org.eclipse.core.runtime.IProgressMonitor
- */
- public static IProgressMonitor getSubMonitorFor(IProgressMonitor monitor, int ticks, int style) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks, style);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishOperation2.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishOperation2.java
deleted file mode 100644
index be1832493..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishOperation2.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jst.server.core.PublishUtil;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleResource;
-import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.eclipse.wst.server.core.model.PublishOperation;
-import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
-/**
- * Tomcat publish helper.
- */
-public class PublishOperation2 extends PublishOperation {
- protected TomcatServerBehaviour server;
- protected IModule[] module;
- protected int kind;
- protected int deltaKind;
-
- public PublishOperation2(TomcatServerBehaviour server, int kind, IModule[] module, int deltaKind) {
- super("Publish to server", "Publish Web module to Tomcat server");
- this.server = server;
- this.module = module;
- this.kind = kind;
- this.deltaKind = deltaKind;
- }
-
- public int getOrder() {
- return 0;
- }
-
- public int getKind() {
- return REQUIRED;
- }
-
- public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException {
- if (module.length == 1) { // web module
- publishDir(module[0], monitor);
- } else { // utility module
- publishJar(monitor);
- }
- server.setModulePublishState2(module, IServer.PUBLISH_STATE_NONE);
- }
-
- private void publishDir(IModule module2, IProgressMonitor monitor) throws CoreException {
- IPath path = server.getTempDirectory().append("webapps");
- path = path.append(module2.getName());
-
- if (kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED) { // clean and republish from scratch
- PublishUtil.deleteDirectory(path.toFile(), monitor);
-
- if (deltaKind == ServerBehaviourDelegate.REMOVED)
- return;
- }
-
- if (kind == IServer.PUBLISH_CLEAN || kind == IServer.PUBLISH_FULL) {
- IModuleResource[] mr = server.getResources(module);
- PublishUtil.copy(mr, path);
- return;
- }
-
- IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
-
- int size = delta.length;
- for (int i = 0; i < size; i++) {
- PublishUtil.handleDelta(kind, path, delta[i]);
- }
- }
-
- private void publishJar(IProgressMonitor monitor) throws CoreException {
- IPath path = server.getTempDirectory().append("webapps");
- path = path.append(module[0].getName()).append("WEB-INF").append("lib");
- IPath jarPath = path.append(module[1].getName() + ".jar");
-
- if (kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED) { // clean and republish from scratch
- if (jarPath.toFile().exists())
- jarPath.toFile().delete();
-
- if (deltaKind == ServerBehaviourDelegate.REMOVED)
- return;
- }
- if (kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
-
- // make directory if it doesn't exist
-
- if (!path.toFile().exists())
- path.toFile().mkdirs();
-
- IModuleResource[] mr = server.getResources(module);
- PublishUtil.createZipFile(mr, jarPath);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishTask.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishTask.java
deleted file mode 100644
index 4b3d55686..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishTask.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.PublishOperation;
-import org.eclipse.wst.server.core.model.PublishTaskDelegate;
-
-public class PublishTask extends PublishTaskDelegate {
- public PublishOperation[] getTasks(IServer server, int kind, List modules, List kindList) {
- if (modules == null)
- return null;
-
- TomcatServerBehaviour tomcatServer = (TomcatServerBehaviour) server.loadAdapter(TomcatServerBehaviour.class, null);
- if (!tomcatServer.getTomcatServer().isTestEnvironment())
- return null;
-
- List tasks = new ArrayList();
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- IModule[] module = (IModule[]) modules.get(i);
- Integer in = (Integer) kindList.get(i);
- tasks.add(new PublishOperation2(tomcatServer, kind, module, in.intValue()));
- }
-
- return (PublishOperation[]) tasks.toArray(new PublishOperation[tasks.size()]);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Configuration.java
deleted file mode 100644
index 66b28f90f..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Configuration.java
+++ /dev/null
@@ -1,575 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.tomcat.core.internal.xml.Factory;
-import org.eclipse.jst.server.tomcat.core.internal.xml.XMLUtil;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server32.*;
-import org.eclipse.osgi.util.NLS;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-
-import org.eclipse.wst.server.core.ServerPort;
-/**
- * Tomcat v3.2 server configuration.
- */
-public class Tomcat32Configuration extends TomcatConfiguration {
- public static final String ID = "org.eclipse.tomcat.configuration.32";
-
- protected static final String HTTP_HANDLER = "org.apache.tomcat.service.http.HttpConnectionHandler";
- protected static final String APACHE_HANDLER = "org.apache.tomcat.service.connector.Ajp12ConnectionHandler";
- protected static final String SSL_SOCKET_FACTORY = "org.apache.tomcat.net.SSLSocketFactory";
-
- protected Server server;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
-
- /**
- * Tomcat32Configuration constructor.
- *
- * @param path a path
- */
- public Tomcat32Configuration(IFolder path) {
- super(path);
- }
-
- /**
- * Returns the main server port.
- * @return TomcatServerPort
- */
- public ServerPort getMainPort() {
- Iterator iterator = getServerPorts().iterator();
- while (iterator.hasNext()) {
- ServerPort port = (ServerPort) iterator.next();
- if (port.getName().equals("HTTP Connector"))
- return port;
- }
- return null;
- }
-
- /**
- * Returns the prefix that is used in front of the
- * web module path property. (e.g. "webapps")
- *
- * @return java.lang.String
- */
- public String getDocBasePrefix() {
- return "webapps/";
- }
-
- /**
- * Returns the mime mappings.
- * @return java.util.List
- */
- public List getMimeMappings() {
- if (webAppDocument == null)
- return new ArrayList(0);
-
- return webAppDocument.getMimeMappings();
- }
-
- /**
- * Returns the server object (root of server.xml).
- * @return org.eclipse.jst.server.tomcat.internal.xml.server32.Server
- */
- public Server getServer() {
- return server;
- }
-
- /**
- * Returns a list of ServerPorts that this configuration uses.
- *
- * @return java.util.List
- */
- public List getServerPorts() {
- List ports = new ArrayList();
-
- try {
- int count = server.getContextManager().getConnectorCount();
- for (int i = 0; i < count; i++) {
- Connector connector = server.getContextManager().getConnector(i);
- int paramCount = connector.getParameterCount();
- String handler = null;
- String name = Messages.portUnknown;
- String socketFactory = null;
- String protocol = "TCPIP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- for (int j = 0; j < paramCount; j++) {
- Parameter p = connector.getParameter(j);
- if ("port".equals(p.getName())) {
- try {
- port = Integer.parseInt(p.getValue());
- } catch (Exception e) {
- // ignore
- }
- } else if ("handler".equals(p.getName()))
- handler = p.getValue();
- else if ("socketFactory".equals(p.getName()))
- socketFactory = p.getValue();
- }
- if (HTTP_HANDLER.equals(handler)) {
- protocol = "HTTP";
- contentTypes = new String[] { "web", "webservices" };
- if (SSL_SOCKET_FACTORY.equals(socketFactory)) {
- protocol = "SSL";
- name = "SSL Connector";
- } else {
- name = "HTTP Connector";
- advanced = false;
- }
- } else if (APACHE_HANDLER.equals(handler))
- name = "Apache Connector";
- if (handler != null)
- ports.add(new ServerPort(i + "", name, port, protocol, contentTypes, advanced));
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting server ports", e);
- }
-
- return ports;
- }
-
- /**
- * Returns the tomcat-users.xml document.
- *
- * @return org.w3c.dom.Document
- */
- public Document getTomcatUsersDocument() {
- return tomcatUsersDocument;
- }
-
- /**
- * Return a list of the web modules in this server.
- * @return java.util.List
- */
- public List getWebModules() {
- List list = new ArrayList();
-
- try {
- ContextManager contextManager = server.getContextManager();
-
- int size = contextManager.getContextCount();
- for (int i = 0; i < size; i++) {
- Context context = contextManager.getContext(i);
- String reload = context.getReloadable();
- if (reload == null)
- reload = "false";
- WebModule module = new WebModule(context.getPath(),
- context.getDocBase(), context.getSource(),
- reload.equalsIgnoreCase("true") ? true : false);
- list.add(module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting project refs", e);
- }
-
- return list;
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 5);
-
- // check for tomcat.policy to verify that this is a v3.2 config
- InputStream in = new FileInputStream(path.append("tomcat.policy").toFile());
- in.read();
- in.close();
- monitor.worked(1);
-
- // create server.xml
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server32");
- server = (Server) serverFactory.loadDocument(new FileInputStream(path.append("server.xml").toFile()));
- monitor.worked(1);
-
- webAppDocument = new WebAppDocument(path.append("web.xml"));
- monitor.worked(1);
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
- monitor.worked(1);
-
- // load policy file
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(new FileInputStream(path.append("tomcat.policy").toFile())));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- br.close();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(1);
-
- if (monitor.isCanceled())
- return;
-
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not load Tomcat v3.2 configuration from " + path.toOSString() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, path.toOSString()), e));
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 800);
-
- // check for tomcat.policy to verify that this is a v3.2 config
- IFile file = folder.getFile("tomcat.policy");
- if (!file.exists())
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), null));
-
- // load server.xml
- file = folder.getFile("server.xml");
- InputStream in = file.getContents();
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server32");
- server = (Server) serverFactory.loadDocument(in);
- monitor.worked(200);
-
- // load web.xml
- file = folder.getFile("web.xml");
- webAppDocument = new WebAppDocument(file);
- monitor.worked(200);
-
- // load tomcat-users.xml
- file = folder.getFile("tomcat-users.xml");
- in = file.getContents();
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- monitor.worked(200);
-
- // load tomcat.policy
- file = folder.getFile("tomcat.policy");
- in = file.getContents();
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(in));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- br.close();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(200);
-
- if (monitor.isCanceled())
- throw new Exception("Cancelled");
-
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not load Tomcat v3.2 configuration from: " + folder.getFullPath() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), e));
- }
- }
-
- /**
- * Save the information held by this object to the given directory.
- *
- * @param path a path
- * @param forceDirty if true, the files will be saved, regardless
- * of whether they have been modified
- * @param monitor a progress monitor
- * @throws CoreException
- */
- protected void save(IPath path, boolean forceDirty, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 5);
-
- // make sure directory exists
- if (!path.toFile().exists()) {
- forceDirty = true;
- path.toFile().mkdir();
- }
- monitor.worked(1);
-
- // save files
- if (forceDirty || isServerDirty)
- serverFactory.save(path.append("server.xml").toOSString());
- monitor.worked(1);
-
- webAppDocument.save(path.append("web.xml").toOSString(), forceDirty);
- monitor.worked(1);
-
- if (forceDirty)
- XMLUtil.save(path.append("tomcat-users.xml").toOSString(), tomcatUsersDocument);
- monitor.worked(1);
-
- if (forceDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("tomcat.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- isServerDirty = false;
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v3.2 configuration to " + path, e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- public void save(IPath path, IProgressMonitor monitor) throws CoreException {
- save(path, true, monitor);
- }
-
- /**
- * Save the information held by this object to the given directory.
- *
- * @param folder a folder
- * @param monitor a progress monitor
- * @throws CoreException
- */
- public void save(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 900);
-
- if (!folder.exists())
- folder.create(true, true, ProgressUtil.getSubMonitorFor(monitor, 100));
- else
- monitor.worked(100);
-
- // save server.xml
- byte[] data = serverFactory.getContents();
- InputStream in = new ByteArrayInputStream(data);
- IFile file = folder.getFile("server.xml");
- if (file.exists()) {
- if (isServerDirty)
- file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- monitor.worked(200);
- } else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save web.xml
- file = folder.getFile("web.xml");
- webAppDocument.save(file, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save tomcat-users.xml
- data = XMLUtil.getContents(tomcatUsersDocument);
- in = new ByteArrayInputStream(data);
- file = folder.getFile("tomcat-users.xml");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save tomcat.policy
- in = new ByteArrayInputStream(policyFile.getBytes());
- file = folder.getFile("tomcat.policy");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v3.2 configuration to " + folder.getFullPath(), e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addMimeMapping(int, IMimeMapping)
- */
- public void addMimeMapping(int index, IMimeMapping map) {
- webAppDocument.addMimeMapping(index, map);
- firePropertyChangeEvent(ADD_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addWebModule(int, ITomcatWebModule)
- */
- public void addWebModule(int index, ITomcatWebModule module) {
- try {
- ContextManager contextManager = server.getContextManager();
- Context context = (Context) contextManager.createElement(index, "Context");
-
- context.setPath(module.getPath());
- context.setDocBase(module.getDocumentBase());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module", e);
- }
- }
-
- /**
- * Localize the web projects in this configuration.
- *
- * @param path a path
- * @param server2 a server type
- * @param monitor a progress monitor
- */
- public void localizeConfiguration(IPath path, TomcatServer server2, IProgressMonitor monitor) {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.updatingConfigurationTask, 100);
-
- Tomcat32Configuration config = new Tomcat32Configuration(null);
- config.load(path, ProgressUtil.getSubMonitorFor(monitor, 30));
-
- if (monitor.isCanceled())
- return;
-
- if (server2.isTestEnvironment()) {
- IPath tomcatPath = path.removeLastSegments(1);
- config.server.getContextManager().setHome(tomcatPath.toOSString());
- config.isServerDirty = true;
- }
- monitor.worked(40);
-
- if (monitor.isCanceled())
- return;
-
- config.save(path, false, ProgressUtil.getSubMonitorFor(monitor, 30));
-
- if (!monitor.isCanceled())
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error localizing configuration", e);
- }
- }
-
- /**
- * Change the extension of a mime mapping.
- *
- * @param index
- * @param map
- */
- public void modifyMimeMapping(int index, IMimeMapping map) {
- webAppDocument.modifyMimeMapping(index, map);
- firePropertyChangeEvent(MODIFY_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * Modify the port with the given id.
- *
- * @param id java.lang.String
- * @param port int
- */
- public void modifyServerPort(String id, int port) {
- try {
- int con = Integer.parseInt(id);
- Connector connector = server.getContextManager().getConnector(con);
-
- int size = connector.getParameterCount();
- for (int i = 0; i < size; i++) {
- Parameter p = connector.getParameter(i);
- if ("port".equals(p.getName())) {
- p.setValue(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
-
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- ContextManager contextManager = server.getContextManager();
- Context context = contextManager.getContext(index);
- context.setPath(path);
- context.setDocBase(docBase);
- context.setReloadable(reloadable ? "true" : "false");
- isServerDirty = true;
- WebModule module = new WebModule(path, docBase, null, reloadable);
- firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY, new Integer(index), module);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
- }
- }
-
- /**
- * Removes a mime mapping.
- * @param index int
- */
- public void removeMimeMapping(int index) {
- webAppDocument.removeMimeMapping(index);
- firePropertyChangeEvent(REMOVE_MAPPING_PROPERTY, null, new Integer(index));
- }
-
- /**
- * Removes a web module.
- * @param index int
- */
- public void removeWebModule(int index) {
- try {
- ContextManager contextManager = server.getContextManager();
- contextManager.removeElement("Context", index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing web module " + index, e);
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Handler.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Handler.java
deleted file mode 100644
index 13d93684d..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Handler.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IModule;
-/**
- * Tomcat 32 handler.
- */
-public class Tomcat32Handler implements ITomcatVersionHandler {
- /**
- * @see ITomcatVersionHandler#verifyInstallPath(IPath)
- */
- public boolean verifyInstallPath(IPath installPath) {
- return TomcatPlugin.verifyInstallPath(installPath, TomcatPlugin.TOMCAT_32);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.tomcat.startup.Tomcat";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath)
- */
- public List getRuntimeClasspath(IPath installPath) {
- List cp = new ArrayList();
- // add all jars from the Tomcat lib directory
- File libDir = installPath.append("lib").toFile();
- if (libDir.exists()) {
- String[] libs = libDir.list();
- for (int i = 0; i < libs.length; i++) {
- if (libs[i].endsWith("jar")) {
- IPath path = installPath.append("lib").append(libs[i]);
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
- }
- }
- }
-
- return cp;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeProgramArguments(IPath, boolean, boolean)
- */
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting) {
- List list = new ArrayList();
- if (configPath != null) {
- list.add("-f \"" + configPath.append("conf").append("server.xml").toOSString() + "\"");
- }
-
- if (!starting)
- list.add("-stop");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, boolean isTestEnv) {
- List list = new ArrayList();
- list.add("-Dtomcat.home=\"" + installPath.toOSString() + "\"");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
- public String getRuntimePolicyFile(IPath configPath) {
- return configPath.append("conf").append("tomcat.policy").toOSString();
- }
-
- /**
- * @see ITomcatVersionHandler#canAddModule(IModule)
- */
- public IStatus canAddModule(IModule module) {
- if ("2.2".equals(module.getModuleType().getVersion()))
- return Status.OK_STATUS;
-
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorSpec32, null);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeBaseDirectory(TomcatServerBehaviour)
- */
- public IPath getRuntimeBaseDirectory(TomcatServerBehaviour serverBehaviour) {
- return serverBehaviour.getServer().getRuntime().getLocation();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java
deleted file mode 100644
index c1fb11033..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java
+++ /dev/null
@@ -1,593 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.tomcat.core.internal.xml.Factory;
-import org.eclipse.jst.server.tomcat.core.internal.xml.XMLUtil;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.*;
-import org.eclipse.osgi.util.NLS;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-
-import org.eclipse.wst.server.core.ServerPort;
-/**
- * Tomcat v4.0 server configuration.
- */
-public class Tomcat40Configuration extends TomcatConfiguration {
- protected static final String DEFAULT_SERVICE = "Tomcat-Standalone";
- protected static final String HTTP_CONNECTOR = "org.apache.catalina.connector.http.HttpConnector";
- protected static final String SSL_SOCKET_FACTORY = "org.apache.catalina.net.SSLServerSocketFactory";
- protected static final String TEST_CONNECTOR = "org.apache.catalina.connector.test.HttpConnector";
- protected static final String APACHE_CONNECTOR = "org.apache.catalina.connector.warp.WarpConnector";
-
- protected Server server;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
- protected boolean isPolicyDirty;
-
- /**
- * Tomcat40Configuration constructor.
- *
- * @param path a path
- */
- public Tomcat40Configuration(IFolder path) {
- super(path);
- }
-
- /**
- * Return the port number.
- * @return int
- */
- public ServerPort getMainPort() {
- Iterator iterator = getServerPorts().iterator();
- while (iterator.hasNext()) {
- ServerPort port = (ServerPort) iterator.next();
- if (port.getName().equals("HTTP Connector"))
- return port;
- }
- return null;
- }
-
- /**
- * Returns the mime mappings.
- * @return java.util.List
- */
- public List getMimeMappings() {
- return webAppDocument.getMimeMappings();
- }
-
- /**
- * Returns a list of ServerPorts that this configuration uses.
- *
- * @return java.util.List
- */
- public List getServerPorts() {
- List ports = new ArrayList();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String className = connector.getClassName();
- String name = Messages.portUnknown;
- String protocol = "TCPIP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- if (HTTP_CONNECTOR.equals(className)) {
- name = "HTTP Connector";
- protocol = "HTTP";
- contentTypes = new String[] { "web", "webservices" };
- // check for SSL connector
- try {
- Element element = connector.getSubElement("Factory");
- if (SSL_SOCKET_FACTORY.equals(element.getAttribute("className"))) {
- name = "SSL Connector";
- protocol = "SSL";
- }
- } catch (Exception e) {
- // ignore
- }
- if ("HTTP".equals(protocol))
- advanced = false;
- } else if (APACHE_CONNECTOR.equals(className))
- name = "Apache Connector";
- if (className != null && className.length() > 0)
- ports.add(new ServerPort(i + "/" + j, name, port, protocol, contentTypes, advanced));
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting server ports", e);
- }
- return ports;
- }
-
- /**
- * Return a list of the web modules in this server.
- * @return java.util.List
- */
- public List getWebModules() {
- List list = new ArrayList();
-
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- Context context = host.getContext(j);
- String reload = context.getReloadable();
- if (reload == null)
- reload = "false";
- WebModule module = new WebModule(context.getPath(),
- context.getDocBase(), context.getSource(),
- reload.equalsIgnoreCase("true") ? true : false);
- list.add(module);
- }
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting modules", e);
- }
- return list;
- }
-
- public void importFromPath(IPath path, boolean isTestEnv, IProgressMonitor monitor) throws CoreException {
- load(path, monitor);
-
- // for test environment, remove existing contexts since a separate
- // catalina.base will be used
- if (isTestEnv) {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Host host = service.getEngine().getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- host.removeElement("Context", 0);
- }
- }
- }
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 5);
-
- // check for catalina.policy to verify that this is a v4.0 config
- InputStream in = new FileInputStream(path.append("catalina.policy").toFile());
- in.read();
- in.close();
- monitor.worked(1);
-
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- server = (Server) serverFactory.loadDocument(new FileInputStream(path.append("server.xml").toFile()));
- monitor.worked(1);
-
- webAppDocument = new WebAppDocument(path.append("web.xml"));
- monitor.worked(1);
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
- monitor.worked(1);
-
- // load policy file
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(new FileInputStream(path.append("catalina.policy").toFile())));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(1);
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load Tomcat v4.0 configuration from " + path.toOSString() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, path.toOSString()), e));
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 800);
-
- // check for catalina.policy to verify that this is a v4.0 config
- IFile file = folder.getFile("catalina.policy");
- if (!file.exists())
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), null));
-
- // load server.xml
- file = folder.getFile("server.xml");
- InputStream in = file.getContents();
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- server = (Server) serverFactory.loadDocument(in);
- monitor.worked(200);
-
- // load web.xml
- file = folder.getFile("web.xml");
- webAppDocument = new WebAppDocument(file);
- monitor.worked(200);
-
- // load tomcat-users.xml
- file = folder.getFile("tomcat-users.xml");
- in = file.getContents();
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- monitor.worked(200);
-
- // load catalina.policy
- file = folder.getFile("catalina.policy");
- in = file.getContents();
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(in));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(200);
-
- if (monitor.isCanceled())
- throw new Exception("Cancelled");
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not reload Tomcat v4.0 configuration from: " + folder.getFullPath() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), e));
- }
- }
-
- /**
- * Save to the given directory.
- *
- * @param path a path
- * @param forceDirty boolean
- * @param monitor a progress monitor
- * @exception CoreException
- */
- protected void save(IPath path, boolean forceDirty, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 3);
-
- // make sure directory exists
- if (!path.toFile().exists()) {
- forceDirty = true;
- path.toFile().mkdir();
- }
- monitor.worked(1);
-
- // save files
- if (forceDirty || isServerDirty)
- serverFactory.save(path.append("server.xml").toOSString());
- monitor.worked(1);
-
- //if (forceDirty || isWebAppDirty)
- // webAppFactory.save(dirPath + "web.xml");
- //webAppDocument.save(path.toOSString(), forceDirty || isPolicyDirty);
- webAppDocument.save(path.append("web.xml").toOSString(), forceDirty);
- monitor.worked(1);
-
- if (forceDirty)
- XMLUtil.save(path.append("tomcat-users.xml").toOSString(), tomcatUsersDocument);
- monitor.worked(1);
-
- if (forceDirty || isPolicyDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- isServerDirty = false;
- isPolicyDirty = false;
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v4.0 configuration to " + path, e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- public void save(IPath path, IProgressMonitor monitor) throws CoreException {
- save(path, true, monitor);
- }
-
- /**
- * Save the information held by this object to the given directory.
- *
- * @param folder a folder
- * @param monitor a progress monitor
- * @throws CoreException
- */
- public void save(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 900);
-
- // save server.xml
- byte[] data = serverFactory.getContents();
- InputStream in = new ByteArrayInputStream(data);
- IFile file = folder.getFile("server.xml");
- if (file.exists()) {
- if (isServerDirty)
- file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- monitor.worked(200);
- } else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save web.xml
- webAppDocument.save(folder.getFile("web.xml"), ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save tomcat-users.xml
- data = XMLUtil.getContents(tomcatUsersDocument);
- in = new ByteArrayInputStream(data);
- file = folder.getFile("tomcat-users.xml");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save catalina.policy
- in = new ByteArrayInputStream(policyFile.getBytes());
- file = folder.getFile("catalina.policy");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v4.0 configuration to " + folder.toString(), e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addMimeMapping(int, IMimeMapping)
- */
- public void addMimeMapping(int index, IMimeMapping map) {
- webAppDocument.addMimeMapping(index, map);
- firePropertyChangeEvent(ADD_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addWebModule(int, ITomcatWebModule)
- */
- public void addWebModule(int index, ITomcatWebModule module) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- Context context = (Context) host.createElement(index, "Context");
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * Change the extension of a mime mapping.
- *
- * @param index
- * @param map
- */
- public void modifyMimeMapping(int index, IMimeMapping map) {
- webAppDocument.modifyMimeMapping(index, map);
- firePropertyChangeEvent(MODIFY_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * Modify the port with the given id.
- *
- * @param id java.lang.String
- * @param port int
- */
- public void modifyServerPort(String id, int port) {
- try {
- if ("server".equals(id)) {
- server.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- return;
- }
-
- int i = id.indexOf("/");
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- Context context = host.getContext(index);
- context.setPath(path);
- context.setDocBase(docBase);
- context.setReloadable(reloadable ? "true" : "false");
- isServerDirty = true;
- WebModule module = new WebModule(path, docBase, null, reloadable);
- firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY, new Integer(index), module);
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
- }
- }
-
- /**
- * Removes a mime mapping.
- * @param index int
- */
- public void removeMimeMapping(int index) {
- webAppDocument.removeMimeMapping(index);
- firePropertyChangeEvent(REMOVE_MAPPING_PROPERTY, null, new Integer(index));
- }
-
- /**
- * Removes a web module.
- * @param index int
- */
- public void removeWebModule(int index) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- host.removeElement("Context", index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- protected IStatus prepareRuntimeDirectory(IPath confDir) {
- Trace.trace(Trace.FINER, "Preparing runtime directory");
- // Prepare a catalina.base directory structure
- File temp = confDir.append("conf").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("logs").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("temp").toFile();
- if (!temp.exists())
- temp.mkdirs();
- IPath tempPath = confDir.append("webapps/ROOT/WEB-INF");
- temp = tempPath.toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = tempPath.append("web.xml").toFile();
- if (!temp.exists()) {
- FileWriter fw;
- try {
- fw = new FileWriter(temp);
- fw.write(DEFAULT_WEBXML_SERVLET23);
- fw.close();
- } catch (IOException e) {
- Trace.trace(Trace.WARNING, "Unable to create web.xml for ROOT context.", e);
- }
- }
- temp = confDir.append("work").toFile();
- if (!temp.exists())
- temp.mkdirs();
-
- return Status.OK_STATUS;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Handler.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Handler.java
deleted file mode 100644
index db4cccb61..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Handler.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IModule;
-/**
- * Tomcat 40 handler.
- */
-public class Tomcat40Handler implements ITomcatVersionHandler {
- /**
- * @see ITomcatVersionHandler#verifyInstallPath(IPath)
- */
- public boolean verifyInstallPath(IPath installPath) {
- if (installPath == null)
- return false;
-
- if (!TomcatPlugin.verifyTomcatVersionFromPath(installPath, TomcatPlugin.TOMCAT_40))
- return false;
- return TomcatPlugin.verifyInstallPath(installPath, TomcatPlugin.TOMCAT_40);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.catalina.startup.Bootstrap";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath)
- */
- public List getRuntimeClasspath(IPath installPath) {
- List cp = new ArrayList();
-
- // 4.0 - add bootstrap.jar from the Tomcat bin directory
- IPath binPath = installPath.append("bin");
- if (binPath.toFile().exists()) {
- IPath path = binPath.append("bootstrap.jar");
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
- }
-
- return cp;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeProgramArguments(IPath, boolean, boolean)
- */
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting) {
- List list = new ArrayList();
-
- if (debug)
- list.add("-debug");
-
- if (starting)
- list.add("start");
- else
- list.add("stop");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, boolean isTestEnv) {
- List list = new ArrayList();
- if (isTestEnv)
- list.add("-Dcatalina.base=\"" + configPath.toOSString() + "\"");
- else
- list.add("-Dcatalina.base=\"" + installPath.toOSString() + "\"");
- list.add("-Dcatalina.home=\"" + installPath.toOSString() + "\"");
- String endorsed = installPath.append("bin").toOSString() +
- installPath.append("common").append("lib").toOSString();
- list.add("-Djava.endorsed.dirs=\"" + endorsed + "\"");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
- public String getRuntimePolicyFile(IPath configPath) {
- return configPath.append("conf").append("catalina.policy").toOSString();
- }
-
- /**
- * @see ITomcatVersionHandler#canAddModule(IModule)
- */
- public IStatus canAddModule(IModule module) {
- String version = module.getModuleType().getVersion();
- if ("2.2".equals(version) || "2.3".equals(version))
- return Status.OK_STATUS;
-
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorSpec40, null);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeBaseDirectory(TomcatServerBehaviour)
- */
- public IPath getRuntimeBaseDirectory(TomcatServerBehaviour serverBehaviour) {
- if (serverBehaviour.getTomcatServer().isTestEnvironment())
- return serverBehaviour.getTempDirectory();
- return serverBehaviour.getServer().getRuntime().getLocation();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java
deleted file mode 100644
index df02e9da8..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java
+++ /dev/null
@@ -1,747 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.tomcat.core.internal.xml.Factory;
-import org.eclipse.jst.server.tomcat.core.internal.xml.XMLUtil;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.*;
-import org.eclipse.osgi.util.NLS;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.eclipse.wst.server.core.ServerPort;
-/**
- * Tomcat v4.1 server configuration.
- */
-public class Tomcat41Configuration extends TomcatConfiguration {
- protected static final String DEFAULT_SERVICE = "Tomcat-Standalone";
- protected static final String HTTP_CONNECTOR = "org.apache.coyote.tomcat4.CoyoteConnector";
- protected static final String JK_PROTOCOL_HANDLER = "org.apache.jk.server.JkCoyoteHandler";
- protected static final String SSL_SOCKET_FACTORY = "org.apache.coyote.tomcat4.CoyoteServerSocketFactory";
- //protected static final String TEST_CONNECTOR = "org.apache.catalina.connector.test.HttpConnector";
- //org.apache.ajp.tomcat4.Ajp13Connector
- protected static final String APACHE_CONNECTOR = "org.apache.catalina.connector.warp.WarpConnector";
-
- protected Server server;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
- protected boolean isPolicyDirty;
-
- /**
- * Tomcat41Configuration constructor.
- *
- * @param path a path
- */
- public Tomcat41Configuration(IFolder path) {
- super(path);
- }
-
- /**
- * Return the port number.
- * @return int
- */
- public ServerPort getMainPort() {
- Iterator iterator = getServerPorts().iterator();
- while (iterator.hasNext()) {
- ServerPort port = (ServerPort) iterator.next();
- if (port.getName().equals("HTTP Connector"))
- return port;
- }
- return null;
- }
-
- /**
- * Returns the mime mappings.
- * @return java.util.List
- */
- public List getMimeMappings() {
- return webAppDocument.getMimeMappings();
- }
-
- /**
- * Returns a list of ServerPorts that this configuration uses.
- *
- * @return java.util.List
- */
- public List getServerPorts() {
- List ports = new ArrayList();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String className = connector.getClassName();
- String name = className;
- String protocol = "TCPIP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- if (HTTP_CONNECTOR.equals(className)) {
- name = "HTTP Connector";
- protocol = "HTTP";
- contentTypes = new String[] { "web", "webservices" };
- // check for AJP/1.3 Coyote connector
- String protocolHandler = connector.getProtocolHandlerClassName();
- if (JK_PROTOCOL_HANDLER.equals(protocolHandler)) {
- name = "AJP/1.3 Connector";
- protocol = "AJP/1.3";
- } else {
- // assume HTTP, check for HTTP SSL connector
- try {
- Element element = connector.getSubElement("Factory");
- if (SSL_SOCKET_FACTORY.equals(element.getAttribute("className"))) {
- name = "SSL Connector";
- protocol = "SSL";
- }
- } catch (Exception e) {
- // ignore
- }
- }
- if ("HTTP".equals(protocol))
- advanced = false;
- } else if (APACHE_CONNECTOR.equals(className))
- name = "Apache Connector";
- if (className != null && className.length() > 0)
- ports.add(new ServerPort(i + "/" + j, name, port, protocol, contentTypes, advanced));
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting server ports", e);
- }
- return ports;
- }
-
- /**
- * Return a list of the web modules in this server.
- * @return java.util.List
- */
- public List getWebModules() {
- List list = new ArrayList();
-
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- Context context = host.getContext(j);
- String reload = context.getReloadable();
- if (reload == null)
- reload = "false";
- WebModule module = new WebModule(context.getPath(),
- context.getDocBase(), context.getSource(),
- reload.equalsIgnoreCase("true") ? true : false);
- list.add(module);
- }
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting project refs", e);
- }
- return list;
- }
-
- public void importFromPath(IPath path, boolean isTestEnv, IProgressMonitor monitor) throws CoreException {
- load(path, monitor);
-
- // for test environment, remove existing contexts since a separate
- // catalina.base will be used
- if (isTestEnv) {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Host host = service.getEngine().getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- host.removeElement("Context", 0);
- }
- }
- }
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 5);
-
- // check for catalina.policy to verify that this is a v4.0 config
- InputStream in = new FileInputStream(path.append("catalina.policy").toFile());
- in.read();
- in.close();
- monitor.worked(1);
-
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- server = (Server) serverFactory.loadDocument(new FileInputStream(path.append("server.xml").toFile()));
- monitor.worked(1);
-
- webAppDocument = new WebAppDocument(path.append("web.xml"));
- monitor.worked(1);
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
- monitor.worked(1);
-
- // load policy file
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(new FileInputStream(path.append("catalina.policy").toFile())));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(1);
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load Tomcat v4.0 configuration from " + path.toOSString() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, path.toOSString()), e));
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 800);
-
- // check for catalina.policy to verify that this is a v4.0 config
- IFile file = folder.getFile("catalina.policy");
- if (!file.exists())
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), null));
-
- // load server.xml
- file = folder.getFile("server.xml");
- InputStream in = file.getContents();
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- server = (Server) serverFactory.loadDocument(in);
- monitor.worked(200);
-
- // load web.xml
- file = folder.getFile("web.xml");
- webAppDocument = new WebAppDocument(file);
- monitor.worked(200);
-
- // load tomcat-users.xml
- file = folder.getFile("tomcat-users.xml");
- in = file.getContents();
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- monitor.worked(200);
-
- // load catalina.policy
- file = folder.getFile("catalina.policy");
- in = file.getContents();
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(in));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(200);
-
- if (monitor.isCanceled())
- throw new Exception("Cancelled");
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not reload Tomcat v4.1 configuration from: " + folder.getFullPath() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), e));
- }
- }
-
- /**
- * Save to the given directory.
- *
- * @param path a path
- * @param forceDirty boolean
- * @param monitor a progress monitor
- * @exception CoreException
- */
- protected void save(IPath path, boolean forceDirty, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 3);
-
- // make sure directory exists
- if (!path.toFile().exists()) {
- forceDirty = true;
- path.toFile().mkdir();
- }
- monitor.worked(1);
-
- // save files
- if (forceDirty || isServerDirty)
- serverFactory.save(path.append("server.xml").toOSString());
- monitor.worked(1);
-
- //if (forceDirty || isWebAppDirty)
- // webAppFactory.save(dirPath + "web.xml");
- //webAppDocument.save(path.toOSString(), forceDirty || isPolicyDirty);
- webAppDocument.save(path.append("web.xml").toOSString(), forceDirty);
- monitor.worked(1);
-
- if (forceDirty)
- XMLUtil.save(path.append("tomcat-users.xml").toOSString(), tomcatUsersDocument);
- monitor.worked(1);
-
- if (forceDirty || isPolicyDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- isServerDirty = false;
- isPolicyDirty = false;
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v4.1 configuration to " + path, e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- public void save(IPath path, IProgressMonitor monitor) throws CoreException {
- save(path, true, monitor);
- }
-
- /**
- * Save the information held by this object to the given directory.
- *
- * @param folder a folder
- * @param monitor a progress monitor
- * @throws CoreException
- */
- public void save(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 900);
-
- // save server.xml
- byte[] data = serverFactory.getContents();
- InputStream in = new ByteArrayInputStream(data);
- IFile file = folder.getFile("server.xml");
- if (file.exists()) {
- if (isServerDirty)
- file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- monitor.worked(200);
- } else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save web.xml
- webAppDocument.save(folder.getFile("web.xml"), ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save tomcat-users.xml
- data = XMLUtil.getContents(tomcatUsersDocument);
- in = new ByteArrayInputStream(data);
- file = folder.getFile("tomcat-users.xml");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save catalina.policy
- in = new ByteArrayInputStream(policyFile.getBytes());
- file = folder.getFile("catalina.policy");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v4.1 configuration to " + folder.toString(), e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- protected static boolean hasMDBListener(Server server) {
- if (server == null)
- return false;
-
- int count = server.getListenerCount();
- if (count == 0)
- return false;
-
- for (int i = 0; i < count; i++) {
- Listener listener = server.getListener(i);
- if (listener != null && listener.getClassName() != null && listener.getClassName().indexOf("mbean") >= 0)
- return true;
- }
- return false;
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addMimeMapping(int, IMimeMapping)
- */
- public void addMimeMapping(int index, IMimeMapping map) {
- webAppDocument.addMimeMapping(index, map);
- firePropertyChangeEvent(ADD_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addWebModule(int, ITomcatWebModule)
- */
- public void addWebModule(int index, ITomcatWebModule module) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- Context context = (Context) host.createElement(index, "Context");
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * Change the extension of a mime mapping.
- *
- * @param index
- * @param map
- */
- public void modifyMimeMapping(int index, IMimeMapping map) {
- webAppDocument.modifyMimeMapping(index, map);
- firePropertyChangeEvent(MODIFY_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * Modify the port with the given id.
- *
- * @param id java.lang.String
- * @param port int
- */
- public void modifyServerPort(String id, int port) {
- try {
- if ("server".equals(id)) {
- server.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- return;
- }
-
- int i = id.indexOf("/");
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- Context context = host.getContext(index);
- context.setPath(path);
- context.setDocBase(docBase);
- context.setReloadable(reloadable ? "true" : "false");
- isServerDirty = true;
- WebModule module = new WebModule(path, docBase, null, reloadable);
- firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY, new Integer(index), module);
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
- }
- }
-
- /**
- * Removes a mime mapping.
- * @param index int
- */
- public void removeMimeMapping(int index) {
- webAppDocument.removeMimeMapping(index);
- firePropertyChangeEvent(REMOVE_MAPPING_PROPERTY, null, new Integer(index));
- }
-
- /**
- * Removes a web module.
- * @param index int
- */
- public void removeWebModule(int index) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- host.removeElement("Context", index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- protected IStatus publishContextConfig(IPath baseDir, IProgressMonitor monitor) {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishConfigurationTask, 300);
-
- Trace.trace(Trace.FINER, "Apply context configurations");
- IPath confDir = baseDir.append("conf");
- IPath webappsDir = baseDir.append("webapps");
- try {
- monitor.subTask(Messages.publishContextConfigTask);
- Factory factory = new Factory();
- factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- Server publishedServer = (Server) factory.loadDocument(new FileInputStream(confDir.append("server.xml").toFile()));
- monitor.worked(100);
-
- boolean modified = false;
-
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, Messages.publishContextConfigTask, null);
- int size = publishedServer.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = publishedServer.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- Context context = host.getContext(j);
- monitor.subTask(NLS.bind(Messages.checkingContextTask,
- new String[] {context.getPath()}));
- if (addContextConfig(webappsDir, context, ms)) {
- modified = true;
- }
- }
- }
- }
- monitor.worked(100);
- if (modified) {
- monitor.subTask(Messages.savingContextConfigTask);
- factory.save(confDir.append("server.xml").toOSString());
- }
- monitor.done();
-
- // If problem(s) occurred adding context configurations, return error status
- if (ms.getChildren().length > 0) {
- return ms;
- }
- Trace.trace(Trace.FINER, "Server.xml updated with context.xml configurations");
- return Status.OK_STATUS;
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not apply context configurations to published Tomcat v5.0 configuration from " + confDir.toOSString() + ": " + e.getMessage());
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- }
- }
-
- /**
- * If the specified Context is linked to a project, try to
- * update it with any configuration from a META-INF/context.xml found
- * relative to the specified web applications directory and context docBase.
- * @param webappsDir Path to server's web applications directory.
- * @param context Context object to receive context.xml contents.
- * @param ms MultiStatus object to receive error status.
- * @return Returns true if context is modified.
- */
- protected boolean addContextConfig(IPath webappsDir, Context context, MultiStatus ms) {
- boolean modified = false;
- String source = context.getSource();
- if (source != null && source.length() > 0 )
- {
- String docBase = context.getDocBase();
- try {
- Context contextConfig = loadContextConfig(webappsDir.append(docBase));
- if (null != contextConfig) {
- if (context.hasChildNodes())
- context.removeChildren();
- contextConfig.copyChildrenTo(context);
- Map attrs = contextConfig.getAttributes();
- Iterator iter = attrs.keySet().iterator();
- while (iter.hasNext()) {
- String name = (String) iter.next();
- if (!name.equalsIgnoreCase("path")
- && !name.equalsIgnoreCase("docBase")
- && !name.equalsIgnoreCase("source")) {
- String value = (String)attrs.get(name);
- context.setAttributeValue(name, value);
- }
- }
- modified = true;
- }
- } catch (Exception e) {
- String contextPath = context.getPath();
- if (contextPath.startsWith("/")) {
- contextPath = contextPath.substring(1);
- }
- Trace.trace(Trace.SEVERE, "Error reading context.xml file for " + contextPath, e);
- IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorCouldNotLoadContextXml, contextPath), e);
- ms.add(s);
- }
- }
- return modified;
- }
-
- /**
- * Tries to read a META-INF/context.xml file relative to the
- * specified web application path. If found, it creates a Context object
- * containing the contexts of that file.
- * @param webappDir Path to the web application
- * @return Context element created from context.xml, or null if not found.
- * @throws SAXException If there is a error parsing the XML.
- * @throws IOException If there is an error reading the file.
- */
- protected Context loadContextConfig(IPath webappDir) throws IOException, SAXException {
- File contextXML = new File(webappDir.toOSString()+ File.separator + "META-INF" + File.separator + "context.xml");
- if (contextXML.exists()) {
- try {
- InputStream is = new FileInputStream(contextXML);
- Factory ctxFactory = new Factory();
- ctxFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- Context ctx = (Context)ctxFactory.loadDocument(is);
- is.close();
- return ctx;
- } catch (FileNotFoundException e) {
- // Ignore, should never occur
- }
- }
- return null;
- }
-
- protected IStatus prepareRuntimeDirectory(IPath confDir) {
- Trace.trace(Trace.FINER, "Preparing runtime directory");
- // Prepare a catalina.base directory structure
- File temp = confDir.append("conf").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("logs").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("temp").toFile();
- if (!temp.exists())
- temp.mkdirs();
- IPath tempPath = confDir.append("webapps/ROOT/WEB-INF");
- temp = tempPath.toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = tempPath.append("web.xml").toFile();
- if (!temp.exists()) {
- FileWriter fw;
- try {
- fw = new FileWriter(temp);
- fw.write(DEFAULT_WEBXML_SERVLET23);
- fw.close();
- } catch (IOException e) {
- Trace.trace(Trace.WARNING, "Unable to create web.xml for ROOT context.", e);
- }
- }
- temp = confDir.append("work").toFile();
- if (!temp.exists())
- temp.mkdirs();
-
- return Status.OK_STATUS;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Handler.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Handler.java
deleted file mode 100644
index 206ef229c..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Handler.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IModule;
-/**
- * Tomcat 41 handler.
- */
-public class Tomcat41Handler implements ITomcatVersionHandler {
- /**
- * @see ITomcatVersionHandler#verifyInstallPath(IPath)
- */
- public boolean verifyInstallPath(IPath installPath) {
- if (installPath == null)
- return false;
-
- if (!TomcatPlugin.verifyTomcatVersionFromPath(installPath, TomcatPlugin.TOMCAT_41))
- return false;
- return TomcatPlugin.verifyInstallPath(installPath, TomcatPlugin.TOMCAT_41);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.catalina.startup.Bootstrap";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath)
- */
- public List getRuntimeClasspath(IPath installPath) {
- List cp = new ArrayList();
-
- // 4.1 - add bootstrap.jar from the Tomcat bin directory
- IPath binPath = installPath.append("bin");
- if (binPath.toFile().exists()) {
- IPath path = binPath.append("bootstrap.jar");
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
- }
-
- return cp;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeProgramArguments(IPath, boolean, boolean)
- */
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting) {
- List list = new ArrayList();
-
- if (debug)
- list.add("-debug");
-
- if (starting)
- list.add("start");
- else
- list.add("stop");
-
- String[] temp = new String[list.size()];
- list.toArray(temp);
- return temp;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, boolean isTestEnv) {
- List list = new ArrayList();
- if (isTestEnv)
- list.add("-Dcatalina.base=\"" + configPath.toOSString() + "\"");
- else
- list.add("-Dcatalina.base=\"" + installPath.toOSString() + "\"");
- list.add("-Dcatalina.home=\"" + installPath.toOSString() + "\"");
- list.add("-Djava.endorsed.dirs=\"" + installPath.append("common").append("endorsed").toOSString() + "\"");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
- public String getRuntimePolicyFile(IPath configPath) {
- return configPath.append("conf").append("catalina.policy").toOSString();
- }
-
- /**
- * @see ITomcatVersionHandler#canAddModule(IModule)
- */
- public IStatus canAddModule(IModule module) {
- String version = module.getModuleType().getVersion();
- if ("2.2".equals(version) || "2.3".equals(version))
- return Status.OK_STATUS;
-
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorSpec41, null);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeBaseDirectory(TomcatServerBehaviour)
- */
- public IPath getRuntimeBaseDirectory(TomcatServerBehaviour serverBehaviour) {
- if (serverBehaviour.getTomcatServer().isTestEnvironment())
- return serverBehaviour.getTempDirectory();
- return serverBehaviour.getServer().getRuntime().getLocation();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java
deleted file mode 100644
index c79674431..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java
+++ /dev/null
@@ -1,823 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.tomcat.core.internal.xml.Factory;
-import org.eclipse.jst.server.tomcat.core.internal.xml.XMLUtil;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.*;
-import org.eclipse.osgi.util.NLS;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.eclipse.wst.server.core.ServerPort;
-/**
- * Tomcat v5.0 server configuration.
- */
-public class Tomcat50Configuration extends TomcatConfiguration {
- protected static final String DEFAULT_SERVICE = "Catalina";
- protected Server server;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
- protected boolean isPolicyDirty;
-
- /**
- * Tomcat50Configuration constructor.
- *
- * @param path a path
- */
- public Tomcat50Configuration(IFolder path) {
- super(path);
- }
-
- /**
- * Return the port number.
- * @return int
- */
- public ServerPort getMainPort() {
- Iterator iterator = getServerPorts().iterator();
- while (iterator.hasNext()) {
- ServerPort port = (ServerPort) iterator.next();
- if (port.getName().equals("HTTP"))
- return port;
- }
- return null;
- }
-
- /**
- * Returns the mime mappings.
- * @return java.util.List
- */
- public List getMimeMappings() {
- return webAppDocument.getMimeMappings();
- }
-
- /**
- * Returns a list of ServerPorts that this configuration uses.
- *
- * @return java.util.List
- */
- public List getServerPorts() {
- List ports = new ArrayList();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String name = "HTTP";
- String protocol2 = "HTTP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- String protocol = connector.getProtocol();
- if (protocol != null && protocol.length() > 0) {
- name = protocol;
- protocol2 = protocol;
- }
- if ("HTTP".equals(protocol))
- contentTypes = new String[] { "web", "webservices" };
- String secure = connector.getSecure();
- if (secure != null && secure.length() > 0) {
- name = "SSL";
- protocol2 = "SSL";
- } else
- advanced = false;
- ports.add(new ServerPort(i +"/" + j, name, port, protocol2, contentTypes, advanced));
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting server ports", e);
- }
- return ports;
- }
-
- /**
- * Return a list of the web modules in this server.
- * @return java.util.List
- */
- public List getWebModules() {
- List list = new ArrayList();
-
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- Context context = host.getContext(j);
- String reload = context.getReloadable();
- if (reload == null)
- reload = "false";
- WebModule module = new WebModule(context.getPath(),
- context.getDocBase(), context.getSource(),
- reload.equalsIgnoreCase("true") ? true : false);
- list.add(module);
- }
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting project refs", e);
- }
- return list;
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 5);
-
- // check for catalina.policy to verify that this is a v5.0 config
- InputStream in = new FileInputStream(path.append("catalina.policy").toFile());
- in.read();
- in.close();
- monitor.worked(1);
-
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- server = (Server) serverFactory.loadDocument(new FileInputStream(path.append("server.xml").toFile()));
- monitor.worked(1);
-
- webAppDocument = new WebAppDocument(path.append("web.xml"));
- monitor.worked(1);
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
- monitor.worked(1);
-
- // load policy file
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(new FileInputStream(path.append("catalina.policy").toFile())));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(1);
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load Tomcat v5.0 configuration from " + path.toOSString() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, path.toOSString()), e));
- }
- }
-
- public void importFromPath(IPath path, boolean isTestEnv, IProgressMonitor monitor) throws CoreException {
- load(path, monitor);
-
- // for test environment, remove existing contexts since a separate
- // catalina.base will be used
- if (isTestEnv) {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Host host = service.getEngine().getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- host.removeElement("Context", 0);
- }
- }
- }
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 800);
-
- // check for catalina.policy to verify that this is a v4.0 config
- IFile file = folder.getFile("catalina.policy");
- if (!file.exists())
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), null));
-
- // load server.xml
- file = folder.getFile("server.xml");
- InputStream in = file.getContents();
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- server = (Server) serverFactory.loadDocument(in);
- monitor.worked(200);
-
- // load web.xml
- file = folder.getFile("web.xml");
- webAppDocument = new WebAppDocument(file);
- monitor.worked(200);
-
- // load tomcat-users.xml
- file = folder.getFile("tomcat-users.xml");
- in = file.getContents();
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- monitor.worked(200);
-
- // load catalina.policy
- file = folder.getFile("catalina.policy");
- in = file.getContents();
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(in));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(200);
-
- if (monitor.isCanceled())
- throw new Exception("Cancelled");
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not reload Tomcat v5.0 configuration from: " + folder.getFullPath() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), e));
- }
- }
-
- /**
- * Save to the given directory.
- * @param path a path
- * @param forceDirty boolean
- * @param monitor a progress monitor
- * @exception CoreException
- */
- protected void save(IPath path, boolean forceDirty, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 3);
-
- // make sure directory exists
- if (!path.toFile().exists()) {
- forceDirty = true;
- path.toFile().mkdir();
- }
- monitor.worked(1);
-
- // save files
- if (forceDirty || isServerDirty)
- serverFactory.save(path.append("server.xml").toOSString());
- monitor.worked(1);
-
- //if (forceDirty || isWebAppDirty)
- // webAppFactory.save(dirPath + "web.xml");
- //webAppDocument.save(path.toOSString(), forceDirty || isPolicyDirty);
- webAppDocument.save(path.append("web.xml").toOSString(), forceDirty);
- monitor.worked(1);
-
- if (forceDirty)
- XMLUtil.save(path.append("tomcat-users.xml").toOSString(), tomcatUsersDocument);
- monitor.worked(1);
-
- if (forceDirty || isPolicyDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- isServerDirty = false;
- isPolicyDirty = false;
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v5.0 configuration to " + path, e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- public void save(IPath path, IProgressMonitor monitor) throws CoreException {
- save(path, true, monitor);
- }
-
- /**
- * Save the information held by this object to the given directory.
- *
- * @param folder a folder
- * @param monitor a progress monitor
- * @throws CoreException
- */
- public void save(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 900);
-
- // save server.xml
- byte[] data = serverFactory.getContents();
- InputStream in = new ByteArrayInputStream(data);
- IFile file = folder.getFile("server.xml");
- if (file.exists()) {
- if (isServerDirty)
- file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- monitor.worked(200);
- } else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save web.xml
- webAppDocument.save(folder.getFile("web.xml"), ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save tomcat-users.xml
- data = XMLUtil.getContents(tomcatUsersDocument);
- in = new ByteArrayInputStream(data);
- file = folder.getFile("tomcat-users.xml");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save catalina.policy
- in = new ByteArrayInputStream(policyFile.getBytes());
- file = folder.getFile("catalina.policy");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v5.0 configuration to " + folder.toString(), e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- protected static boolean hasMDBListener(Server server) {
- if (server == null)
- return false;
-
- int count = server.getListenerCount();
- if (count == 0)
- return false;
-
- for (int i = 0; i < count; i++) {
- Listener listener = server.getListener(i);
- if (listener != null && listener.getClassName() != null && listener.getClassName().indexOf("mbean") >= 0)
- return true;
- }
- return false;
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addMimeMapping(int, IMimeMapping)
- */
- public void addMimeMapping(int index, IMimeMapping map) {
- webAppDocument.addMimeMapping(index, map);
- firePropertyChangeEvent(ADD_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addWebModule(int, ITomcatWebModule)
- */
- public void addWebModule(int index, ITomcatWebModule module) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- Context context = (Context) host.createElement(index, "Context");
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * Change the extension of a mime mapping.
- *
- * @param index
- * @param map
- */
- public void modifyMimeMapping(int index, IMimeMapping map) {
- webAppDocument.modifyMimeMapping(index, map);
- firePropertyChangeEvent(MODIFY_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * Modify the port with the given id.
- *
- * @param id java.lang.String
- * @param port int
- */
- public void modifyServerPort(String id, int port) {
- try {
- if ("server".equals(id)) {
- server.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- return;
- }
-
- int i = id.indexOf("/");
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- Context context = host.getContext(index);
- context.setPath(path);
- context.setDocBase(docBase);
- context.setReloadable(reloadable ? "true" : "false");
- isServerDirty = true;
- WebModule module = new WebModule(path, docBase, null, reloadable);
- firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY, new Integer(index), module);
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
- }
- }
-
- /**
- * Removes a mime mapping.
- * @param index int
- */
- public void removeMimeMapping(int index) {
- webAppDocument.removeMimeMapping(index);
- firePropertyChangeEvent(REMOVE_MAPPING_PROPERTY, null, new Integer(index));
- }
-
- /**
- * Removes a web module.
- * @param index int
- */
- public void removeWebModule(int index) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- host.removeElement("Context", index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- protected IStatus publishContextConfig(IPath baseDir, IProgressMonitor monitor) {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishConfigurationTask, 300);
-
- Trace.trace(Trace.FINER, "Apply context configurations");
- IPath confDir = baseDir.append("conf");
- IPath webappsDir = baseDir.append("webapps");
- try {
- monitor.subTask(Messages.publishContextConfigTask);
- Factory factory = new Factory();
- factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- Server publishedServer = (Server) factory.loadDocument(new FileInputStream(confDir.append("server.xml").toFile()));
- monitor.worked(100);
-
- boolean modified = false;
-
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, Messages.publishContextConfigTask, null);
- int size = publishedServer.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = publishedServer.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- Context context = host.getContext(j);
- monitor.subTask(NLS.bind(Messages.checkingContextTask,
- new String[] {context.getPath()}));
- if (addContextConfig(webappsDir, context, ms)) {
- modified = true;
- }
- }
- }
- }
- monitor.worked(100);
- if (modified) {
- monitor.subTask(Messages.savingContextConfigTask);
- factory.save(confDir.append("server.xml").toOSString());
- }
- monitor.done();
-
- // If problem(s) occurred adding context configurations, return error status
- if (ms.getChildren().length > 0) {
- return ms;
- }
- Trace.trace(Trace.FINER, "Server.xml updated with context.xml configurations");
- return Status.OK_STATUS;
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not apply context configurations to published Tomcat v5.0 configuration from " + confDir.toOSString() + ": " + e.getMessage());
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- }
- }
-
- /**
- * If the specified Context is linked to a project, try to
- * update it with any configuration from a META-INF/context.xml found
- * relative to the specified web applications directory and context docBase.
- * @param webappsDir Path to server's web applications directory.
- * @param context Context object to receive context.xml contents.
- * @param ms MultiStatus object to receive error status.
- * @return Returns true if context is modified.
- */
- protected boolean addContextConfig(IPath webappsDir, Context context, MultiStatus ms) {
- boolean modified = false;
- String source = context.getSource();
- if (source != null && source.length() > 0 )
- {
- String docBase = context.getDocBase();
- try {
- Context contextConfig = loadContextConfig(webappsDir.append(docBase));
- if (null != contextConfig) {
- if (context.hasChildNodes())
- context.removeChildren();
- contextConfig.copyChildrenTo(context);
- Map attrs = contextConfig.getAttributes();
- Iterator iter = attrs.keySet().iterator();
- while (iter.hasNext()) {
- String name = (String) iter.next();
- if (!name.equalsIgnoreCase("path")
- && !name.equalsIgnoreCase("docBase")
- && !name.equalsIgnoreCase("source")) {
- String value = (String)attrs.get(name);
- context.setAttributeValue(name, value);
- }
- }
- modified = true;
- }
- } catch (Exception e) {
- String contextPath = context.getPath();
- if (contextPath.startsWith("/")) {
- contextPath = contextPath.substring(1);
- }
- Trace.trace(Trace.SEVERE, "Error reading context.xml file for " + contextPath, e);
- IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorCouldNotLoadContextXml, contextPath), e);
- ms.add(s);
- }
- }
- return modified;
- }
-
- /**
- * Tries to read a META-INF/context.xml file relative to the
- * specified web application path. If found, it creates a Context object
- * containing the contexts of that file.
- * @param webappDir Path to the web application
- * @return Context element created from context.xml, or null if not found.
- * @throws SAXException If there is a error parsing the XML.
- * @throws IOException If there is an error reading the file.
- */
- protected Context loadContextConfig(IPath webappDir) throws IOException, SAXException {
- File contextXML = new File(webappDir.toOSString()+ File.separator + "META-INF" + File.separator + "context.xml");
- if (contextXML.exists()) {
- try {
- InputStream is = new FileInputStream(contextXML);
- Factory ctxFactory = new Factory();
- ctxFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- Context ctx = (Context)ctxFactory.loadDocument(is);
- is.close();
- return ctx;
- } catch (FileNotFoundException e) {
- // Ignore, should never occur
- }
- }
- return null;
- }
-
- protected IStatus cleanupServer(IPath confDir, IPath installDir, IProgressMonitor monitor) {
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, Messages.cleanupServerTask, null);
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.cleanupServerTask, 200);
-
- try {
- monitor.subTask(Messages.detectingRemovedProjects);
-
- // Try to read old server configuration
- Factory factory = new Factory();
- factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- File serverFile = confDir.append("conf").append("server.xml").toFile();
- if (serverFile.exists()) {
- Server oldServer = (Server) factory.loadDocument(new FileInputStream(serverFile));
-
- // Begin building path to context directory
- IPath contextDir = confDir.append("conf");
-
- // Collect paths of old web modules managed by WTP
- Set oldPaths = new HashSet();
- int size = oldServer.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = oldServer.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- // Finish path to context directory
- contextDir = contextDir.append(engine.getName()).append(host.getName());
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- Context context = host.getContext(j);
- String source = context.getSource();
- if (source != null && source.length() > 0 ) {
- oldPaths.add(context.getPath());
- }
- }
- }
- }
-
- // Remove paths for web modules that are staying around
- List modules = getWebModules();
- size = modules.size();
- for (int i = 0; i < size; i++) {
- WebModule module = (WebModule) modules.get(i);
- oldPaths.remove(module.getPath());
- }
- monitor.worked(100);
-
- // Delete context files for managed web modules that have gone away
- if (oldPaths.size() > 0 ) {
- IProgressMonitor subMonitor = ProgressUtil.getSubMonitorFor(monitor, 100);
- subMonitor.beginTask(Messages.deletingContextFilesTask, oldPaths.size() * 100);
-
- Iterator iter = oldPaths.iterator();
- while (iter.hasNext()) {
- // Derive the context file name from the path + ".xml", minus the leading '/'
- String fileName = (String)iter.next();
- if (fileName.length() > 0)
- fileName = fileName.substring(1) + ".xml";
- else
- fileName = "ROOT.xml";
- IPath contextPath = contextDir.append(fileName);
- File contextFile = contextPath.toFile();
- if (contextFile.exists()) {
- subMonitor.subTask(NLS.bind(Messages.deletingContextFile, fileName));
- if (contextFile.delete()) {
- Trace.trace(Trace.FINER, "Leftover context file " + fileName + " deleted.");
- ms.add(new Status(IStatus.OK, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.deletedContextFile, fileName), null));
- } else {
- Trace.trace(Trace.SEVERE, "Could not delete obsolete context file " + contextPath.toOSString());
- ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorCouldNotDeleteContextFile, contextPath.toOSString()), null));
- }
- subMonitor.worked(100);
- }
- }
- subMonitor.done();
- } else {
- monitor.worked(100);
- }
- }
- // Else no server.xml. Assume first publish to new temp directory
- else {
- monitor.worked(200);
- }
- Trace.trace(Trace.FINER, "Server cleaned");
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not cleanup server at " + confDir.toOSString() + ": " + e.getMessage());
- ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorCleanupServer, new String[] {e.getLocalizedMessage()}), e));
- }
-
- monitor.done();
- return ms;
- }
-
- protected IStatus prepareRuntimeDirectory(IPath confDir) {
- Trace.trace(Trace.FINER, "Preparing runtime directory");
- // Prepare a catalina.base directory structure
- File temp = confDir.append("conf").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("logs").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("temp").toFile();
- if (!temp.exists())
- temp.mkdirs();
- IPath tempPath = confDir.append("webapps/ROOT/WEB-INF");
- temp = tempPath.toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = tempPath.append("web.xml").toFile();
- if (!temp.exists()) {
- FileWriter fw;
- try {
- fw = new FileWriter(temp);
- fw.write(DEFAULT_WEBXML_SERVLET24);
- fw.close();
- } catch (IOException e) {
- Trace.trace(Trace.WARNING, "Unable to create web.xml for ROOT context.", e);
- }
- }
- temp = confDir.append("work").toFile();
- if (!temp.exists())
- temp.mkdirs();
-
- return Status.OK_STATUS;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Handler.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Handler.java
deleted file mode 100644
index b0ef35e81..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Handler.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IModule;
-/**
- * Tomcat 50 handler.
- */
-public class Tomcat50Handler implements ITomcatVersionHandler {
- /**
- * @see ITomcatVersionHandler#verifyInstallPath(IPath)
- */
- public boolean verifyInstallPath(IPath installPath) {
- if (installPath == null)
- return false;
-
-if (!TomcatPlugin.verifyTomcatVersionFromPath(installPath, TomcatPlugin.TOMCAT_50))
- return false;
- return TomcatPlugin.verifyInstallPath(installPath, TomcatPlugin.TOMCAT_50);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.catalina.startup.Bootstrap";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath)
- */
- public List getRuntimeClasspath(IPath installPath) {
- List cp = new ArrayList();
-
- // 5.0 - add bootstrap.jar from the Tomcat bin directory
- IPath binPath = installPath.append("bin");
- if (binPath.toFile().exists()) {
- IPath path = binPath.append("bootstrap.jar");
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
- }
-
- return cp;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeProgramArguments(IPath, boolean, boolean)
- */
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting) {
- List list = new ArrayList();
-
- if (debug)
- list.add("-debug");
-
- if (starting)
- list.add("start");
- else
- list.add("stop");
-
- String[] temp = new String[list.size()];
- list.toArray(temp);
- return temp;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, boolean isTestEnv) {
- List list = new ArrayList();
- if (isTestEnv)
- list.add("-Dcatalina.base=\"" + configPath.toOSString() + "\"");
- else
- list.add("-Dcatalina.base=\"" + installPath.toOSString() + "\"");
- list.add("-Dcatalina.home=\"" + installPath.toOSString() + "\"");
- list.add("-Djava.endorsed.dirs=\"" + installPath.append("common").append("endorsed").toOSString() + "\"");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
- public String getRuntimePolicyFile(IPath configPath) {
- return configPath.append("conf").append("catalina.policy").toOSString();
- }
-
- /**
- * @see ITomcatVersionHandler#canAddModule(IModule)
- */
- public IStatus canAddModule(IModule module) {
- String version = module.getModuleType().getVersion();
- if ("2.2".equals(version) || "2.3".equals(version) || "2.4".equals(version))
- return Status.OK_STATUS;
-
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorSpec50, null);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeBaseDirectory(TomcatServerBehaviour)
- */
- public IPath getRuntimeBaseDirectory(TomcatServerBehaviour serverBehaviour) {
- if (serverBehaviour.getTomcatServer().isTestEnvironment())
- return serverBehaviour.getTempDirectory();
- return serverBehaviour.getServer().getRuntime().getLocation();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java
deleted file mode 100644
index 77ab8c717..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java
+++ /dev/null
@@ -1,724 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.tomcat.core.internal.xml.Factory;
-import org.eclipse.jst.server.tomcat.core.internal.xml.XMLUtil;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.*;
-import org.eclipse.osgi.util.NLS;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.eclipse.wst.server.core.ServerPort;
-/**
- * Tomcat v5.5 server configuration.
- */
-public class Tomcat55Configuration extends TomcatConfiguration {
- protected static final String DEFAULT_SERVICE = "Catalina";
- protected Server server;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
- protected boolean isPolicyDirty;
-
- /**
- * Tomcat55Configuration constructor.
- *
- * @param path a path
- */
- public Tomcat55Configuration(IFolder path) {
- super(path);
- }
-
- /**
- * Return the port number.
- * @return int
- */
- public ServerPort getMainPort() {
- Iterator iterator = getServerPorts().iterator();
- while (iterator.hasNext()) {
- ServerPort port = (ServerPort) iterator.next();
- if (port.getName().equals("HTTP"))
- return port;
- }
- return null;
- }
-
- /**
- * Returns the mime mappings.
- * @return java.util.List
- */
- public List getMimeMappings() {
- return webAppDocument.getMimeMappings();
- }
-
- /**
- * Returns a list of ServerPorts that this configuration uses.
- *
- * @return java.util.List
- */
- public List getServerPorts() {
- List ports = new ArrayList();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String name = "HTTP";
- String protocol2 = "TCPIP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- String protocol = connector.getProtocol();
- if (protocol != null && protocol.length() > 0) {
- name = protocol;
- protocol2 = protocol;
- }
- if ("HTTP".equals(protocol))
- contentTypes = new String[] { "web", "webservices" };
- String secure = connector.getSecure();
- if (secure != null && secure.length() > 0) {
- name = "SSL";
- protocol2 = "SSL";
- } else
- advanced = false;
- ports.add(new ServerPort(i +"/" + j, name, port, protocol2, contentTypes, advanced));
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting server ports", e);
- }
- return ports;
- }
-
- /**
- * Return a list of the web modules in this server.
- * @return java.util.List
- */
- public List getWebModules() {
- List list = new ArrayList();
-
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- Context context = host.getContext(j);
- String reload = context.getReloadable();
- if (reload == null)
- reload = "false";
- WebModule module = new WebModule(context.getPath(),
- context.getDocBase(), context.getSource(),
- reload.equalsIgnoreCase("true") ? true : false);
- list.add(module);
- }
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting project refs", e);
- }
- return list;
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 5);
-
- // check for catalina.policy to verify that this is a v5.5 config
- InputStream in = new FileInputStream(path.append("catalina.policy").toFile());
- in.read();
- in.close();
- monitor.worked(1);
-
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- server = (Server) serverFactory.loadDocument(new FileInputStream(path.append("server.xml").toFile()));
- monitor.worked(1);
-
- webAppDocument = new WebAppDocument(path.append("web.xml"));
- monitor.worked(1);
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
- monitor.worked(1);
-
- // load policy file
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(new FileInputStream(path.append("catalina.policy").toFile())));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(1);
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load Tomcat v5.5 configuration from " + path.toOSString() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, path.toOSString()), e));
- }
- }
-
- public void importFromPath(IPath path, boolean isTestEnv, IProgressMonitor monitor) throws CoreException {
- load(path, monitor);
-
- // for test environment, remove existing contexts since a separate
- // catalina.base will be used
- if (isTestEnv) {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Host host = service.getEngine().getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- host.removeElement("Context", 0);
- }
- }
- }
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 800);
-
- // check for catalina.policy to verify that this is a v4.0 config
- IFile file = folder.getFile("catalina.policy");
- if (!file.exists())
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), null));
-
- // load server.xml
- file = folder.getFile("server.xml");
- InputStream in = file.getContents();
- serverFactory = new Factory();
- serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- server = (Server) serverFactory.loadDocument(in);
- monitor.worked(200);
-
- // load web.xml
- file = folder.getFile("web.xml");
- webAppDocument = new WebAppDocument(file);
- monitor.worked(200);
-
- // load tomcat-users.xml
- file = folder.getFile("tomcat-users.xml");
- in = file.getContents();
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- monitor.worked(200);
-
- // load catalina.policy
- file = folder.getFile("catalina.policy");
- in = file.getContents();
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(in));
- String temp = br.readLine();
- policyFile = "";
- while (temp != null) {
- policyFile += temp + "\n";
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load policy file", e);
- } finally {
- if (br != null)
- br.close();
- }
- monitor.worked(200);
-
- if (monitor.isCanceled())
- throw new Exception("Cancelled");
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not reload Tomcat v5.5 configuration from: " + folder.getFullPath() + ": " + e.getMessage());
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, folder.getFullPath().toOSString()), e));
- }
- }
-
- /**
- * Save to the given directory.
- * @param path a path
- * @param forceDirty boolean
- * @param monitor a progress monitor
- * @exception CoreException
- */
- protected void save(IPath path, boolean forceDirty, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 3);
-
- // make sure directory exists
- if (!path.toFile().exists()) {
- forceDirty = true;
- path.toFile().mkdir();
- }
- monitor.worked(1);
-
- // save files
- if (forceDirty || isServerDirty)
- serverFactory.save(path.append("server.xml").toOSString());
- monitor.worked(1);
-
- //if (forceDirty || isWebAppDirty)
- // webAppFactory.save(dirPath + "web.xml");
- //webAppDocument.save(path.toOSString(), forceDirty || isPolicyDirty);
- webAppDocument.save(path.append("web.xml").toOSString(), forceDirty);
- monitor.worked(1);
-
- if (forceDirty)
- XMLUtil.save(path.append("tomcat-users.xml").toOSString(), tomcatUsersDocument);
- monitor.worked(1);
-
- if (forceDirty || isPolicyDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- isServerDirty = false;
- isPolicyDirty = false;
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v5.5 configuration to " + path, e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- public void save(IPath path, IProgressMonitor monitor) throws CoreException {
- save(path, true, monitor);
- }
-
- /**
- * Save the information held by this object to the given directory.
- *
- * @param folder a folder
- * @param monitor a progress monitor
- * @throws CoreException
- */
- public void save(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.savingTask, 900);
-
- // save server.xml
- byte[] data = serverFactory.getContents();
- InputStream in = new ByteArrayInputStream(data);
- IFile file = folder.getFile("server.xml");
- if (file.exists()) {
- if (isServerDirty)
- file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- monitor.worked(200);
- } else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save web.xml
- webAppDocument.save(folder.getFile("web.xml"), ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save tomcat-users.xml
- data = XMLUtil.getContents(tomcatUsersDocument);
- in = new ByteArrayInputStream(data);
- file = folder.getFile("tomcat-users.xml");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save catalina.policy
- in = new ByteArrayInputStream(policyFile.getBytes());
- file = folder.getFile("catalina.policy");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
-
- if (monitor.isCanceled())
- return;
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save Tomcat v5.5 configuration to " + folder.toString(), e);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotSaveConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
-
- protected static boolean hasMDBListener(Server server) {
- if (server == null)
- return false;
-
- int count = server.getListenerCount();
- if (count == 0)
- return false;
-
- for (int i = 0; i < count; i++) {
- Listener listener = server.getListener(i);
- if (listener != null && listener.getClassName() != null && listener.getClassName().indexOf("mbean") >= 0)
- return true;
- }
- return false;
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addMimeMapping(int, IMimeMapping)
- */
- public void addMimeMapping(int index, IMimeMapping map) {
- webAppDocument.addMimeMapping(index, map);
- firePropertyChangeEvent(ADD_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addWebModule(int, ITomcatWebModule)
- */
- public void addWebModule(int index, ITomcatWebModule module) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- Context context = (Context) host.createElement(index, "Context");
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * Change the extension of a mime mapping.
- *
- * @param index
- * @param map
- */
- public void modifyMimeMapping(int index, IMimeMapping map) {
- webAppDocument.modifyMimeMapping(index, map);
- firePropertyChangeEvent(MODIFY_MAPPING_PROPERTY, new Integer(index), map);
- }
-
- /**
- * Modify the port with the given id.
- *
- * @param id java.lang.String
- * @param port int
- */
- public void modifyServerPort(String id, int port) {
- try {
- if ("server".equals(id)) {
- server.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- return;
- }
-
- int i = id.indexOf("/");
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- Context context = host.getContext(index);
- context.setPath(path);
- context.setDocBase(docBase);
- context.setReloadable(reloadable ? "true" : "false");
- isServerDirty = true;
- WebModule module = new WebModule(path, docBase, null, reloadable);
- firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY, new Integer(index), module);
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
- }
- }
-
- /**
- * Removes a mime mapping.
- * @param index int
- */
- public void removeMimeMapping(int index) {
- webAppDocument.removeMimeMapping(index);
- firePropertyChangeEvent(REMOVE_MAPPING_PROPERTY, null, new Integer(index));
- }
-
- /**
- * Removes a web module.
- * @param index int
- */
- public void removeWebModule(int index) {
- try {
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- host.removeElement("Context", index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- return;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- protected IStatus publishContextConfig(IPath baseDir, IProgressMonitor monitor) {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishConfigurationTask, 300);
-
- Trace.trace(Trace.FINER, "Apply context configurations");
- IPath confDir = baseDir.append("conf");
- IPath webappsDir = baseDir.append("webapps");
- try {
- monitor.subTask(Messages.publishContextConfigTask);
- Factory factory = new Factory();
- factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- Server publishedServer = (Server) factory.loadDocument(new FileInputStream(confDir.append("server.xml").toFile()));
- monitor.worked(100);
-
- boolean modified = false;
-
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, Messages.publishContextConfigTask, null);
- int size = publishedServer.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = publishedServer.getService(i);
- if (service.getName().equalsIgnoreCase(DEFAULT_SERVICE)) {
- Engine engine = service.getEngine();
- Host host = engine.getHost();
- int size2 = host.getContextCount();
- for (int j = 0; j < size2; j++) {
- Context context = host.getContext(j);
- monitor.subTask(NLS.bind(Messages.checkingContextTask,
- new String[] {context.getPath()}));
- if (addContextConfig(webappsDir, context, ms)) {
- modified = true;
- }
- }
- }
- }
- monitor.worked(100);
- if (modified) {
- monitor.subTask(Messages.savingContextConfigTask);
- factory.save(confDir.append("server.xml").toOSString());
- }
- monitor.done();
-
- // If problem(s) occurred adding context configurations, return error status
- if (ms.getChildren().length > 0) {
- return ms;
- }
- Trace.trace(Trace.FINER, "Server.xml updated with context.xml configurations");
- return Status.OK_STATUS;
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not apply context configurations to published Tomcat v5.5 configuration from " + confDir.toOSString() + ": " + e.getMessage());
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- }
- }
-
- /**
- * If the specified Context is linked to a project, try to
- * update it with any configuration from a META-INF/context.xml found
- * relative to the specified web applications directory and context docBase.
- * @param webappsDir Path to server's web applications directory.
- * @param context Context object to receive context.xml contents.
- * @param ms MultiStatus object to receive error status.
- * @return Returns true if context is modified.
- */
- protected boolean addContextConfig(IPath webappsDir, Context context, MultiStatus ms) {
- boolean modified = false;
- String source = context.getSource();
- if (source != null && source.length() > 0 )
- {
- String docBase = context.getDocBase();
- try {
- Context contextConfig = loadContextConfig(webappsDir.append(docBase));
- if (null != contextConfig) {
- if (context.hasChildNodes())
- context.removeChildren();
- contextConfig.copyChildrenTo(context);
- Map attrs = contextConfig.getAttributes();
- Iterator iter = attrs.keySet().iterator();
- while (iter.hasNext()) {
- String name = (String) iter.next();
- if (!name.equalsIgnoreCase("path")
- && !name.equalsIgnoreCase("docBase")
- && !name.equalsIgnoreCase("source")) {
- String value = (String)attrs.get(name);
- context.setAttributeValue(name, value);
- }
- }
- modified = true;
- }
- } catch (Exception e) {
- String contextPath = context.getPath();
- if (contextPath.startsWith("/")) {
- contextPath = contextPath.substring(1);
- }
- Trace.trace(Trace.SEVERE, "Error reading context.xml file for " + contextPath, e);
- IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorCouldNotLoadContextXml, contextPath), e);
- ms.add(s);
- }
- }
- return modified;
- }
-
- /**
- * Tries to read a META-INF/context.xml file relative to the
- * specified web application path. If found, it creates a Context object
- * containing the contexts of that file.
- * @param webappDir Path to the web application
- * @return Context element created from context.xml, or null if not found.
- * @throws SAXException If there is a error parsing the XML.
- * @throws IOException If there is an error reading the file.
- */
- protected Context loadContextConfig(IPath webappDir) throws IOException, SAXException {
- File contextXML = new File(webappDir.toOSString()+ File.separator + "META-INF" + File.separator + "context.xml");
- if (contextXML.exists()) {
- try {
- InputStream is = new FileInputStream(contextXML);
- Factory ctxFactory = new Factory();
- ctxFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- Context ctx = (Context)ctxFactory.loadDocument(is);
- is.close();
- return ctx;
- } catch (FileNotFoundException e) {
- // Ignore, should never occur
- }
- }
- return null;
- }
-
- protected IStatus prepareRuntimeDirectory(IPath confDir) {
- Trace.trace(Trace.FINER, "Preparing runtime directory");
- // Prepare a catalina.base directory structure
- File temp = confDir.append("conf").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("logs").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("temp").toFile();
- if (!temp.exists())
- temp.mkdirs();
- IPath tempPath = confDir.append("webapps/ROOT/WEB-INF");
- temp = tempPath.toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = tempPath.append("web.xml").toFile();
- if (!temp.exists()) {
- FileWriter fw;
- try {
- fw = new FileWriter(temp);
- fw.write(DEFAULT_WEBXML_SERVLET24);
- fw.close();
- } catch (IOException e) {
- Trace.trace(Trace.WARNING, "Unable to create web.xml for ROOT context.", e);
- }
- }
- temp = confDir.append("work").toFile();
- if (!temp.exists())
- temp.mkdirs();
-
- return Status.OK_STATUS;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Handler.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Handler.java
deleted file mode 100644
index 0f1b8f203..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Handler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-/**
- * Tomcat 55 handler.
- */
-public class Tomcat55Handler extends Tomcat50Handler {
- /**
- * @see ITomcatVersionHandler#verifyInstallPath(IPath)
- */
- public boolean verifyInstallPath(IPath installPath) {
- if (installPath == null)
- return false;
-
- if (!TomcatPlugin.verifyTomcatVersionFromPath(installPath, TomcatPlugin.TOMCAT_55))
- return false;
- return TomcatPlugin.verifyInstallPath(installPath, TomcatPlugin.TOMCAT_55);
- }
-
- /**
- * @see ITomcatVersionHandler#canAddModule(IModule)
- */
- public IStatus canAddModule(IModule module) {
- String version = module.getModuleType().getVersion();
- if ("2.2".equals(version) || "2.3".equals(version) || "2.4".equals(version))
- return Status.OK_STATUS;
-
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorSpec55, null);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java
deleted file mode 100644
index 3fce997af..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.osgi.util.NLS;
-
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.ServerPort;
-/**
- * Generic Tomcat server configuration.
- */
-public abstract class TomcatConfiguration implements ITomcatConfiguration, ITomcatConfigurationWorkingCopy {
- public static final String NAME_PROPERTY = "name";
- public static final String PORT_PROPERTY = "port";
- public static final String MODIFY_PORT_PROPERTY = "modifyPort";
- public static final String ADD_MAPPING_PROPERTY = "addMapping";
- public static final String REMOVE_MAPPING_PROPERTY = "removeMapping";
- public static final String MODIFY_MAPPING_PROPERTY = "modifyMapping";
-
- public static final String MODIFY_WEB_MODULE_PROPERTY = "modifyWebModule";
- public static final String ADD_WEB_MODULE_PROPERTY = "addWebModule";
- public static final String REMOVE_WEB_MODULE_PROPERTY = "removeWebModule";
-
- public static final String DEFAULT_WEBXML_SERVLET23 =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<!DOCTYPE web-app PUBLIC \"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN\" \"http://java.sun.com/dtd/web-app_2_3.dtd\">\n" +
- "<web-app>\n</web-app>";
-
- public static final String DEFAULT_WEBXML_SERVLET24 =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<web-app id=\"WebApp_ID\" version=\"2.4\" xmlns=\"http://java.sun.com/xml/ns/j2ee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\">\n" +
- "</web-app>";
-
- protected IFolder configPath;
-
- // property change listeners
- private transient List propertyListeners;
-
- /**
- * TomcatConfiguration constructor.
- *
- * @param path a path
- */
- public TomcatConfiguration(IFolder path) {
- super();
- this.configPath = path;
- /*try {
- load(configPath, new NullProgressMonitor());
- } catch (Exception e) {
- // ignore
- }*/
- }
-
- protected IFolder getFolder() {
- return configPath;
- }
-
- /**
- * Copies all files from the given directory in the workbench
- * to the given location. Can be overridden by version specific
- * class to modify or enhance what publish does.
- *
- * @param tomcatDir Destination tomcat directory. Equivalent to catalina.base
- * for Tomcat 4.x and up.
- * @param doBackup Backup existing configuration files (true if not test mode).
- * @param monitor Progress monitor to use
- * @return org.eclipse.core.runtime.IStatus
- */
- protected IStatus backupAndPublish(IPath tomcatDir, boolean doBackup, IProgressMonitor monitor) {
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, Messages.publishConfigurationTask, null);
- Trace.trace(Trace.FINER, "Backup and publish");
- monitor = ProgressUtil.getMonitorFor(monitor);
-
- try {
- IPath backup = null;
- if (doBackup) {
- // create backup directory
- backup = tomcatDir.append("backup");
- if (!backup.toFile().exists())
- backup.toFile().mkdir();
- }
- backupFolder(getFolder(), tomcatDir.append("conf"), backup, ms, monitor);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
- IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- ms.add(s);
- }
-
- monitor.done();
- return ms;
- }
-
- protected void backupFolder(IFolder folder, IPath confDir, IPath backup, MultiStatus ms, IProgressMonitor monitor) throws CoreException {
- IResource[] children = folder.members();
- if (children == null)
- return;
-
- int size = children.length;
- monitor.beginTask(Messages.publishConfigurationTask, size * 100);
- for (int i = 0; i < size; i++) {
- if (children[i] instanceof IFile) {
- try {
- IFile file = (IFile) children[i];
- String name = file.getName();
- monitor.subTask(NLS.bind(Messages.publisherPublishTask, new String[] {name}));
- Trace.trace(Trace.FINEST, "Publishing " + name);
-
- // backup and copy file
- boolean copy = true;
- if (backup != null && !(backup.append(name).toFile().exists())) {
- IStatus status = FileUtil.copyFile(confDir.append(name).toOSString(), backup + File.separator + name);
- ms.add(status);
- if (!status.isOK())
- copy = false;
- }
-
- if (copy) {
- InputStream in = file.getContents();
- ms.add(FileUtil.copyFile(in, confDir.append(name).toOSString()));
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
- ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- }
- monitor.worked(100);
- }
- }
-
- protected void backupPath(IPath path, IPath confDir, IPath backup, MultiStatus ms, IProgressMonitor monitor) {
- File[] files = path.toFile().listFiles();
- if (files == null)
- return;
-
- int size = files.length;
- monitor.beginTask(Messages.publishConfigurationTask, size * 100);
- for (int i = 0; i < size; i++) {
- try {
- File file = files[i];
- String name = file.getName();
- monitor.subTask(NLS.bind(Messages.publisherPublishTask, new String[] {name}));
- Trace.trace(Trace.FINEST, "Publishing " + name);
-
- // backup and copy file
- boolean copy = true;
- if (backup != null && !(backup.append(name).toFile().exists())) {
- IStatus status = FileUtil.copyFile(confDir.append(name).toOSString(), backup + File.separator + name);
- ms.add(status);
- if (!status.isOK())
- copy = false;
- }
-
- if (copy)
- ms.add(FileUtil.copyFile(file.getAbsolutePath(), confDir.append(name).toOSString()));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
- ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e));
- }
- monitor.worked(100);
- }
- }
-
- protected IStatus publishContextConfig(IPath baseDir, IProgressMonitor monitor) {
- // Default implementation assumes nothing to do
- return Status.OK_STATUS;
- }
-
-
- protected IStatus cleanupServer(IPath confDir, IPath installDir, IProgressMonitor monitor) {
- // Default implementation assumes nothing to clean
- return Status.OK_STATUS;
- }
-
- protected IStatus prepareRuntimeDirectory(IPath confDir) {
- File temp = confDir.append("conf").toFile();
- if (!temp.exists())
- temp.mkdirs();
-
- return Status.OK_STATUS;
- }
-
- public void localizeConfiguration(IPath path, TomcatServer server, IProgressMonitor monitor) {
- // do nothing
- }
-
- /**
- * Returns the main server port.
- * @return ServerPort
- */
- public abstract ServerPort getMainPort();
-
- /**
- * Returns the prefix that is used in front of the
- * web module path property. (e.g. "webapps")
- *
- * @return java.lang.String
- */
- public String getDocBasePrefix() {
- return "";
- }
-
- /**
- * Returns the partial URL applicable to this module.
- *
- * @param webModule a web module
- * @return the partial URL
- */
- protected String getWebModuleURL(IModule webModule) {
- WebModule module = getWebModule(webModule);
- if (module != null)
- return module.getPath();
-
- IWebModule webModule2 = (IWebModule) webModule.loadAdapter(IWebModule.class, null);
- return "/" + webModule2.getContextRoot();
- }
-
- /**
- * Returns the given module from the config.
- *
- * @param module a web module
- * @return a web module
- */
- protected WebModule getWebModule(IModule module) {
- if (module == null)
- return null;
-
- String memento = module.getId();
-
- List modules = getWebModules();
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- WebModule webModule = (WebModule) modules.get(i);
- if (memento.equals(webModule.getMemento())) {
- return webModule;
- }
- }
- return null;
- }
-
- protected abstract void save(IFolder folder, IProgressMonitor monitor) throws CoreException;
-
- protected void firePropertyChangeEvent(String propertyName, Object oldValue, Object newValue) {
- if (propertyListeners == null)
- return;
-
- PropertyChangeEvent event = new PropertyChangeEvent(this, propertyName, oldValue, newValue);
- try {
- Iterator iterator = propertyListeners.iterator();
- while (iterator.hasNext()) {
- try {
- PropertyChangeListener listener = (PropertyChangeListener) iterator.next();
- listener.propertyChange(event);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error firing property change event", e);
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error in property event", e);
- }
- }
-
- /**
- * Adds a property change listener to this server.
- *
- * @param listener java.beans.PropertyChangeListener
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- if (propertyListeners == null)
- propertyListeners = new ArrayList();
- propertyListeners.add(listener);
- }
-
- /**
- * Removes a property change listener from this server.
- *
- * @param listener java.beans.PropertyChangeListener
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- if (propertyListeners != null)
- propertyListeners.remove(listener);
- }
-
- public void importFromPath(IPath path, boolean isTestEnv, IProgressMonitor monitor) throws CoreException {
- load(path, monitor);
- }
-
- /*public void importFromRuntime(IRuntime runtime, IProgressMonitor monitor) throws CoreException {
- load(runtime.getLocation().append("conf"), monitor);
- }*/
-
- protected abstract void load(IPath path, IProgressMonitor monitor) throws CoreException;
-
- protected abstract void load(IFolder folder, IProgressMonitor monitor) throws CoreException;
-
- public abstract void addWebModule(int index, ITomcatWebModule module);
-
- public abstract void removeWebModule(int index);
-
- /**
- * Return a string representation of this object.
- * @return java.lang.String
- */
- public String toString() {
- return "TomcatConfiguration[" + this + "]";
- }
-} \ 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
deleted file mode 100644
index 43e26db4d..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchConfigurationDelegate.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.File;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.jdt.launching.*;
-
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerUtil;
-/**
- *
- */
-public class TomcatLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate {
-
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
- if (server == null) {
- Trace.trace(Trace.FINEST, "Launch configuration could not find server");
- // throw CoreException();
- return;
- }
-
- TomcatServerBehaviour tomcatServer = (TomcatServerBehaviour) server.loadAdapter(TomcatServerBehaviour.class, null);
- tomcatServer.setupLaunch(launch, mode, monitor);
-
- String mainTypeName = tomcatServer.getRuntimeClass();
-
- IVMInstall vm = verifyVMInstall(configuration);
-
- IVMRunner runner = vm.getVMRunner(mode);
-
- File workingDir = verifyWorkingDirectory(configuration);
- String workingDirName = null;
- if (workingDir != null)
- workingDirName = workingDir.getAbsolutePath();
-
- // Program & VM args
- String pgmArgs = getProgramArguments(configuration);
- String vmArgs = getVMArguments(configuration);
-
- ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
-
- // VM-specific attributes
- Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
-
- // Classpath
- String[] classpath = getClasspath(configuration);
-
- // Create VM config
- VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
- runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
- runConfig.setVMArguments(execArgs.getVMArgumentsArray());
- runConfig.setWorkingDirectory(workingDirName);
- runConfig.setVMSpecificAttributesMap(vmAttributesMap);
-
- // Bootpath
- String[] bootpath = getBootpath(configuration);
- if (bootpath != null && bootpath.length > 0)
- runConfig.setBootClassPath(bootpath);
-
- setDefaultSourceLocator(launch, configuration);
-
- // Launch the configuration
- runner.run(runConfig, launch, monitor);
- tomcatServer.setProcess(launch.getProcesses()[0]);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchableAdapterDelegate.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchableAdapterDelegate.java
deleted file mode 100644
index dbcb3841d..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchableAdapterDelegate.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.net.URL;
-
-import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.jst.server.core.Servlet;
-import org.eclipse.wst.server.core.IModuleArtifact;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.*;
-import org.eclipse.wst.server.core.util.HttpLaunchable;
-import org.eclipse.wst.server.core.util.WebResource;
-/**
- * Launchable adapter delegate for Web resources in Tomcat.
- */
-public class TomcatLaunchableAdapterDelegate extends LaunchableAdapterDelegate {
- /*
- * @see LaunchableAdapterDelegate#getLaunchable(IServer, IModuleArtifact)
- */
- public Object getLaunchable(IServer server, IModuleArtifact moduleObject) {
- Trace.trace(Trace.FINER, "TomcatLaunchableAdapter " + server + "-" + moduleObject);
- if (server.getAdapter(TomcatServer.class) == null)
- return null;
- if (!(moduleObject instanceof Servlet) &&
- !(moduleObject instanceof WebResource))
- return null;
- if (moduleObject.getModule().loadAdapter(IWebModule.class, null) == null)
- return null;
-
- try {
- URL url = ((IURLProvider) server.getAdapter(IURLProvider.class)).getModuleRootURL(moduleObject.getModule());
-
- Trace.trace(Trace.FINER, "root: " + url);
-
- if (moduleObject instanceof Servlet) {
- Servlet servlet = (Servlet) moduleObject;
- if (servlet.getAlias() != null) {
- String path = servlet.getAlias();
- if (path.startsWith("/"))
- path = path.substring(1);
- url = new URL(url, path);
- } else
- url = new URL(url, "servlet/" + servlet.getServletClassName());
- } else if (moduleObject instanceof WebResource) {
- WebResource resource = (WebResource) moduleObject;
- String path = resource.getPath().toString();
- Trace.trace(Trace.FINER, "path: " + path);
- if (path != null && path.startsWith("/") && path.length() > 0)
- path = path.substring(1);
- if (path != null && path.length() > 0)
- url = new URL(url, path);
- }
- return new HttpLaunchable(url);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting URL for " + moduleObject, e);
- return null;
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPlugin.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPlugin.java
deleted file mode 100644
index d2fb8fb28..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPlugin.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-/**
- * The Tomcat plugin.
- */
-public class TomcatPlugin extends Plugin {
- protected static TomcatPlugin singleton;
-
- public static final String PLUGIN_ID = "org.eclipse.jst.server.tomcat.core";
-
- public static final String TOMCAT_32 = "org.eclipse.jst.server.tomcat.32";
- public static final String TOMCAT_40 = "org.eclipse.jst.server.tomcat.40";
- public static final String TOMCAT_41 = "org.eclipse.jst.server.tomcat.41";
- public static final String TOMCAT_50 = "org.eclipse.jst.server.tomcat.50";
- public static final String TOMCAT_55 = "org.eclipse.jst.server.tomcat.55";
-
- protected static final String VERIFY_INSTALL_FILE = "verifyInstall.properties";
- protected static String[] verify32;
- protected static String[] verify40;
- protected static String[] verify41;
- protected static String[] verify50;
- protected static String[] verify55;
-
- /**
- * TomcatPlugin constructor comment.
- */
- public TomcatPlugin() {
- super();
- singleton = this;
- }
-
- /**
- * Returns the singleton instance of this plugin.
- * @return org.eclipse.jst.server.tomcat.internal.TomcatPlugin
- */
- public static TomcatPlugin getInstance() {
- return singleton;
- }
-
- /**
- * Return the install location preference.
- *
- * @param id a runtime type id
- * @return the install location
- */
- public static String getPreference(String id) {
- return getInstance().getPluginPreferences().getString(id);
- }
-
- /**
- * Set the install location preference.
- *
- * @param id the runtimt type id
- * @param value the location
- */
- public static void setPreference(String id, String value) {
- getInstance().getPluginPreferences().setValue(id, value);
- getInstance().savePluginPreferences();
- }
-
- /**
- * Convenience method for logging.
- *
- * @param status a status object
- */
- public static void log(IStatus status) {
- getInstance().getLog().log(status);
- }
-
- /**
- * Returns the Tomcat home directory.
- * @return java.lang.String
- */
- protected static String getTomcatStateLocation() {
- try {
- return getInstance().getStateLocation().toOSString();
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * Return the Tomcat version handler.
- *
- * @param id
- * @return a version handler
- */
- public static ITomcatVersionHandler getTomcatVersionHandler(String id) {
- if (id.indexOf("runtime") > 0)
- id = id.substring(0, 30) + id.substring(38);
- //id = id.substring(0, id.length() - 8);
- if (TOMCAT_32.equals(id))
- return new Tomcat32Handler();
- else if (TOMCAT_40.equals(id))
- return new Tomcat40Handler();
- else if (TOMCAT_41.equals(id))
- return new Tomcat41Handler();
- else if (TOMCAT_50.equals(id))
- return new Tomcat50Handler();
- else if (TOMCAT_55.equals(id))
- return new Tomcat55Handler();
- else
- return null;
- }
-
- /**
- * Loads the files to verify the Tomcat installation.
- */
- public static void loadVerifyFiles() {
- if (verify32 != null)
- return;
-
- // backup (empty) values
- verify32 = new String[0];
- verify40 = new String[0];
- verify41 = new String[0];
- verify50 = new String[0];
- verify55 = new String[0];
-
- try {
- URL url = getInstance().getBundle().getEntry(VERIFY_INSTALL_FILE);
- url = Platform.resolve(url);
- Properties p = new Properties();
- p.load(url.openStream());
-
- String verify = p.getProperty("verify32install");
- verify.replace('/', File.separatorChar);
-
- StringTokenizer st = new StringTokenizer(verify, ",");
- List list = new ArrayList();
- while (st.hasMoreTokens())
- list.add(st.nextToken());
- Trace.trace(Trace.FINEST, "Verify32: " + list.toString());
- verify32 = new String[list.size()];
- list.toArray(verify32);
-
- // v4.0
- verify = p.getProperty("verify40install");
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList();
- while (st.hasMoreTokens())
- list.add(st.nextToken());
- Trace.trace(Trace.FINEST, "Verify40: " + list.toString());
- verify40 = new String[list.size()];
- list.toArray(verify40);
-
- // v4.1
- verify = p.getProperty("verify41install");
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList();
- while (st.hasMoreTokens())
- list.add(st.nextToken());
- Trace.trace(Trace.FINEST, "Verify41: " + list.toString());
- verify41 = new String[list.size()];
- list.toArray(verify41);
-
- // v5.0
- verify = p.getProperty("verify50install");
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList();
- while (st.hasMoreTokens())
- list.add(st.nextToken());
- Trace.trace(Trace.FINEST, "Verify50: " + list.toString());
- verify50 = new String[list.size()];
- list.toArray(verify50);
-
- // v5.5
- verify = p.getProperty("verify55install");
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList();
- while (st.hasMoreTokens())
- list.add(st.nextToken());
- Trace.trace(Trace.FINEST, "Verify55: " + list.toString());
- verify55 = new String[list.size()];
- list.toArray(verify55);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not load installation verification properties", e);
- }
- }
-
- /**
- * Verify the Tomcat installation directory.
- *
- * @param installPath
- * @param id
- * @return <code>true</code> if the directory may be a Tomcat installation,
- * and <code>false</code> otherwise
- */
- public static boolean verifyInstallPath(IPath installPath, String id) {
- if (installPath == null)
- return false;
-
- String dir = installPath.toOSString();
- if (!dir.endsWith(File.separator))
- dir += File.separator;
-
- // look for the following files and directories
- TomcatPlugin.loadVerifyFiles();
-
- String[] paths = null;
- if (TOMCAT_32.equals(id))
- paths = verify32;
- else if (TOMCAT_40.equals(id))
- paths = verify40;
- else if (TOMCAT_41.equals(id))
- paths = verify41;
- else if (TOMCAT_50.equals(id))
- paths = verify50;
- else if (TOMCAT_55.equals(id))
- paths = verify55;
- else
- return false;
-
- for (int i = 0; i < paths.length; i++) {
- File temp = new File(dir + paths[i]);
- if (!temp.exists())
- return false;
- }
- return true;
- }
-
- public static boolean verifyTomcatVersionFromPath(IPath installPath, String version) {
- if (installPath == null || version == null)
- return false;
- String s = installPath.lastSegment();
- if (s == null)
- return false;
- if (s.indexOf("-3.2") > 0 || s.indexOf(" 3.2") > 0)
- return TOMCAT_32.equals(version);
- if (s.indexOf("-4.0") > 0 || s.indexOf(" 4.0") > 0)
- return TOMCAT_40.equals(version);
- if (s.indexOf("-4.1") > 0 || s.indexOf(" 4.1") > 0)
- return TOMCAT_41.equals(version);
- if (s.indexOf("-5.0") > 0 || s.indexOf(" 5.0") > 0)
- return TOMCAT_50.equals(version);
- if (s.indexOf("-5.5") > 0 || s.indexOf(" 5.5") > 0)
- return TOMCAT_55.equals(version);
- return true;
- }
-
- /**
- * Return a <code>java.io.File</code> object that corresponds to the specified
- * <code>IPath</code> in the plugin directory.
- *
- * @return a file
- */
- protected static File getPlugin() {
- try {
- URL installURL = getInstance().getBundle().getEntry("/");
- URL localURL = Platform.asLocalURL(installURL);
- return new File(localURL.getFile());
- } catch (IOException ioe) {
- return null;
- }
- }
-
- public static void log(String message) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, null));
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java
deleted file mode 100644
index 41a3b5d95..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.Launch;
-import org.eclipse.debug.core.model.IStreamsProxy;
-import org.eclipse.jdt.launching.*;
-
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.model.RuntimeDelegate;
-/**
- *
- */
-public class TomcatRuntime extends RuntimeDelegate implements ITomcatRuntime, ITomcatRuntimeWorkingCopy {
- protected static final String PROP_VM_INSTALL_TYPE_ID = "vm-install-type-id";
- protected static final String PROP_VM_INSTALL_ID = "vm-install-id";
-
- protected static Map sdkMap = new HashMap(2);
-
- public TomcatRuntime() {
- // do nothing
- }
-
- public ITomcatVersionHandler getVersionHandler() {
- IRuntimeType type = getRuntime().getRuntimeType();
- return TomcatPlugin.getTomcatVersionHandler(type.getId());
- }
-
- protected String getVMInstallTypeId() {
- return getAttribute(PROP_VM_INSTALL_TYPE_ID, (String)null);
- }
-
- protected String getVMInstallId() {
- return getAttribute(PROP_VM_INSTALL_ID, (String)null);
- }
-
- public boolean isUsingDefaultJRE() {
- return getVMInstallTypeId() == null;
- }
-
- public IVMInstall getVMInstall() {
- if (getVMInstallTypeId() == null)
- return JavaRuntime.getDefaultVMInstall();
- try {
- IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId());
- IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
- int size = vmInstalls.length;
- String id = getVMInstallId();
- for (int i = 0; i < size; i++) {
- if (id.equals(vmInstalls[i].getId()))
- return vmInstalls[i];
- }
- } catch (Exception e) {
- // ignore
- }
- return null;
- }
-
- public List getRuntimeClasspath() {
- return getVersionHandler().getRuntimeClasspath(getRuntime().getLocation());
- }
-
- /**
- * Verifies the Tomcat installation directory. If it is
- * correct, true is returned. Otherwise, the user is notified
- * and false is returned.
- * @return boolean
- */
- public boolean verifyLocation() {
- return getVersionHandler().verifyInstallPath(getRuntime().getLocation());
- }
-
- /*
- * Validate the runtime
- */
- public IStatus validate() {
- IStatus status = super.validate();
- if (!status.isOK())
- return status;
-
- if (!verifyLocation())
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorInstallDir, null);
- // don't accept trailing space since that can cause startup problems
- if (getRuntime().getLocation().hasTrailingSeparator())
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorInstallDirTrailingSlash, null);
- if (getVMInstall() == null)
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorJRE, null);
-
- // check for tools.jar (contains the javac compiler on Windows & Linux) to see whether
- // Tomcat will be able to compile JSPs.
- boolean found = false;
- File file = getVMInstall().getInstallLocation();
- if (file != null) {
- File toolsJar = new File(file, "lib" + File.separator + "tools.jar");
- if (toolsJar.exists())
- found = true;
- }
-
- // on Mac, tools.jar is merged into classes.zip. if tools.jar wasn't found,
- // try loading the javac class by running a check inside the VM
- if (!found) {
- String os = Platform.getOS();
- if (os != null && os.toLowerCase().indexOf("mac") >= 0)
- found = checkForCompiler();
- }
-
- if (!found)
- return new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, Messages.warningJRE, null);
-
- return Status.OK_STATUS;
- }
-
- /**
- * @see RuntimeDelegate#setDefaults(IProgressMonitor)
- */
- public void setDefaults(IProgressMonitor monitor) {
- IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
- setVMInstall(vmInstall.getVMInstallType().getId(), vmInstall.getId());
-
- IRuntimeType type = getRuntimeWorkingCopy().getRuntimeType();
- getRuntimeWorkingCopy().setLocation(new Path(TomcatPlugin.getPreference("location" + type.getId())));
- }
-
- public void setVMInstall(IVMInstall vmInstall) {
- if (vmInstall == null) {
- setVMInstall(null, null);
- } else
- setVMInstall(vmInstall.getVMInstallType().getId(), vmInstall.getId());
- }
-
- protected void setVMInstall(String typeId, String id) {
- if (typeId == null)
- setAttribute(PROP_VM_INSTALL_TYPE_ID, (String)null);
- else
- setAttribute(PROP_VM_INSTALL_TYPE_ID, typeId);
-
- if (id == null)
- setAttribute(PROP_VM_INSTALL_ID, (String)null);
- else
- setAttribute(PROP_VM_INSTALL_ID, id);
- }
-
- /**
- * Checks for the existance of the Java compiler in the given java
- * executable. A main program is run (<code>org.eclipse.jst.tomcat.core.
- * internal.ClassDetector</code>), that dumps a true or false value
- * depending on whether the compiler is found. This output is then
- * parsed and cached for future reference.
- *
- * @return true if the compiler was found
- */
- protected boolean checkForCompiler() {
- // first try the cache
- File javaHome = getVMInstall().getInstallLocation();
- try {
- Boolean b = (Boolean) sdkMap.get(javaHome);
- return b.booleanValue();
- } catch (Exception e) {
- // ignore
- }
-
- // locate tomcatcore.jar - it contains the class detector main program
- File file = TomcatPlugin.getPlugin();
- if (file != null && file.exists()) {
- IVMRunner vmRunner = getVMInstall().getVMRunner(ILaunchManager.RUN_MODE);
- VMRunnerConfiguration config = new VMRunnerConfiguration("org.eclipse.jst.server.tomcat.core.internal.ClassDetector", new String[] { file.getAbsolutePath() });
- config.setProgramArguments(new String[] { "com.sun.tools.javac.Main" });
- ILaunch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
- try {
- vmRunner.run(config, launch, null);
- for (int i = 0; i < 200; i++) {
- // wait no more than 10 seconds (200 * 50 mils)
- if (launch.isTerminated()) {
- break;
- }
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- // ignore
- }
- }
- IStreamsProxy streamsProxy = launch.getProcesses()[0].getStreamsProxy();
- String text = null;
- if (streamsProxy != null) {
- text = streamsProxy.getOutputStreamMonitor().getContents();
-
- if (text != null && text.length() > 0) {
- boolean found = false;
- if ("true".equals(text))
- found = true;
-
- sdkMap.put(javaHome, new Boolean(found));
- return found;
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error checking for JDK", e);
- } finally {
- if (!launch.isTerminated()) {
- try {
- launch.terminate();
- } catch (Exception ex) {
- // ignore
- }
- }
- }
- }
-
- // log error that we were unable to check for the compiler
- TomcatPlugin.log(MessageFormat.format("Failed compiler check for {0}", new String[] { javaHome.getAbsolutePath() }));
- return 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/TomcatRuntimeClasspathProvider.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeClasspathProvider.java
deleted file mode 100644
index d8a8a9d48..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeClasspathProvider.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate;
-
-import org.eclipse.wst.server.core.IRuntime;
-/**
- * Classpath provider for the Tomcat runtime.
- */
-public class TomcatRuntimeClasspathProvider extends RuntimeClasspathProviderDelegate {
- public IClasspathEntry[] getDelegateClasspathEntries(IRuntime runtime, IProgressMonitor monitor) {
- ITomcatRuntime tomcatRuntime = (ITomcatRuntime) runtime.loadAdapter(ITomcatRuntime.class, null);
- IVMInstall vmInstall = tomcatRuntime.getVMInstall();
- if (vmInstall != null) {
- String name = vmInstall.getName();
- String typeId = vmInstall.getVMInstallType().getId();
- return new IClasspathEntry[] { JavaCore.newContainerEntry(new Path(JavaRuntime.JRE_CONTAINER).append(typeId).append(name)) };
- }
- return null;
- }
-
- /**
- * @see RuntimeClasspathProviderDelegate#getClasspathContainerLabel(IRuntime)
- */
- public String getClasspathContainerLabel(IRuntime runtime) {
- String id2 = runtime.getRuntimeType().getId();
- if (id2.indexOf("32") > 0)
- return Messages.target32runtime;
- else if (id2.indexOf("40") > 0)
- return Messages.target40runtime;
- else if (id2.indexOf("41") > 0)
- return Messages.target41runtime;
- else if (id2.indexOf("50") > 0)
- return Messages.target50runtime;
-
- return Messages.target55runtime;
- }
-
- /**
- * @see RuntimeClasspathProviderDelegate#resolveClasspathContainer(IRuntime)
- */
- public IClasspathEntry[] resolveClasspathContainer(IRuntime runtime) {
- return resolveClasspathContainer2(runtime);
- }
-
- /**
- * Resolve the classpath container.
- */
- protected IClasspathEntry[] resolveClasspathContainer2(IRuntime runtime) {
- IPath installPath = runtime.getLocation();
-
- if (installPath == null)
- return new IClasspathEntry[0];
-
- List list = new ArrayList();
- if (runtime.getRuntimeType().getId().indexOf("32") > 0) {
- IPath path = installPath.append("lib");
- addLibraryEntries(list, path.toFile(), true);
- } else {
- IPath path = installPath.append("common");
- addLibraryEntries(list, path.append("lib").toFile(), true);
- addLibraryEntries(list, path.append("endorsed").toFile(), true);
- }
- return (IClasspathEntry[])list.toArray(new IClasspathEntry[list.size()]);
- }
-} \ No newline at end of file
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
deleted file mode 100644
index a2f564adf..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeLocator.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.File;
-import java.io.FileFilter;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.jdt.launching.JavaRuntime;
-
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.model.RuntimeLocatorDelegate;
-/**
- *
- */
-public class TomcatRuntimeLocator extends RuntimeLocatorDelegate {
- protected static final String[] runtimeTypes = new String[] {
- "org.eclipse.jst.server.tomcat.runtime.32",
- "org.eclipse.jst.server.tomcat.runtime.40",
- "org.eclipse.jst.server.tomcat.runtime.41",
- "org.eclipse.jst.server.tomcat.runtime.50",
- "org.eclipse.jst.server.tomcat.runtime.55"};
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.server.core.model.IRuntimeFactoryDelegate#getKnownRuntimes()
- */
- public void searchForRuntimes(IPath path, IRuntimeSearchListener listener, IProgressMonitor monitor) {
- searchForRuntimes2(path, listener, monitor);
- }
-
- protected static void searchForRuntimes2(IPath path, IRuntimeSearchListener listener, IProgressMonitor monitor) {
- File[] files = null;
- if (path != null) {
- File f = path.toFile();
- if (f.exists())
- files = f.listFiles();
- else
- return;
- } else
- files = File.listRoots();
-
- if (files != null) {
- int size = files.length;
- int work = 100 / size;
- int workLeft = 100 - (work * size);
- for (int i = 0; i < size; i++) {
- if (monitor.isCanceled())
- return;
- if (files[i] != null && files[i].isDirectory())
- searchDir(listener, files[i], 4, monitor);
- monitor.worked(work);
- }
- monitor.worked(workLeft);
- } else
- monitor.worked(100);
- }
-
- protected static void searchDir(IRuntimeSearchListener listener, File dir, int depth, IProgressMonitor monitor) {
- if ("conf".equals(dir.getName())) {
- IRuntimeWorkingCopy runtime = getRuntimeFromDir(dir.getParentFile(), monitor);
- if (runtime != null) {
- listener.runtimeFound(runtime);
- return;
- }
- }
-
- if (depth == 0)
- return;
-
- File[] files = dir.listFiles(new FileFilter() {
- public boolean accept(File file) {
- return file.isDirectory();
- }
- });
- if (files != null) {
- int size = files.length;
- for (int i = 0; i < size; i++) {
- if (monitor.isCanceled())
- return;
- searchDir(listener, files[i], depth - 1, monitor);
- }
- }
- }
-
- protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir, IProgressMonitor monitor) {
- for (int i = 0; i < runtimeTypes.length; i++) {
- try {
- IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypes[i]);
- String absolutePath = dir.getAbsolutePath();
- String id = absolutePath.replace(File.separatorChar,'_').replace(':','-');
- IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id, monitor);
- runtime.setName(dir.getName());
- runtime.setLocation(new Path(absolutePath));
- ITomcatRuntimeWorkingCopy wc = (ITomcatRuntimeWorkingCopy) runtime.loadAdapter(ITomcatRuntimeWorkingCopy.class, null);
- wc.setVMInstall(JavaRuntime.getDefaultVMInstall());
- IStatus status = runtime.validate(monitor);
- if (status == null || status.getSeverity() != IStatus.ERROR)
- return runtime;
-
- Trace.trace(Trace.FINER, "False runtime found at " + dir.getAbsolutePath() + ": " + status.getMessage());
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not find runtime", e);
- }
- }
- return null;
- }
-} \ No newline at end of file
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
deleted file mode 100644
index f4e95953b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.net.URL;
-import java.util.List;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.jst.server.core.internal.J2EEUtil;
-import org.eclipse.osgi.util.NLS;
-
-import org.eclipse.wst.server.core.*;
-import org.eclipse.wst.server.core.model.*;
-/**
- * Generic Tomcat server.
- */
-public class TomcatServer extends ServerDelegate implements ITomcatServer, ITomcatServerWorkingCopy {
- public static final String PROPERTY_SECURE = "secure";
- public static final String PROPERTY_DEBUG = "debug";
-
- protected transient TomcatConfiguration configuration;
-
- /**
- * TomcatServer.
- */
- public TomcatServer() {
- super();
- }
-
- public TomcatRuntime getTomcatRuntime() {
- if (getServer().getRuntime() == null)
- return null;
-
- return (TomcatRuntime) getServer().getRuntime().loadAdapter(TomcatRuntime.class, null);
- }
-
- public ITomcatVersionHandler getTomcatVersionHandler() {
- if (getServer().getRuntime() == null || getTomcatRuntime() == null)
- return null;
-
- return getTomcatRuntime().getVersionHandler();
- }
-
- public ITomcatConfiguration getServerConfiguration() throws CoreException {
- return getTomcatConfiguration();
- }
-
- public TomcatConfiguration getTomcatConfiguration() throws CoreException {
- if (configuration == null) {
- IFolder folder = getServer().getServerConfiguration();
- if (folder == null || !folder.exists()) {
- String path = null;
- if (folder != null)
- path = folder.getFullPath().toOSString();
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorNoConfiguration, path), null));
- }
-
- String id = getServer().getServerType().getId();
- if (id.indexOf("32") > 0)
- configuration = new Tomcat32Configuration(folder);
- else if (id.indexOf("40") > 0)
- configuration = new Tomcat40Configuration(folder);
- else if (id.indexOf("41") > 0)
- configuration = new Tomcat41Configuration(folder);
- else if (id.indexOf("50") > 0)
- configuration = new Tomcat50Configuration(folder);
- else if (id.indexOf("55") > 0)
- configuration = new Tomcat55Configuration(folder);
- try {
- configuration.load(folder, null);
- } catch (CoreException ce) {
- // ignore
- configuration = null;
- throw ce;
- }
- }
- return configuration;
- }
-
- public void importConfiguration(IRuntime runtime, IProgressMonitor monitor) {
- if (runtime == null) {
- configuration = null;
- return;
- }
- IPath path = runtime.getLocation().append("conf");
-
- String id = getServer().getServerType().getId();
- IFolder folder = getServer().getServerConfiguration();
- if (id.indexOf("32") > 0)
- configuration = new Tomcat32Configuration(folder);
- else if (id.indexOf("40") > 0)
- configuration = new Tomcat40Configuration(folder);
- else if (id.indexOf("41") > 0)
- configuration = new Tomcat41Configuration(folder);
- else if (id.indexOf("50") > 0)
- configuration = new Tomcat50Configuration(folder);
- else if (id.indexOf("55") > 0)
- configuration = new Tomcat55Configuration(folder);
- try {
- configuration.importFromPath(path, isTestEnvironment(), monitor);
- } catch (CoreException ce) {
- // ignore
- configuration = null;
- }
- }
-
- public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
- if (configuration == null)
- return;
- configuration.save(getServer().getServerConfiguration(), monitor);
- }
-
- public void configurationChanged() {
- configuration = null;
- }
-
- /**
- * 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)
- return null;
-
- TomcatConfiguration config = getTomcatConfiguration();
- if (config == null)
- return null;
-
- String url = "http://localhost";
- int port = config.getMainPort().getPort();
- port = ServerUtil.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(Trace.SEVERE, "Could not get root URL", e);
- return null;
- }
- }
-
- /**
- * Returns true if the process is set to run in debug mode.
- * This feature only works with Tomcat v4.0.
- *
- * @return boolean
- */
- public boolean isDebug() {
- return getAttribute(PROPERTY_DEBUG, false);
- }
-
- /**
- * Returns true if this is a test (run code out of the workbench) server.
- *
- * @return boolean
- */
- public boolean isTestEnvironment() {
- return getAttribute(PROPERTY_TEST_ENVIRONMENT, false);
- }
-
- /**
- * Returns true if the process is set to run in secure mode.
- *
- * @return boolean
- */
- public boolean isSecure() {
- return getAttribute(PROPERTY_SECURE, false);
- }
-
- 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();
- }
-
- /*
- * Returns the child module(s) of this module.
- */
- public IModule[] getChildModules(IModule[] module) {
- if (module == null)
- return null;
-
- IModuleType moduleType = module[0].getModuleType();
-
- if (module.length == 1 && moduleType != null && "jst.web".equals(moduleType.getId())) {
- IWebModule webModule = (IWebModule) module[0].loadAdapter(IWebModule.class, null);
- if (webModule != null) {
- IModule[] modules = webModule.getModules();
- //if (modules != null)
- // System.out.println(modules.length);
- return modules;
- }
- }
- return new IModule[0];
- }
-
- /*
- * Returns the root module(s) of this module.
- */
- public IModule[] getRootModules(IModule module) throws CoreException {
- if ("jst.web".equals(module.getModuleType().getId())) {
- IStatus status = canModifyModules(new IModule[] { module }, null);
- if (status == null || !status.isOK())
- throw new CoreException(status);
- return new IModule[] { module };
- }
-
- return J2EEUtil.getWebModules(module, null);
- }
-
- /**
- * Returns true if the given project is supported by this
- * server, and false otherwise.
- *
- * @param add modules
- * @param remove modules
- * @return the status
- */
- public IStatus canModifyModules(IModule[] add, IModule[] remove) {
- if (add != null) {
- int size = add.length;
- for (int i = 0; i < size; i++) {
- IModule module = add[i];
- if (!"jst.web".equals(module.getModuleType().getId()))
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorWebModulesOnly, null);
-
- if (getTomcatVersionHandler() == null)
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorNoRuntime, null);
-
- IStatus status = getTomcatVersionHandler().canAddModule(module);
- if (status != null && !status.isOK())
- return status;
- }
- }
-
- return Status.OK_STATUS;
- }
-
- public ServerPort[] getServerPorts() {
- if (getServer().getServerConfiguration() == null)
- return new ServerPort[0];
-
- try {
- List list = getTomcatConfiguration().getServerPorts();
- ServerPort[] sp = new ServerPort[list.size()];
- list.toArray(sp);
- return sp;
- } catch (Exception e) {
- return new ServerPort[0];
- }
- }
-
- public void setDefaults(IProgressMonitor monitor) {
- setTestEnvironment(true);
- setAttribute("auto-publish-setting", 2);
- setAttribute("auto-publish-time", 1);
- }
-
- /**
- * 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);
- }
-
- /**
- * @see ServerDelegate#modifyModules(IModule[], IModule[], IProgressMonitor)
- */
- 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);
-
- TomcatConfiguration config = getTomcatConfiguration();
-
- if (add != null) {
- int size = add.length;
- for (int i = 0; i < size; i++) {
- IModule module3 = add[i];
- IWebModule module = (IWebModule) module3.loadAdapter(IWebModule.class, monitor);
- String contextRoot = module.getContextRoot();
- if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0)
- contextRoot = "/" + contextRoot;
- String docBase = config.getDocBasePrefix() + module3.getName();
- WebModule module2 = new WebModule(contextRoot, docBase, module3.getId(), true);
- config.addWebModule(-1, module2);
- }
- }
-
- if (remove != null) {
- int size2 = remove.length;
- for (int j = 0; j < size2; j++) {
- IModule module3 = remove[j];
- String memento = module3.getId();
- List 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()))
- config.removeWebModule(i);
- }
- }
- }
- //config.save(config.getFolder(), monitor);
- }
-
- /**
- * Return a string representation of this object.
- * @return java.lang.String
- */
- public String toString() {
- return "TomcatServer";
- }
-} \ 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
deleted file mode 100644
index c23c6f03a..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java
+++ /dev/null
@@ -1,819 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-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.core.PublishUtil;
-import org.eclipse.osgi.util.NLS;
-
-import org.eclipse.wst.server.core.*;
-import org.eclipse.wst.server.core.internal.IModulePublishHelper;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.model.*;
-import org.eclipse.wst.server.core.util.SocketUtil;
-/**
- * Generic Tomcat server.
- */
-public class TomcatServerBehaviour extends ServerBehaviourDelegate implements ITomcatServerBehaviour, IModulePublishHelper {
- private static final String ATTR_STOP = "stop-server";
-
- // the thread used to ping the server to check for startup
- protected transient PingThread ping = null;
- protected transient IProcess process;
- protected transient IDebugEventSetListener processListener;
-
- /**
- * TomcatServerBehaviour.
- */
- public TomcatServerBehaviour() {
- super();
- }
-
- public void initialize(IProgressMonitor monitor) {
- // do nothing
- }
-
- public TomcatRuntime getTomcatRuntime() {
- if (getServer().getRuntime() == null)
- return null;
-
- return (TomcatRuntime) getServer().getRuntime().loadAdapter(TomcatRuntime.class, null);
- }
-
- public ITomcatVersionHandler getTomcatVersionHandler() {
- if (getServer().getRuntime() == null || getTomcatRuntime() == null)
- return null;
-
- return getTomcatRuntime().getVersionHandler();
- }
-
- public TomcatConfiguration getTomcatConfiguration() throws CoreException {
- return getTomcatServer().getTomcatConfiguration();
- }
-
- public TomcatServer getTomcatServer() {
- return (TomcatServer) getServer().loadAdapter(TomcatServer.class, null);
- }
-
- /**
- * Return the runtime class name.
- *
- * @return the class name
- */
- public String getRuntimeClass() {
- return getTomcatVersionHandler().getRuntimeClass();
- }
-
- /**
- * Returns the runtime base path for relative paths in the server
- * configuration.
- *
- * @return the base path
- */
- public IPath getRuntimeBaseDirectory() {
- return getTomcatVersionHandler().getRuntimeBaseDirectory(this);
- }
-
- /**
- * Return the program's runtime arguments to start or stop.
- *
- * @param starting true if starting
- * @return an array of runtime program arguments
- */
- protected String[] getRuntimeProgramArguments(boolean starting) {
- IPath configPath = null;
- if (getTomcatServer().isTestEnvironment())
- configPath = getTempDirectory();
- return getTomcatVersionHandler().getRuntimeProgramArguments(configPath, getTomcatServer().isDebug(), starting);
- }
-
- /**
- * Return the runtime (VM) arguments.
- *
- * @return an array of runtime arguments
- */
- protected String[] getRuntimeVMArguments() {
- IPath installPath = getServer().getRuntime().getLocation();
- IPath configPath = null;
- if (getTomcatServer().isTestEnvironment())
- configPath = getTempDirectory();
- else
- configPath = installPath;
- return getTomcatVersionHandler().getRuntimeVMArguments(installPath, configPath,
- getTomcatServer().isTestEnvironment());
- }
-
- protected String getRuntimePolicyFile() {
- IPath configPath;
- if (getTomcatServer().isTestEnvironment())
- configPath = getTempDirectory();
- else
- configPath = getServer().getRuntime().getLocation();
- return getTomcatVersionHandler().getRuntimePolicyFile(configPath);
- }
-
- protected static String renderCommandLine(String[] commandLine, String separator) {
- if (commandLine == null || commandLine.length < 1)
- return "";
- StringBuffer buf= new StringBuffer(commandLine[0]);
- for (int i = 1; i < commandLine.length; i++) {
- buf.append(separator);
- buf.append(commandLine[i]);
- }
- return buf.toString();
- }
-
- public void setProcess(final IProcess newProcess) {
- if (process != null)
- return;
-
- process = newProcess;
- if (processListener != null)
- DebugPlugin.getDefault().removeDebugEventListener(processListener);
- if (newProcess == null)
- return;
-
- processListener = new IDebugEventSetListener() {
- public void handleDebugEvents(DebugEvent[] events) {
- if (events != null) {
- int size = events.length;
- for (int i = 0; i < size; i++) {
- if (process != null && process.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) {
- DebugPlugin.getDefault().removeDebugEventListener(this);
- stopImpl();
- }
- }
- }
- }
- };
- DebugPlugin.getDefault().addDebugEventListener(processListener);
- }
-
- protected void setServerStarted() {
- setServerState(IServer.STATE_STARTED);
- }
-
- protected void stopImpl() {
- if (ping != null) {
- ping.stop();
- ping = null;
- }
- if (process != null) {
- process = null;
- DebugPlugin.getDefault().removeDebugEventListener(processListener);
- processListener = null;
- }
- setServerState(IServer.STATE_STOPPED);
- }
-
- protected void publishServer(int kind, IProgressMonitor monitor) throws CoreException {
- if (getServer().getRuntime() == null)
- return;
-
- IPath installDir = getServer().getRuntime().getLocation();
- IPath confDir = null;
- if (getTomcatServer().isTestEnvironment()) {
- confDir = getTempDirectory();
- IStatus status = getTomcatConfiguration().prepareRuntimeDirectory(confDir);
- if (status != null && !status.isOK())
- throw new CoreException(status);
-/* File temp = confDir.append("conf").toFile();
- if (!temp.exists())
- temp.mkdirs();*/
- } else
- confDir = installDir;
-
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishServerTask, 600);
-
- IStatus status = getTomcatConfiguration().cleanupServer(confDir, installDir, ProgressUtil.getSubMonitorFor(monitor, 100));
- if (status != null && !status.isOK())
- throw new CoreException(status);
-
- status = getTomcatConfiguration().backupAndPublish(confDir, !getTomcatServer().isTestEnvironment(), ProgressUtil.getSubMonitorFor(monitor, 400));
- if (status != null && !status.isOK())
- throw new CoreException(status);
-
- getTomcatConfiguration().localizeConfiguration(confDir.append("conf"), getTomcatServer(), ProgressUtil.getSubMonitorFor(monitor, 100));
-
- monitor.done();
-
- setServerPublishState(IServer.PUBLISH_STATE_NONE);
- }
-
- /*
- * Publishes the given module to the server.
- */
- protected void publishModule(int kind, int deltaKind, IModule[] moduleTree, IProgressMonitor monitor) throws CoreException {
- if (getServer().getServerState() != IServer.STATE_STOPPED) {
- if (deltaKind == ServerBehaviourDelegate.ADDED || deltaKind == ServerBehaviourDelegate.REMOVED)
- setServerRestartState(true);
- }
- if (getTomcatServer().isTestEnvironment())
- return;
-
- IPath path = getTempDirectory().append("publish.txt");
- Properties p = new Properties();
- FileInputStream fin = null;
- try {
- fin = new FileInputStream(path.toFile());
- p.load(fin);
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- fin.close();
- } catch (Exception ex) {
- // ignore
- }
- }
-
- if (moduleTree.length == 1) // web module
- publishDir(deltaKind, p, moduleTree, monitor);
- else // utility jar
- publishJar(kind, deltaKind, p, moduleTree, monitor);
-
- setModulePublishState(moduleTree, IServer.PUBLISH_STATE_NONE);
-
- try {
- p.store(new FileOutputStream(path.toFile()), "Tomcat publish data");
- } catch (Exception e) {
- // ignore
- }
- }
-
- /**
- * Publish a web module.
- *
- * @param deltaKind
- * @param p
- * @param module
- * @param monitor
- * @throws CoreException
- */
- private void publishDir(int deltaKind, Properties p, IModule module[], IProgressMonitor monitor) throws CoreException {
- if (deltaKind == REMOVED) {
- try {
- String publishPath = (String) p.get(module[0].getId());
- PublishUtil.deleteDirectory(new File(publishPath), monitor);
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, "Could not remove module", e));
- }
- } else {
- IPath to = getServer().getRuntime().getLocation().append("webapps").append(module[0].getName());
- IModuleResource[] mr = getResources(module);
- PublishUtil.smartCopy(mr, to, monitor);
- p.put(module[0].getId(), to.toOSString());
- }
- }
-
- /**
- * Publish a jar file.
- *
- * @param deltaKind
- * @param p
- * @param module
- * @param monitor
- * @throws CoreException
- */
- private void publishJar(int kind, int deltaKind, Properties p, IModule[] module, IProgressMonitor monitor) throws CoreException {
- if (deltaKind == REMOVED) {
- try {
- String publishPath = (String) p.get(module[1].getId());
- new File(publishPath).delete();
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, "Could not remove module", e));
- }
- } else {
- if (kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
-
- IPath path = getServer().getRuntime().getLocation().append("webapps").append(module[0].getName());
- path = path.append("WEB-INF").append("lib");
- if (!path.toFile().exists())
- path.toFile().mkdirs();
-
- IModuleResource[] mr = getResources(module);
- PublishUtil.createZipFile(mr, path.append(module[1].getName() + ".jar"));
- p.put(module[1].getId(), path.toOSString());
- }
- }
-
- protected void publishFinish(IProgressMonitor monitor) throws CoreException {
- IPath baseDir;
- if (getTomcatServer().isTestEnvironment())
- baseDir = getTempDirectory();
- else
- baseDir = getServer().getRuntime().getLocation();
-
- // Publish context configuration for servers that support META-INF/context.xml
- IStatus status = getTomcatConfiguration().publishContextConfig(baseDir, monitor);
- if (!status.isOK())
- throw new CoreException(status);
- }
-
- /**
- * Setup for starting the server.
- *
- * @param launch ILaunch
- * @param launchMode String
- * @param monitor IProgressMonitor
- * @throws CoreException if anything goes wrong
- */
- public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException {
- if ("true".equals(launch.getLaunchConfiguration().getAttribute(ATTR_STOP, "false")))
- return;
- //if (getTomcatRuntime() == null)
- // throw new CoreException();
-
- IStatus status = getTomcatRuntime().validate();
- if (status != null && status.getSeverity() == IStatus.ERROR)
- throw new CoreException(status);
-
- //setRestartNeeded(false);
- TomcatConfiguration configuration = getTomcatConfiguration();
-
- // check that ports are free
- Iterator iterator = configuration.getServerPorts().iterator();
- List usedPorts = new ArrayList();
- while (iterator.hasNext()) {
- ServerPort sp = (ServerPort) iterator.next();
- if (sp.getPort() < 0)
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorPortInvalid, null));
- if (SocketUtil.isPortInUse(sp.getPort(), 5)) {
- usedPorts.add(sp);
- }
- }
- if (usedPorts.size() == 1) {
- ServerPort port = (ServerPort) usedPorts.get(0);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPortInUse, new String[] {port.getPort() + "", getServer().getName()}), null));
- } else if (usedPorts.size() > 1) {
- String portStr = "";
- iterator = usedPorts.iterator();
- boolean first = true;
- while (iterator.hasNext()) {
- if (!first)
- portStr += ", ";
- first = false;
- ServerPort sp = (ServerPort) iterator.next();
- portStr += "" + sp.getPort();
- }
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPortsInUse, new String[] {portStr, getServer().getName()}), null));
- }
-
- // check that there is only one app for each context root
- iterator = configuration.getWebModules().iterator();
- List contextRoots = new ArrayList();
- while (iterator.hasNext()) {
- WebModule module = (WebModule) iterator.next();
- String contextRoot = module.getPath();
- if (contextRoots.contains(contextRoot))
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDuplicateContextRoot, new String[] { contextRoot }), null));
-
- contextRoots.add(contextRoot);
- }
-
- setServerRestartState(false);
- setServerState(IServer.STATE_STARTING);
- setMode(launchMode);
-
- // 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(), url, 50, this);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Can't ping for Tomcat startup.");
- }
- }
-
- /**
- * Cleanly shuts down and terminates the server.
- *
- * @param force <code>true</code> to kill 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 = ((Server)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);
- }
- }
-
- public IPath getTempDirectory() {
- return super.getTempDirectory();
- }
-
- /**
- * Return a string representation of this object.
- * @return java.lang.String
- */
- public String toString() {
- return "TomcatServer";
- }
-
- protected static int getNextToken(String s, int start) {
- int i = start;
- int length = s.length();
- char lookFor = ' ';
-
- while (i < length) {
- char c = s.charAt(i);
- if (lookFor == c) {
- if (lookFor == '"')
- return i+1;
- return i;
- }
- if (c == '"')
- lookFor = '"';
- i++;
- }
- return -1;
- }
-
- /**
- * Merge the given arguments into the original argument string, replacing
- * invalid values if they have been changed.
- *
- * @param originalArg
- * @param vmArgs
- * @return merged argument string
- */
- public static String mergeArguments(String originalArg, String[] vmArgs) {
- if (vmArgs == null)
- return originalArg;
-
- if (originalArg == null)
- originalArg = "";
-
- // replace and null out all vmargs that already exist
- int size = vmArgs.length;
- for (int i = 0; i < size; i++) {
- int ind = vmArgs[i].indexOf(" ");
- int ind2 = vmArgs[i].indexOf("=");
- if (ind >= 0 && (ind2 == -1 || ind < ind2)) { // -a bc style
- int index = originalArg.indexOf(vmArgs[i].substring(0, ind + 1));
- if (index == 0 || (index > 0 && originalArg.charAt(index - 1) == ' ')) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index + ind + 1);
- if (index2 >= 0)
- originalArg = s + vmArgs[i] + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- }
- } else if (ind2 >= 0) { // a=b style
- int index = originalArg.indexOf(vmArgs[i].substring(0, ind2 + 1));
- if (index == 0 || (index > 0 && originalArg.charAt(index - 1) == ' ')) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (index2 >= 0)
- originalArg = s + vmArgs[i] + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- }
- } else { // abc style
- int index = originalArg.indexOf(vmArgs[i]);
- if (index == 0 || (index > 0 && originalArg.charAt(index-1) == ' ')) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (index2 >= 0)
- originalArg = s + vmArgs[i] + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- }
- }
- }
-
- // add remaining vmargs to the end
- for (int i = 0; i < size; i++) {
- if (vmArgs[i] != null) {
- if (originalArg.length() > 0 && !originalArg.endsWith(" "))
- originalArg += " ";
- originalArg += vmArgs[i];
- }
- }
-
- return originalArg;
- }
-
- /**
- * Replace the current JRE container classpath with the given entry.
- *
- * @param cp
- * @param entry
- */
- public static void replaceJREContainer(List cp, IRuntimeClasspathEntry entry) {
- int size = cp.size();
- for (int i = 0; i < size; i++) {
- IRuntimeClasspathEntry entry2 = (IRuntimeClasspathEntry) cp.get(i);
- if (entry2.getPath().uptoSegment(2).isPrefixOf(entry.getPath())) {
- cp.set(i, entry);
- return;
- }
- }
-
- cp.add(0, entry);
- }
-
- /**
- * Merge a single classpath entry into the classpath list.
- *
- * @param cp
- * @param entry
- */
- public static void mergeClasspath(List cp, IRuntimeClasspathEntry entry) {
- Iterator iterator = cp.iterator();
- while (iterator.hasNext()) {
- IRuntimeClasspathEntry entry2 = (IRuntimeClasspathEntry) iterator.next();
-
- if (entry2.getPath().equals(entry.getPath()))
- return;
- }
-
- cp.add(entry);
- }
-
- public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
- String existingProgArgs = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, mergeArguments(existingProgArgs, getRuntimeProgramArguments(true)));
-
- String existingVMArgs = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null);
- String[] parsedVMArgs = null;
- if (null != existingVMArgs) {
- parsedVMArgs = DebugPlugin.parseArguments(existingVMArgs);
- }
- String [] configVMArgs = getRuntimeVMArguments();
- if (getTomcatServer().isSecure()) {
- boolean addSecurityArgs = true;
- if (null != parsedVMArgs) {
- for (int i = 0; i < parsedVMArgs.length; i++) {
- if (parsedVMArgs[i].startsWith("wtp.configured.security")) {
- addSecurityArgs = false;
- break;
- }
- }
- }
- if (addSecurityArgs) {
- String [] newVMArgs = new String [configVMArgs.length + 3];
- System.arraycopy(configVMArgs, 0, newVMArgs, 0, configVMArgs.length);
- newVMArgs[configVMArgs.length] = "-Djava.security.manager";
- newVMArgs[configVMArgs.length + 1] = "-Djava.security.policy=\""
- + getRuntimePolicyFile() +"\"";
- newVMArgs[configVMArgs.length + 2] = "-Dwtp.configured.security=true";
- configVMArgs = newVMArgs;
- }
- }
- else if (null != parsedVMArgs){
- boolean removeSecurityArgs = false;
- for (int i = 0; i < parsedVMArgs.length; i++) {
- if (parsedVMArgs[i].startsWith("-Dwtp.configured.security")) {
- removeSecurityArgs = true;
- break;
- }
- }
- if (removeSecurityArgs) {
- StringBuffer filteredVMArgs = new StringBuffer();
- for (int i = 0; i < parsedVMArgs.length; i++) {
- String arg = parsedVMArgs[i];
- if (!arg.startsWith("-Djava.security.manager")
- && !arg.startsWith("-Djava.security.policy=")
- && !arg.startsWith("-Dwtp.configured.security=")) {
- if (filteredVMArgs.length() > 0) {
- filteredVMArgs.append(' ');
- }
- filteredVMArgs.append(arg);
- }
- }
- existingVMArgs = filteredVMArgs.toString();
- }
- }
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, mergeArguments(existingVMArgs, configVMArgs));
-
- 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());
- }
-
- // update classpath
- IRuntimeClasspathEntry[] originalClasspath = JavaRuntime.computeUnresolvedRuntimeClasspath(workingCopy);
- int size = originalClasspath.length;
- List oldCp = new ArrayList(originalClasspath.length + 2);
- for (int i = 0; i < size; i++)
- oldCp.add(originalClasspath[i]);
-
- List cp2 = runtime.getRuntimeClasspath();
- Iterator iterator = cp2.iterator();
- while (iterator.hasNext()) {
- IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) iterator.next();
- mergeClasspath(oldCp, entry);
- }
-
- if (vmInstall != null) {
- try {
- String typeId = vmInstall.getVMInstallType().getId();
- replaceJREContainer(oldCp, JavaRuntime.newRuntimeContainerClasspathEntry(new Path(JavaRuntime.JRE_CONTAINER).append(typeId).append(vmInstall.getName()), IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
- } catch (Exception e) {
- // ignore
- }
-
- IPath jrePath = new Path(vmInstall.getInstallLocation().getAbsolutePath());
- if (jrePath != null) {
- IPath toolsPath = jrePath.append("lib").append("tools.jar");
- if (toolsPath.toFile().exists()) {
- IRuntimeClasspathEntry toolsJar = JavaRuntime.newArchiveRuntimeClasspathEntry(toolsPath);
- // Search for index to any existing tools.jar entry
- int toolsIndex;
- for (toolsIndex = 0; toolsIndex < oldCp.size(); toolsIndex++ ) {
- IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) oldCp.get(toolsIndex);
- if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE
- && entry.getPath().lastSegment().equals("tools.jar")) {
- break;
- }
- }
- // If existing tools.jar found, replace in case it's different. Otherwise add.
- if (toolsIndex < oldCp.size())
- oldCp.set(toolsIndex, toolsJar);
- else
- mergeClasspath(oldCp, toolsJar);
- }
- }
- }
-
- iterator = oldCp.iterator();
- List list = new ArrayList();
- while (iterator.hasNext()) {
- IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) iterator.next();
- try {
- list.add(entry.getMemento());
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not resolve classpath entry: " + entry, e);
- }
- }
-
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, list);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
- }
-
- protected IModuleResource[] getResources(IModule[] module) {
- return super.getResources(module);
- }
-
- protected IModuleResourceDelta[] getPublishedResourceDelta(IModule[] module) {
- return super.getPublishedResourceDelta(module);
- }
-
- /**
- * @see ServerBehaviourDelegate#handleResourceChange()
- */
- public void handleResourceChange() {
- if (getServer().getServerRestartState())
- return;
-
- Iterator iterator = getAllModules().iterator();
- while (iterator.hasNext()) {
- IModule[] module = (IModule[]) iterator.next();
- IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- continue;
-
- if (containsNonResourceChange(delta)) {
- setServerRestartState(true);
- return;
- }
- }
- }
-
- protected boolean containsNonResourceChange(IModuleResourceDelta[] delta) {
- int size = delta.length;
- for (int i = 0; i < size; i++) {
- IModuleResourceDelta d = delta[i];
- if (d.getModuleRelativePath().segmentCount() == 0) {
- if ("WEB-INF".equals(d.getModuleResource().getName())) {
- return containsNonResourceChange(d.getAffectedChildren());
- }
- continue;
- }
- if (d.getModuleResource() instanceof IModuleFile)
- return true;
-
- boolean b = containsNonAddChange(d.getAffectedChildren());
- if (b)
- return true;
- }
- return false;
- }
-
- protected boolean containsNonAddChange(IModuleResourceDelta[] delta) {
- if (delta == null)
- return false;
- int size = delta.length;
- for (int i = 0; i < size; i++) {
- IModuleResourceDelta d = delta[i];
- if (d.getModuleResource() instanceof IModuleFile) {
- if (d.getKind() != IModuleResourceDelta.ADDED)
- return true;
- }
-
- boolean b = containsNonAddChange(d.getAffectedChildren());
- if (b)
- return true;
- }
- return false;
- }
-
- /**
- * Temporary method to help web services team. Returns the path that the module is
- * published to when in test environment mode.
- *
- * @param module a module on the server
- * @return the path that the module is published to when in test environment mode,
- * or null if not running as a test environment or the module is not a web module
- */
- public IPath getPublishDirectory(IModule[] module) {
- if (!getTomcatServer().isTestEnvironment() || module == null || module.length != 1)
- return null;
-
- return getTempDirectory().append("webapps").append(module[0].getName());
- }
-
- public void setModulePublishState2(IModule[] module, int state) {
- setModulePublishState(module, state);
- }
-} \ 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
deleted file mode 100644
index 208761810..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerLocator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.wst.server.core.*;
-import org.eclipse.wst.server.core.internal.provisional.ServerLocatorDelegate;
-/**
- *
- */
-public class TomcatServerLocator extends ServerLocatorDelegate {
- public void searchForServers(String host, final IServerSearchListener listener, final IProgressMonitor monitor) {
- TomcatRuntimeLocator.IRuntimeSearchListener listener2 = new TomcatRuntimeLocator.IRuntimeSearchListener() {
- public void runtimeFound(IRuntimeWorkingCopy runtime) {
- String runtimeTypeId = runtime.getRuntimeType().getId();
- String serverTypeId = runtimeTypeId.substring(0, runtimeTypeId.length() - 8);
- IServerType serverType = ServerCore.findServerType(serverTypeId);
- try {
- IServerWorkingCopy server = serverType.createServer(serverTypeId, null, runtime, monitor);
- listener.serverFound(server);
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not create Tomcat server", e);
- }
- }
- };
- TomcatRuntimeLocator.searchForRuntimes2(null, listener2, 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/TomcatServerUtil.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerUtil.java
deleted file mode 100644
index 4f720e8d6..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerUtil.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
-/**
- * Helper class to load and save Tomcat server and identify configurations.
- */
-public class TomcatServerUtil {
- /**
- * TomcatServerSerializer constructor comment.
- */
- protected TomcatServerUtil() {
- super();
- }
-
- /**
- * Returns the kind of a <code>PackageFragmentRoot</code> from its <code>String</code> form.
- */
- protected static int getClasspathKindFromString(String kindStr) {
- //if (kindStr.equalsIgnoreCase("prj"))
- // return IClasspathEntry.CPE_PROJECT;
- if (kindStr.equalsIgnoreCase("var"))
- return IClasspathEntry.CPE_VARIABLE;
- //if (kindStr.equalsIgnoreCase("src"))
- // return IClasspathEntry.CPE_SOURCE;
- if (kindStr.equalsIgnoreCase("lib"))
- return IClasspathEntry.CPE_LIBRARY;
- return -1;
- }
-
- /**
- * Returns a <code>String</code> for the kind of a class path entry.
- */
- protected static String getClasspathKindToString(int kind) {
- switch (kind) {
- //case IClasspathEntry.CPE_PROJECT :
- // return "prj";
- //case IClasspathEntry.CPE_SOURCE :
- // return "src";
- case IClasspathEntry.CPE_LIBRARY :
- return "lib";
- case IClasspathEntry.CPE_VARIABLE :
- return "var";
- default :
- return "unknown";
- }
- }
-
- /**
- * Create's a classpath entry of the specified kind.
- *
- * Returns null if unable to create a valid entry.
- */
- protected static IClasspathEntry createClasspathEntry(IPath path, int kind, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath) {
- switch (kind) {
- /*case IClasspathEntry.CPE_PROJECT:
- if (!path.isAbsolute())
- return null;
- else
- return JavaCore.newProjectEntry(path);*/
-
- case IClasspathEntry.CPE_LIBRARY:
- if (!path.isAbsolute())
- return null;
-
- return JavaCore.newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath);
-
- case IClasspathEntry.CPE_VARIABLE:
- return JavaCore.newVariableEntry(path, sourceAttachmentPath, sourceAttachmentRootPath);
-
- default:
- return null;
- }
- }
-} \ 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
deleted file mode 100644
index d73cfdcd6..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.sourcelookup.ISourceContainer;
-import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
-import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerUtil;
-/**
- *
- */
-public class TomcatSourcePathComputerDelegate implements ISourcePathComputerDelegate {
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
- */
- public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
- IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
- List sourcefolderList = new ArrayList();
-
- IServer server = ServerUtil.getServer(configuration);
- if (server != null) {
- //IPath basePath = ((TomcatServerBehaviour)server.getAdapter(TomcatServerBehaviour.class)).getRuntimeBaseDirectory();
- List list = new ArrayList();
- //List pathList = new ArrayList();
- IModule[] modules = server.getModules();
- for (int i = 0; i < modules.length; i++) {
- IProject project = modules[i].getProject();
- if (project != null) {
-
- IFolder moduleFolder = project.getFolder(modules[i].getName());
- if (moduleFolder.exists()) {
- sourcefolderList.add(new FolderSourceContainer(moduleFolder, true));
- }
-
- try {
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
- if (!list.contains(javaProject))
- list.add(javaProject);
- }
- } catch (Exception e) {
- // ignore
- }
-
- //IPath path = basePath.append("work").append("Catalina").append("localhost").append(modules[i].getName());
- //pathList.add(path);
- }
- }
- int size = list.size();
- IJavaProject[] projects = new IJavaProject[size];
- list.toArray(projects);
-
- int size2 = entries.length;
- //int size3 = pathList.size();
- IRuntimeClasspathEntry[] entries2 = new IRuntimeClasspathEntry[size + size2];
- System.arraycopy(entries, 0, entries2, 0, size2);
-
- for (int i = 0; i < size; i++)
- entries2[size2 + i] = JavaRuntime.newProjectRuntimeClasspathEntry(projects[i]);
-
- //for (int i = 0; i < size3; i++)
- // entries2[size + size2 + i] = JavaRuntime.newArchiveRuntimeClasspathEntry((IPath) pathList.get(i));
-
- entries = entries2;
- }
-
- IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration);
- ISourceContainer[] sourceContainers = JavaRuntime.getSourceContainers(resolved);
-
- if (!sourcefolderList.isEmpty()) {
- ISourceContainer[] combinedSourceContainers = new ISourceContainer[sourceContainers.length + sourcefolderList.size()];
- sourcefolderList.toArray(combinedSourceContainers);
- System.arraycopy(sourceContainers, 0, combinedSourceContainers, sourcefolderList.size(), sourceContainers.length);
- sourceContainers = combinedSourceContainers;
- }
-
- return sourceContainers;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java
deleted file mode 100644
index fae3fbc2b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-/**
- * Helper class to route trace output.
- */
-public class Trace {
- public static byte CONFIG = 0;
- public static byte WARNING = 1;
- public static byte SEVERE = 2;
- public static byte FINEST = 3;
- public static byte FINER = 4;
-
- private static final String[] levelNames = new String[] {
- "CONFIG ", "WARNING ", "SEVERE ", "FINER ", "FINEST "};
- private static final String spacer = " ";
-
- private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm.ss.SSS");
-
- protected static int pluginLength = -1;
-
- /**
- * Trace constructor comment.
- */
- private Trace() {
- super();
- }
-
- /**
- * Trace the given text.
- *
- * @param level the trace level
- * @param s a message
- */
- public static void trace(byte level, String s) {
- Trace.trace(level, s, null);
- }
-
- /**
- * Trace the given message and exception.
- *
- * @param level the trace level
- * @param s a message
- * @param t a throwable
- */
- public static void trace(byte level, String s, Throwable t) {
- if (!TomcatPlugin.getInstance().isDebugging())
- return;
-
- /*System.out.println(TomcatPlugin.PLUGIN_ID + " " + s);
- if (t != null)
- t.printStackTrace();*/
- trace(TomcatPlugin.PLUGIN_ID, level, s, t);
- }
-
- /**
- * Trace the given message and exception.
- *
- * @param level a trace level
- * @param s a message
- * @param t a throwable
- */
- private static void trace(String pluginId, int level, String s, Throwable t) {
- if (pluginId == null || s == null)
- return;
-
- if (!TomcatPlugin.getInstance().isDebugging())
- return;
-
- StringBuffer sb = new StringBuffer(pluginId);
- if (pluginId.length() > pluginLength)
- pluginLength = pluginId.length();
- else if (pluginId.length() < pluginLength)
- sb.append(spacer.substring(0, pluginLength - pluginId.length()));
- sb.append(" ");
- sb.append(levelNames[level]);
- sb.append(" ");
- sb.append(sdf.format(new Date()));
- sb.append(" ");
- sb.append(s);
- //Platform.getDebugOption(ServerCore.PLUGIN_ID + "/" + "resources");
-
- System.out.println(sb.toString());
- if (t != null)
- t.printStackTrace();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebAppDocument.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebAppDocument.java
deleted file mode 100644
index b9c0751de..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebAppDocument.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jst.server.tomcat.core.internal.xml.XMLUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-/**
- * Helper class to access a web.xml file.
- */
-public class WebAppDocument {
- protected boolean isWebAppDirty;
- protected Document webAppDocument;
-
- /**
- * Loads a web.xml from the given URL.
- *
- * @param path a path
- * @throws Exception if anything goes wrong
- */
- public WebAppDocument(IPath path) throws Exception {
- webAppDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.toFile())));
- }
-
- /**
- * Loads a web.xml from the given resource.
- *
- * @param file a file
- * @throws Exception if anything goes wrong
- */
- public WebAppDocument(IFile file) throws Exception {
- webAppDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(file.getContents()));
- }
-
- /**
- * Adds a MimeMapping.
- *
- * @param index int
- * @param map org.eclipse.jst.server.tomcat.IMimeMapping
- */
- public void addMimeMapping(int index, IMimeMapping map) {
- Trace.trace(Trace.FINER, "Adding mime mapping " + index + " " + map.getMimeType() + " " + map.getExtension());
- Element element = webAppDocument.getDocumentElement();
- Element mapping = XMLUtil.createChildElement(webAppDocument, element, index, "mime-mapping");
- XMLUtil.insertText(webAppDocument, mapping, "\n\t");
- XMLUtil.createTextChildElement(webAppDocument, mapping, "extension", map.getExtension());
- XMLUtil.insertText(webAppDocument, mapping, "\n\t");
- XMLUtil.createTextChildElement(webAppDocument, mapping, "mime-type", map.getMimeType());
- XMLUtil.insertText(webAppDocument, mapping, "\n");
-
- isWebAppDirty = true;
- }
-
- /**
- * Returns a list of MimeMappings.
- *
- * @return java.util.List
- */
- public List getMimeMappings() {
- List map = new ArrayList();
-
- Element root = webAppDocument.getDocumentElement();
- Iterator iterator = XMLUtil.getNodeIterator(root, "mime-mapping");
- while (iterator.hasNext()) {
- Element element = (Element) iterator.next();
- String mimeType = XMLUtil.getSubNodeValue(element, "mime-type");
- String extension = XMLUtil.getSubNodeValue(element, "extension");
- MimeMapping mm = new MimeMapping(extension, mimeType);
- map.add(mm);
- }
-
- return map;
- }
-
- /**
- * Modifies a mime mapping.
- *
- * @param index
- * @param map
- */
- public void modifyMimeMapping(int index, IMimeMapping map) {
- Element element = webAppDocument.getDocumentElement();
- NodeList list = element.getElementsByTagName("mime-mapping");
- Element element2 = (Element) list.item(index);
- XMLUtil.setNodeValue(element2.getElementsByTagName("extension").item(0), "extension", map.getExtension());
- XMLUtil.setNodeValue(element2.getElementsByTagName("mime-type").item(0), "mime-type", map.getMimeType());
-
- isWebAppDirty = true;
- }
-
- /**
- * Removes the mime mapping at the specified index.
- *
- * @param index int
- */
- public void removeMimeMapping(int index) {
- Element element = webAppDocument.getDocumentElement();
- NodeList list = element.getElementsByTagName("mime-mapping");
- Node node = list.item(index);
- element.removeChild(node);
- isWebAppDirty = true;
- }
-
- /**
- * Saves the Web app document.
- *
- * @param path a path
- * @param forceDirty true to force a save
- * @throws IOException if anything goes wrong
- */
- public void save(String path, boolean forceDirty) throws IOException {
- if (forceDirty || isWebAppDirty)
- XMLUtil.save(path, webAppDocument);
- }
-
- /**
- * Saves the Web app document.
- *
- * @param file a file
- * @param monitor a progress monitor
- * @throws Exception if anything goes wrong
- */
- public void save(IFile file, IProgressMonitor monitor) throws Exception {
- byte[] data = XMLUtil.getContents(webAppDocument);
- InputStream in = null;
- try {
- in = new ByteArrayInputStream(data);
- if (file.exists())
- file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- in.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebModule.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebModule.java
deleted file mode 100644
index 8117169b8..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebModule.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-/**
- * A Web module.
- */
-public class WebModule implements ITomcatWebModule {
- private String docBase;
- private String path;
- private String memento;
- private boolean reloadable;
-
- /**
- * WebModule constructor comment.
- *
- * @param path a path
- * @param docBase a document base
- * @param memento a memento
- * @param reloadable <code>true</code> if reloadable
- */
- public WebModule(String path, String docBase, String memento, boolean reloadable) {
- super();
- this.path = path;
- this.docBase = docBase;
- this.memento = memento;
- this.reloadable = reloadable;
- }
-
- /**
- * Get the document base.
- *
- * @return java.lang.String
- */
- public String getDocumentBase() {
- return docBase;
- }
-
- /**
- * Return the path. (context root)
- *
- * @return java.lang.String
- */
- public String getPath() {
- return path;
- }
-
- /**
- * Return the memento.
- *
- * @return java.lang.String
- */
- public String getMemento() {
- return memento;
- }
-
- /**
- * Return true if the web module is auto-reloadable.
- *
- * @return java.lang.String
- */
- public boolean isReloadable() {
- return reloadable;
- }
-
- /**
- * @see Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (!(obj instanceof WebModule))
- return false;
-
- WebModule wm = (WebModule) obj;
- if (!getDocumentBase().equals(wm.getDocumentBase()))
- return false;
- if (!getPath().equals(wm.getPath()))
- return false;
- if (!getMemento().equals(wm.getMemento()))
- return false;
- return true;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddMimeMappingCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddMimeMappingCommand.java
deleted file mode 100644
index b88404f6c..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddMimeMappingCommand.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.MimeMapping;
-/**
- * Command to add a mime mapping.
- */
-public class AddMimeMappingCommand extends ConfigurationCommand {
- protected MimeMapping map;
-
- /**
- * AddMimeMappingCommand constructor.
- *
- * @param configuration a tomcat configuration
- * @param map a mime mapping
- */
- public AddMimeMappingCommand(ITomcatConfigurationWorkingCopy configuration, MimeMapping map) {
- super(configuration, Messages.configurationEditorActionAddMimeMapping);
- this.map = map;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- configuration.addMimeMapping(0, map);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.removeMimeMapping(0);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddModuleCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddModuleCommand.java
deleted file mode 100644
index 1afeae1ce..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddModuleCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.AbstractOperation;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-/**
- * Command to add a web module to a server.
- */
-public class AddModuleCommand extends AbstractOperation {
- protected IServerWorkingCopy server;
- protected IModule module;
- protected int modules = -1;
-
- /**
- * AddModuleCommand constructor comment.
- *
- * @param server a server
- * @param module a web module
- */
- public AddModuleCommand(IServerWorkingCopy server, IModule module) {
- super(Messages.configurationEditorActionAddWebModule);
- this.server = server;
- this.module = module;
- }
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- server.modifyModules(new IModule[] { module }, null, monitor);
- } catch (Exception e) {
- // ignore
- }
- return Status.OK_STATUS;
- }
-
- public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- return execute(monitor, info);
- }
-
- public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- server.modifyModules(null, new IModule[] { module }, monitor);
- } catch (Exception e) {
- // ignore
- }
- return Status.OK_STATUS;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddWebModuleCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddWebModuleCommand.java
deleted file mode 100644
index e01d3b7d4..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/AddWebModuleCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.WebModule;
-/**
- * Command to add a web module.
- */
-public class AddWebModuleCommand extends ConfigurationCommand {
- protected WebModule module;
- protected int modules = -1;
-
- /**
- * AddWebModuleCommand constructor comment.
- *
- * @param configuration a tomcat configuration
- * @param module a web module
- */
- public AddWebModuleCommand(ITomcatConfigurationWorkingCopy configuration, WebModule module) {
- super(configuration, Messages.configurationEditorActionAddWebModule);
- this.module = module;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- modules = configuration.getWebModules().size();
- configuration.addWebModule(-1, module);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.removeWebModule(modules);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ConfigurationCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ConfigurationCommand.java
deleted file mode 100644
index 8dcc1422a..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ConfigurationCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.AbstractOperation;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-/**
- * Configuration command.
- */
-public abstract class ConfigurationCommand extends AbstractOperation {
- protected ITomcatConfigurationWorkingCopy configuration;
-
- /**
- * ConfigurationCommand constructor comment.
- *
- * @param configuration a Tomcat configuration
- * @param label a label
- */
- public ConfigurationCommand(ITomcatConfigurationWorkingCopy configuration, String label) {
- super(label);
- this.configuration = configuration;
- }
-
- public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- return execute(monitor, info);
- }
-
- public abstract void execute();
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- execute();
- return null;
- }
-
- public abstract void undo();
-
- public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- undo();
- return null;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/FixModuleContextRootTask.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/FixModuleContextRootTask.java
deleted file mode 100644
index e123cfc69..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/FixModuleContextRootTask.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jst.server.tomcat.core.internal.*;
-import org.eclipse.osgi.util.NLS;
-
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.TaskModel;
-import org.eclipse.wst.server.core.model.PublishOperation;
-/**
- * Task to fix a context root on a web module.
- */
-public class FixModuleContextRootTask extends PublishOperation {
- protected int index;
- protected WebModule module;
- protected IModule webModule;
- protected String contextRoot;
- protected int kind;
-
- /**
- * FixModuleContextRootTask constructor.
- *
- * @param webModule
- * @param index
- * @param contextRoot
- * @param kind
- */
- public FixModuleContextRootTask(IModule webModule, int index, String contextRoot, int kind) {
- super(NLS.bind(Messages.fixModuleContextRoot, webModule.getName()), Messages.fixModuleContextRootDescription);
- this.webModule = webModule;
- this.index = index;
- this.contextRoot = contextRoot;
- this.kind = kind;
- }
-
- /**
- * Execute the command.
- *
- * @param monitor a progress monitor
- * @param info
- * @throws CoreException
- */
- public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException {
- IServerWorkingCopy wc = null;
- IServer server2 = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
- if (server2 instanceof IServerWorkingCopy)
- wc = (IServerWorkingCopy) server2;
- else
- wc = server2.createWorkingCopy();
-
- TomcatServer server = (TomcatServer) wc.loadAdapter(TomcatServer.class, monitor);
- TomcatConfiguration configuration = server.getTomcatConfiguration();
- if (configuration.getWebModules().size() <= index)
- return;
- module = (WebModule) configuration.getWebModules().get(index);
- if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0)
- contextRoot = "/" + contextRoot;
- if (!contextRoot.equals(module.getPath())) {
- configuration.modifyWebModule(index, module.getDocumentBase(), contextRoot, module.isReloadable());
- wc.save(true, monitor);
- }
- }
-
- public int getKind() {
- return kind;
- }
-
- public int getOrder() {
- return 0;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyMimeMappingCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyMimeMappingCommand.java
deleted file mode 100644
index 34aa15f60..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyMimeMappingCommand.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.MimeMapping;
-/**
- * Command to change a mime type extension.
- */
-public class ModifyMimeMappingCommand extends ConfigurationCommand {
- protected int index;
- protected MimeMapping oldMap;
- protected MimeMapping newMap;
-
- /**
- * A command to modify a mime mapping.
- *
- * @param configuration a tomcat configuration
- * @param index an index
- * @param map a mime mapping
- */
- public ModifyMimeMappingCommand(ITomcatConfigurationWorkingCopy configuration, int index, MimeMapping map) {
- super(configuration, Messages.configurationEditorActionModifyMimeMapping);
- this.index = index;
- newMap = map;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldMap = (MimeMapping) configuration.getMimeMappings().get(index);
- configuration.modifyMimeMapping(index, newMap);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.modifyMimeMapping(index, oldMap);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyPortCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyPortCommand.java
deleted file mode 100644
index 10ed13a7b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyPortCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import java.util.Iterator;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.wst.server.core.ServerPort;
-/**
- * Command to change the configuration port.
- */
-public class ModifyPortCommand extends ConfigurationCommand {
- protected String id;
- protected int port;
- protected int oldPort;
-
- /**
- * ModifyPortCommand constructor.
- *
- * @param configuration a Tomcat configuration
- * @param id a port id
- * @param port new port number
- */
- public ModifyPortCommand(ITomcatConfigurationWorkingCopy configuration, String id, int port) {
- super(configuration, Messages.configurationEditorActionModifyPort);
- this.id = id;
- this.port = port;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- // find old port number
- Iterator iterator = configuration.getServerPorts().iterator();
- while (iterator.hasNext()) {
- ServerPort temp = (ServerPort) iterator.next();
- if (id.equals(temp.getId()))
- oldPort = temp.getPort();
- }
-
- // make the change
- configuration.modifyServerPort(id, port);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.modifyServerPort(id, oldPort);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyWebModuleCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyWebModuleCommand.java
deleted file mode 100644
index 69c3ffd49..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ModifyWebModuleCommand.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.WebModule;
-/**
- * Command to change a web module.
- */
-public class ModifyWebModuleCommand extends ConfigurationCommand {
- protected int index;
- protected WebModule oldModule;
- protected WebModule newModule;
-
- public ModifyWebModuleCommand(ITomcatConfigurationWorkingCopy configuration, int index, WebModule module) {
- super(configuration, Messages.configurationEditorActionModifyWebModule);
- this.index = index;
- newModule = module;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldModule = (WebModule) configuration.getWebModules().get(index);
- configuration.modifyWebModule(index, newModule.getDocumentBase(), newModule.getPath(), newModule.isReloadable());
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.modifyWebModule(index, oldModule.getDocumentBase(), oldModule.getPath(), oldModule.isReloadable());
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveMimeMappingCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveMimeMappingCommand.java
deleted file mode 100644
index d8c27583a..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveMimeMappingCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.MimeMapping;
-/**
- * Command to remove a mime mapping.
- */
-public class RemoveMimeMappingCommand extends ConfigurationCommand {
- protected int index;
- protected MimeMapping mapping;
-
- /**
- * RemoveMimeMappingCommand constructor.
- *
- * @param configuration a tomcat configuration
- * @param index an index
- */
- public RemoveMimeMappingCommand(ITomcatConfigurationWorkingCopy configuration, int index) {
- super(configuration, Messages.configurationEditorActionRemoveMimeMapping);
- this.index = index;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- mapping = (MimeMapping) configuration.getMimeMappings().get(index);
- configuration.removeMimeMapping(index);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.addMimeMapping(index, mapping);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveModuleCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveModuleCommand.java
deleted file mode 100644
index df51f2713..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveModuleCommand.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.AbstractOperation;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-/**
- * Command to remove a web module from a server.
- */
-public class RemoveModuleCommand extends AbstractOperation {
- protected IServerWorkingCopy server;
- protected IModule module;
-
- /**
- * AddModuleCommand constructor comment.
- *
- * @param server a server
- * @param module a web module
- */
- public RemoveModuleCommand(IServerWorkingCopy server, IModule module) {
- super(Messages.configurationEditorActionRemoveWebModule);
- this.server = server;
- this.module = module;
- }
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- server.modifyModules(null, new IModule[] { module }, monitor);
- } catch (Exception e) {
- // ignore
- }
- return Status.OK_STATUS;
- }
-
- public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- return execute(monitor, info);
- }
-
- public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- server.modifyModules(new IModule[] { module }, null, monitor);
- } catch (Exception e) {
- // ignore
- }
- return Status.OK_STATUS;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveWebModuleCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveWebModuleCommand.java
deleted file mode 100644
index 3849d1ca9..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/RemoveWebModuleCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.WebModule;
-/**
- * Command to remove a web module.
- */
-public class RemoveWebModuleCommand extends ConfigurationCommand {
- protected int index;
- protected WebModule module;
-
- /**
- * RemoveWebModuleCommand constructor comment.
- *
- * @param configuration a tomcat configuration
- * @param index an index
- */
- public RemoveWebModuleCommand(ITomcatConfigurationWorkingCopy configuration, int index) {
- super(configuration, Messages.configurationEditorActionRemoveWebModule);
- this.index = index;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- module = (WebModule) configuration.getWebModules().get(index);
- configuration.removeWebModule(index);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.addWebModule(index, module);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ServerCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ServerCommand.java
deleted file mode 100644
index 56e8ad2c3..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/ServerCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.AbstractOperation;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatServerWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.TomcatServer;
-/**
- * A command on a Tomcat server.
- */
-public abstract class ServerCommand extends AbstractOperation {
- protected TomcatServer server;
-
- /**
- * ServerCommand constructor comment.
- *
- * @param server a Tomcat server
- * @param label a label
- */
- public ServerCommand(ITomcatServerWorkingCopy server, String label) {
- super(label);
- this.server = (TomcatServer) server;
- }
-
- public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- return execute(monitor, info);
- }
-
- public abstract void execute();
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- execute();
- return null;
- }
-
- public abstract void undo();
-
- public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- undo();
- return null;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetDebugModeCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetDebugModeCommand.java
deleted file mode 100644
index 02b56c44f..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetDebugModeCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatServerWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-/**
- * Command to change the server debug mode.
- */
-public class SetDebugModeCommand extends ServerCommand {
- protected boolean debug;
- protected boolean oldDebug;
-
- /**
- * SetDebugModeCommand constructor comment.
- *
- * @param server a Tomcat server
- * @param debug <code>true</code> for debug mode
- */
- public SetDebugModeCommand(ITomcatServerWorkingCopy server, boolean debug) {
- super(server, Messages.serverEditorActionSetDebugMode);
- this.debug = debug;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldDebug = server.isDebug();
- server.setDebug(debug);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- server.setDebug(oldDebug);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetSecureCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetSecureCommand.java
deleted file mode 100644
index e15429f01..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetSecureCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatServerWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-/**
- * Command to change the server security option.
- */
-public class SetSecureCommand extends ServerCommand {
- protected boolean secure;
- protected boolean oldSecure;
-
- /**
- * SetSecureCommand constructor comment.
- *
- * @param server a Tomcat server
- * @param secure <code>true</code> for security on
- */
- public SetSecureCommand(ITomcatServerWorkingCopy server, boolean secure) {
- super(server, Messages.serverEditorActionSetSecure);
- this.secure = secure;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldSecure = server.isSecure();
- server.setSecure(secure);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- server.setSecure(oldSecure);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetTestEnvironmentCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetTestEnvironmentCommand.java
deleted file mode 100644
index a2b48afe0..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetTestEnvironmentCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatServerWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-/**
- * Command to change the server debug mode.
- */
-public class SetTestEnvironmentCommand extends ServerCommand {
- protected boolean te;
- protected boolean oldTe;
-
- /**
- * SetTestEnvironmentCommand constructor comment.
- *
- * @param server a Tomcat server
- * @param te <code>true</code> for a test environment.
- */
- public SetTestEnvironmentCommand(ITomcatServerWorkingCopy server, boolean te) {
- super(server, Messages.serverEditorActionSetTestEnvironment);
- this.te = te;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldTe = server.isTestEnvironment();
- server.setTestEnvironment(te);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- server.setTestEnvironment(oldTe);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetWebModulePathCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetWebModulePathCommand.java
deleted file mode 100644
index e40f1daa7..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetWebModulePathCommand.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.command;
-
-import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.WebModule;
-/**
- * Command to modify the path of a Web module.
- */
-public class SetWebModulePathCommand extends ConfigurationCommand {
- protected int index;
- protected WebModule oldModule;
- protected String path;
-
- /**
- * SetWebModulePathCommand constructor comment.
- *
- * @param configuration a tomcat configuration
- * @param index an index
- * @param contextRoot the context root
- */
- public SetWebModulePathCommand(ITomcatConfigurationWorkingCopy configuration, int index, String contextRoot) {
- super(configuration, Messages.configurationEditorActionEditWebModulePath);
- this.index = index;
- this.path = contextRoot;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldModule = (WebModule) configuration.getWebModules().get(index);
- configuration.removeWebModule(index);
-
- WebModule module = new WebModule(path, oldModule.getDocumentBase(), oldModule.getMemento(), oldModule.isReloadable());
- configuration.addWebModule(index, module);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- configuration.removeWebModule(index);
- configuration.addWebModule(index, oldModule);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java
deleted file mode 100644
index 36bdbaac1..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml;
-
-import java.io.*;
-
-import org.w3c.dom.*;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.eclipse.jst.server.tomcat.core.internal.Trace;
-/**
- * Factory for reading and writing from XML files.
- */
-public class Factory {
- protected String packageName;
- protected Document document;
-
- public Factory() {
- // do nothing
- }
-
- protected Attr createAttribute(String s, Element element) {
- Attr attr = document.createAttribute(s);
- element.setAttributeNode(attr);
- return attr;
- }
-
- protected XMLElement createElement(int index, String s, Node node) {
- if (index < 0)
- return createElement(s, node);
-
- Element element = document.createElement(s);
- try {
- Node child = node.getFirstChild();
- for (int i = 0; i < index; i++)
- child = child.getNextSibling();
-
- node.insertBefore(element, child);
- } catch (Exception e) {
- node.appendChild(element);
- }
- return newInstance(element);
- }
-
- protected XMLElement createElement(String s, Node node) {
- Element element = document.createElement(s);
- node.appendChild(element);
- return newInstance(element);
- }
-
- public byte[] getContents() throws IOException {
- return XMLUtil.getContents(document);
- }
-
- /**
- *
- * @return org.w3c.dom.Document
- */
- public Document getDocument() {
- return document;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public XMLElement loadDocument(InputStream in) throws IOException, SAXException {
- try {
- document = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- Element element = document.getDocumentElement();
- return newInstance(element);
- } catch (IllegalArgumentException exception) {
- Trace.trace(Trace.WARNING, "Error loading document", exception);
- throw new IOException("Could not load document");
- }
- }
-
- protected XMLElement newInstance(Element element) {
- String s = element.getNodeName();
- try {
- // change "web-app:test" to "WebAppTest"
- s = s.substring(0, 1).toUpperCase() + s.substring(1);
- int i = s.indexOf("-");
- while (i >= 0) {
- s = s.substring(0, i) + s.substring(i+1, i+2).toUpperCase() + s.substring(i+2);
- i = s.indexOf("-");
- }
- i = s.indexOf(":");
- while (i >= 0) {
- s = s.substring(0, i) + s.substring(i+1, i+2).toUpperCase() + s.substring(i+2);
- i = s.indexOf(":");
- }
-
- // add package name
- if (packageName != null)
- s = packageName + "." + s;
- Class class1 = Class.forName(s);
-
- XMLElement xmlElement = (XMLElement) class1.newInstance();
- xmlElement.setElement(element);
- xmlElement.setFactory(this);
- return xmlElement;
- } catch (Exception exception) {
- // ignore
- }
- return null;
- }
-
- public void save(String filename) throws IOException {
- XMLUtil.save(filename, document);
- }
-
- public void setDocument(Document d) {
- document = d;
- }
-
- public void setPackageName(String s) {
- packageName = s;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLElement.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLElement.java
deleted file mode 100644
index b14c15fe2..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLElement.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.w3c.dom.*;
-/**
- * An XML element.
- */
-public class XMLElement {
- private Element xmlElement;
- protected Factory factory;
-
- public XMLElement() {
- // do nothing
- }
-
- public Attr addAttribute(String s, String s1) {
- Attr attr = factory.createAttribute(s, xmlElement);
- attr.setValue(s1);
- return attr;
- }
-
- public XMLElement createElement(int index, String s) {
- return factory.createElement(index, s, xmlElement);
- }
-
- public XMLElement createElement(String s) {
- return factory.createElement(s, xmlElement);
- }
-
- public XMLElement findElement(String s) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int i = nodelist == null ? 0 : nodelist.getLength();
- for (int j = 0; j < i; j++) {
- Node node = nodelist.item(j);
- String s1 = node.getNodeName().trim();
- if (s1.equals(s))
- return factory.newInstance((Element) node);
- }
-
- return createElement(s);
- }
-
- public XMLElement findElement(String s, int i) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int j = nodelist == null ? 0 : nodelist.getLength();
- for (int k = 0; k < j; k++) {
- Node node = nodelist.item(k);
- String s1 = node.getNodeName().trim();
- if (s1.equals(s) && k == i)
- return factory.newInstance((Element) node);
- }
-
- return createElement(s);
- }
-
- public String getAttributeValue(String s) {
- Attr attr = xmlElement.getAttributeNode(s);
- if (attr != null)
- return attr.getValue();
-
- return null;
- }
-
- public Map getAttributes() {
- Map attributes = new LinkedHashMap();
- NamedNodeMap attrs = xmlElement.getAttributes();
- if (null != attrs) {
- for (int i = 0; i < attrs.getLength(); i++) {
- Node attr = attrs.item(i);
- String name = attr.getNodeName();
- String value = attr.getNodeValue();
- attributes.put(name, value);
- }
- }
- return attributes;
- }
-
- public String getElementName() {
- return xmlElement.getNodeName();
- }
-
- public String getElementValue() {
- return getElementValue(xmlElement);
- }
-
- protected static String getElementValue(Element element) {
- String s = element.getNodeValue();
- if (s != null)
- return s;
- NodeList nodelist = element.getChildNodes();
- for (int i = 0; i < nodelist.getLength(); i++)
- if (nodelist.item(i) instanceof Text)
- return ((Text) nodelist.item(i)).getData();
-
- return null;
- }
-
- public Element getSubElement(String s) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int i = nodelist == null ? 0 : nodelist.getLength();
- for (int j = 0; j < i; j++) {
- Node node = nodelist.item(j);
- String s1 = node.getNodeName().trim();
- if (s1.equals(s))
- return (Element) node;
- }
-
- return null;
- }
-
- public String getSubElementValue(String s) {
- Element element = getSubElement(s);
- if (element == null)
- return null;
-
- String value = getElementValue(element);
- if (value == null)
- return null;
-
- return value.trim();
- }
-
- public boolean removeAttribute(String s) {
- try {
- xmlElement.removeAttribute(s);
- return true;
- } catch (Exception ex) {
- return false;
- }
- }
-
- public boolean removeElement(String s, int i) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int j = nodelist == null ? 0 : nodelist.getLength();
- for (int k = 0; k < j; k++) {
- Node node = nodelist.item(k);
- String s1 = node.getNodeName().trim();
- if (s1.equals(s) && k == i) {
- xmlElement.removeChild(node);
- return true;
- }
- }
-
- return false;
- }
-
- public void setAttributeValue(String s, String s1) {
- Attr attr = xmlElement.getAttributeNode(s);
- if (attr == null)
- attr = addAttribute(s, s1);
- else
- attr.setValue(s1);
- }
-
- void setElement(Element element) {
- xmlElement = element;
- }
-
- protected static void setElementValue(Element element, String value) {
- String s = element.getNodeValue();
- if (s != null) {
- element.setNodeValue(value);
- return;
- }
- NodeList nodelist = element.getChildNodes();
- for (int i = 0; i < nodelist.getLength(); i++)
- if (nodelist.item(i) instanceof Text) {
- Text text = (Text) nodelist.item(i);
- text.setData(value);
- return;
- }
-
- return;
- }
-
- void setFactory(Factory factory1) {
- factory = factory1;
- }
-
- public void setSubElementValue(String s, String value) {
- Element element = getSubElement(s);
- if (element == null) {
- element = factory.document.createElement(s);
- element.appendChild(factory.document.createTextNode("temp"));
- xmlElement.appendChild(element);
- }
- setElementValue(element, value);
- }
-
- public int sizeOfElement(String s) {
- NodeList nodelist = xmlElement.getElementsByTagName(s);
- int i = nodelist == null ? 0 : nodelist.getLength();
- return i;
- }
-
- public void updateElementValue(String s) {
- try {
- xmlElement.setNodeValue(s);
- } catch (DOMException ex) {
- NodeList nodelist = xmlElement.getChildNodes();
- int i = nodelist == null ? 0 : nodelist.getLength();
- if (i > 0) {
- for (int j = 0; j < i; j++)
- if (nodelist.item(j) instanceof Text) {
- ((Text) nodelist.item(j)).setData(s);
- return;
- }
- } else {
- xmlElement.appendChild(factory.document.createTextNode(s));
- }
- }
- }
-
- public boolean hasChildNodes() {
- return xmlElement.hasChildNodes();
- }
-
- public void removeChildren()
- {
- while (xmlElement.hasChildNodes()) {
- xmlElement.removeChild(xmlElement.getFirstChild());
- }
- }
-
- public void copyChildrenTo(XMLElement destination) {
- NodeList nodelist = xmlElement.getChildNodes();
- int len = nodelist == null ? 0 : nodelist.getLength();
- for (int i = 0; i < len; i++) {
- Node node = nodelist.item(i);
- destination.importNode(node, true);
- }
- }
-
- void importNode(Node node, boolean deep) {
- xmlElement.appendChild(xmlElement.getOwnerDocument().importNode(node, deep));
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java
deleted file mode 100644
index 76d96f6e7..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml;
-
-import java.io.*;
-import java.util.*;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.eclipse.jst.server.tomcat.core.internal.Trace;
-import org.w3c.dom.*;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-/**
- * Utility class to create and read XML documents.
- */
-public class XMLUtil {
- private static DocumentBuilder documentBuilder;
-
- /**
- * XMLUtil constructor comment.
- */
- public XMLUtil() {
- super();
- }
-
- public static DocumentBuilder getDocumentBuilder() {
- if (documentBuilder == null)
- try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(false);
- factory.setExpandEntityReferences(false);
- //factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd", new Boolean(false));
- documentBuilder = factory.newDocumentBuilder();
- documentBuilder.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- return new InputSource(new ByteArrayInputStream(new byte[0]));
- }
- });
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Rrror creating document builder");
- }
-
- return documentBuilder;
- }
-
- /**
- * Create a child of the given node at the given index.
- *
- * @param doc a document
- * @param element an element
- * @param index an index
- * @param nodeName a node name
- * @return org.w3c.dom.Element
- */
- public static Element createChildElement(Document doc, Element element, int index, String nodeName) {
- Element element2 = doc.createElement(nodeName);
- try {
- NodeList childList = element.getElementsByTagName(nodeName);
- Node child = childList.item(index);
- element.insertBefore(element2, child);
- } catch (Exception e) {
- element.appendChild(element2);
- }
- return element2;
- }
-
- /**
- * Create a child of the given node.
- *
- * @param doc a document
- * @param node a node
- * @param nodeName a node name
- * @return org.w3c.dom.Element
- */
- public static Element createChildElement(Document doc, Node node, String nodeName) {
- Element element = doc.createElement(nodeName);
- node.appendChild(element);
- return element;
- }
-
- /*
- * Set the value of the given node to the given text.
- */
- public static void createTextChildElement(Document doc, Node node, String name, String value) {
- Element element = createChildElement(doc, node, name);
- element.appendChild(doc.createTextNode(value));
- }
-
- /**
- * Return the attribute value.
- * @return java.lang.String
- * @param element org.w3c.dom.Element
- * @param attr java.lang.String
- */
- public static String getAttributeValue(Element element, String attr) {
- return element.getAttributeNode(attr).getValue();
- }
-
- public static byte[] getContents(Document document) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try {
- print(new PrintStream(out, true, "UTF-8"), document);
- return out.toByteArray();
- } catch (Exception ex) {
- throw new IOException(ex.getLocalizedMessage());
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
-
- protected static String getDocumentTypeData(DocumentType doctype) {
- String data = doctype.getName();
- if (doctype.getPublicId() != null) {
- data += " PUBLIC \"" + doctype.getPublicId() + "\"";
- String systemId = doctype.getSystemId();
- if (systemId == null)
- systemId = "";
- data += " \"" + systemId + "\"";
- } else
- data += " SYSTEM \"" + doctype.getSystemId() + "\"";
-
- return data;
- }
-
- /**
- * Return an iterator for the subelements.
- * @return java.util.Iterator
- * @param element org.w3c.dom.Element
- * @param name java.lang.String
- */
- public static Iterator getNodeIterator(Element element, String name) {
- List list = new ArrayList();
- NodeList nodeList = element.getElementsByTagName(name);
-
- int length = nodeList.getLength();
- for (int i = 0; i < length; i++)
- list.add(nodeList.item(i));
-
- return list.iterator();
- }
-
- /**
- * Get the value of this node. Will return "" instead of null.
- * @return java.lang.String
- * @param node org.w3c.dom.Node
- */
- public static String getNodeValue(Node node) {
- NodeList nodeList = node.getChildNodes();
-
- int length = nodeList.getLength();
- for (int i = 0; i < length; i++) {
- Node n = nodeList.item(i);
- if (n instanceof Text) {
- Text t = (Text) n;
- return t.getNodeValue();
- }
- }
- return "";
- }
-
- /*
- * Get the value of a subnode.
-
- * @return java.lang.String
- */
- public static String getSubNodeValue(Element element, String name) {
- NodeList nodeList = element.getElementsByTagName(name);
- return getNodeValue(nodeList.item(0)).trim();
- }
-
- /*
- * Insert the given text.
- */
- public static void insertText(Document doc, Node node, String text) {
- node.appendChild(doc.createCDATASection(text));
- }
-
- protected static String normalize(String s) {
- StringBuffer stringbuffer = new StringBuffer();
- int i = s == null ? 0 : s.length();
- for (int j = 0; j < i; j++) {
- char c = s.charAt(j);
- switch (c) {
- case 60 : /* '<' */
- stringbuffer.append("&lt;");
- break;
-
- case 62 : /* '>' */
- stringbuffer.append("&gt;");
- break;
-
- case 38 : /* '&' */
- stringbuffer.append("&amp;");
- break;
-
- case 34 : /* '"' */
- stringbuffer.append("&quot;");
- break;
-
- case 10 : /* '\n' */
- case 13 : /* '\r' */
- default :
- stringbuffer.append(c);
- break;
-
- }
- }
-
- return stringbuffer.toString();
- }
-
- protected static void print(PrintStream out, Node node) {
- if (node == null)
- return;
- short type = node.getNodeType();
- switch (type) {
- case Node.DOCUMENT_NODE: {
- out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- //out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
- NodeList nodelist = node.getChildNodes();
- int size = nodelist.getLength();
- for (int i = 0; i < size; i++)
- print(out, nodelist.item(i));
- break;
- }
-
- case Node.DOCUMENT_TYPE_NODE: {
- DocumentType docType = (DocumentType) node;
- out.print("<!DOCTYPE " + getDocumentTypeData(docType) + ">\n");
- break;
- }
-
- case Node.ELEMENT_NODE: {
- out.print('<');
- out.print(node.getNodeName());
- NamedNodeMap map = node.getAttributes();
- if (map != null) {
- int size = map.getLength();
- for (int i = 0; i < size; i++) {
- Attr attr = (Attr) map.item(i);
- out.print(' ');
- out.print(attr.getNodeName());
- out.print("=\"");
- out.print(normalize(attr.getNodeValue()));
- out.print('"');
- }
- }
-
- if (!node.hasChildNodes())
- out.print("/>");
- else {
- out.print('>');
- NodeList nodelist = node.getChildNodes();
- int numChildren = nodelist.getLength();
- for (int i = 0; i < numChildren; i++)
- print(out, nodelist.item(i));
-
- out.print("</");
- out.print(node.getNodeName());
- out.print('>');
- }
- break;
- }
-
- case Node.ENTITY_REFERENCE_NODE: {
- NodeList nodelist = node.getChildNodes();
- if (nodelist != null) {
- int size = nodelist.getLength();
- for (int i = 0; i < size; i++)
- print(out, nodelist.item(i));
-
- }
- break;
- }
-
- case Node.CDATA_SECTION_NODE: {
- out.print(normalize(node.getNodeValue()));
- break;
- }
-
- case Node.TEXT_NODE: {
- out.print(normalize(node.getNodeValue()));
- break;
- }
-
- case Node.PROCESSING_INSTRUCTION_NODE: {
- out.print("<?");
- out.print(node.getNodeName());
- String s = node.getNodeValue();
- if (s != null && s.length() > 0) {
- out.print(' ');
- out.print(s);
- }
- out.print("?>");
- break;
- }
-
- case Node.COMMENT_NODE: {
- out.print("<!--");
- out.print(node.getNodeValue());
- out.print("-->");
- break;
- }
-
- default: {
- out.print(normalize(node.getNodeValue()));
- break;
- }
- }
- out.flush();
- }
-
- public static void save(String filename, Document document) throws IOException {
- PrintStream out = null;
- try {
- out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)), true, "UTF-8");
- //traceNode(document, "");
- print(out, document);
- } catch (Exception ex) {
- throw new IOException(ex.getLocalizedMessage());
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
-
- /*
- * Set the value of the subnode
- *
- * @param name java.lang.String
- * @param value java.lang.String
- */
- public static void setNodeValue(Node node, String name, String value) {
- String s = node.getNodeValue();
- if (s != null) {
- node.setNodeValue(value);
- return;
- }
- NodeList nodelist = node.getChildNodes();
- for (int i = 0; i < nodelist.getLength(); i++) {
- if (nodelist.item(i) instanceof Text) {
- Text text = (Text) nodelist.item(i);
- text.setData(value);
- return;
- }
- }
- return;
- }
-
- public static String toString(Document document) {
- PrintStream out = null;
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
- out = new PrintStream(baos);
- print(out, document);
- return new String(baos.toByteArray(), "UTF-8");
- } catch (Exception ex) {
- // ignore
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Connector.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Connector.java
deleted file mode 100644
index a0324f245..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Connector.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server32;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Connector extends XMLElement {
- public Connector() {
- // do nothing
- }
-
- public String getClassName() {
- return getAttributeValue("className");
- }
-
- public Parameter getParameter(int index) {
- return (Parameter) findElement("Parameter", index);
- }
-
- public int getParameterCount() {
- return sizeOfElement("Parameter");
- }
-
- public void setClassName(String className) {
- setAttributeValue("className", className);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Context.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Context.java
deleted file mode 100644
index b5568e8db..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Context.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server32;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Context extends XMLElement {
- public Context() {
- // do nothing
- }
-
- public String getCrossContext() {
- return getAttributeValue("crossContext");
- }
-
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- public String getDocBase() {
- return getAttributeValue("docBase");
- }
-
- public String getPath() {
- return getAttributeValue("path");
- }
-
- public String getReloadable() {
- return getAttributeValue("reloadable");
- }
-
- public String getSource() {
- return getAttributeValue("source");
- }
-
- public String getTrusted() {
- return getAttributeValue("trusted");
- }
-
- public void setCrossContext(String crossContext) {
- setAttributeValue("crossContext", crossContext);
- }
-
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-
- public void setDocBase(String docBase) {
- setAttributeValue("docBase", docBase);
- }
-
- public void setPath(String path) {
- setAttributeValue("path", path);
- }
-
- public void setReloadable(String reloadable) {
- setAttributeValue("reloadable", reloadable);
- }
-
- public void setSource(String source) {
- setAttributeValue("source", source);
- }
-
- public void setTrusted(String trusted) {
- setAttributeValue("trusted", trusted);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/ContextManager.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/ContextManager.java
deleted file mode 100644
index e7829d12f..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/ContextManager.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server32;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class ContextManager extends XMLElement {
- public ContextManager() {
- // do nothing
- }
-
- public Connector getConnector(int index) {
- return (Connector) findElement("Connector", index);
- }
-
- public int getConnectorCount() {
- return sizeOfElement("Connector");
- }
-
- public Context getContext(int index) {
- return (Context) findElement("Context", index);
- }
-
- public int getContextCount() {
- return sizeOfElement("Context");
- }
-
- public int getContextInterceptorCount() {
- return sizeOfElement("ContextInterceptor");
- }
-
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- public String getHome() {
- return getAttributeValue("home");
- }
-
- public int getRequestInterceptorCount() {
- return sizeOfElement("RequestInterceptor");
- }
-
- public String getShowDebugInfo() {
- return getAttributeValue("showDebugInfo");
- }
-
- public String getWorkDir() {
- return getAttributeValue("workDir");
- }
-
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-
- public void setHome(String home) {
- setAttributeValue("home", home);
- }
-
- public void setShowDebugInfo(String showDebugInfo) {
- setAttributeValue("showDebugInfo", showDebugInfo);
- }
-
- public void setWorkDir(String workDir) {
- setAttributeValue("workDir", workDir);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Parameter.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Parameter.java
deleted file mode 100644
index 1608cf186..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Parameter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server32;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Parameter extends XMLElement {
- public Parameter() {
- // do nothing
- }
-
- public String getName() {
- return getAttributeValue("name");
- }
-
- public String getValue() {
- return getAttributeValue("value");
- }
-
- public void setName(String name) {
- setAttributeValue("name", name);
- }
-
- public void setValue(String value) {
- setAttributeValue("value", value);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Server.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Server.java
deleted file mode 100644
index 5d8cdd0a7..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/Server.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server32;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Server extends XMLElement {
- public Server() {
- // do nothing
- }
-
- public ContextManager getContextManager() {
- return (ContextManager) findElement("ContextManager");
- }
-
- public int getLoggerCount() {
- return sizeOfElement("Logger");
- }
-
- public String getName() {
- return getAttributeValue("name");
- }
-
- public void setName(String name) {
- setAttributeValue("name", name);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Connector.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Connector.java
deleted file mode 100644
index 79bf6c93a..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Connector.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Connector extends XMLElement {
- public Connector() {
- // do nothing
- }
-
- public String getAcceptCount() {
- return getAttributeValue("acceptCount");
- }
-
- public String getClassName() {
- return getAttributeValue("className");
- }
-
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- public String getMaxProcessors() {
- return getAttributeValue("maxProcessors");
- }
-
- public String getMinProcessors() {
- return getAttributeValue("minProcessors");
- }
-
- public String getPort() {
- return getAttributeValue("port");
- }
-
- public String getSecure() {
- return getAttributeValue("secure");
- }
-
- public String getProtocol() {
- return getAttributeValue("protocol");
- }
-
- public String getProtocolHandlerClassName() {
- return getAttributeValue("protocolHandlerClassName");
- }
-
- public void setAcceptCount(String acceptCount) {
- setAttributeValue("acceptCount", acceptCount);
- }
-
- public void setClassName(String className) {
- setAttributeValue("className", className);
- }
-
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-
- public void setMaxProcessors(String maxProcessors) {
- setAttributeValue("maxProcessors", maxProcessors);
- }
-
- public void setMinProcessors(String minProcessors) {
- setAttributeValue("minProcessors", minProcessors);
- }
-
- public void setPort(String port) {
- setAttributeValue("port", port);
- }
-
- public void setProtocolHandlerClassName(String protocolHandlerClassName) {
- setAttributeValue("protocolHandlerClassName", protocolHandlerClassName);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Context.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Context.java
deleted file mode 100644
index b597c8984..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Context.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Context extends XMLElement {
- public Context() {
- // do nothing
- }
-
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- public String getDocBase() {
- return getAttributeValue("docBase");
- }
-
- public String getPath() {
- return getAttributeValue("path");
- }
-
- public String getReloadable() {
- return getAttributeValue("reloadable");
- }
-
- public String getSource() {
- return getAttributeValue("source");
- }
-
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-
- public void setDocBase(String docBase) {
- setAttributeValue("docBase", docBase);
- }
-
- public void setPath(String path) {
- setAttributeValue("path", path);
- }
-
- public void setReloadable(String reloadable) {
- setAttributeValue("reloadable", reloadable);
- }
-
- public void setSource(String source) {
- setAttributeValue("source", source);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Engine.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Engine.java
deleted file mode 100644
index 166ce0bc2..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Engine.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Engine extends XMLElement {
- public Engine() {
- // do nothing
- }
-
- public String getAppBase() {
- return getAttributeValue("appBase");
- }
-
- public String getClassName() {
- return getAttributeValue("className");
- }
-
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- public String getDefaultHost() {
- return getAttributeValue("defaultHost");
- }
-
- public Host getHost() {
- return (Host) findElement("Host");
- }
-
- public String getName() {
- return getAttributeValue("name");
- }
-
- public void setAppBase(String appBase) {
- setAttributeValue("appBase", appBase);
- }
-
- public void setClassName(String className) {
- setAttributeValue("className", className);
- }
-
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-
- public void setDefaultHost(String defaultHost) {
- setAttributeValue("defaultHost", defaultHost);
- }
-
- public void setName(String name) {
- setAttributeValue("name", name);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Host.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Host.java
deleted file mode 100644
index dc91098ab..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Host.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Host extends XMLElement {
- public Host() {
- // do nothing
- }
-
- public String getAppBase() {
- return getAttributeValue("appBase");
- }
-
- public Context getContext(int index) {
- return (Context) findElement("Context", index);
- }
-
- public int getContextCount() {
- return sizeOfElement("Context");
- }
-
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- public String getName() {
- return getAttributeValue("name");
- }
-
- public void setAppBase(String appBase) {
- setAttributeValue("appBase", appBase);
- }
-
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-
- public void setName(String name) {
- setAttributeValue("name", name);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Listener.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Listener.java
deleted file mode 100644
index 97378bc47..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Listener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Listener extends XMLElement {
- public Listener() {
- // do nothing
- }
-
- public String getClassName() {
- return getAttributeValue("className");
- }
-
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- public void setClassName(String className) {
- setAttributeValue("className", className);
- }
-
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Server.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Server.java
deleted file mode 100644
index 097111d4e..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Server.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Server extends XMLElement {
- public Server() {
- // do nothing
- }
-
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- public String getName() {
- return getAttributeValue("name");
- }
-
- public String getPort() {
- return getAttributeValue("port");
- }
-
- public Service getService(int index) {
- return (Service) findElement("Service", index);
- }
-
- public int getServiceCount() {
- return sizeOfElement("Service");
- }
-
- public String getShutdown() {
- return getAttributeValue("shutdown");
- }
-
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-
- public void setName(String name) {
- setAttributeValue("name", name);
- }
-
- public void setPort(String port) {
- setAttributeValue("port", port);
- }
-
- public void setShutdown(String shutdown) {
- setAttributeValue("shutdown", shutdown);
- }
-
- public Listener getListener(int index) {
- return (Listener) findElement("Listener", index);
- }
-
- public int getListenerCount() {
- return sizeOfElement("Listener");
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Service.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Service.java
deleted file mode 100644
index cc24a4ad7..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Service.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.*;
-/**
- *
- */
-public class Service extends XMLElement {
- public Service() {
- // do nothing
- }
-
- public Connector getConnector(int index) {
- return (Connector) findElement("Connector", index);
- }
-
- public int getConnectorCount() {
- return sizeOfElement("Connector");
- }
-
- public Engine getEngine() {
- return (Engine) findElement("Engine");
- }
-
- public String getName() {
- return getAttributeValue("name");
- }
-
- public void setName(String name) {
- setAttributeValue("name", name);
- }
-} \ No newline at end of file

Back to the top