Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorndai2012-04-17 16:09:47 +0000
committerndai2012-04-17 16:09:47 +0000
commit1c49b99e2745ea2edbf2f19db2103c0cabee9209 (patch)
treea6ef8e69b6f0a9e4b80010f9a051bc24d85b11fe /plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org
parent878ce71b06159ea72427988c46f6d99571befef5 (diff)
downloadwebtools.servertools-1c49b99e2745ea2edbf2f19db2103c0cabee9209.tar.gz
webtools.servertools-1c49b99e2745ea2edbf2f19db2103c0cabee9209.tar.xz
webtools.servertools-1c49b99e2745ea2edbf2f19db2103c0cabee9209.zip
This commit was manufactured by cvs2svn to create tag 'v20120417_1210'.v20120417_1210
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/CatalinaPropertiesUtil.java136
-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/ConfigurationResourceListener.java88
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/FileUtil.java249
-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.java27
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntimeWorkingCopy.java19
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServer.java89
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerBehaviour.java36
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerWorkingCopy.java65
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatVersionHandler.java180
-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.java120
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.properties126
-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.java283
-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.java768
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Handler.java198
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java578
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Handler.java193
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java614
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Handler.java187
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java675
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Handler.java200
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java710
-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/Tomcat60Configuration.java710
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Handler.java194
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Configuration.java710
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Handler.java207
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java364
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchConfigurationDelegate.java105
-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.java414
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPublishModuleVisitor.java602
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java313
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeClasspathProvider.java53
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeLocator.java118
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java551
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java1182
-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.java168
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java1253
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java107
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/VerifyResourceSpec.java92
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebAppDocument.java168
-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/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/SetDeployDirectoryCommand.java49
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetInstanceDirectoryCommand.java55
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetSaveSeparateContextFilesCommand.java48
-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/SetServeModulesWithoutPublishCommand.java48
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetTestEnvironmentCommand.java54
-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/wst/IModuleVisitor.java85
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/wst/ModuleTraverser.java600
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java139
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLElement.java384
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java415
-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/server32/ServerInstance.java298
-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.java126
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Engine.java73
-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/JarScanner.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/Loader.java70
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Resources.java71
-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/ServerInstance.java535
-rw-r--r--plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Service.java41
94 files changed, 0 insertions, 18038 deletions
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/CatalinaPropertiesUtil.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/CatalinaPropertiesUtil.java
deleted file mode 100644
index 4c96c47f0..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/CatalinaPropertiesUtil.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2011 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:
- * Igor Fedorenko & Fabrizio Giustina - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-/**
- * Utility methods for handling loaders in catalina.properties.
- */
-public class CatalinaPropertiesUtil {
-
- /**
- * Don't instantiate
- */
- private CatalinaPropertiesUtil() {
- // unused
- }
-
- /**
- * Adds a list of path elements to a specific loader in catalina.properties.
- * This method doesn't use java.util.Properties in order to keep file
- * formatting intact.
- *
- * @param file catalina.properties file
- * @param loader loader name
- * @param elements List of classpath elements
- * @throws IOException
- */
- public static void addGlobalClasspath(File file, String loader,
- String[] elements) throws IOException {
-
- String propertyName = loader + ".loader";
-
- BufferedReader br = null;
- StringBuffer buffer = new StringBuffer();
- boolean added = false;
-
- try {
- br = new BufferedReader(new FileReader(file));
- String line = br.readLine();
- while (line != null) {
-
- if (line.startsWith(propertyName)) {
- added = true;
- line = addElements(line, elements);
- }
-
- buffer.append(line);
- buffer.append("\n");
- line = br.readLine();
- }
- } finally {
- if (br != null) {
- br.close();
- }
- }
- if (!added) {
- // should never happen with an original catalina.properties,
- // but better handle also files modified by users
- buffer.append(propertyName);
- buffer.append("=");
- for (int i = 0; i < elements.length; i++) {
- buffer.append(elements[i]);
- }
- buffer.append("\n");
- }
-
- String propertyFile = buffer.toString();
-
- BufferedWriter bw = null;
- try {
- bw = new BufferedWriter(new FileWriter(file));
- bw.write(propertyFile);
- } finally {
- if (br != null) {
- bw.close();
- }
- }
- }
-
- /**
- * Append a list of path to the property at the given line and returns the
- * modified name.
- * @param line line (property=value)
- * @param elements classpath elements to add.
- * @return modified line
- */
- private static String addElements(String line, String[] elements) {
- String[] propAndValue = line.split("=");
- String loaderProperty = "";
-
- if (propAndValue.length > 1) {
- loaderProperty = propAndValue[1];
- }
-
- Set<String> classpath = new LinkedHashSet<String>();
-
- StringTokenizer st = new StringTokenizer(loaderProperty, ",");
- while (st.hasMoreTokens()) {
- classpath.add(st.nextToken());
- }
-
- for (int i = 0; i < elements.length; i++) {
- classpath.add(elements[i]);
- }
-
- StringBuffer sb = new StringBuffer();
- sb.append(propAndValue[0]);
- sb.append("=");
- for (Iterator it = classpath.iterator(); it.hasNext();) {
- sb.append(it.next());
- if (it.hasNext()) {
- sb.append(',');
- }
- }
-
- return sb.toString();
- }
-}
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/ConfigurationResourceListener.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ConfigurationResourceListener.java
deleted file mode 100644
index 2474b4ad3..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ConfigurationResourceListener.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2011 SAS Institute, Inc and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAS Institute, Inc - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.internal.ServerType;
-
-public class ConfigurationResourceListener implements IResourceChangeListener {
-
- private IProject serversProject;
-
- /**
- * Currently, only changes to Tomcat configuration files are detected and the associated
- * server's state updated. This method needs to be as brief as possible if the change
- * is unrelated to server configuration changes. Since the Servers project would change
- * so rarely, it is worth saving some cycles in the resource listener by caching this project.
- */
- public void resourceChanged(IResourceChangeEvent event) {
- if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
- IProject project = getServersProject();
- if (project != null) {
- IResourceDelta delta = event.getDelta();
- if (delta != null) {
- IResourceDelta serversProjectDelta = delta.findMember(project.getFullPath());
- if (serversProjectDelta != null) {
- // The change occurred within the Servers project.
- IResourceDelta [] childDelta = serversProjectDelta.getAffectedChildren();
- if (childDelta.length > 0) {
- IServer [] servers = ServerCore.getServers();
- for (int i = 0; i < childDelta.length; i++) {
- // Check if this subfolder of the Servers folder matches a Tomcat configuration folder
- for (int j = 0; j < servers.length; j++) {
- IServerType serverType = servers[j].getServerType();
- if (serverType.getId().startsWith("org.eclipse.jst.server.tomcat.")) {
- IFolder configFolder = servers[j].getServerConfiguration();
- if (configFolder != null) {
- if (childDelta[i].getFullPath().equals(configFolder.getFullPath())) {
- // Found a Tomcat server affected by this delta. Update this server's publish state.
- TomcatServerBehaviour tcServerBehaviour = (TomcatServerBehaviour)servers[j].loadAdapter(TomcatServerBehaviour.class, null);
- if (tcServerBehaviour != null) {
- // Indicate that this server needs to publish and restart if running
- tcServerBehaviour.setTomcatServerPublishState(IServer.PUBLISH_STATE_INCREMENTAL);
- tcServerBehaviour.setTomcatServerRestartState(true);
- }
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- private IProject getServersProject() {
- if (serversProject == null) {
- IProject project;
- try {
- project = ServerType.getServerProject();
- synchronized (this) {
- serversProject = project;
- }
- } catch (CoreException e) {
- // Ignore
- }
- }
- return serversProject;
- }
-}
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 d0301e4ad..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/FileUtil.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 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.osgi.util.NLS;
-import org.eclipse.wst.server.core.util.PublishHelper;
-/**
- * Utility class with an assortment of useful file methods.
- */
-public class FileUtil {
- // size of the buffer
- private static final int BUFFER = 10240;
-
- // 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
- * @deprecated will be removed in next release
- */
- public static void smartCopyDirectory(String from, String to, IProgressMonitor monitor) {
- try {
- File fromDir = new File(from);
- File toDir = new File(to);
-
- File[] fromFiles = fromDir.listFiles();
- int fromSize = fromFiles.length;
-
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(NLS.bind(Messages.copyingTask, new String[] {from, to}), 550);
-
- File[] toFiles = null;
-
- // delete old files and directories from this directory
- if (toDir.exists() && toDir.isDirectory()) {
- toFiles = toDir.listFiles();
- int toSize = toFiles.length;
-
- // check if this exact file exists in the new directory
- for (int i = 0; i < toSize; i++) {
- String name = toFiles[i].getName();
- boolean isDir = toFiles[i].isDirectory();
- boolean found = false;
- for (int j = 0; j < fromSize; j++) {
- if (name.equals(fromFiles[j].getName()) && isDir == fromFiles[j].isDirectory())
- found = true;
- }
-
- // delete file if it can't be found or isn't the correct type
- if (!found) {
- if (isDir)
- PublishHelper.deleteDirectory(toFiles[i], null);
- else
- toFiles[i].delete();
- }
- if (monitor.isCanceled())
- return;
- }
- } else {
- if (toDir.isFile())
- toDir.delete();
- toDir.mkdir();
- }
- monitor.worked(50);
-
- // cycle through files and only copy when it doesn't exist
- // or is newer
- toFiles = toDir.listFiles();
- int toSize = toFiles.length;
- int dw = 0;
- if (toSize > 0)
- dw = 500 / toSize;
-
- for (int i = 0; i < fromSize; i++) {
- File current = fromFiles[i];
-
- // check if this is a new or newer file
- boolean copy = true;
- if (!current.isDirectory()) {
- String name = current.getName();
- long mod = current.lastModified();
- for (int j = 0; j < toSize; j++) {
- if (name.equals(toFiles[j].getName()) && mod <= toFiles[j].lastModified())
- copy = false;
- }
- }
-
- if (copy) {
- String fromFile = current.getAbsolutePath();
- String toFile = to;
- if (!toFile.endsWith(File.separator))
- toFile += File.separator;
- toFile += current.getName();
- if (current.isFile()) {
- copyFile(fromFile, toFile);
- monitor.worked(dw);
- } else if (current.isDirectory()) {
- monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {fromFile, toFile}));
- smartCopyDirectory(fromFile, toFile, ProgressUtil.getSubMonitorFor(monitor, dw));
- }
- }
- if (monitor.isCanceled())
- return;
- }
- monitor.worked(500 - dw * toSize);
- monitor.done();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error smart copying directory " + from + " - " + to, e);
- }
- }
-}
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 884151cd5..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntime.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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.jst.server.core.IJavaRuntime;
-/**
- *
- */
-public interface ITomcatRuntime extends IJavaRuntime {
- /**
- * Returns the runtime classpath that is used by this runtime.
- *
- * @return the runtime classpath
- */
- public List getRuntimeClasspath(IPath configPath);
-} \ 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 b5e939430..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatRuntimeWorkingCopy.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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.jst.server.core.IJavaRuntimeWorkingCopy;
-/**
- *
- */
-public interface ITomcatRuntimeWorkingCopy extends ITomcatRuntime, IJavaRuntimeWorkingCopy {
- // no new methods
-} \ 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 6d531a989..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServer.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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 {
- /**
- * Property which specifies whether this server is configured
- * for testing environment.
- */
- public static final String PROPERTY_TEST_ENVIRONMENT = "testEnvironment";
-
- /**
- * Property which specifies the directory where the server instance
- * exists. If not specified, instance directory is derived
- * from the textEnvironment setting.
- */
- public static final String PROPERTY_INSTANCE_DIR = "instanceDir";
- /**
- * Property which specifies the directory where web applications
- * are published.
- */
- public static final String PROPERTY_DEPLOY_DIR = "deployDir";
-
- /**
- * Property which specifies if modules should be served without
- * publishing.
- */
- public static final String PROPERTY_SERVE_MODULES_WITHOUT_PUBLISH = "serveModulesWithoutPublish";
-
- /**
- * Property which specifies contexts in the server.xml file should
- * be saved to separate context files.
- */
- public static final String PROPERTY_SAVE_SEPARATE_CONTEXT_FILES = "saveSeparateContextFiles";
-
- /**
- * Returns true if this is a test (publish and run code out of the
- * workbench) environment server.
- *
- * @return boolean
- */
- public boolean isTestEnvironment();
-
- /**
- * Gets the directory where the server instance exists. If not set,
- * the instance directory is derived from the testEnvironment setting.
- *
- * @return directory where the server instance exists. Returns null
- * if not set.
- */
- public String getInstanceDirectory();
-
- /**
- * Gets the directory to which web applications are to be deployed.
- * If relative, it is relative to the runtime base directory for the
- * server.
- *
- * @return directory where web applications are deployed
- */
- public String getDeployDirectory();
-
- /**
- * Returns true if modules should be served directly from the project
- * folders without publishing.
- *
- * @return true if modules should not be published but served directly
- */
- public boolean isServeModulesWithoutPublish();
-
- /**
- * Returns true if contexts should be saved to separate context
- * files instead of being kept within server.xml when the server
- * is published.
- * @return true if contexts should be saved to separate files
- */
- public boolean isSaveSeparateContextFiles();
-}
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 eba573bf3..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerBehaviour.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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;
-/**
- *
- */
-public interface ITomcatServerBehaviour {
- /**
- * Returns the main class that is used to launch the Tomcat server.
- *
- * @return the main runtime class
- */
- public String getRuntimeClass();
-
- /**
- * Setup for starting the server.
- *
- * @param launch ILaunch
- * @param launchMode String
- * @param monitor IProgressMonitor
- * @throws CoreException if anything goes wrong
- */
- public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException;
-} \ 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 425efa942..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatServerWorkingCopy.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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 {
- /**
- * The default deployment directory. Avoid "webapps" due to
- * side effects.
- */
- public static final String DEFAULT_DEPLOYDIR = "wtpwebapps";
-
- /**
- * The deployment directory used by default in prior versions.
- */
- public static final String LEGACY_DEPLOYDIR = "webapps";
-
- /**
- * Sets this server to test environment mode.
- *
- * @param b boolean
- */
- public void setTestEnvironment(boolean b);
-
- /**
- * Sets the instance directory for the server. If set to
- * null, the instance directory is derived from the
- * testEnvironment setting.'
- *
- * @param instanceDir absolule path to the instance directory.
- */
- public void setInstanceDirectory(String instanceDir);
-
- /**
- * Set the deployment directory for the server. May be absolute
- * or relative to runtime base directory.
- *
- * @param deployDir deployment directory for the server
- */
- public void setDeployDirectory(String deployDir);
-
- /**
- * Set this server to serve modules without publishing.
- *
- * @param b true if modules should be served without publishing
- */
- public void setServeModulesWithoutPublish(boolean b);
-
- /**
- * Set this server to save contexts to separate context
- * files when publishing the server.
- * @param b true if contexts should be saved to separate files
- * when publishing the server
- */
- public void setSaveSeparateContextFiles(boolean b);
-}
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 89edad812..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/ITomcatVersionHandler.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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 {
- /**
- * Verifies if the specified path points to a a Tomcat
- * installation of this version.
- *
- * @param installPath an installation path
- * @return OK status if a valid installation
- * exists at the location. If not valid, the IStatus
- * contains an indication of why.
- */
- public IStatus verifyInstallPath(IPath installPath);
-
- /**
- * Gets the startup class for the Tomcat server.
- *
- * @return server startup class
- */
- public String getRuntimeClass();
-
- /**
- * Gets the startup classpath for the Tomcat server.
- *
- * @param installPath an installation path
- * @return list of classpath entries required to
- * start the Tomcat server.
- */
- public List getRuntimeClasspath(IPath installPath, IPath configPath);
-
- /**
- * Return the program's runtime arguments.
- *
- * @param configPath a config path
- * @param debug <code>true</code> if debug mode is on
- * @param starting <code>true</code> if the server is starting
- * @return a string array of program arguments
- */
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting);
-
- /**
- * Arguments that should not appear in the runtime arguments based on
- * the specified configuration.
- *
- * @param debug <code>true</code> if debug mode is on
- * @param starting <code>true</code> if the server is starting
- * @return array of excluded arguments
- */
- public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting);
-
- /**
- * Gets the startup VM arguments for the Tomcat server.
- *
- * @param installPath installation path for the server
- * @param configPath configuration path for the server
- * @param deployPath deploy path for the server
- * @param isTestEnv test environment flag
- * @return array of VM arguments for starting the server
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv);
-
- /**
- * Gets the contents of the Java policy file for the Tomcat server.
- *
- * @param configPath path to configuration
- * @return contents of Java policy file in the configuration
- */
- public String getRuntimePolicyFile(IPath configPath);
-
- /**
- * Returns true if the given project is supported by this
- * server, and false otherwise.
- *
- * @param module a web module
- * @return the status
- */
- public IStatus canAddModule(IModule module);
-
- /**
- * Returns the runtime base path for relative paths in the server
- * configuration.
- *
- * @param server TomcatServer instance from which to determine
- * the base path.
- * @return path to Tomcat instance directory
- */
- public IPath getRuntimeBaseDirectory(TomcatServer server);
-
- /**
- * Prepare server runtime directory. Create catalina instance set of
- * directories.
- *
- * @param baseDir Tomcat instance directory to prepare
- * @return result of creation operation
- */
- public IStatus prepareRuntimeDirectory(IPath baseDir);
-
- /**
- * Prepares the specified directory by making sure it exists and is
- * initialized appropriately.
- *
- * @param deployPath path to the deployment directory
- * being prepared
- * @return status result of the operation
- */
- public IStatus prepareDeployDirectory(IPath deployPath);
-
- /**
- * Prepare directory for serving contexts directly if enabled.
- * If not enabled, restore directory if necessary.
- *
- * @param baseDir path to Tomcat instance directory
- * @param server TomcatServer instance from which to determine
- * if serving directly is enabled
- * @return status result of the operation
- */
- public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server, String tomcatVersion);
-
- /**
- * Gets the name of the "shared" loader to use with serving
- * modules without publishing. Returns null if serving modules
- * without publishing is not supported.
- *
- * @param baseDir path to Tomcat instance directory
- * @return name of shared loader
- */
- public String getSharedLoader(IPath baseDir);
-
- /**
- * Returns true if this server supports serving modules without
- * publishing.
- *
- * @return true if serving modules without publishing is supported
- */
- public boolean supportsServeModulesWithoutPublish();
-
- /**
- * Returns true if this server supports a debug argument. This
- * argument is expected to affect the level of logging. Newer
- * versions of Tomcat use different means of controlling logging
- * and ignore this argument.
- *
- * @return true if debug argument is supported
- */
- public boolean supportsDebugArgument();
-
- /**
- * Returns true if this server supports separate context files.
- *
- * @return true if this server supports separate context files
- */
- public boolean supportsSeparateContextFiles();
-
- /**
- * Returns the endorsed directories derived using the
- * specified install path.
- *
- * @param installPath installation path for the server
- * @return The endorsed directories for this server.
- */
- public String getEndorsedDirectories(IPath installPath);
-}
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 b4937f29f..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 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 errorVersionEmpty;
- public static String errorUnknownVersion;
- public static String errorInstallDirEmpty;
- public static String errorInstallDirWrongVersion;
- public static String errorInstallDirWrongVersion2;
- public static String errorInstallDirDoesNotExist;
- public static String errorInstallDirMissingFile;
- public static String errorInstallDirMissingFile2;
- public static String errorInstallDirMissingFile3;
- public static String errorInstallDirTrailingSlash;
- public static String errorJRE;
- public static String errorJRETomcat60;
- public static String errorJRETomcat70;
- public static String warningJRE;
- public static String warningCantReadConfig;
- 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 errorPublish;
- 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 errorSpec60;
- public static String errorSpec70;
- 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 errorPublishServer;
- 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 errorConfigurationProjectClosed;
- 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 errorXMLServiceNotFound;
- public static String errorXMLNoService;
- public static String errorXMLEngineNotFound;
- public static String errorXMLHostNotFound;
- public static String errorXMLContextNotFoundPath;
- public static String errorXMLContextMangerNotFound;
- public static String errorXMLContextNotFoundPath32;
- public static String errorXMLNullContextArg;
- public static String errorNoPublishNotSupported;
- public static String errorPublishContextNotFound;
- public static String errorPublishCouldNotRemoveModule;
- public static String errorPublishLoaderJarNotFound;
- public static String errorPublishURLConvert;
- public static String errorPublishCantDeleteLoaderJar;
- public static String errorPublishCatalinaProps;
- public static String errorPublishPathDup;
- public static String errorPublishPathConflict;
- public static String errorPublishPathMissing;
-
- public static String configurationEditorActionModifyPort;
- public static String configurationEditorActionModifyMimeMapping;
- public static String configurationEditorActionAddMimeMapping;
- public static String configurationEditorActionAddWebModule;
- public static String configurationEditorActionModifyWebModule;
- public static String configurationEditorActionRemoveMimeMapping;
- public static String configurationEditorActionRemoveWebModule;
- public static String configurationEditorActionEditWebModulePath;
- public static String serverEditorActionSetDebugMode;
- public static String serverEditorActionSetSecure;
- public static String serverEditorActionSetServerDirectory;
- public static String serverEditorActionSetDeployDirectory;
- public static String serverEditorActionSetServeWithoutPublish;
- public static String serverEidtorActionSetSeparateContextFiles;
-
- 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 17afafd20..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Messages.properties
+++ /dev/null
@@ -1,126 +0,0 @@
-###############################################################################
-# Copyright (c) 2004, 2010 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}...
-
-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}
-errorPublish=Publishing failed with multiple errors
-
-# Editor commands (used in undo/redo menus)
-configurationEditorActionAddMimeMapping=MIME Mapping Addition
-configurationEditorActionModifyMimeMapping=MIME Mapping Change
-configurationEditorActionRemoveMimeMapping=MIME Mapping Removal
-configurationEditorActionAddWebModule=Web Module Addition
-configurationEditorActionModifyWebModule=Web Module Change
-configurationEditorActionRemoveWebModule=Web Module Removal
-configurationEditorActionModifyPort=Port Number Change
-configurationEditorActionEditWebModulePath=Web Module Path Change
-
-# --------------- General ---------------
-canAddModule=Web module can be added to the server.
-portServer=Tomcat admin port
-portUnknown=unknown port
-
-# --------------- Errors and Info ---------------
-errorVersionEmpty=The Tomcat version must be specified.
-errorUnknownVersion=Unknown version of Tomcat was specified.
-errorInstallDirEmpty=The Tomcat installation directory may not be empty.
-errorInstallDirWrongVersion=The name of the Tomcat installation directory indicates it is for different version of Tomcat.
-errorInstallDirWrongVersion2=The Apache Tomcat installation at this directory is version {0}. A Tomcat {1} installation is expected.
-errorInstallDirDoesNotExist=The specified Tomcat installation directory does not exist.
-errorInstallDirMissingFile=The Tomcat installation directory is not valid. It is missing expected file or folder {0}.
-errorInstallDirMissingFile2=The Tomcat installation directory is not valid. It is missing expected file or folder {0} (alternate name {1}).
-errorInstallDirMissingFile3=The Tomcat installation directory is not valid. It is missing expected file or folder {0} (alternate names {1}).
-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.
-errorJRETomcat60=Tomcat version 6.0 requires J2SE 5.0 or later. Change the JRE to one that meets this requirement.
-errorJRETomcat70=Tomcat version 7.0 requires Java SE 6 or later. Change the JRE to one that meets this requirement.
-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.
-errorConfigurationProjectClosed=Could not load the Tomcat server configuration at {0}. The {1} project is closed.
-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}.
-errorPublishServer=Could not publish server configuration for {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
-errorSpec60=Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules
-errorSpec70=Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 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.
-errorXMLServiceNotFound=Service \"{0}\" was not found.
-errorXMLNoService=No Service was found.
-errorXMLEngineNotFound=Engine element not found under Service \"{0}\".
-errorXMLHostNotFound=Host \"{0}\" was not found under Engine \"{1}\" and Service \"{2}\".
-errorXMLContextNotFoundPath=Context with path \"{0}\" was not found under Service \"{1}\", Engine \"{2}\", and Host \"{3}\".
-errorXMLContextMangerNotFound=ContextManager element was not found.
-errorXMLContextNotFoundPath32=Context with path \"{0}\" was not found under ContextManager.
-errorXMLNullContextArg=Context argument may not be null.
-errorNoPublishNotSupported=Serving modules without publishing is not supported by this server.
-errorPublishContextNotFound=Context not found for module {0}.
-errorPublishCouldNotRemoveModule=Could not remove module {0}.
-errorPublishLoaderJarNotFound=Loader jar not found for server ID: {0}.
-errorPublishURLConvert=Exception occurred converting URL {0}: {1}.
-errorPublishCantDeleteLoaderJar=Unable to delete the custom loader jar {0} from Tomcat server.
-errorPublishCatalinaProps=Exception occurred modifying catalina.properties: {0}.
-errorPublishPathDup=Multiple Contexts have a path of "{0}".
-errorPublishPathConflict=Context with path "{0}" conflicts with another Context with path "{1}".
-errorPublishPathMissing=A Context was found with no path.
-
-warningJRE=Tomcat requires a Java SDK in order to compile JSP files. Ensure that the JRE preference settings point to an SDK install location.
-warningCantReadConfig=Cannot read the Tomcat configuration.
-
-# Actions (used in undo/redo menus)
-serverEditorActionSetSecure=Tomcat Security Option Change
-serverEditorActionSetDebugMode=Tomcat Debug Logging Option Change
-serverEditorActionSetServerDirectory=Tomcat Server Path Change
-serverEditorActionSetDeployDirectory=Tomcat Deploy Path Change
-serverEditorActionSetServeWithoutPublish=Serve Modules Without Publish Option Change
-serverEidtorActionSetSeparateContextFiles=Publish Contexts To Separate Files Option Change
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 60332e241..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, 2006 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;
-
- private boolean stop = false;
- private String url;
- private IServer server;
- private TomcatServerBehaviour behaviour;
-
- /**
- * Create a new PingThread.
- *
- * @param server
- * @param url
- * @param maxPings the maximum number of times to try pinging, or -1 to continue forever
- * @param behaviour
- */
- public PingThread(IServer server, String url, int maxPings, 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 " + count);
- URL pingUrl = new URL(url);
- URLConnection conn = pingUrl.openConnection();
- ((HttpURLConnection)conn).getResponseCode();
-
- // ping worked - server is up
- if (!stop) {
- Trace.trace(Trace.FINEST, "Ping: success");
- Thread.sleep(200);
- behaviour.setServerStarted();
- }
- stop = true;
- } catch (FileNotFoundException fe) {
- try {
- Thread.sleep(200);
- } catch (Exception e) {
- // ignore
- }
- behaviour.setServerStarted();
- stop = true;
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Ping: failed");
- // pinging failed
- if (!stop) {
- try {
- Thread.sleep(PING_INTERVAL);
- } catch (InterruptedException e2) {
- // ignore
- }
- }
- }
- }
- }
-
- /**
- * Tell the pinging to stop.
- */
- public void stop() {
- Trace.trace(Trace.FINEST, "Ping: stopping");
- stop = true;
- }
-}
diff --git a/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 ed5dbb4ac..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/PublishOperation2.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 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 java.util.Properties;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.core.IJ2EEModule;
-import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.*;
-import org.eclipse.wst.server.core.util.PublishHelper;
-/**
- * Tomcat publish helper.
- */
-public class PublishOperation2 extends PublishOperation {
- protected TomcatServerBehaviour server;
- protected IModule[] module;
- protected int kind;
- protected int deltaKind;
- private PublishHelper helper;
-
- /**
- * Construct the operation object to publish the specified module
- * to the specified server.
- *
- * @param server server to which the module will be published
- * @param kind kind of publish
- * @param module module to publish
- * @param deltaKind kind of change
- */
- public PublishOperation2(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;
- IPath base = server.getRuntimeBaseDirectory();
- if (base != null) {
- helper = new PublishHelper(base.append("temp").toFile());
- }
- else {
- // We are doomed without a base directory. However, allow the catastrophe
- // to occur elsewhere and hope for a useful error message.
- helper = new PublishHelper(null);
- }
- }
-
- /**
- * @see PublishOperation#getOrder()
- */
- public int getOrder() {
- return 0;
- }
-
- /**
- * @see PublishOperation#getKind()
- */
- public int getKind() {
- return REQUIRED;
- }
-
- /**
- * @see PublishOperation#execute(IProgressMonitor, IAdaptable)
- */
- public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException {
- List<IStatus> status = new ArrayList<IStatus>();
- // If parent web module
- if (module.length == 1) {
- publishDir(module[0], status, monitor);
- }
- // Else a child module
- else {
- Properties p = server.loadModulePublishLocations();
-
- // Try to determine the URI for the child module
- IWebModule webModule = (IWebModule)module[0].loadAdapter(IWebModule.class, monitor);
- String childURI = null;
- if (webModule != null) {
- childURI = webModule.getURI(module[1]);
- }
- // Try to determine if child is binary
- IJ2EEModule childModule = (IJ2EEModule)module[1].loadAdapter(IJ2EEModule.class, monitor);
- boolean isBinary = false;
- if (childModule != null) {
- isBinary = childModule.isBinary();
- }
-
- if (isBinary) {
- publishArchiveModule(childURI, p, status, monitor);
- }
- else {
- publishJar(childURI, p, status, monitor);
- }
- server.saveModulePublishLocations(p);
- }
- throwException(status);
- server.setModulePublishState2(module, IServer.PUBLISH_STATE_NONE);
- }
-
- private void publishDir(IModule module2, List<IStatus> status, IProgressMonitor monitor) throws CoreException {
- IPath path = server.getModuleDeployDirectory(module2);
-
- // Remove if requested or if previously published and are now serving without publishing
- if (kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getTomcatServer().isServeModulesWithoutPublish()) {
- File f = path.toFile();
- if (f.exists()) {
- IStatus[] stat = PublishHelper.deleteDirectory(f, monitor);
- addArrayToList(status, stat);
- }
-
- if (deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getTomcatServer().isServeModulesWithoutPublish())
- return;
- }
-
- if (kind == IServer.PUBLISH_CLEAN || kind == IServer.PUBLISH_FULL) {
- IModuleResource[] mr = server.getResources(module);
- IStatus[] stat = helper.publishFull(mr, path, monitor);
- addArrayToList(status, stat);
- return;
- }
-
- IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
-
- int size = delta.length;
- for (int i = 0; i < size; i++) {
- IStatus[] stat = helper.publishDelta(delta[i], path, monitor);
- addArrayToList(status, stat);
- }
- }
-
- private void publishJar(String jarURI, Properties p, List<IStatus> status, IProgressMonitor monitor) throws CoreException {
- IPath path = server.getModuleDeployDirectory(module[0]);
- boolean moving = false;
- // Get URI used for previous publish, if known
- String oldURI = (String)p.get(module[1].getId());
- if (oldURI != null) {
- // If old URI found, detect if jar is moving or changing its name
- if (jarURI != null) {
- moving = !oldURI.equals(jarURI);
- }
- }
- // If we don't have a jar URI, make a guess so we have one if we need it
- if (jarURI == null) {
- jarURI = "WEB-INF/lib/" + module[1].getName() + ".jar";
- }
- IPath jarPath = path.append(jarURI);
- // Make our best determination of the path to the old jar
- IPath oldJarPath = jarPath;
- if (oldURI != null) {
- oldJarPath = path.append(oldURI);
- }
- // Establish the destination directory
- path = jarPath.removeLastSegments(1);
-
- // Remove if requested or if previously published and are now serving without publishing
- if (moving || kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getTomcatServer().isServeModulesWithoutPublish()) {
- File file = oldJarPath.toFile();
- if (file.exists())
- file.delete();
- p.remove(module[1].getId());
-
- if (deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getTomcatServer().isServeModulesWithoutPublish())
- return;
- }
- if (!moving && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
-
- // make directory if it doesn't exist
- if (!path.toFile().exists())
- path.toFile().mkdirs();
-
- IModuleResource[] mr = server.getResources(module);
- IStatus[] stat = helper.publishZip(mr, jarPath, monitor);
- addArrayToList(status, stat);
- p.put(module[1].getId(), jarURI);
- }
-
- private void publishArchiveModule(String jarURI, Properties p, List<IStatus> status, IProgressMonitor monitor) {
- IPath path = server.getModuleDeployDirectory(module[0]);
- boolean moving = false;
- // Get URI used for previous publish, if known
- String oldURI = (String)p.get(module[1].getId());
- if (oldURI != null) {
- // If old URI found, detect if jar is moving or changing its name
- if (jarURI != null) {
- moving = !oldURI.equals(jarURI);
- }
- }
- // If we don't have a jar URI, make a guess so we have one if we need it
- if (jarURI == null) {
- jarURI = "WEB-INF/lib/" + module[1].getName();
- }
- IPath jarPath = path.append(jarURI);
- // Make our best determination of the path to the old jar
- IPath oldJarPath = jarPath;
- if (oldURI != null) {
- oldJarPath = path.append(oldURI);
- }
- // Establish the destination directory
- path = jarPath.removeLastSegments(1);
-
- // Remove if requested or if previously published and are now serving without publishing
- if (moving || kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getTomcatServer().isServeModulesWithoutPublish()) {
- File file = oldJarPath.toFile();
- if (file.exists()) {
- file.delete();
- }
- p.remove(module[1].getId());
-
- if (deltaKind == ServerBehaviourDelegate.REMOVED
- || server.getTomcatServer().isServeModulesWithoutPublish())
- return;
- }
- if (!moving && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
-
- // make directory if it doesn't exist
- if (!path.toFile().exists())
- path.toFile().mkdirs();
-
- IModuleResource[] mr = server.getResources(module);
- IStatus[] stat = helper.publishToPath(mr, jarPath, monitor);
- addArrayToList(status, stat);
- p.put(module[1].getId(), jarURI);
- }
-
- /**
- * Utility method to throw a CoreException based on the contents of a list of
- * error and warning status.
- *
- * @param status a List containing error and warning IStatus
- * @throws CoreException
- */
- protected static void throwException(List<IStatus> status) throws CoreException {
- if (status == null || status.size() == 0)
- return;
-
- if (status.size() == 1) {
- IStatus status2 = status.get(0);
- throw new CoreException(status2);
- }
- IStatus[] children = new IStatus[status.size()];
- status.toArray(children);
- String message = Messages.errorPublish;
- MultiStatus status2 = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, children, message, null);
- throw new CoreException(status2);
- }
-
- protected static void addArrayToList(List<IStatus> list, IStatus[] a) {
- if (list == null || a == null || a.length == 0)
- return;
-
- int size = a.length;
- for (int i = 0; i < size; i++)
- list.add(a[i]);
- }
-}
diff --git a/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 194a6adc6..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, 2011 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<PublishOperation> tasks = new ArrayList<PublishOperation>();
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- IModule[] module = (IModule[]) modules.get(i);
- Integer in = (Integer) kindList.get(i);
- tasks.add(new PublishOperation2(tomcatServer, kind, module, in.intValue()));
- }
-
- return 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 b18e1dce2..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Configuration.java
+++ /dev/null
@@ -1,768 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.HashMap;
-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.server32.*;
-import org.eclipse.osgi.util.NLS;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-
-import org.eclipse.wst.server.core.ServerPort;
-import org.eclipse.wst.server.core.util.PublishHelper;
-/**
- * Tomcat v3.2 server configuration.
- */
-public class Tomcat32Configuration extends TomcatConfiguration {
- 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 ServerInstance serverInstance;
- 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<ServerPort> ports = new ArrayList<ServerPort>();
-
- try {
- Connector [] connectors = serverInstance.getConnectors();
- if (connectors != null) {
- for (int i = 0; i < connectors.length; i++) {
- Connector connector = connectors[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<WebModule> list = new ArrayList<WebModule>();
-
- try {
- Context [] contexts = serverInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[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#getServerWorkDirectory(IPath)
- */
- public IPath getServerWorkDirectory(IPath basePath) {
- return serverInstance.getServerWorkDirectory(basePath);
- }
-
- /**
- * @see TomcatConfiguration#getContextWorkDirectory(IPath, ITomcatWebModule)
- */
- public IPath getContextWorkDirectory(IPath basePath, ITomcatWebModule module) {
- Context context = serverInstance.getContext(module.getPath());
- if (context != null)
- return serverInstance.getContextWorkDirectory(basePath, context);
-
- return null;
- }
-
- /**
- * @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()));
- serverInstance = new ServerInstance(server);
- 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
- policyFile = TomcatVersionHelper.getFileContents(new FileInputStream(path.append("tomcat.policy").toFile()));
- 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#importFromPath(IPath, boolean, IProgressMonitor)
- */
- public void importFromPath(IPath path, boolean isTestEnv, IProgressMonitor monitor) throws CoreException {
- load(path, monitor);
-
- // for test environment, remove existing contexts since an instance
- // directory relative to server.xml will be used
- if (isTestEnv) {
- while (serverInstance.removeContext(0)) {
- // no-op
- }
- }
- }
-
- /**
- * @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);
- serverInstance = new ServerInstance(server);
- 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();
- policyFile = TomcatVersionHelper.getFileContents(in);
- 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));
- }
- }
-
- /**
- * Save the information held by this object to the given directory.
- * All files are forced to be saved.
- *
- * @param path desination path for the files
- * @param monitor a progress monitor
- * @exception CoreException
- */
- 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));
- isServerDirty = false;
-
- // 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 {
- Context context = serverInstance.createContext(index);
-
- 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 baseDir runtime base directory for the server
- * @param deployDir deployment directory for the server
- * @param server2 a server type
- * @param monitor a progress monitor
- * @return result of operation
- */
- public IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer server2, IProgressMonitor monitor) {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.updatingConfigurationTask, 100);
- IPath confDir = baseDir.append("conf");
-
- Tomcat32Configuration config = new Tomcat32Configuration(null);
- config.load(confDir, ProgressUtil.getSubMonitorFor(monitor, 300));
-
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
-
- if (server2.isTestEnvironment()) {
- config.server.getContextManager().setHome(baseDir.toOSString());
- config.isServerDirty = true;
- }
-
- // Only add root module if running in a test env (i.e. not on the installation)
- boolean addRootWebapp = server2.isTestEnvironment();
-
- // If not deploying to "webapps", context docBase attributes need updating
- boolean deployingToWebapps = "webapps".equals(server2.getDeployDirectory());
-
- Map<String, String> pathMap = new HashMap<String, String>();
-
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorPublishServer, server2.getServer().getName()), null);
- Context [] contexts = config.serverInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[i];
-
- // Normalize path and check for duplicates
- String path = context.getPath();
- if (path != null) {
- // Save a copy of original in case it's "/"
- String origPath = path;
- // Normalize "/" to ""
- if ("/".equals(path)) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Context path is being changed from \"/\" to \"\".");
- path = "";
- context.setPath(path);
- config.isServerDirty = true;
- }
-
- // Context paths that are the same or differ only in case are not allowed
- String lcPath = path.toLowerCase();
- if (!pathMap.containsKey(lcPath)) {
- pathMap.put(lcPath, origPath);
- }
- else {
- String otherPath = pathMap.get(lcPath);
- IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID,
- origPath.equals(otherPath) ? NLS.bind(Messages.errorPublishPathDup, origPath)
- : NLS.bind(Messages.errorPublishPathConflict, origPath, otherPath));
- ms.add(s);
- }
- }
- else {
- IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID,
- Messages.errorPublishPathMissing);
- ms.add(s);
- }
-
- // If default webapp has not been found, check this one
- // TODO Need to add a root context if deploying to webapps but with auto-deploy off
- if (addRootWebapp && "".equals(context.getPath())) {
- // A default webapp is being deployed, don't add one
- addRootWebapp = false;
- }
-
- // If not deploying to "webapps", convert to absolute path under deploy dir
- if (!deployingToWebapps) {
- String source = context.getSource();
- if (source != null && source.length() > 0 ) {
- String name = context.getDocBase();
- // Update docBase only if name begins with the expected prefix
- if (name.startsWith(getDocBasePrefix())) {
- name = name.substring(getDocBasePrefix().length());
- context.setDocBase(deployDir.append(name).toOSString());
- config.isServerDirty = true;
- }
- }
- }
- }
- }
- // If errors are present, return status
- if (!ms.isOK())
- return ms;
-
- if (addRootWebapp) {
- // Add a context for the default webapp
- Context rootContext = config.serverInstance.createContext(0);
- rootContext.setPath("");
- rootContext.setDocBase(deployDir.append("ROOT").toOSString());
- rootContext.setReloadable("false");
- config.isServerDirty = true;
- }
- monitor.worked(100);
-
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
-
- config.save(confDir, false, ProgressUtil.getSubMonitorFor(monitor, 30));
- monitor.worked(100);
-
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error localizing configuration", e);
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- /**
- * 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 = serverInstance.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 {
- Context context = serverInstance.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 {
- serverInstance.removeContext(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);
- }
- }
-
- 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.server32");
- File serverFile = confDir.append("conf").append("server.xml").toFile();
- if (serverFile.exists()) {
- Server oldServer = (Server) factory.loadDocument(new FileInputStream(serverFile));
- ServerInstance oldInstance = new ServerInstance(oldServer);
-
- // Collect paths of old web modules managed by WTP
- Set<String> oldPaths = new HashSet<String>();
- Context [] contexts = oldInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- String source = contexts[i].getSource();
- if (source != null && source.length() > 0 ) {
- oldPaths.add(contexts[i].getPath());
- }
- }
- }
-
- // Remove paths for web modules that are staying around
- List modules = getWebModules();
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- WebModule module = (WebModule) modules.get(i);
- oldPaths.remove(module.getPath());
- }
- monitor.worked(100);
-
- // Delete work directories 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()) {
- String oldPath = (String)iter.next();
-
- // Delete work directory associated with the removed context if it is within confDir.
- // If it is outside of confDir, assume user is going to manage it.
- Context ctx = oldInstance.getContext(oldPath);
- IPath ctxWorkPath = oldInstance.getContextWorkDirectory(confDir, ctx);
- if (confDir.isPrefixOf(ctxWorkPath)) {
- File ctxWorkDir = ctxWorkPath.toFile();
- if (ctxWorkDir.exists() && ctxWorkDir.isDirectory()) {
- IStatus [] results = PublishHelper.deleteDirectory(ctxWorkDir, ProgressUtil.getSubMonitorFor(monitor, 100));
- if (results.length > 0) {
- Trace.trace(Trace.SEVERE, "Could not delete work directory " + ctxWorkDir.getPath() + " for removed context " + oldPath);
- for (int i = 0; i < results.length; i++) {
- ms.add(results[i]);
- }
- }
- }
- else
- monitor.worked(100);
- }
- else
- monitor.worked(100);
- }
- subMonitor.done();
- } else {
- monitor.worked(100);
- }
- }
- // Else no server.xml. Assume first publish to new temp directory
- else {
- monitor.worked(200);
- }
- if (Trace.isTraceEnabled())
- 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;
- }
-
-}
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 76fd28adb..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat32Handler.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.IRuntimeClasspathEntry;
-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 IStatus 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, IPath)
- */
- public List getRuntimeClasspath(IPath installPath, IPath configPath) {
- List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
- // 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<String> list = new ArrayList<String>();
- 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#getExcludedRuntimeProgramArguments(boolean, boolean)
- */
- public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting) {
- return null;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv) {
- List<String> list = new ArrayList<String>();
- list.add("-Dtomcat.home=\"" + installPath.toOSString() + "\"");
- // Include a system property for the configurable deploy location
- list.add("-Dwtp.deploy=\"" + deployPath.toOSString() + "\"");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimePolicyFile(IPath)
- */
- 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(TomcatServer)
- */
- public IPath getRuntimeBaseDirectory(TomcatServer server) {
- return TomcatVersionHelper.getStandardBaseDirectory(server);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareRuntimeDirectory(IPath)
- */
- public IStatus prepareRuntimeDirectory(IPath confDir) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Preparing runtime directory");
- // Prepare instance directory structure that is relative to server.xml
- File temp = confDir.append("conf").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("webapps").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = confDir.append("work").toFile();
- if (!temp.exists())
- temp.mkdirs();
-
- return Status.OK_STATUS;
- }
-
- /**
- * @see ITomcatVersionHandler#prepareDeployDirectory(IPath)
- */
- public IStatus prepareDeployDirectory(IPath deployPath) {
- return TomcatVersionHelper.createDeploymentDirectory(deployPath,
- TomcatVersionHelper.DEFAULT_WEBXML_SERVLET22);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareForServingDirectly(IPath, TomcatServer)
- */
- public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server, String tomcatVersion) {
- if (server.isServeModulesWithoutPublish())
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorNoPublishNotSupported, null);
- return Status.OK_STATUS;
- }
-
- /**
- * @see ITomcatVersionHandler#getSharedLoader(IPath)
- */
- public String getSharedLoader(IPath baseDir) {
- // Not supported
- return null;
- }
-
- /**
- * Returns false since Tomcat 3.2 doesn't support this feature.
- *
- * @return false since feature is not supported
- */
- public boolean supportsServeModulesWithoutPublish() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsDebugArgument()
- */
- public boolean supportsDebugArgument() {
- return true;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsSeparateContextFiles()
- */
- public boolean supportsSeparateContextFiles() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#getEndorsedDirectories(IPath)
- */
- public String getEndorsedDirectories(IPath installPath) {
- return "";
- }
-
-}
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 a12fa1bed..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java
+++ /dev/null
@@ -1,578 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-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.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-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.Connector;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.ServerPort;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-/**
- * 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 AJP_CONNECTOR = "org.apache.ajp.tomcat4.Ajp13Connector";
- protected static final String WARP_CONNECTOR = "org.apache.catalina.connector.warp.WarpConnector";
-
- protected Server server;
- protected ServerInstance serverInstance;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
-
- /**
- * 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();
- // Return only an HTTP port from the selected Service
- if (port.getName().equals("HTTP Connector") && port.getId().indexOf('/') < 0)
- 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<ServerPort> ports = new ArrayList<ServerPort>();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- String instanceServiceName = serverInstance.getService().getName();
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String 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 (AJP_CONNECTOR.equals(className))
- name = "AJP Connector";
- else if (WARP_CONNECTOR.equals(className))
- name = "Warp Connector";
- String portId;
- if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
- portId = Integer.toString(j);
- else
- portId = i +"/" + j;
- if (className != null && className.length() > 0)
- ports.add(new ServerPort(portId, 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<WebModule> list = new ArrayList<WebModule>();
-
- try {
- Context [] contexts = serverInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[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 modules", e);
- }
- return list;
- }
-
- /**
- * @see TomcatConfiguration#getServerWorkDirectory(IPath)
- */
- public IPath getServerWorkDirectory(IPath basePath) {
- return serverInstance.getHostWorkDirectory(basePath);
- }
-
- /**
- * @see TomcatConfiguration#getContextWorkDirectory(IPath, ITomcatWebModule)
- */
- public IPath getContextWorkDirectory(IPath basePath, ITomcatWebModule module) {
- Context context = serverInstance.getContext(module.getPath());
- if (context != null)
- return serverInstance.getContextWorkDirectory(basePath, context);
-
- return null;
- }
-
- /**
- * @see TomcatConfiguration#importFromPath(IPath, boolean, IProgressMonitor)
- */
- 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) {
- while (serverInstance.removeContext(0)) {
- // no-op
- }
- }
- }
-
- /**
- * @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()));
- serverInstance = new ServerInstance(server, null, null);
- 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
- policyFile = TomcatVersionHelper.getFileContents(new FileInputStream(path.append("catalina.policy").toFile()));
- 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);
- serverInstance = new ServerInstance(server, null, null);
- 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();
- policyFile = TomcatVersionHelper.getFileContents(in);
- 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());
- isServerDirty = false;
- }
- 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("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
-
- 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));
- }
- }
-
- /**
- * Save to the given directory. All files are forced to be saved.
- *
- * @param path desination path for the files
- * @param monitor a progress monitor
- * @exception CoreException
- */
- 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));
- isServerDirty = false;
-
- // 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 {
- Context context = serverInstance.createContext(index);
- if (context != null) {
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * 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("/");
- // If a connector in the instance Service
- if (i < 0) {
- int connNum = Integer.parseInt(id);
- Connector connector = serverInstance.getConnector(connNum);
- if (connector != null) {
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- }
- // Else a connector in another Service
- else {
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- Context context = serverInstance.getContext(index);
- if (context != null) {
- 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 {
- serverInstance.removeContext(index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- /**
- * Cleanup the server instance. This consists of deleting the work
- * directory associated with Contexts that are going away in the
- * up coming publish.
- *
- * @param baseDir path to server instance directory, i.e. catalina.base
- * @param installDir path to server installation directory (not currently used)
- * @param monitor a progress monitor or null
- * @return MultiStatus containing results of the cleanup operation
- */
- protected IStatus cleanupServer(IPath baseDir, IPath installDir, boolean removeKeptContextFiles, IProgressMonitor monitor) {
- List modules = getWebModules();
- return TomcatVersionHelper.cleanupCatalinaServer(baseDir, installDir, removeKeptContextFiles, modules, monitor);
- }
-
- /**
- * @see TomcatConfiguration#localizeConfiguration(IPath, IPath, TomcatServer, IProgressMonitor)
- */
- public IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer tomcatServer, IProgressMonitor monitor) {
- return TomcatVersionHelper.localizeConfiguration(baseDir, deployDir, tomcatServer, monitor);
- }
-}
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 f1531686d..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Handler.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.IRuntimeClasspathEntry;
-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 IStatus verifyInstallPath(IPath installPath) {
- return TomcatPlugin.verifyInstallPathWithFolderCheck(installPath, TomcatPlugin.TOMCAT_40);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.catalina.startup.Bootstrap";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath, IPath)
- */
- public List getRuntimeClasspath(IPath installPath, IPath configPath) {
- List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
-
- // 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<String> list = new ArrayList<String>();
-
- 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#getExcludedRuntimeProgramArguments(boolean, boolean)
- */
- public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting) {
- if (!debug) {
- return new String [] { "-debug" };
- }
- return null;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv) {
- List<String> list = new ArrayList<String>();
- if (isTestEnv)
- list.add("-Dcatalina.base=\"" + configPath.toOSString() + "\"");
- else
- list.add("-Dcatalina.base=\"" + installPath.toOSString() + "\"");
- list.add("-Dcatalina.home=\"" + installPath.toOSString() + "\"");
- // Include a system property for the configurable deploy location
- list.add("-Dwtp.deploy=\"" + deployPath.toOSString() + "\"");
- list.add("-Djava.endorsed.dirs=\"" + getEndorsedDirectories(installPath) + "\"");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimePolicyFile(IPath)
- */
- 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(TomcatServer)
- */
- public IPath getRuntimeBaseDirectory(TomcatServer server) {
- return TomcatVersionHelper.getStandardBaseDirectory(server);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareRuntimeDirectory(IPath)
- */
- public IStatus prepareRuntimeDirectory(IPath baseDir) {
- return TomcatVersionHelper.createCatalinaInstanceDirectory(baseDir);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareDeployDirectory(IPath)
- */
- public IStatus prepareDeployDirectory(IPath deployPath) {
- return TomcatVersionHelper.createDeploymentDirectory(deployPath,
- TomcatVersionHelper.DEFAULT_WEBXML_SERVLET23);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareForServingDirectly(IPath, TomcatServer)
- */
- public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server, String tomcatVersion) {
- if (server.isServeModulesWithoutPublish())
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorNoPublishNotSupported, null);
- return Status.OK_STATUS;
- }
-
- /**
- * @see ITomcatVersionHandler#getSharedLoader(IPath)
- */
- public String getSharedLoader(IPath baseDir) {
- // Not supported
- return null;
- }
-
- /**
- * Returns false since Tomcat 4.0 doesn't support this feature.
- *
- * @return false since feature is not supported
- */
- public boolean supportsServeModulesWithoutPublish() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsDebugArgument()
- */
- public boolean supportsDebugArgument() {
- return true;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsSeparateContextFiles()
- */
- public boolean supportsSeparateContextFiles() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#getEndorsedDirectories(IPath)
- */
- public String getEndorsedDirectories(IPath installPath) {
- return installPath.append("bin").toOSString() +
- java.io.File.pathSeparator +
- installPath.append("common").append("lib").toOSString();
- }
-
-}
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 67ed8c5e6..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java
+++ /dev/null
@@ -1,614 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-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.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-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.Connector;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.ServerPort;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-/**
- * 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 ServerInstance serverInstance;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
-
- /**
- * 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();
- // Return only an HTTP port from the selected Service
- if (port.getName().equals("HTTP Connector") && port.getId().indexOf('/') < 0)
- 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<ServerPort> ports = new ArrayList<ServerPort>();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- String instanceServiceName = serverInstance.getService().getName();
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String 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";
- String portId;
- if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
- portId = Integer.toString(j);
- else
- portId = i +"/" + j;
- if (className != null && className.length() > 0)
- ports.add(new ServerPort(portId, 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<WebModule> list = new ArrayList<WebModule>();
-
- try {
- Context [] contexts = serverInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[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#getServerWorkDirectory(IPath)
- */
- public IPath getServerWorkDirectory(IPath basePath) {
- return serverInstance.getHostWorkDirectory(basePath);
- }
-
- /**
- * @see TomcatConfiguration#getContextWorkDirectory(IPath, ITomcatWebModule)
- */
- public IPath getContextWorkDirectory(IPath basePath, ITomcatWebModule module) {
- Context context = serverInstance.getContext(module.getPath());
- if (context != null)
- return serverInstance.getContextWorkDirectory(basePath, context);
-
- return null;
- }
-
- /**
- * @see TomcatConfiguration#importFromPath(IPath, boolean, IProgressMonitor)
- */
- 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) {
- while (serverInstance.removeContext(0)) {
- // no-op
- }
- }
- }
-
- /**
- * @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()));
- serverInstance = new ServerInstance(server, null, null);
- 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
- policyFile = TomcatVersionHelper.getFileContents(new FileInputStream(path.append("catalina.policy").toFile()));
- 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);
- serverInstance = new ServerInstance(server, null, null);
- 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();
- policyFile = TomcatVersionHelper.getFileContents(in);
- 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());
- isServerDirty = false;
- }
- 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("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
-
- 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));
- }
- }
-
- /**
- * Save to the given directory. All files are forced to be saved.
- *
- * @param path desination path for the files
- * @param monitor a progress monitor
- * @exception CoreException
- */
- 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));
- isServerDirty = false;
-
- // 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 {
- Context context = serverInstance.createContext(index);
- if (context != null) {
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * 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("/");
- // If a connector in the instance Service
- if (i < 0) {
- int connNum = Integer.parseInt(id);
- Connector connector = serverInstance.getConnector(connNum);
- if (connector != null) {
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- }
- // Else a connector in another Service
- else {
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- Context context = serverInstance.getContext(index);
- if (context != null) {
- 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 {
- serverInstance.removeContext(index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- /**
- * Add context configuration found in META-INF/context.xml files
- * present in projects to published server.xml.
- *
- * @param baseDir path to catalina instance directory
- * @param deployDir path to deployment directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus publishContextConfig(IPath baseDir, IPath deployDir, IProgressMonitor monitor) {
- return TomcatVersionHelper.publishCatalinaContextConfig(baseDir, deployDir, monitor);
- }
-
- /**
- * Cleanup the server instance. This consists of deleting the work
- * directory associated with Contexts that are going away in the
- * up coming publish.
- *
- * @param baseDir path to server instance directory, i.e. catalina.base
- * @param installDir path to server installation directory (not currently used)
- * @param monitor a progress monitor or null
- * @return MultiStatus containing results of the cleanup operation
- */
- protected IStatus cleanupServer(IPath baseDir, IPath installDir, boolean removeKeptContextFiles, IProgressMonitor monitor) {
- List modules = getWebModules();
- return TomcatVersionHelper.cleanupCatalinaServer(baseDir, installDir, removeKeptContextFiles, modules, monitor);
- }
-
- /**
- * @see TomcatConfiguration#localizeConfiguration(IPath, IPath, TomcatServer, IProgressMonitor)
- */
- public IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer tomcatServer, IProgressMonitor monitor) {
- return TomcatVersionHelper.localizeConfiguration(baseDir, deployDir, tomcatServer, monitor);
- }
-}
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 6e6db231b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Handler.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.IRuntimeClasspathEntry;
-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 IStatus verifyInstallPath(IPath installPath) {
- IStatus result = TomcatVersionHelper.checkCatalinaVersion(installPath, TomcatPlugin.TOMCAT_41);
- // If check was canceled, use folder check
- if (result.getSeverity() == IStatus.CANCEL) {
- result = TomcatPlugin.verifyInstallPathWithFolderCheck(installPath, TomcatPlugin.TOMCAT_41);
- }
- return result;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.catalina.startup.Bootstrap";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath, IPath)
- */
- public List getRuntimeClasspath(IPath installPath, IPath configPath) {
- List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
-
- // 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<String> list = new ArrayList<String>();
-
- 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#getExcludedRuntimeProgramArguments(boolean, boolean)
- */
- public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting) {
- if (!debug) {
- return new String [] { "-debug" };
- }
- return null;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv) {
- return TomcatVersionHelper.getCatalinaVMArguments(installPath, configPath, deployPath, getEndorsedDirectories(installPath), isTestEnv);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimePolicyFile(IPath)
- */
- 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(TomcatServer)
- */
- public IPath getRuntimeBaseDirectory(TomcatServer server) {
- return TomcatVersionHelper.getStandardBaseDirectory(server);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareRuntimeDirectory(IPath)
- */
- public IStatus prepareRuntimeDirectory(IPath baseDir) {
- return TomcatVersionHelper.createCatalinaInstanceDirectory(baseDir);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareDeployDirectory(IPath)
- */
- public IStatus prepareDeployDirectory(IPath deployPath) {
- return TomcatVersionHelper.createDeploymentDirectory(deployPath,
- TomcatVersionHelper.DEFAULT_WEBXML_SERVLET23);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareForServingDirectly(IPath, TomcatServer)
- */
- public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server, String tomcatVersion) {
- if (server.isServeModulesWithoutPublish())
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorNoPublishNotSupported, null);
- return Status.OK_STATUS;
- }
-
- /**
- * @see ITomcatVersionHandler#getSharedLoader(IPath)
- */
- public String getSharedLoader(IPath baseDir) {
- // Not supported
- return null;
- }
-
- /**
- * Returns false since Tomcat 4.1 doesn't support this feature.
- *
- * @return false since feature is not supported
- */
- public boolean supportsServeModulesWithoutPublish() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsDebugArgument()
- */
- public boolean supportsDebugArgument() {
- return true;
- }
-
- /**
- * While Tomcat 4.1.x does implement a form of separate
- * context files, these file are found outside of the
- * &quot;conf&quot; directory and is not practical to
- * support.
- * @see ITomcatVersionHandler#supportsSeparateContextFiles()
- */
- public boolean supportsSeparateContextFiles() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#getEndorsedDirectories(IPath)
- */
- public String getEndorsedDirectories(IPath installPath) {
- return installPath.append("common").append("endorsed").toOSString();
- }
-}
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 6be6a4480..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-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.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-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.Connector;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.ServerPort;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-/**
- * Tomcat v5.0 server configuration.
- */
-public class Tomcat50Configuration extends TomcatConfiguration {
- protected static final String DEFAULT_SERVICE = "Catalina";
- protected Server server;
- protected ServerInstance serverInstance;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
-
- protected String propertiesFile;
-
- protected static final Map<String, String> protocolHandlerMap = new HashMap<String, String>();
- static {
- protocolHandlerMap.put("org.apache.coyote.http11.Http11Protocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.jk.server.JkCoyoteHandler", "AJP/1.3");
- }
-
- /**
- * 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();
- // Return only an HTTP port from the selected Service
- if (port.getProtocol().toLowerCase().equals("http") && port.getId().indexOf('/') < 0)
- 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<ServerPort> ports = new ArrayList<ServerPort>();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- String instanceServiceName = serverInstance.getService().getName();
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String name = "HTTP/1.1";
- String protocol2 = "HTTP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- String protocol = connector.getProtocol();
- if (protocol != null && protocol.length() > 0) {
- if (protocol.startsWith("HTTP")) {
- name = protocol;
- }
- else if (protocol.startsWith("AJP")) {
- name = protocol;
- protocol2 = "AJP";
- }
- else {
- // Get Tomcat equivalent name if protocol handler class specified
- name = protocolHandlerMap.get(protocol);
- if (name != null) {
- // Prepare simple protocol string for ServerPort protocol
- int index = name.indexOf('/');
- if (index > 0)
- protocol2 = name.substring(0, index);
- else
- protocol2 = name;
- }
- // Specified protocol is unknown, just use as is
- else {
- name = protocol;
- protocol2 = protocol;
- }
- }
- }
- if (protocol2.toLowerCase().equals("http"))
- contentTypes = new String[] { "web", "webservices" };
- String secure = connector.getSecure();
- if (secure != null && secure.length() > 0) {
- name = "SSL";
- protocol2 = "SSL";
- } else
- advanced = false;
- String portId;
- if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
- portId = Integer.toString(j);
- else
- portId = i +"/" + j;
- ports.add(new ServerPort(portId, name, port, protocol2, contentTypes, advanced));
- }
- }
- } 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<WebModule> list = new ArrayList<WebModule>();
-
- try {
- Context [] contexts = serverInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[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#getServerWorkDirectory(IPath)
- */
- public IPath getServerWorkDirectory(IPath basePath) {
- return serverInstance.getHostWorkDirectory(basePath);
- }
-
- /**
- * @see TomcatConfiguration#getContextWorkDirectory(IPath, ITomcatWebModule)
- */
- public IPath getContextWorkDirectory(IPath basePath, ITomcatWebModule module) {
- Context context = serverInstance.getContext(module.getPath());
- if (context != null)
- return serverInstance.getContextWorkDirectory(basePath, context);
-
- return null;
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 6);
-
- // 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()));
- serverInstance = new ServerInstance(server, null, null);
- 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
- policyFile = TomcatVersionHelper.getFileContents(new FileInputStream(path.append("catalina.policy").toFile()));
- monitor.worked(1);
-
- // load properties file
- File file = path.append("catalina.properties").toFile();
- if (file.exists())
- propertiesFile = TomcatVersionHelper.getFileContents(new FileInputStream(file));
- else
- propertiesFile = null;
- 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));
- }
- }
-
- /**
- * @see TomcatConfiguration#importFromPath(IPath, boolean, IProgressMonitor)
- */
- 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) {
- while (serverInstance.removeContext(0)) {
- // no-op
- }
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 1000);
-
- // 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);
- serverInstance = new ServerInstance(server, null, null);
- 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();
- policyFile = TomcatVersionHelper.getFileContents(in);
- monitor.worked(200);
-
- // load catalina.properties
- file = folder.getFile("catalina.properties");
- if (file.exists()) {
- in = file.getContents();
- propertiesFile = TomcatVersionHelper.getFileContents(in);
- }
- else
- propertiesFile = null;
- 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, 4);
-
- // 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());
- isServerDirty = false;
- }
- 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("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- if (propertiesFile != null && forceDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("catalina.properties").toFile()));
- bw.write(propertiesFile);
- bw.close();
- }
- monitor.worked(1);
-
- 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));
- }
- }
-
- /**
- * Save to the given directory. All files are forced to be saved.
- *
- * @param path desination path for the files
- * @param monitor a progress monitor
- * @exception CoreException
- */
- 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, 1100);
-
- // 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));
- isServerDirty = false;
-
- // 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));
-
- // save catalina.properties
- if (propertiesFile != null) {
- in = new ByteArrayInputStream(propertiesFile.getBytes());
- file = folder.getFile("catalina.properties");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- } else
- monitor.worked(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 {
- Context context = serverInstance.createContext(index);
- if (context != null) {
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * 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("/");
- // If a connector in the instance Service
- if (i < 0) {
- int connNum = Integer.parseInt(id);
- Connector connector = serverInstance.getConnector(connNum);
- if (connector != null) {
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- }
- // Else a connector in another Service
- else {
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
-
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- Context context = serverInstance.getContext(index);
- if (context != null) {
- 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 {
- serverInstance.removeContext(index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- /**
- * Add context configuration found in META-INF/context.xml files
- * present in projects to published server.xml.
- *
- * @param baseDir path to catalina instance directory
- * @param deployDir path to deployment directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus publishContextConfig(IPath baseDir, IPath deployDir, IProgressMonitor monitor) {
- return TomcatVersionHelper.publishCatalinaContextConfig(baseDir, deployDir, monitor);
- }
-
- /**
- * Update contexts in server.xml to serve projects directly without
- * publishing.
- *
- * @param baseDir path to catalina instance directory
- * @param homeDir path to catalina install directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
- return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, tomcatVersion, loader, false, monitor);
- }
-
- /**
- * Cleanup the server instance. This consists of deleting the work
- * directory associated with Contexts that are going away in the
- * up coming publish. In addition, Context XML files which may have been
- * created for these Contexts are also deleted.
- *
- * @param baseDir path to server instance directory, i.e. catalina.base
- * @param installDir path to server installation directory (not currently used)
- * @param monitor a progress monitor or null
- * @return MultiStatus containing results of the cleanup operation
- */
- protected IStatus cleanupServer(IPath baseDir, IPath installDir, boolean removeKeptContextFiles, IProgressMonitor monitor) {
- List modules = getWebModules();
- return TomcatVersionHelper.cleanupCatalinaServer(baseDir, installDir, false, modules, monitor);
- }
-
- /**
- * @see TomcatConfiguration#localizeConfiguration(IPath, IPath, TomcatServer, IProgressMonitor)
- */
- public IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer tomcatServer, IProgressMonitor monitor) {
- return TomcatVersionHelper.localizeConfiguration(baseDir, deployDir, tomcatServer, monitor);
- }
-}
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 a08dd26e6..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Handler.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.IRuntimeClasspathEntry;
-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 IStatus verifyInstallPath(IPath installPath) {
- IStatus result = TomcatVersionHelper.checkCatalinaVersion(installPath, TomcatPlugin.TOMCAT_50);
- // If check was canceled, use folder check
- if (result.getSeverity() == IStatus.CANCEL) {
- result = TomcatPlugin.verifyInstallPathWithFolderCheck(installPath, TomcatPlugin.TOMCAT_50);
- }
- return result;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.catalina.startup.Bootstrap";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath, IPath)
- */
- public List getRuntimeClasspath(IPath installPath, IPath configPath) {
- List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
-
- // 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<String> list = new ArrayList<String>();
-
- 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#getExcludedRuntimeProgramArguments(boolean, boolean)
- */
- public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting) {
- if (!debug) {
- return new String [] { "-debug" };
- }
- return null;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv) {
- return TomcatVersionHelper.getCatalinaVMArguments(installPath, configPath, deployPath, getEndorsedDirectories(installPath), isTestEnv);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimePolicyFile(IPath)
- */
- 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(TomcatServer)
- */
- public IPath getRuntimeBaseDirectory(TomcatServer server) {
- return TomcatVersionHelper.getStandardBaseDirectory(server);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareRuntimeDirectory(IPath)
- */
- public IStatus prepareRuntimeDirectory(IPath baseDir) {
- return TomcatVersionHelper.createCatalinaInstanceDirectory(baseDir);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareDeployDirectory(IPath)
- */
- public IStatus prepareDeployDirectory(IPath deployPath) {
- return TomcatVersionHelper.createDeploymentDirectory(deployPath,
- TomcatVersionHelper.DEFAULT_WEBXML_SERVLET24);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareForServingDirectly(IPath, TomcatServer)
- */
- public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server, String tomcatVersion) {
- IStatus status;
- // If serving modules without publishing, loader jar is needed
- if (server.isServeModulesWithoutPublish()) {
- status = TomcatVersionHelper.copyLoaderJar(
- getRuntimeBaseDirectory(server).append("server/lib"),
- server.getServer().getRuntime().getRuntimeType().getId(), tomcatVersion);
- // If copy successful and running a separate server instance, modify catalina.properties
- if (status.isOK() && server.isTestEnvironment()) {
- status = TomcatVersionHelper.updatePropertiesToServeDirectly(baseDir, "server/lib", "server");
- }
- }
- // Else ensure jar is removed
- else {
- TomcatVersionHelper.removeLoaderJar(
- getRuntimeBaseDirectory(server).append("server/lib"),
- server.getServer().getRuntime().getRuntimeType().getId(), tomcatVersion);
- // TODO Decide what to do with removal warning, maybe nothing
- status = Status.OK_STATUS;
- }
- return status;
- }
-
- /**
- * @see ITomcatVersionHandler#getSharedLoader(IPath)
- */
- public String getSharedLoader(IPath baseDir) {
- // Use shared loader
- return "shared";
- }
-
- /**
- * Returns true since Tomcat 5.x supports this feature.
- *
- * @return true since feature is supported
- */
- public boolean supportsServeModulesWithoutPublish() {
- return true;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsDebugArgument()
- */
- public boolean supportsDebugArgument() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsSeparateContextFiles()
- */
- public boolean supportsSeparateContextFiles() {
- return true;
- }
-
- /**
- * @see ITomcatVersionHandler#getEndorsedDirectories(IPath)
- */
- public String getEndorsedDirectories(IPath installPath) {
- return installPath.append("common").append("endorsed").toOSString();
- }
-}
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 994327dad..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java
+++ /dev/null
@@ -1,710 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-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.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-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.Connector;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.ServerPort;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-/**
- * Tomcat v5.5 server configuration.
- */
-public class Tomcat55Configuration extends TomcatConfiguration {
- protected static final String DEFAULT_SERVICE = "Catalina";
- protected Server server;
- protected ServerInstance serverInstance;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document contextDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
-
- protected String propertiesFile;
-
- protected static final Map<String, String> protocolHandlerMap = new HashMap<String, String>();
- static {
- protocolHandlerMap.put("org.apache.coyote.http11.Http11Protocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.coyote.http11.Http11AprProtocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.coyote.ajp.AjpAprProtocol", "AJP/1.3");
- protocolHandlerMap.put("org.apache.jk.server.JkCoyoteHandler", "AJP/1.3");
- }
-
- /**
- * 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();
- // Return only an HTTP port from the selected Service
- if (port.getProtocol().toLowerCase().equals("http") && port.getId().indexOf('/') < 0)
- 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<ServerPort> ports = new ArrayList<ServerPort>();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- String instanceServiceName = serverInstance.getService().getName();
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String name = "HTTP/1.1";
- String protocol2 = "HTTP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- String protocol = connector.getProtocol();
- if (protocol != null && protocol.length() > 0) {
- if (protocol.startsWith("HTTP")) {
- name = protocol;
- }
- else if (protocol.startsWith("AJP")) {
- name = protocol;
- protocol2 = "AJP";
- }
- else {
- // Get Tomcat equivalent name if protocol handler class specified
- name = protocolHandlerMap.get(protocol);
- if (name != null) {
- // Prepare simple protocol string for ServerPort protocol
- int index = name.indexOf('/');
- if (index > 0)
- protocol2 = name.substring(0, index);
- else
- protocol2 = name;
- }
- // Specified protocol is unknown, just use as is
- else {
- name = protocol;
- protocol2 = protocol;
- }
- }
- }
- if (protocol2.toLowerCase().equals("http"))
- contentTypes = new String[] { "web", "webservices" };
- String secure = connector.getSecure();
- if (secure != null && secure.length() > 0) {
- name = "SSL";
- protocol2 = "SSL";
- } else
- advanced = false;
- String portId;
- if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
- portId = Integer.toString(j);
- else
- portId = i +"/" + j;
- ports.add(new ServerPort(portId, name, port, protocol2, contentTypes, advanced));
- }
- }
- } 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<WebModule> list = new ArrayList<WebModule>();
-
- try {
- Context [] contexts = serverInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[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#getServerWorkDirectory(IPath)
- */
- public IPath getServerWorkDirectory(IPath basePath) {
- return serverInstance.getHostWorkDirectory(basePath);
- }
-
- /**
- * @see TomcatConfiguration#getContextWorkDirectory(IPath, ITomcatWebModule)
- */
- public IPath getContextWorkDirectory(IPath basePath, ITomcatWebModule module) {
- Context context = serverInstance.getContext(module.getPath());
- if (context != null)
- return serverInstance.getContextWorkDirectory(basePath, context);
-
- return null;
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 7);
-
- // 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()));
- serverInstance = new ServerInstance(server, null, null);
- monitor.worked(1);
-
- webAppDocument = new WebAppDocument(path.append("web.xml"));
- monitor.worked(1);
-
- // load context.xml file
- File file = path.append("context.xml").toFile();
- if (file.exists())
- contextDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(file)));
- else
- contextDocument = null;
- monitor.worked(1);
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
- monitor.worked(1);
-
- // load policy file
- policyFile = TomcatVersionHelper.getFileContents(new FileInputStream(path.append("catalina.policy").toFile()));
- monitor.worked(1);
-
- // load properties file
- file = path.append("catalina.properties").toFile();
- if (file.exists())
- propertiesFile = TomcatVersionHelper.getFileContents(new FileInputStream(file));
- else
- propertiesFile = null;
- 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));
- }
- }
-
- /**
- * @see TomcatConfiguration#importFromPath(IPath, boolean, IProgressMonitor)
- */
- 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) {
- while (serverInstance.removeContext(0)) {
- // no-op
- }
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 1200);
-
- // 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);
- serverInstance = new ServerInstance(server, null, null);
- monitor.worked(200);
-
- // load web.xml
- file = folder.getFile("web.xml");
- webAppDocument = new WebAppDocument(file);
- monitor.worked(200);
-
- // load context.xml
- file = folder.getFile("context.xml");
- if (file.exists()) {
- in = file.getContents();
- contextDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- }
- else
- contextDocument = null;
- 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();
- policyFile = TomcatVersionHelper.getFileContents(in);
- monitor.worked(200);
-
- // load catalina.properties
- file = folder.getFile("catalina.properties");
- if (file.exists()) {
- in = file.getContents();
- propertiesFile = TomcatVersionHelper.getFileContents(in);
- }
- else
- propertiesFile = null;
- 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, 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());
- isServerDirty = false;
- }
- monitor.worked(1);
-
- webAppDocument.save(path.append("web.xml").toOSString(), forceDirty);
- monitor.worked(1);
-
- if (forceDirty && contextDocument != null)
- XMLUtil.save(path.append("context.xml").toOSString(), contextDocument);
- 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("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- if (propertiesFile != null && forceDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("catalina.properties").toFile()));
- bw.write(propertiesFile);
- bw.close();
- }
- monitor.worked(1);
-
- 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));
- }
- }
-
- /**
- * Save to the given directory. All files are forced to be saved.
- *
- * @param path desination path for the files
- * @param monitor a progress monitor
- * @exception CoreException
- */
- 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, 1200);
-
- // 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));
- isServerDirty = false;
-
- // save web.xml
- webAppDocument.save(folder.getFile("web.xml"), ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save context.xml
- if (contextDocument != null) {
- data = XMLUtil.getContents(contextDocument);
- in = new ByteArrayInputStream(data);
- file = folder.getFile("context.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-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));
-
- // save catalina.properties
- if (propertiesFile != null) {
- in = new ByteArrayInputStream(propertiesFile.getBytes());
- file = folder.getFile("catalina.properties");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- } else
- monitor.worked(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 {
- Context context = serverInstance.createContext(index);
- if (context != null) {
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * 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("/");
- // If a connector in the instance Service
- if (i < 0) {
- int connNum = Integer.parseInt(id);
- Connector connector = serverInstance.getConnector(connNum);
- if (connector != null) {
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- }
- // Else a connector in another Service
- else {
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- Context context = serverInstance.getContext(index);
- if (context != null) {
- 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 {
- serverInstance.removeContext(index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- /**
- * Add context configuration found in META-INF/context.xml files
- * present in projects to published server.xml.
- *
- * @param baseDir path to catalina instance directory
- * @param deployDir path to deployment directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus publishContextConfig(IPath baseDir, IPath deployDir, IProgressMonitor monitor) {
- return TomcatVersionHelper.publishCatalinaContextConfig(baseDir, deployDir, monitor);
- }
-
- /**
- * Update contexts in server.xml to serve projects directly without
- * publishing.
- *
- * @param baseDir path to catalina instance directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
- return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, tomcatVersion, loader, false, monitor);
- }
-
- /**
- * Cleanup the server instance. This consists of deleting the work
- * directory associated with Contexts that are going away in the
- * up coming publish.
- *
- * @param baseDir path to server instance directory, i.e. catalina.base
- * @param installDir path to server installation directory (not currently used)
- * @param monitor a progress monitor or null
- * @return MultiStatus containing results of the cleanup operation
- */
- protected IStatus cleanupServer(IPath baseDir, IPath installDir, boolean removeKeptContextFiles, IProgressMonitor monitor) {
- List modules = getWebModules();
- return TomcatVersionHelper.cleanupCatalinaServer(baseDir, installDir, removeKeptContextFiles, modules, monitor);
- }
-
- /**
- * @see TomcatConfiguration#localizeConfiguration(IPath, IPath, TomcatServer, IProgressMonitor)
- */
- public IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer tomcatServer, IProgressMonitor monitor) {
- return TomcatVersionHelper.localizeConfiguration(baseDir, deployDir, tomcatServer, monitor);
- }
-}
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 3f4bc048f..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, 2010 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 IStatus verifyInstallPath(IPath installPath) {
- IStatus result = TomcatVersionHelper.checkCatalinaVersion(installPath, TomcatPlugin.TOMCAT_55);
- // If check was canceled, use folder check
- if (result.getSeverity() == IStatus.CANCEL) {
- result = TomcatPlugin.verifyInstallPathWithFolderCheck(installPath, TomcatPlugin.TOMCAT_55);
- }
- return result;
- }
-
- /**
- * @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);
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Configuration.java
deleted file mode 100644
index 098a4e7c0..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Configuration.java
+++ /dev/null
@@ -1,710 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2011 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.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-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.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-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.Connector;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.ServerPort;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-/**
- * Tomcat v6.0 server configuration.
- */
-public class Tomcat60Configuration extends TomcatConfiguration {
- protected static final String DEFAULT_SERVICE = "Catalina";
- protected static final String EOL = System.getProperty("line.separator");
- protected Server server;
- protected ServerInstance serverInstance;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document contextDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
-
- protected String propertiesFile;
-
- protected static final Map<String, String> protocolHandlerMap = new HashMap<String, String>();
- static {
- protocolHandlerMap.put("org.apache.coyote.http11.Http11Protocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.coyote.http11.Http11NioProtocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.coyote.http11.Http11AprProtocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.coyote.ajp.AjpAprProtocol", "AJP/1.3");
- protocolHandlerMap.put("org.apache.jk.server.JkCoyoteHandler", "AJP/1.3");
- }
-
- /**
- * Tomcat60Configuration constructor.
- *
- * @param path a path
- */
- public Tomcat60Configuration(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();
- // Return only an HTTP port from the selected Service
- if (port.getProtocol().toLowerCase().equals("http") && port.getId().indexOf('/') < 0)
- 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<ServerPort> ports = new ArrayList<ServerPort>();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- String instanceServiceName = serverInstance.getService().getName();
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String name = "HTTP/1.1";
- String protocol2 = "HTTP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- String protocol = connector.getProtocol();
- if (protocol != null && protocol.length() > 0) {
- if (protocol.startsWith("HTTP")) {
- name = protocol;
- }
- else if (protocol.startsWith("AJP")) {
- name = protocol;
- protocol2 = "AJP";
- }
- else {
- // Get Tomcat equivalent name if protocol handler class specified
- name = protocolHandlerMap.get(protocol);
- if (name != null) {
- // Prepare simple protocol string for ServerPort protocol
- int index = name.indexOf('/');
- if (index > 0)
- protocol2 = name.substring(0, index);
- else
- protocol2 = name;
- }
- // Specified protocol is unknown, just use as is
- else {
- name = protocol;
- protocol2 = protocol;
- }
- }
- }
- if (protocol2.toLowerCase().equals("http"))
- contentTypes = new String[] { "web", "webservices" };
- String secure = connector.getSecure();
- if (secure != null && secure.length() > 0) {
- name = "SSL";
- protocol2 = "SSL";
- } else
- advanced = false;
- String portId;
- if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
- portId = Integer.toString(j);
- else
- portId = i +"/" + j;
- ports.add(new ServerPort(portId, name, port, protocol2, contentTypes, advanced));
- }
- }
- } 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<WebModule> list = new ArrayList<WebModule>();
-
- try {
- Context [] contexts = serverInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[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#getServerWorkDirectory(IPath)
- */
- public IPath getServerWorkDirectory(IPath basePath) {
- return serverInstance.getHostWorkDirectory(basePath);
- }
-
- /**
- * @see TomcatConfiguration#getContextWorkDirectory(IPath, ITomcatWebModule)
- */
- public IPath getContextWorkDirectory(IPath basePath, ITomcatWebModule module) {
- Context context = serverInstance.getContext(module.getPath());
- if (context != null)
- return serverInstance.getContextWorkDirectory(basePath, context);
-
- return null;
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 7);
-
- // 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()));
- serverInstance = new ServerInstance(server, null, null);
- monitor.worked(1);
-
- webAppDocument = new WebAppDocument(path.append("web.xml"));
- monitor.worked(1);
-
- File file = path.append("context.xml").toFile();
- if (file.exists())
- contextDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(file)));
- monitor.worked(1);
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
- monitor.worked(1);
-
- // load policy file
- policyFile = TomcatVersionHelper.getFileContents(new FileInputStream(path.append("catalina.policy").toFile()));
- monitor.worked(1);
-
- // load properties file
- file = path.append("catalina.properties").toFile();
- if (file.exists())
- propertiesFile = TomcatVersionHelper.getFileContents(new FileInputStream(file));
- else
- propertiesFile = null;
- 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));
- }
- }
-
- /**
- * @see TomcatConfiguration#importFromPath(IPath, boolean, IProgressMonitor)
- */
- 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) {
- while (serverInstance.removeContext(0)) {
- // no-op
- }
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 1200);
-
- // 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);
- serverInstance = new ServerInstance(server, null, null);
- monitor.worked(200);
-
- // load web.xml
- file = folder.getFile("web.xml");
- webAppDocument = new WebAppDocument(file);
- monitor.worked(200);
-
- // load context.xml
- file = folder.getFile("context.xml");
- if (file.exists()) {
- in = file.getContents();
- contextDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- }
- else
- contextDocument = null;
- 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();
- policyFile = TomcatVersionHelper.getFileContents(in);
- monitor.worked(200);
-
- // load catalina.properties
- file = folder.getFile("catalina.properties");
- if (file.exists()) {
- in = file.getContents();
- propertiesFile = TomcatVersionHelper.getFileContents(in);
- }
- else
- propertiesFile = null;
- 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, 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());
- isServerDirty = false;
- }
- monitor.worked(1);
-
- webAppDocument.save(path.append("web.xml").toOSString(), forceDirty);
- monitor.worked(1);
-
- if (forceDirty && contextDocument != null)
- XMLUtil.save(path.append("context.xml").toOSString(), contextDocument);
- 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("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- if (propertiesFile != null && forceDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("catalina.properties").toFile()));
- bw.write(propertiesFile);
- bw.close();
- }
- monitor.worked(1);
-
- 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));
- }
- }
-
- /**
- * Save to the given directory. All configuration files
- * are forced to be saved.
- *
- * @param path Desination path for the configuration files.
- * @param monitor A progress monitor
- * @exception CoreException
- */
- 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, 1200);
-
- // 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));
- isServerDirty = false;
-
- // save web.xml
- webAppDocument.save(folder.getFile("web.xml"), ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save context.xml
- if (contextDocument != null) {
- data = XMLUtil.getContents(contextDocument);
- in = new ByteArrayInputStream(data);
- file = folder.getFile("context.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-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));
-
- // save catalina.properties
- if (propertiesFile != null) {
- in = new ByteArrayInputStream(propertiesFile.getBytes());
- file = folder.getFile("catalina.properties");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- } else
- monitor.worked(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 {
- Context context = serverInstance.createContext(index);
- if (context != null) {
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * 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("/");
- // If a connector in the instance Service
- if (i < 0) {
- int connNum = Integer.parseInt(id);
- Connector connector = serverInstance.getConnector(connNum);
- if (connector != null) {
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- }
- // Else a connector in another Service
- else {
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- Context context = serverInstance.getContext(index);
- if (context != null) {
- 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 {
- serverInstance.removeContext(index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- /**
- * Add context configuration found in META-INF/context.xml files
- * present in projects to published server.xml.
- *
- * @param baseDir path to catalina instance directory
- * @param deployDir path to deployment directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus publishContextConfig(IPath baseDir, IPath deployDir, IProgressMonitor monitor) {
- return TomcatVersionHelper.publishCatalinaContextConfig(baseDir, deployDir, monitor);
- }
-
- /**
- * Update contexts in server.xml to serve projects directly without
- * publishing.
- *
- * @param baseDir path to catalina instance directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
- return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, tomcatVersion, loader, false, monitor);
- }
-
- /**
- * Cleanup the server instance. This consists of deleting the work
- * directory associated with Contexts that are going away in the
- * up coming publish.
- *
- * @param baseDir path to server instance directory, i.e. catalina.base
- * @param installDir path to server installation directory (not currently used)
- * @param monitor a progress monitor or null
- * @return MultiStatus containing results of the cleanup operation
- */
- protected IStatus cleanupServer(IPath baseDir, IPath installDir, boolean removeKeptContextFiles, IProgressMonitor monitor) {
- List modules = getWebModules();
- return TomcatVersionHelper.cleanupCatalinaServer(baseDir, installDir, removeKeptContextFiles, modules, monitor);
- }
-
- /**
- * @see TomcatConfiguration#localizeConfiguration(IPath, IPath, TomcatServer, IProgressMonitor)
- */
- public IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer tomcatServer, IProgressMonitor monitor) {
- return TomcatVersionHelper.localizeConfiguration(baseDir, deployDir, tomcatServer, monitor);
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Handler.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Handler.java
deleted file mode 100644
index 41356114a..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Handler.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2011 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.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IModule;
-/**
- * Tomcat 60 handler.
- */
-public class Tomcat60Handler implements ITomcatVersionHandler {
- /**
- * @see ITomcatVersionHandler#verifyInstallPath(IPath)
- */
- public IStatus verifyInstallPath(IPath installPath) {
- IStatus result = TomcatVersionHelper.checkCatalinaVersion(installPath, TomcatPlugin.TOMCAT_60);
- // If check was canceled, use folder check
- if (result.getSeverity() == IStatus.CANCEL) {
- result = TomcatPlugin.verifyInstallPathWithFolderCheck(installPath, TomcatPlugin.TOMCAT_60);
- }
- return result;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.catalina.startup.Bootstrap";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath, IPath)
- */
- public List getRuntimeClasspath(IPath installPath, IPath configPath) {
- List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
-
- // 6.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<String> list = new ArrayList<String>();
-
- if (starting)
- list.add("start");
- else
- list.add("stop");
-
- String[] temp = new String[list.size()];
- list.toArray(temp);
- return temp;
- }
-
- /**
- * @see ITomcatVersionHandler#getExcludedRuntimeProgramArguments(boolean, boolean)
- */
- public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting) {
- return null;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv) {
- return TomcatVersionHelper.getCatalinaVMArguments(installPath, configPath, deployPath, getEndorsedDirectories(installPath), isTestEnv);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimePolicyFile(IPath)
- */
- 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)|| "2.5".equals(version))
- return Status.OK_STATUS;
-
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorSpec60, null);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeBaseDirectory(TomcatServer)
- */
- public IPath getRuntimeBaseDirectory(TomcatServer server) {
- return TomcatVersionHelper.getStandardBaseDirectory(server);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareRuntimeDirectory(IPath)
- */
- public IStatus prepareRuntimeDirectory(IPath baseDir) {
- return TomcatVersionHelper.createCatalinaInstanceDirectory(baseDir);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareDeployDirectory(IPath)
- */
- public IStatus prepareDeployDirectory(IPath deployPath) {
- return TomcatVersionHelper.createDeploymentDirectory(deployPath,
- TomcatVersionHelper.DEFAULT_WEBXML_SERVLET25);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareForServingDirectly(IPath, TomcatServer)
- */
- public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server, String tomcatVersion) {
- IStatus status;
- // If serving modules without publishing, loader jar is needed
- // TODO Need to examine catalina.properties to ensure loader jar and catalina.properties are handled appropriately
- if (server.isServeModulesWithoutPublish()) {
- status = TomcatVersionHelper.copyLoaderJar(
- getRuntimeBaseDirectory(server).append("lib"),
- server.getServer().getRuntime().getRuntimeType().getId(), tomcatVersion);
- // If copy successful and running a separate server instance, modify catalina.properties
- if (status.isOK() && server.isTestEnvironment()) {
- status = TomcatVersionHelper.updatePropertiesToServeDirectly(baseDir, "lib", "common");
- }
- }
- // Else ensure jar is removed
- else {
- TomcatVersionHelper.removeLoaderJar(
- getRuntimeBaseDirectory(server).append("lib"),
- server.getServer().getRuntime().getRuntimeType().getId(), tomcatVersion);
- // TODO Decide what to do with removal warning, maybe nothing
- status = Status.OK_STATUS;
- }
- return status;
- }
-
- /**
- * @see ITomcatVersionHandler#getSharedLoader(IPath)
- */
- public String getSharedLoader(IPath baseDir) {
- return "common";
- }
-
- /**
- * Returns true since Tomcat 6.x supports this feature.
- *
- * @return true since feature is supported
- */
- public boolean supportsServeModulesWithoutPublish() {
- return true;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsDebugArgument()
- */
- public boolean supportsDebugArgument() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsSeparateContextFiles()
- */
- public boolean supportsSeparateContextFiles() {
- return true;
- }
-
- /**
- * @see ITomcatVersionHandler#getEndorsedDirectories(IPath)
- */
- public String getEndorsedDirectories(IPath installPath) {
- return installPath.append("endorsed").toOSString();
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Configuration.java
deleted file mode 100644
index dc37b1d4b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Configuration.java
+++ /dev/null
@@ -1,710 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2011 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.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-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.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-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.Connector;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.ServerPort;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-/**
- * Tomcat v7.0 server configuration.
- */
-public class Tomcat70Configuration extends TomcatConfiguration {
- protected static final String DEFAULT_SERVICE = "Catalina";
- protected static final String EOL = System.getProperty("line.separator");
- protected Server server;
- protected ServerInstance serverInstance;
- protected Factory serverFactory;
- protected boolean isServerDirty;
-
- protected WebAppDocument webAppDocument;
-
- protected Document contextDocument;
-
- protected Document tomcatUsersDocument;
-
- protected String policyFile;
-
- protected String propertiesFile;
-
- protected static final Map<String, String> protocolHandlerMap = new HashMap<String, String>();
- static {
- protocolHandlerMap.put("org.apache.coyote.http11.Http11Protocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.coyote.http11.Http11NioProtocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.coyote.http11.Http11AprProtocol", "HTTP/1.1");
- protocolHandlerMap.put("org.apache.coyote.ajp.AjpAprProtocol", "AJP/1.3");
- protocolHandlerMap.put("org.apache.jk.server.JkCoyoteHandler", "AJP/1.3");
- }
-
- /**
- * Tomcat60Configuration constructor.
- *
- * @param path a path
- */
- public Tomcat70Configuration(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();
- // Return only an HTTP port from the selected Service
- if (port.getProtocol().toLowerCase().equals("http") && port.getId().indexOf('/') < 0)
- 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<ServerPort> ports = new ArrayList<ServerPort>();
-
- // first add server port
- try {
- int port = Integer.parseInt(server.getPort());
- ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
- } catch (Exception e) {
- // ignore
- }
-
- // add connectors
- try {
- String instanceServiceName = serverInstance.getService().getName();
- int size = server.getServiceCount();
- for (int i = 0; i < size; i++) {
- Service service = server.getService(i);
- int size2 = service.getConnectorCount();
- for (int j = 0; j < size2; j++) {
- Connector connector = service.getConnector(j);
- String name = "HTTP/1.1";
- String protocol2 = "HTTP";
- boolean advanced = true;
- String[] contentTypes = null;
- int port = -1;
- try {
- port = Integer.parseInt(connector.getPort());
- } catch (Exception e) {
- // ignore
- }
- String protocol = connector.getProtocol();
- if (protocol != null && protocol.length() > 0) {
- if (protocol.startsWith("HTTP")) {
- name = protocol;
- }
- else if (protocol.startsWith("AJP")) {
- name = protocol;
- protocol2 = "AJP";
- }
- else {
- // Get Tomcat equivalent name if protocol handler class specified
- name = protocolHandlerMap.get(protocol);
- if (name != null) {
- // Prepare simple protocol string for ServerPort protocol
- int index = name.indexOf('/');
- if (index > 0)
- protocol2 = name.substring(0, index);
- else
- protocol2 = name;
- }
- // Specified protocol is unknown, just use as is
- else {
- name = protocol;
- protocol2 = protocol;
- }
- }
- }
- if (protocol2.toLowerCase().equals("http"))
- contentTypes = new String[] { "web", "webservices" };
- String secure = connector.getSecure();
- if (secure != null && secure.length() > 0) {
- name = "SSL";
- protocol2 = "SSL";
- } else
- advanced = false;
- String portId;
- if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
- portId = Integer.toString(j);
- else
- portId = i +"/" + j;
- ports.add(new ServerPort(portId, name, port, protocol2, contentTypes, advanced));
- }
- }
- } 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<WebModule> list = new ArrayList<WebModule>();
-
- try {
- Context [] contexts = serverInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[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#getServerWorkDirectory(IPath)
- */
- public IPath getServerWorkDirectory(IPath basePath) {
- return serverInstance.getHostWorkDirectory(basePath);
- }
-
- /**
- * @see TomcatConfiguration#getContextWorkDirectory(IPath, ITomcatWebModule)
- */
- public IPath getContextWorkDirectory(IPath basePath, ITomcatWebModule module) {
- Context context = serverInstance.getContext(module.getPath());
- if (context != null)
- return serverInstance.getContextWorkDirectory(basePath, context);
-
- return null;
- }
-
- /**
- * @see TomcatConfiguration#load(IPath, IProgressMonitor)
- */
- public void load(IPath path, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 7);
-
- // 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()));
- serverInstance = new ServerInstance(server, null, null);
- monitor.worked(1);
-
- webAppDocument = new WebAppDocument(path.append("web.xml"));
- monitor.worked(1);
-
- File file = path.append("context.xml").toFile();
- if (file.exists())
- contextDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(file)));
- monitor.worked(1);
-
- tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
- monitor.worked(1);
-
- // load policy file
- policyFile = TomcatVersionHelper.getFileContents(new FileInputStream(path.append("catalina.policy").toFile()));
- monitor.worked(1);
-
- // load properties file
- file = path.append("catalina.properties").toFile();
- if (file.exists())
- propertiesFile = TomcatVersionHelper.getFileContents(new FileInputStream(file));
- else
- propertiesFile = null;
- 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));
- }
- }
-
- /**
- * @see TomcatConfiguration#importFromPath(IPath, boolean, IProgressMonitor)
- */
- 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) {
- while (serverInstance.removeContext(0)) {
- // no-op
- }
- }
- }
-
- /**
- * @see TomcatConfiguration#load(IFolder, IProgressMonitor)
- */
- public void load(IFolder folder, IProgressMonitor monitor) throws CoreException {
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.loadingTask, 1200);
-
- // 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);
- serverInstance = new ServerInstance(server, null, null);
- monitor.worked(200);
-
- // load web.xml
- file = folder.getFile("web.xml");
- webAppDocument = new WebAppDocument(file);
- monitor.worked(200);
-
- // load context.xml
- file = folder.getFile("context.xml");
- if (file.exists()) {
- in = file.getContents();
- contextDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- }
- else
- contextDocument = null;
- 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();
- policyFile = TomcatVersionHelper.getFileContents(in);
- monitor.worked(200);
-
- // load catalina.properties
- file = folder.getFile("catalina.properties");
- if (file.exists()) {
- in = file.getContents();
- propertiesFile = TomcatVersionHelper.getFileContents(in);
- }
- else
- propertiesFile = null;
- 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, 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());
- isServerDirty = false;
- }
- monitor.worked(1);
-
- webAppDocument.save(path.append("web.xml").toOSString(), forceDirty);
- monitor.worked(1);
-
- if (forceDirty && contextDocument != null)
- XMLUtil.save(path.append("context.xml").toOSString(), contextDocument);
- 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("catalina.policy").toFile()));
- bw.write(policyFile);
- bw.close();
- }
- monitor.worked(1);
- if (propertiesFile != null && forceDirty) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(path.append("catalina.properties").toFile()));
- bw.write(propertiesFile);
- bw.close();
- }
- monitor.worked(1);
-
- 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));
- }
- }
-
- /**
- * Save to the given directory. All configuration files
- * are forced to be saved.
- *
- * @param path Desination path for the configuration files.
- * @param monitor A progress monitor
- * @exception CoreException
- */
- 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, 1200);
-
- // 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));
- isServerDirty = false;
-
- // save web.xml
- webAppDocument.save(folder.getFile("web.xml"), ProgressUtil.getSubMonitorFor(monitor, 200));
-
- // save context.xml
- if (contextDocument != null) {
- data = XMLUtil.getContents(contextDocument);
- in = new ByteArrayInputStream(data);
- file = folder.getFile("context.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-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));
-
- // save catalina.properties
- if (propertiesFile != null) {
- in = new ByteArrayInputStream(propertiesFile.getBytes());
- file = folder.getFile("catalina.properties");
- if (file.exists())
- monitor.worked(200);
- //file.setContents(in, true, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- else
- file.create(in, true, ProgressUtil.getSubMonitorFor(monitor, 200));
- } else
- monitor.worked(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 {
- Context context = serverInstance.createContext(index);
- if (context != null) {
- context.setDocBase(module.getDocumentBase());
- context.setPath(module.getPath());
- context.setReloadable(module.isReloadable() ? "true" : "false");
- if (module.getMemento() != null && module.getMemento().length() > 0)
- context.setSource(module.getMemento());
- isServerDirty = true;
- firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
- }
- }
-
- /**
- * 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("/");
- // If a connector in the instance Service
- if (i < 0) {
- int connNum = Integer.parseInt(id);
- Connector connector = serverInstance.getConnector(connNum);
- if (connector != null) {
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- }
- // Else a connector in another Service
- else {
- int servNum = Integer.parseInt(id.substring(0, i));
- int connNum = Integer.parseInt(id.substring(i + 1));
-
- Service service = server.getService(servNum);
- Connector connector = service.getConnector(connNum);
- connector.setPort(port + "");
- isServerDirty = true;
- firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
- }
- }
- /**
- * Change a web module.
- * @param index int
- * @param docBase java.lang.String
- * @param path java.lang.String
- * @param reloadable boolean
- */
- public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
- try {
- Context context = serverInstance.getContext(index);
- if (context != null) {
- 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 {
- serverInstance.removeContext(index);
- isServerDirty = true;
- firePropertyChangeEvent(REMOVE_WEB_MODULE_PROPERTY, null, new Integer(index));
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
- }
- }
-
- /**
- * Add context configuration found in META-INF/context.xml files
- * present in projects to published server.xml.
- *
- * @param baseDir path to catalina instance directory
- * @param deployDir path to deployment directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus publishContextConfig(IPath baseDir, IPath deployDir, IProgressMonitor monitor) {
- return TomcatVersionHelper.publishCatalinaContextConfig(baseDir, deployDir, monitor);
- }
-
- /**
- * Update contexts in server.xml to serve projects directly without
- * publishing.
- *
- * @param baseDir path to catalina instance directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
- return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, tomcatVersion, loader, true, monitor);
- }
-
- /**
- * Cleanup the server instance. This consists of deleting the work
- * directory associated with Contexts that are going away in the
- * up coming publish.
- *
- * @param baseDir path to server instance directory, i.e. catalina.base
- * @param installDir path to server installation directory (not currently used)
- * @param monitor a progress monitor or null
- * @return MultiStatus containing results of the cleanup operation
- */
- protected IStatus cleanupServer(IPath baseDir, IPath installDir, boolean removeKeptContextFiles, IProgressMonitor monitor) {
- List modules = getWebModules();
- return TomcatVersionHelper.cleanupCatalinaServer(baseDir, installDir, removeKeptContextFiles, modules, monitor);
- }
-
- /**
- * @see TomcatConfiguration#localizeConfiguration(IPath, IPath, TomcatServer, IProgressMonitor)
- */
- public IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer tomcatServer, IProgressMonitor monitor) {
- return TomcatVersionHelper.localizeConfiguration(baseDir, deployDir, tomcatServer, monitor);
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Handler.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Handler.java
deleted file mode 100644
index 98bcb32c5..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Handler.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2010, 2011 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.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IModule;
-/**
- * Tomcat 70 handler.
- */
-public class Tomcat70Handler implements ITomcatVersionHandler {
- /**
- * @see ITomcatVersionHandler#verifyInstallPath(IPath)
- */
- public IStatus verifyInstallPath(IPath installPath) {
- IStatus result = TomcatVersionHelper.checkCatalinaVersion(installPath, TomcatPlugin.TOMCAT_70);
- // If check was canceled, use folder check
- if (result.getSeverity() == IStatus.CANCEL) {
- result = TomcatPlugin.verifyInstallPathWithFolderCheck(installPath, TomcatPlugin.TOMCAT_70);
- }
- return result;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.catalina.startup.Bootstrap";
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeClasspath(IPath, IPath)
- */
- public List getRuntimeClasspath(IPath installPath, IPath configPath) {
- List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
-
- // 7.0 - add bootstrap.jar and tomcat-juli.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));
- // Add tomcat-juli.jar if it exists
- path = binPath.append("tomcat-juli.jar");
- if (path.toFile().exists()) {
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
- }
- // If tomcat-juli.jar is not found in the install, check the config directory
- else if (configPath != null){
- path = configPath.append("bin/tomcat-juli.jar");
- if (path.toFile().exists()) {
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
- }
- }
- }
-
- return cp;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeProgramArguments(IPath, boolean, boolean)
- */
- public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting) {
- List<String> list = new ArrayList<String>();
-
- if (starting)
- list.add("start");
- else
- list.add("stop");
-
- String[] temp = new String[list.size()];
- list.toArray(temp);
- return temp;
- }
-
- /**
- * @see ITomcatVersionHandler#getExcludedRuntimeProgramArguments(boolean, boolean)
- */
- public String[] getExcludedRuntimeProgramArguments(boolean debug, boolean starting) {
- return null;
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeVMArguments(IPath, IPath, IPath, boolean)
- */
- public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv) {
- return TomcatVersionHelper.getCatalinaVMArguments(installPath, configPath, deployPath, getEndorsedDirectories(installPath), isTestEnv);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimePolicyFile(IPath)
- */
- 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) || "2.5".equals(version)
- || "3.0".equals(version))
- return Status.OK_STATUS;
-
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorSpec70, null);
- }
-
- /**
- * @see ITomcatVersionHandler#getRuntimeBaseDirectory(TomcatServer)
- */
- public IPath getRuntimeBaseDirectory(TomcatServer server) {
- return TomcatVersionHelper.getStandardBaseDirectory(server);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareRuntimeDirectory(IPath)
- */
- public IStatus prepareRuntimeDirectory(IPath baseDir) {
- return TomcatVersionHelper.createCatalinaInstanceDirectory(baseDir);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareDeployDirectory(IPath)
- */
- public IStatus prepareDeployDirectory(IPath deployPath) {
- return TomcatVersionHelper.createDeploymentDirectory(deployPath,
- TomcatVersionHelper.DEFAULT_WEBXML_SERVLET25);
- }
-
- /**
- * @see ITomcatVersionHandler#prepareForServingDirectly(IPath, TomcatServer)
- */
- public IStatus prepareForServingDirectly(IPath baseDir, TomcatServer server, String tomcatVersion) {
- IStatus status;
- // If serving modules without publishing, loader jar is needed
- // TODO Need to examine catalina.properties to ensure loader jar and catalina.properties are handled appropriately
- if (server.isServeModulesWithoutPublish()) {
- status = TomcatVersionHelper.copyLoaderJar(
- getRuntimeBaseDirectory(server).append("lib"),
- server.getServer().getRuntime().getRuntimeType().getId(), tomcatVersion);
- // If copy successful and running a separate server instance, modify catalina.properties
- if (status.isOK() && server.isTestEnvironment()) {
- status = TomcatVersionHelper.updatePropertiesToServeDirectly(baseDir, "lib", "common");
- }
- }
- // Else ensure jar is removed
- else {
- TomcatVersionHelper.removeLoaderJar(
- getRuntimeBaseDirectory(server).append("lib"),
- server.getServer().getRuntime().getRuntimeType().getId(), tomcatVersion);
- // TODO Decide what to do with removal warning, maybe nothing
- status = Status.OK_STATUS;
- }
- return status;
- }
-
- /**
- * @see ITomcatVersionHandler#getSharedLoader(IPath)
- */
- public String getSharedLoader(IPath baseDir) {
- return "common";
- }
-
- /**
- * Returns true since Tomcat 6.x supports this feature.
- *
- * @return true since feature is supported
- */
- public boolean supportsServeModulesWithoutPublish() {
- return true;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsDebugArgument()
- */
- public boolean supportsDebugArgument() {
- return false;
- }
-
- /**
- * @see ITomcatVersionHandler#supportsSeparateContextFiles()
- */
- public boolean supportsSeparateContextFiles() {
- return true;
- }
-
- /**
- * @see ITomcatVersionHandler#getEndorsedDirectories(IPath)
- */
- public String getEndorsedDirectories(IPath installPath) {
- return installPath.append("endorsed").toOSString();
- }
-}
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 c905841c1..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.FileInputStream;
-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";
-
- protected IFolder configPath;
-
- // property change listeners
- private transient List<PropertyChangeListener> 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 result of operation
- */
- protected IStatus backupAndPublish(IPath tomcatDir, boolean doBackup, IProgressMonitor monitor) {
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, Messages.publishConfigurationTask, null);
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Backup and publish");
- monitor = ProgressUtil.getMonitorFor(monitor);
-
- try {
- IPath backup = null;
- if (doBackup) {
- // create backup directory
- backup = 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}));
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINEST, "Publishing " + name);
-
- // backup and copy file
- boolean copy = true;
- if (backup != null && !(backup.append(name).toFile().exists())) {
- IStatus status = FileUtil.copyFile(confDir.append(name).toOSString(), backup + File.separator + name);
- ms.add(status);
- if (!status.isOK())
- copy = false;
- }
-
- if (copy) {
- String destPath = confDir.append(name).toOSString();
- String destContents = null;
- String srcContents = null;
- File dest = new File(destPath);
- if (dest.exists()) {
- InputStream fis = new FileInputStream(destPath);
- destContents = TomcatVersionHelper.getFileContents(fis);
- if (destContents != null) {
- fis = file.getContents();
- srcContents = TomcatVersionHelper.getFileContents(fis);
- }
- }
- if (destContents == null || srcContents == null || !srcContents.equals(destContents)) {
- InputStream in = file.getContents();
- ms.add(FileUtil.copyFile(in, destPath));
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
- ms.add(new Status(IStatus.ERROR, 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}));
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINEST, "Publishing " + name);
-
- // backup and copy file
- boolean copy = true;
- if (backup != null && !(backup.append(name).toFile().exists())) {
- IStatus status = FileUtil.copyFile(confDir.append(name).toOSString(), backup + File.separator + name);
- ms.add(status);
- if (!status.isOK())
- copy = false;
- }
-
- 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, IPath deployDir, IProgressMonitor monitor) {
- // Default implementation assumes nothing to do
- return Status.OK_STATUS;
- }
-
-
- protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
- // Default implementation assumes nothing to do
- return Status.OK_STATUS;
- }
-
- protected IStatus cleanupServer(IPath confDir, IPath installDir, boolean removeKeptContextFiles, IProgressMonitor monitor) {
- // Default implementation assumes nothing to clean
- return Status.OK_STATUS;
- }
-
- /**
- * Make any local changes to the server configuration at the specified runtime
- * base directory needed to complete publishing the server.
- *
- * @param baseDir runtime base directory for the server
- * @param deployDir deployment directory for the server
- * @param server server being localized
- * @param monitor a progress monitor
- * @return result of operation
- */
- public abstract IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer server, IProgressMonitor monitor);
-
- /**
- * 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
- */
- public 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<PropertyChangeListener>();
- propertyListeners.add(listener);
- }
-
- /**
- * Removes a property change listener from this server.
- *
- * @param listener java.beans.PropertyChangeListener
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- if (propertyListeners != null)
- propertyListeners.remove(listener);
- }
-
- 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;
-
- /**
- * @see ITomcatConfigurationWorkingCopy#addWebModule(int, ITomcatWebModule)
- */
- public abstract void addWebModule(int index, ITomcatWebModule module);
-
- /**
- * @see ITomcatConfigurationWorkingCopy#removeWebModule(int)
- */
- public abstract void removeWebModule(int index);
-
- /**
- * Gets the work directory for the server.
- *
- * @param basePath path to server runtime directory
- * @return path for the server's work directory
- */
- public abstract IPath getServerWorkDirectory(IPath basePath);
-
- /**
- * Gets the work directory for the specified module on the
- * server.
- *
- * @param basePath path to server runtime directory
- * @param module a Tomcat web module
- * @return path for the module's work directory on the server
- */
- public abstract IPath getContextWorkDirectory(IPath basePath, ITomcatWebModule module);
-
- /**
- * Return a string representation of this object.
- * @return java.lang.String
- */
- public String toString() {
- return "TomcatConfiguration[" + getFolder() + "]";
- }
-}
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 b82db3be4..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatLaunchConfigurationDelegate.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2009 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.debug.core.ILaunchManager;
-import org.eclipse.jdt.launching.*;
-import org.eclipse.jst.server.core.ServerProfilerDelegate;
-
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerCore;
-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;
- }
-
- if (server.shouldPublish() && ServerCore.isAutoPublishing())
- server.publish(IServer.PUBLISH_INCREMENTAL, monitor);
-
- TomcatServerBehaviour tomcatServer = (TomcatServerBehaviour) server.loadAdapter(TomcatServerBehaviour.class, null);
-
- String mainTypeName = tomcatServer.getRuntimeClass();
-
- IVMInstall vm = verifyVMInstall(configuration);
-
- IVMRunner runner = vm.getVMRunner(mode);
- if (runner == null)
- runner = vm.getVMRunner(ILaunchManager.RUN_MODE);
-
- File workingDir = verifyWorkingDirectory(configuration);
- String workingDirName = null;
- if (workingDir != null)
- workingDirName = workingDir.getAbsolutePath();
-
- // Program & VM args
- String pgmArgs = getProgramArguments(configuration);
- String vmArgs = getVMArguments(configuration);
- String[] envp = getEnvironment(configuration);
-
- ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
-
- // VM-specific attributes
- Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
-
- // Classpath
- String[] classpath = getClasspath(configuration);
-
- // Create VM config
- VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
- runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
- runConfig.setVMArguments(execArgs.getVMArgumentsArray());
- runConfig.setWorkingDirectory(workingDirName);
- runConfig.setEnvironment(envp);
- runConfig.setVMSpecificAttributesMap(vmAttributesMap);
-
- // Bootpath
- String[] bootpath = getBootpath(configuration);
- if (bootpath != null && bootpath.length > 0)
- runConfig.setBootClassPath(bootpath);
-
- setDefaultSourceLocator(launch, configuration);
-
- if (ILaunchManager.PROFILE_MODE.equals(mode)) {
- try {
- ServerProfilerDelegate.configureProfiling(launch, vm, runConfig, monitor);
- } catch (CoreException ce) {
- tomcatServer.stopImpl();
- throw ce;
- }
- }
-
- // Launch the configuration
- tomcatServer.setupLaunch(launch, mode, monitor);
- try {
- runner.run(runConfig, launch, monitor);
- tomcatServer.addProcessListener(launch.getProcesses()[0]);
- } catch (Exception e) {
- // Ensure we don't continue to think the server is starting
- tomcatServer.stopImpl();
- }
- }
-} \ 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 eaf390333..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, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.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.loadAdapter(IURLProvider.class, null)).getModuleRootURL(moduleObject.getModule());
-
- Trace.trace(Trace.FINER, "root: " + url);
-
- if (moduleObject instanceof Servlet) {
- Servlet servlet = (Servlet) moduleObject;
- if (servlet.getAlias() != null) {
- String path = servlet.getAlias();
- if (path.startsWith("/"))
- path = path.substring(1);
- url = new URL(url, path);
- } else
- url = new URL(url, "servlet/" + servlet.getServletClassName());
- } else if (moduleObject instanceof WebResource) {
- WebResource resource = (WebResource) moduleObject;
- String path = resource.getPath().toString();
- Trace.trace(Trace.FINER, "path: " + path);
- if (path != null && path.startsWith("/") && path.length() > 0)
- path = path.substring(1);
- if (path != null && path.length() > 0)
- url = new URL(url, path);
- }
- return new HttpLaunchable(url);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error getting URL for " + moduleObject, e);
- return null;
- }
- }
-}
diff --git a/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 814d90b48..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPlugin.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.BundleContext;
-/**
- * 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";
- public static final String TOMCAT_60 = "org.eclipse.jst.server.tomcat.60";
- public static final String TOMCAT_70 = "org.eclipse.jst.server.tomcat.70";
-
- protected static final String VERIFY_INSTALL_FILE = "verifyInstall.properties";
- protected static VerifyResourceSpec[] verify32;
- protected static VerifyResourceSpec[] verify40;
- protected static VerifyResourceSpec[] verify41;
- protected static VerifyResourceSpec[] verify50;
- protected static VerifyResourceSpec[] verify55;
- protected static VerifyResourceSpec[] verify60;
- protected static VerifyResourceSpec[] verify70;
-
- protected static final IStatus emptyInstallDirStatus = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorInstallDirEmpty, null);
- protected static final IStatus wrongDirVersionStatus = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorInstallDirWrongVersion, null);
- protected static final IStatus installDirDoesNotExist = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorInstallDirDoesNotExist, null);
-
- private static ConfigurationResourceListener configurationListener;
- /**
- * TomcatPlugin constructor comment.
- */
- public TomcatPlugin() {
- super();
- singleton = this;
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- configurationListener = new ConfigurationResourceListener();
- ResourcesPlugin.getWorkspace().addResourceChangeListener(configurationListener, IResourceChangeEvent.POST_CHANGE);
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(configurationListener);
- super.stop(context);
- }
-
- /**
- * 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 if (TOMCAT_60.equals(id))
- return new Tomcat60Handler();
- else if (TOMCAT_70.equals(id))
- return new Tomcat70Handler();
- else
- return null;
- }
-
- /**
- * Loads the files to verify the Tomcat installation.
- */
- public static void loadVerifyFiles() {
- if (verify32 != null)
- return;
-
- // backup (empty) values
- verify32 = new VerifyResourceSpec[0];
- verify40 = new VerifyResourceSpec[0];
- verify41 = new VerifyResourceSpec[0];
- verify50 = new VerifyResourceSpec[0];
- verify55 = new VerifyResourceSpec[0];
- verify60 = new VerifyResourceSpec[0];
- verify70 = new VerifyResourceSpec[0];
-
- try {
- URL url = getInstance().getBundle().getEntry(VERIFY_INSTALL_FILE);
- url = FileLocator.resolve(url);
- Properties p = new Properties();
- p.load(url.openStream());
-
- // Check backdoor system property, use internal spec if not found
- String verify = System.getProperty(PLUGIN_ID + ".verify32install");
- if (verify == null) {
- verify = p.getProperty("verify32install");
- }
- verify.replace('/', File.separatorChar);
-
- StringTokenizer st = new StringTokenizer(verify, ",");
- List<VerifyResourceSpec> list = new ArrayList<VerifyResourceSpec>();
- while (st.hasMoreTokens())
- list.add(new VerifyResourceSpec(st.nextToken()));
- Trace.trace(Trace.FINEST, "Verify32: " + list.toString());
- verify32 = new VerifyResourceSpec[list.size()];
- list.toArray(verify32);
-
- // v4.0
- // Check backdoor system property, use internal spec if not found
- verify = System.getProperty(PLUGIN_ID + ".verify40install");
- if (verify == null) {
- verify = p.getProperty("verify40install");
- }
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList<VerifyResourceSpec>();
- while (st.hasMoreTokens())
- list.add(new VerifyResourceSpec(st.nextToken()));
- Trace.trace(Trace.FINEST, "Verify40: " + list.toString());
- verify40 = new VerifyResourceSpec[list.size()];
- list.toArray(verify40);
-
- // v4.1
- // Check backdoor system property, use internal spec if not found
- verify = System.getProperty(PLUGIN_ID + ".verify41install");
- if (verify == null) {
- verify = p.getProperty("verify41install");
- }
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList<VerifyResourceSpec>();
- while (st.hasMoreTokens())
- list.add(new VerifyResourceSpec(st.nextToken()));
- Trace.trace(Trace.FINEST, "Verify41: " + list.toString());
- verify41 = new VerifyResourceSpec[list.size()];
- list.toArray(verify41);
-
- // v5.0
- // Check backdoor system property, use internal spec if not found
- verify = System.getProperty(PLUGIN_ID + ".verify50install");
- if (verify == null) {
- verify = p.getProperty("verify50install");
- }
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList<VerifyResourceSpec>();
- while (st.hasMoreTokens())
- list.add(new VerifyResourceSpec(st.nextToken()));
- Trace.trace(Trace.FINEST, "Verify50: " + list.toString());
- verify50 = new VerifyResourceSpec[list.size()];
- list.toArray(verify50);
-
- // v5.5
- // Check backdoor system property, use internal spec if not found
- verify = System.getProperty(PLUGIN_ID + ".verify55install");
- if (verify == null) {
- verify = p.getProperty("verify55install");
- }
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList<VerifyResourceSpec>();
- while (st.hasMoreTokens())
- list.add(new VerifyResourceSpec(st.nextToken()));
- Trace.trace(Trace.FINEST, "Verify55: " + list.toString());
- verify55 = new VerifyResourceSpec[list.size()];
- list.toArray(verify55);
-
- // v6.0
- // Check backdoor system property, use internal spec if not found
- verify = System.getProperty(PLUGIN_ID + ".verify60install");
- if (verify == null) {
- verify = p.getProperty("verify60install");
- }
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList<VerifyResourceSpec>();
- while (st.hasMoreTokens())
- list.add(new VerifyResourceSpec(st.nextToken()));
- Trace.trace(Trace.FINEST, "Verify60: " + list.toString());
- verify60 = new VerifyResourceSpec[list.size()];
- list.toArray(verify60);
-
- // v7.0
- // Check backdoor system property, use internal spec if not found
- verify = System.getProperty(PLUGIN_ID + ".verify70install");
- if (verify == null) {
- verify = p.getProperty("verify70install");
- }
- verify.replace('/', File.separatorChar);
-
- st = new StringTokenizer(verify, ",");
- list = new ArrayList<VerifyResourceSpec>();
- while (st.hasMoreTokens())
- list.add(new VerifyResourceSpec(st.nextToken()));
- Trace.trace(Trace.FINEST, "Verify70: " + list.toString());
- verify70 = new VerifyResourceSpec[list.size()];
- list.toArray(verify70);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not load installation verification properties", e);
- }
- }
-
- /**
- * Utility method to verify an installation directory according to the
- * specified server ID. The verification includes checking the installation
- * directory name to see if it indicates a different version of Tomcat.
- *
- * @param installPath Path to verify
- * @param id Type ID of the server
- * @return Status of the verification. Will be Status.OK_STATUS, if verification
- * was successful, or error status if not.
- */
- public static IStatus verifyInstallPathWithFolderCheck(IPath installPath, String id) {
- IStatus status = verifyTomcatVersionFromPath(installPath, id);
- if (status.isOK()) {
- status = verifyInstallPath(installPath, id);
- }
- return status;
- }
-
- /**
- * Verify the Tomcat installation directory.
- *
- * @param installPath Path to verify
- * @param id Type ID of the server
- * @return Status of the verification. Will be Status.OK_STATUS, if verification
- * was successful, or error status if not.
- */
- public static IStatus verifyInstallPath(IPath installPath, String id) {
- if (installPath == null)
- return emptyInstallDirStatus;
-
- String dir = installPath.toOSString();
- if (dir.trim().length() == 0)
- return emptyInstallDirStatus;
-
- File file = new File(dir);
- if (!file.exists())
- return installDirDoesNotExist;
-
- if (!dir.endsWith(File.separator))
- dir += File.separator;
-
- // look for the following files and directories
- TomcatPlugin.loadVerifyFiles();
-
- VerifyResourceSpec[] specs = null;
- if (TOMCAT_32.equals(id))
- specs = verify32;
- else if (TOMCAT_40.equals(id))
- specs = verify40;
- else if (TOMCAT_41.equals(id))
- specs = verify41;
- else if (TOMCAT_50.equals(id))
- specs = verify50;
- else if (TOMCAT_55.equals(id)) {
- specs = verify55;
- }
- else if (TOMCAT_60.equals(id)) {
- specs = verify60;
- }
- else
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorUnknownVersion, null);
-
- for (int i = 0; i < specs.length; i++) {
- VerifyResourceSpec fs = specs[i];
- IStatus status = fs.checkResource(dir);
- if (!status.isOK()) {
- return status;
- }
- }
- return Status.OK_STATUS;
- }
-
- public static IStatus verifyTomcatVersionFromPath(IPath installPath, String version) {
- if (version == null)
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorVersionEmpty, null);
- if (installPath == null)
- return emptyInstallDirStatus;
-
- String s = installPath.lastSegment();
- if (s == null)
- return Status.OK_STATUS;
- if (s.indexOf("-3.2") > 0 || s.indexOf(" 3.2") > 0)
- return TOMCAT_32.equals(version) ? Status.OK_STATUS : wrongDirVersionStatus;
- if (s.indexOf("-4.0") > 0 || s.indexOf(" 4.0") > 0)
- return TOMCAT_40.equals(version) ? Status.OK_STATUS : wrongDirVersionStatus;
- if (s.indexOf("-4.1") > 0 || s.indexOf(" 4.1") > 0)
- return TOMCAT_41.equals(version) ? Status.OK_STATUS : wrongDirVersionStatus;
- if (s.indexOf("-5.0") > 0 || s.indexOf(" 5.0") > 0)
- return TOMCAT_50.equals(version) ? Status.OK_STATUS : wrongDirVersionStatus;
- if (s.indexOf("-5.5") > 0 || s.indexOf(" 5.5") > 0)
- return TOMCAT_55.equals(version) ? Status.OK_STATUS : wrongDirVersionStatus;
- if (s.indexOf("-6.0") > 0 || s.indexOf(" 6.0") > 0)
- return TOMCAT_60.equals(version) ? Status.OK_STATUS : wrongDirVersionStatus;
- return Status.OK_STATUS;
- }
-
- /**
- * 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 = FileLocator.toFileURL(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));
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPublishModuleVisitor.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPublishModuleVisitor.java
deleted file mode 100644
index 4e161cf2b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPublishModuleVisitor.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2011 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:
- * Igor Fedorenko & Fabrizio Giustina - Initial API and implementation
- * Matteo TURRA - Support for multiple web resource paths
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jst.server.tomcat.core.internal.wst.IModuleVisitor;
-import org.eclipse.jst.server.tomcat.core.internal.xml.Factory;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Loader;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
-import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.ServerUtil;
-
-/**
- * Handles "publishing" for servers that can load classes and resources directly
- * from the workspace. Instead of creating and deploying jars to the webapp this
- * simply update the virtual classpath in the context xml file.
- */
-public class TomcatPublishModuleVisitor implements IModuleVisitor {
-
- /**
- * Server base path (Catalina base).
- */
- protected final IPath baseDir;
-
- /**
- * Tomcat version (from "server.info" property in org.apache.catalina.util.ServerInfo.properties).
- */
- protected final String tomcatVersion;
-
- /**
- * Server instance in which to modify the context
- */
- protected final ServerInstance serverInstance;
-
- /**
- * Catalina.properties loader to add global classpath entries
- */
- protected final String sharedLoader;
-
- /**
- *
- */
- protected final boolean enableMetaInfResources;
-
- /**
- * Classpath entries added by ear configurations.
- */
- protected final List<String> earCommonResources = new ArrayList<String>();
-
- /**
- * List of classpath elements that will be used by the custom tomcat loader.
- * This set should include any class dir from referenced project.
- */
- protected Set<String> virtualClassClasspathElements = new LinkedHashSet<String>();
- protected Set<String> virtualJarClasspathElements = new LinkedHashSet<String>();
-
- /**
- * Map of resources found in "META-INF/resources" folder of dependent projects
- */
- protected Map<String, List<String>> virtualDependentResources = new LinkedHashMap<String, List<String>>();
-
- /**
- * Instantiate a new TomcatPublishModuleVisitor
- *
- * @param baseDir catalina base path
- * @param tomcatVersion tomcat version
- * @param serverInstance ServerInstance containing server.xml contents
- * @param sharedLoader string value for shared.loader catalina configuration property
- * @param enableMetaInfResources flag to indicate if Servlet 3.0 "META-INF/resources" feature should be supported
- */
- TomcatPublishModuleVisitor(IPath baseDir, String tomcatVersion, ServerInstance serverInstance, String sharedLoader, boolean enableMetaInfResources) {
- this.baseDir = baseDir;
- this.tomcatVersion = tomcatVersion;
- this.serverInstance = serverInstance;
- this.sharedLoader = sharedLoader;
- this.enableMetaInfResources = enableMetaInfResources;
- }
-
- /**
- * @see IModuleVisitor#visitWebComponent(IVirtualComponent)
- */
- public void visitWebComponent(IVirtualComponent component)
- throws CoreException {
- // nothing to do, everything is done in endVisitWebComponent
- }
-
- /**
- * @see IModuleVisitor#visitArchiveComponent(IPath, IPath)
- */
- public void visitArchiveComponent(IPath runtimePath, IPath workspacePath) {
- addVirtualJarResource(runtimePath, workspacePath);
- }
-
- /**
- * @see IModuleVisitor#visitDependentJavaProject(IJavaProject javaProject)
- */
- public void visitDependentJavaProject(IJavaProject javaProject) {
- // Useful for finding source folders, so do nothing.
- }
-
- /**
- * @see IModuleVisitor#visitDependentComponent(IPath, IPath)
- */
- public void visitDependentComponent(IPath runtimePath, IPath workspacePath) {
- addVirtualJarResource(runtimePath, workspacePath);
- }
-
- /**
- * @see IModuleVisitor#visitWebResource(IPath, IPath)
- */
- public void visitWebResource(IPath runtimePath, IPath workspacePath) {
- addVirtualClassResource(runtimePath, workspacePath);
- }
-
- /**
- * @see IModuleVisitor#visitDependentContentResource(IPath, IPath)
- */
- public void visitDependentContentResource(IPath runtimePath, IPath workspacePath) {
- // Currently, only handle "META-INF/resources" folders if supported
- if (enableMetaInfResources) {
- addContentResource(runtimePath, workspacePath);
- }
- }
-
- /**
- * @see IModuleVisitor#visitEarResource(IPath, IPath)
- */
- public void visitEarResource(IPath runtimePath, IPath workspacePath) {
- earCommonResources.add(workspacePath.toOSString());
- }
-
- /**
- * @see IModuleVisitor#endVisitEarComponent(IVirtualComponent)
- */
- public void endVisitEarComponent(IVirtualComponent component)
- throws CoreException {
- if (earCommonResources.size() > 0) {
- try {
- CatalinaPropertiesUtil.addGlobalClasspath(baseDir.append(
- "conf/catalina.properties").toFile(), sharedLoader,
- earCommonResources.toArray(new String[earCommonResources.size()]));
- } catch (IOException e) {
- Trace.trace(Trace.WARNING, "Unable to add ear path entries to catalina.properties", e);
- } finally {
- earCommonResources.clear();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void endVisitWebComponent(IVirtualComponent component)
- throws CoreException {
-
- // track context changes, don't rewrite if not needed
- boolean dirty = false;
-
- IModule module = ServerUtil.getModule(component.getProject());
-
- // we need this for the user-specified context path
- Context context = findContext(module);
- if (context == null) {
- String name = module != null ? module.getName() : component.getName();
- Trace.trace(Trace.SEVERE, "Could not find context for module " + name);
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorPublishContextNotFound, name), null));
- }
-
- String contextName = null;
- boolean reloadable = true;
-
- contextName = context.getPath();
- reloadable = Boolean.valueOf(context.getReloadable()).booleanValue();
-
- // now strip initial /
- if (contextName.startsWith("/")) {
- contextName = contextName.substring(1);
- }
-
- // root context is deployed with the "ROOT" name in tomcat
- if ("".equals(contextName)) {
- contextName = "ROOT";
- }
-
- // handle project context.xml
- Context projectContext = getProjectContextXml(component);
-
- if (projectContext != null) {
- // copy configuration to server context
- projectContext.copyChildrenTo(context);
-
- Map attrs = projectContext.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);
- String actualValue = context.getAttributeValue(name);
- if (!value.equals(actualValue)) {
- context.setAttributeValue(name, value);
- dirty = true;
- }
- }
- }
- }
-
- // handle changes in docBase
- String docBase = component.getRootFolder().getUnderlyingFolder()
- .getLocation().toOSString();
- if (!docBase.equals(context.getDocBase())) {
- dirty = true;
- context.setDocBase(docBase);
- }
-
- // handle changes in reloadable flag
- if (reloadable != (Boolean.valueOf((context.getReloadable()))
- .booleanValue())) {
- dirty = true;
- context.setReloadable(Boolean.toString(reloadable));
- }
-
- String path = (contextName.equals("ROOT") ? "" : "/" + contextName);
- // handle changes in the path
- // PATH is required for tomcat 5.0, but ignored in tomcat 5.5
- if (!path.equals(context.getPath())) {
- dirty = true;
- context.setPath(path);
- }
-
- context.getResources().setClassName(
- "org.eclipse.jst.server.tomcat.loader.WtpDirContext");
-
- Loader loader = context.getLoader();
-
- loader.setClassName("org.eclipse.jst.server.tomcat.loader.WtpWebappLoader");
-
- // required for tomcat 5.5.20 due to the change in
- // http://issues.apache.org/bugzilla/show_bug.cgi?id=39704
- loader.setUseSystemClassLoaderAsParent(Boolean.FALSE.toString());
-
- // Build the virtual classPath setting
- StringBuffer vcBuffer = new StringBuffer();
- // Build list of additional resource paths and check for additional jars
- StringBuffer rpBuffer = new StringBuffer();
-
- boolean isTomcat7 = tomcatVersion.startsWith("7.");
- // Add WEB-INF/classes elements to both settings
- for (Iterator iterator = virtualClassClasspathElements.iterator();
- iterator.hasNext();) {
- Object element = iterator.next();
- if (vcBuffer.length() > 0) {
- vcBuffer.append(";");
- }
- vcBuffer.append(element);
- if (isTomcat7) {
- if (rpBuffer.length() > 0) {
- rpBuffer.append(";");
- }
- // Add to resource paths too, so resource artifacts can be found
- rpBuffer.append("/WEB-INF/classes").append("|").append(element);
- }
- }
- if (vcBuffer.length() > 0 && virtualJarClasspathElements.size() > 0) {
- vcBuffer.append(";");
- }
- for (Iterator iterator = virtualJarClasspathElements.iterator();
- iterator.hasNext();) {
- vcBuffer.append(iterator.next());
- if (iterator.hasNext()) {
- vcBuffer.append(";");
- }
- }
- virtualClassClasspathElements.clear();
- virtualJarClasspathElements.clear();
-
- Set<String> rtPathsProcessed = new HashSet<String>();
- Set<String> locationsIncluded = new HashSet<String>();
- locationsIncluded.add(docBase);
- Map<String, String> retryLocations = new HashMap<String, String>();
- IVirtualResource [] virtualResources = component.getRootFolder().getResources("");
- // Loop over the module's resources
- for (int i = 0; i < virtualResources.length; i++) {
- String rtPath = virtualResources[i].getRuntimePath().toString();
- // Note: The virtual resources returned only know their runtime path.
- // Asking for the project path for this resource performs a lookup
- // that will only return the path for the first mapping for the
- // runtime path. Thus use of getUnderlyingResources() is necessary.
- // However, this returns matching resources from all mappings so
- // we have to try to keep only those that are mapped directly
- // to the runtime path in the .components file.
-
- // If this runtime path has not yet been processed
- if (!rtPathsProcessed.contains(rtPath)) {
- // If not a Java related resource
- if (!"/WEB-INF/classes".equals(rtPath)) {
- // Get all resources for this runtime path
- IResource[] underlyingResources = virtualResources[i].getUnderlyingResources();
- // If resource is mapped to "/", then we know it corresponds directly
- // to a mapping in the .components file
- if ("/".equals(rtPath)) {
- for (int j = 0; j < underlyingResources.length; j++) {
- IPath resLoc = underlyingResources[j].getLocation();
- String location = resLoc.toOSString();
- if (!location.equals(docBase)) {
- if (rpBuffer.length() != 0) {
- rpBuffer.append(";");
- }
- // Add this location to extra paths setting
- rpBuffer.append(location);
- // Add to the set of locations included
- locationsIncluded.add(location);
- // Check if this extra content location contains jars
- File webInfLib = resLoc.append("WEB-INF/lib").toFile();
- // If this "WEB-INF/lib" exists and is a directory, add
- // its jars to the virtual classpath
- if (webInfLib.exists() && webInfLib.isDirectory()) {
- String [] jars = webInfLib.list(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- File f = new File(dir, name);
- return f.isFile() && name.endsWith(".jar");
- }
- });
- for (int k = 0; k < jars.length; k++) {
- if (vcBuffer.length() != 0) {
- vcBuffer.append(";");
- }
- vcBuffer.append(webInfLib.getPath() + File.separator + jars[k]);
- }
- }
- }
- }
- }
- // Else this runtime path is something other than "/"
- else {
- int idx = rtPath.lastIndexOf('/');
- // If a "normal" runtime path
- if (idx >= 0) {
- // Get the name of the last segment in the runtime path
- String lastSegment = rtPath.substring(idx + 1);
- // Check the underlying resources to determine which correspond to mappings
- for (int j = 0; j < underlyingResources.length; j++) {
- IPath resLoc = underlyingResources[j].getLocation();
- String location = resLoc.toOSString();
- // If the last segment of the runtime path doesn't match the
- // the last segment of the location, then we have a direct mapping
- // from the .contents file.
- if (!lastSegment.equals(resLoc.lastSegment())) {
- if (rpBuffer.length() != 0) {
- rpBuffer.append(";");
- }
- // Add this location to extra paths setting
- rpBuffer.append(rtPath).append("|").append(location);
- // Add to the set of locations included
- locationsIncluded.add(location);
- // Check if this extra content location contains jars
- File webInfLib = null;
- if ("/WEB-INF".equals(rtPath)) {
- webInfLib = resLoc.append("lib").toFile();
- }
- else if ("/WEB-INF/lib".equals(rtPath)) {
- webInfLib = resLoc.toFile();
- }
- // If this "WEB-INF/lib" exists and is a directory, add
- // its jars to the virtual classpath
- if (webInfLib != null && webInfLib.exists() && webInfLib.isDirectory()) {
- String [] jars = webInfLib.list(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- File f = new File(dir, name);
- return f.isFile() && name.endsWith(".jar");
- }
- });
- for (int k = 0; k < jars.length; k++) {
- if (vcBuffer.length() != 0) {
- vcBuffer.append(";");
- }
- vcBuffer.append(webInfLib.getPath() + File.separator + jars[k]);
- }
- }
- }
- // Else last segment of runtime path did match the last segment
- // of the location. We likely have a subfolder of a mapping
- // that matches a portion of the runtime path.
- else {
- // Since we can't be sure, save so it can be check again later
- retryLocations.put(location, rtPath);
- }
- }
- }
- }
- }
- // Add the runtime path to those already processed
- rtPathsProcessed.add(rtPath);
- }
- }
- // If there are locations to retry, add any not yet included in extra paths setting
- if (!retryLocations.isEmpty()) {
- // Remove retry locations already included in the extra paths
- for (Iterator iterator = retryLocations.keySet().iterator(); iterator.hasNext();) {
- String location = (String)iterator.next();
- for (Iterator iterator2 = locationsIncluded.iterator(); iterator2.hasNext();) {
- String includedLocation = (String)iterator2.next();
- if (location.equals(includedLocation) || location.startsWith(includedLocation + File.separator)) {
- iterator.remove();
- break;
- }
- }
- }
- // If any entries are left, include them in the extra paths
- if (!retryLocations.isEmpty()) {
- for (Iterator iterator = retryLocations.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry entry = (Map.Entry)iterator.next();
- String location = (String)entry.getKey();
- String rtPath = (String)entry.getValue();
- if (rpBuffer.length() != 0) {
- rpBuffer.append(";");
- }
- rpBuffer.append(rtPath).append("|").append(location);
- // Check if this extra content location contains jars
- File webInfLib = null;
- if ("/WEB-INF".equals(rtPath)) {
- webInfLib = new File(location, "lib");
- }
- else if ("/WEB-INF/lib".equals(rtPath)) {
- webInfLib = new File(location);
- }
- // If this "WEB-INF/lib" exists and is a directory, add
- // its jars to the virtual classpath
- if (webInfLib != null && webInfLib.exists() && webInfLib.isDirectory()) {
- String [] jars = webInfLib.list(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- File f = new File(dir, name);
- return f.isFile() && name.endsWith(".jar");
- }
- });
- for (int k = 0; k < jars.length; k++) {
- if (vcBuffer.length() != 0) {
- vcBuffer.append(";");
- }
- vcBuffer.append(webInfLib.getPath() + File.separator + jars[k]);
- }
- }
- }
- }
- }
- if (!virtualDependentResources.isEmpty()) {
- for (Iterator iterator = virtualDependentResources.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry entry = (Map.Entry)iterator.next();
- String rtPath = (String)entry.getKey();
- List locations = (List)entry.getValue();
- for (Iterator iterator2 = locations.iterator(); iterator2.hasNext();) {
- String location = (String)iterator2.next();
- if (rpBuffer.length() != 0) {
- rpBuffer.append(";");
- }
- if (rtPath.length() > 0) {
- rpBuffer.append(entry.getKey()).append("|").append(location);
- }
- else {
- rpBuffer.append(location);
- }
- }
- }
- }
-
- String vcp = vcBuffer.toString();
- String oldVcp = loader.getVirtualClasspath();
- if (!vcp.equals(oldVcp)) {
- // save only if needed
- dirty = true;
- loader.setVirtualClasspath(vcp);
- context.getResources().setVirtualClasspath(vcp);
- }
-
- String resPaths = rpBuffer.toString();
- String oldResPaths = context.getResources().getExtraResourcePaths();
- if (!resPaths.equals(oldResPaths)) {
- dirty = true;
- context.getResources().setExtraResourcePaths(resPaths);
- }
-
- if (enableMetaInfResources) {
- context.findElement("JarScanner").setAttributeValue("scanAllDirectories", "true");
- }
-
- if (dirty) {
- //TODO If writing to separate context XML files, save "dirty" status for later use
- }
- }
-
- private void addVirtualClassResource(IPath runtimePath, IPath workspacePath) {
- virtualClassClasspathElements.add(workspacePath.toOSString());
- }
-
- private void addVirtualJarResource(IPath runtimePath, IPath workspacePath) {
- virtualJarClasspathElements.add(workspacePath.toOSString());
- }
-
- private void addContentResource(IPath runtimePath, IPath workspacePath) {
- String rtPath = runtimePath.toString();
- List<String> locations = virtualDependentResources.get(rtPath);
- if (locations == null) {
- locations = new ArrayList<String>();
- virtualDependentResources.put(rtPath, locations);
- }
- locations.add(workspacePath.toOSString());
- }
-
- /**
- * Load a META-INF/context.xml file from project, if available
- *
- * @param component web component containing the context.xml
- * @return context element containing the context.xml
- * @throws CoreException
- */
- protected Context getProjectContextXml(IVirtualComponent component)
- throws CoreException {
-
- // load or create module's context.xml document
- IVirtualFile contextFile = (IVirtualFile) component.getRootFolder()
- .findMember("META-INF/context.xml");
-
- Context contextElement = null;
-
- if (contextFile != null && contextFile.exists()) {
-
- Factory factory = new Factory();
- factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
-
- InputStream fis = null;
- try {
- fis = contextFile.getUnderlyingFile().getContents();
- contextElement = (Context) factory.loadDocument(fis);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Exception reading " + contextFile, e);
- } finally {
- try {
- fis.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- return contextElement;
- }
-
- /**
- * Returns the given module from the config.
- *
- * @param module a web module
- * @return a web module
- */
- protected Context findContext(IModule module) {
- if (module == null) {
- return null;
- }
-
- String source = module.getId();
-
- Context [] contexts = serverInstance.getContexts();
- for (int i = 0; i < contexts.length; i++) {
- if (source.equals(contexts[i].getSource()))
- return contexts[i];
- }
- return null;
- }
-}
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 5d4093576..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.text.MessageFormat;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.eclipse.core.runtime.IPath;
-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<File, Boolean> sdkMap = new HashMap<File, Boolean>(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(IPath configPath) {
- IPath installPath = getRuntime().getLocation();
- // If installPath is relative, convert to canonical path and hope for the best
- if (!installPath.isAbsolute()) {
- try {
- String installLoc = (new File(installPath.toOSString())).getCanonicalPath();
- installPath = new Path(installLoc);
- } catch (IOException e) {
- // Ignore if there is a problem
- }
- }
- return getVersionHandler().getRuntimeClasspath(installPath, configPath);
- }
-
- /**
- * Verifies the Tomcat installation directory. If it is
- * correct, true is returned. Otherwise, the user is notified
- * and false is returned.
- * @return boolean
- */
- public IStatus verifyLocation() {
- return getVersionHandler().verifyInstallPath(getRuntime().getLocation());
- }
-
- /*
- * Validate the runtime
- */
- public IStatus validate() {
- IStatus status = super.validate();
- if (!status.isOK())
- return status;
-
- status = verifyLocation();
- if (!status.isOK())
- return status;
-// 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 Tomcat 5.5 and later, the Eclipse JDT compiler is used for JSP's
- String id = getRuntime().getRuntimeType().getId();
- if (!found) {
- if (id != null && (id.indexOf("55") > 0 || id.indexOf("60") > 0 || id.indexOf("70") > 0))
- found = true;
- }
-
- // on Mac, tools.jar is merged into classes.zip. if tools.jar wasn't found,
- // try loading the javac class by running a check inside the VM
- if (!found) {
- String os = Platform.getOS();
- if (os != null && os.toLowerCase().indexOf("mac") >= 0)
- found = checkForCompiler();
- }
-
- if (!found)
- return new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, Messages.warningJRE, null);
-
- File f = getRuntime().getLocation().append("conf").toFile();
- File[] conf = f.listFiles();
- if (conf != null) {
- int size = conf.length;
- for (int i = 0; i < size; i++) {
- if (!f.canRead())
- return new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, Messages.warningCantReadConfig, null);
- }
- }
-
- // For Tomcat 6.0, ensure we have J2SE 5.0
- if (id != null && id.indexOf("60") > 0) {
- IVMInstall vmInstall = getVMInstall();
- if (vmInstall instanceof IVMInstall2) {
- String javaVersion = ((IVMInstall2)vmInstall).getJavaVersion();
- if (javaVersion != null && !isVMMinimumVersion(javaVersion, 105)) {
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorJRETomcat60, null);
- }
- }
- }
- // Else for Tomcat 7.0, ensure we have J2SE 6.0
- else if (id != null && id.indexOf("70") > 0) {
- IVMInstall vmInstall = getVMInstall();
- if (vmInstall instanceof IVMInstall2) {
- String javaVersion = ((IVMInstall2)vmInstall).getJavaVersion();
- if (javaVersion != null && !isVMMinimumVersion(javaVersion, 106)) {
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorJRETomcat70, null);
- }
- }
- }
-
- return Status.OK_STATUS;
- }
-
- /**
- * @see RuntimeDelegate#setDefaults(IProgressMonitor)
- */
- public void setDefaults(IProgressMonitor monitor) {
- 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 existence 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 = 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 < 600; i++) {
- // wait no more than 30 seconds (600 * 50 mils)
- if (launch.isTerminated()) {
- break;
- }
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- // ignore
- }
- }
- IStreamsProxy streamsProxy = launch.getProcesses()[0].getStreamsProxy();
- String text = null;
- if (streamsProxy != null) {
- text = streamsProxy.getOutputStreamMonitor().getContents();
-
- if (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}", (Object []) new String[] { javaHome.getAbsolutePath() }));
- return false;
- }
-
- private static Map<String, Integer> javaVersionMap = new ConcurrentHashMap<String, Integer>();
-
- private boolean isVMMinimumVersion(String javaVersion, int minimumVersion) {
- Integer version = javaVersionMap.get(javaVersion);
- if (version == null) {
- int index = javaVersion.indexOf('.');
- if (index > 0) {
- try {
- int major = Integer.parseInt(javaVersion.substring(0, index)) * 100;
- index++;
- int index2 = javaVersion.indexOf('.', index);
- if (index2 > 0) {
- int minor = Integer.parseInt(javaVersion.substring(index, index2));
- version = new Integer(major + minor);
- javaVersionMap.put(javaVersion, version);
- }
- }
- catch (NumberFormatException e) {
- // Ignore
- }
- }
- }
- // If we have a version, and it's less than the minimum, fail the check
- if (version != null && version.intValue() < minimumVersion) {
- return false;
- }
- return true;
- }
-}
diff --git a/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 7f55952bd..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeClasspathProvider.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathEntry;
-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 {
- /**
- * @see RuntimeClasspathProviderDelegate#resolveClasspathContainer(IProject, IRuntime)
- */
- public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime) {
- IPath installPath = runtime.getLocation();
-
- if (installPath == null)
- return new IClasspathEntry[0];
-
- List<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- String runtimeId = runtime.getRuntimeType().getId();
- if (runtimeId.indexOf("32") > 0) {
- IPath path = installPath.append("lib");
- addLibraryEntries(list, path.toFile(), true);
- } else if (runtimeId.indexOf("60") > 0 || runtimeId.indexOf("70") > 0) {
- // TODO May need some flexibility in case the installation has been configured differently
- // This lib "simplification" may cause issues for some.
- // Not known yet whether packaged Linux installs will go along.
- 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 list.toArray(new IClasspathEntry[list.size()]);
- }
-}
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 ed14a6ba2..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntimeLocator.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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",
- "org.eclipse.jst.server.tomcat.runtime.60"};
-
- /* (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;
- }
-}
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 665e6f2d1..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java
+++ /dev/null
@@ -1,551 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.resources.IProject;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jst.server.core.FacetUtil;
-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;
- protected transient ITomcatVersionHandler versionHandler;
-
- // Configuration version control
- private int currentVersion;
- private int loadedVersion;
- private Object versionLock = new Object();
-
- /**
- * TomcatServer.
- */
- public TomcatServer() {
- super();
- }
-
- /**
- * Get the Tomcat runtime for this server.
- *
- * @return Tomcat runtime for this server
- */
- public TomcatRuntime getTomcatRuntime() {
- if (getServer().getRuntime() == null)
- return null;
-
- return (TomcatRuntime) getServer().getRuntime().loadAdapter(TomcatRuntime.class, null);
- }
-
- /**
- * Gets the Tomcat version handler for this server.
- *
- * @return version handler for this server
- */
- public ITomcatVersionHandler getTomcatVersionHandler() {
- if (versionHandler == null) {
- if (getServer().getRuntime() == null || getTomcatRuntime() == null)
- return null;
-
- versionHandler = getTomcatRuntime().getVersionHandler();
- }
- return versionHandler;
- }
-
- public ITomcatConfiguration getServerConfiguration() throws CoreException {
- return getTomcatConfiguration();
- }
-
- public TomcatConfiguration getTomcatConfiguration() throws CoreException {
- int current;
- TomcatConfiguration tcConfig;
- // Grab current state
- synchronized (versionLock) {
- current = currentVersion;
- tcConfig = configuration;
- }
- // If configuration needs loading
- if (tcConfig == null || loadedVersion != current) {
- IFolder folder = getServer().getServerConfiguration();
- if (folder == null || !folder.exists()) {
- String path = null;
- if (folder != null) {
- path = folder.getFullPath().toOSString();
- IProject project = folder.getProject();
- if (project != null && project.exists() && !project.isOpen())
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorConfigurationProjectClosed, path, project.getName()), null));
- }
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorNoConfiguration, path), null));
- }
- // If not yet loaded
- if (tcConfig == null) {
-
- String id = getServer().getServerType().getId();
- if (id.indexOf("32") > 0)
- tcConfig = new Tomcat32Configuration(folder);
- else if (id.indexOf("40") > 0)
- tcConfig = new Tomcat40Configuration(folder);
- else if (id.indexOf("41") > 0)
- tcConfig = new Tomcat41Configuration(folder);
- else if (id.indexOf("50") > 0)
- tcConfig = new Tomcat50Configuration(folder);
- else if (id.indexOf("55") > 0)
- tcConfig = new Tomcat55Configuration(folder);
- else if (id.indexOf("60") > 0)
- tcConfig = new Tomcat60Configuration(folder);
- else if (id.indexOf("70") > 0)
- tcConfig = new Tomcat70Configuration(folder);
- else {
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorUnknownVersion, null));
- }
- }
- try {
- tcConfig.load(folder, null);
- // Update loaded version
- synchronized (versionLock) {
- // If newer version not already loaded, update version
- if (configuration == null || loadedVersion < current) {
- configuration = tcConfig;
- loadedVersion = current;
- }
- }
- } catch (CoreException ce) {
- // Ignore
- throw ce;
- }
- }
- return tcConfig;
- }
-
- public void importRuntimeConfiguration(IRuntime runtime, IProgressMonitor monitor) throws CoreException {
- // Initialize state
- synchronized (versionLock) {
- configuration = null;
- currentVersion = 0;
- loadedVersion = 0;
- }
- if (runtime == null) {
- return;
- }
- IPath path = runtime.getLocation().append("conf");
-
- String id = getServer().getServerType().getId();
- IFolder folder = getServer().getServerConfiguration();
- TomcatConfiguration tcConfig;
- if (id.indexOf("32") > 0)
- tcConfig = new Tomcat32Configuration(folder);
- else if (id.indexOf("40") > 0)
- tcConfig = new Tomcat40Configuration(folder);
- else if (id.indexOf("41") > 0)
- tcConfig = new Tomcat41Configuration(folder);
- else if (id.indexOf("50") > 0)
- tcConfig = new Tomcat50Configuration(folder);
- else if (id.indexOf("55") > 0)
- tcConfig = new Tomcat55Configuration(folder);
- else if (id.indexOf("60") > 0)
- tcConfig = new Tomcat60Configuration(folder);
- else if (id.indexOf("70") > 0)
- tcConfig = new Tomcat70Configuration(folder);
- else {
- throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorUnknownVersion, null));
- }
-
- try {
- tcConfig.importFromPath(path, isTestEnvironment(), monitor);
- } catch (CoreException ce) {
- throw ce;
- }
- // Update version
- synchronized (versionLock) {
- // If not already initialized by some other thread, save the configuration
- if (configuration == null) {
- configuration = tcConfig;
- }
- }
- }
-
- public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
- TomcatConfiguration tcConfig = configuration;
- if (tcConfig == null)
- return;
- tcConfig.save(getServer().getServerConfiguration(), monitor);
- }
-
- public void configurationChanged() {
- synchronized (versionLock) {
- // Alter the current version
- currentVersion++;
- }
- }
-
- /**
- * 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://" + getServer().getHost();
- 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);
- }
-
- /**
- * @see ITomcatServer#getInstanceDirectory()
- */
- public String getInstanceDirectory() {
- return getAttribute(PROPERTY_INSTANCE_DIR, (String)null);
- }
-
- /**
- * @see ITomcatServer#getDeployDirectory()
- */
- public String getDeployDirectory() {
- // Default to value used by prior WTP versions
- return getAttribute(PROPERTY_DEPLOY_DIR, LEGACY_DEPLOYDIR);
- }
-
- /**
- * Returns true if modules should be served without publishing.
- *
- * @return boolean
- */
- public boolean isServeModulesWithoutPublish() {
- // If feature is supported, return current setting
- ITomcatVersionHandler tvh = getTomcatVersionHandler();
- if (tvh != null && tvh.supportsServeModulesWithoutPublish())
- return getAttribute(PROPERTY_SERVE_MODULES_WITHOUT_PUBLISH, false);
- return false;
- }
-
- /**
- * Returns true if contexts should be saved in separate files
- * during server publish.
- *
- * @return boolean
- */
- public boolean isSaveSeparateContextFiles() {
- // If feature is supported, return current setting
- ITomcatVersionHandler tvh = getTomcatVersionHandler();
- if (tvh != null && tvh.supportsSeparateContextFiles())
- return getAttribute(PROPERTY_SAVE_SEPARATE_CONTEXT_FILES, false);
- return false;
- }
-
-
- /**
- * Gets the base directory where the server instance runs. This
- * path can vary depending on the configuration. Null may be returned
- * if a runtime hasn't been specified for the server.
- *
- * @return path to base directory for the server or null if
- * runtime hasn't been specified.
- */
- public IPath getRuntimeBaseDirectory() {
- ITomcatVersionHandler tvh = getTomcatVersionHandler();
- if (tvh != null)
- return tvh.getRuntimeBaseDirectory(this);
- return null;
- }
-
- /**
- * Gets the directory to which modules should be deployed for
- * this server.
- *
- * @return full path to deployment directory for the server
- */
- public IPath getServerDeployDirectory() {
- String deployDir = getDeployDirectory();
- IPath deployPath = new Path(deployDir);
- if (!deployPath.isAbsolute()) {
- IPath base = getRuntimeBaseDirectory();
- deployPath = base.append(deployPath);
- }
- return deployPath;
- }
-
- 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.
- * @param module module from which to get child module(s)
- * @return array of child module(s)
- */
- 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.
- * @param module module from which to get the root module
- * @return root module
- * @throws CoreException
- */
- 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;
-
- if (module.getProject() != null) {
- status = FacetUtil.verifyFacets(module.getProject(), getServer());
- if (status != null && !status.isOK())
- return status;
- }
- }
- }
-
- return Status.OK_STATUS;
- }
-
- public ServerPort[] getServerPorts() {
- if (getServer().getServerConfiguration() == null)
- return new ServerPort[0];
-
- try {
- @SuppressWarnings("unchecked")
- List<ServerPort> 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);
- setDeployDirectory(DEFAULT_DEPLOYDIR);
- }
-
- /**
- * 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 ITomcatServerWorkingCopy#setInstanceDirectory(String)
- */
- public void setInstanceDirectory(String instanceDir) {
- setAttribute(PROPERTY_INSTANCE_DIR, instanceDir);
- }
-
- /**
- * @see ITomcatServerWorkingCopy#setDeployDirectory(String)
- */
- public void setDeployDirectory(String deployDir) {
- // Remove attribute if setting to legacy value assumed in prior versions of WTP.
- // Allowing values that differ only in case is asking for more trouble that it is worth.
- if (LEGACY_DEPLOYDIR.equalsIgnoreCase(deployDir))
- setAttribute(PROPERTY_DEPLOY_DIR, (String)null);
- else
- setAttribute(PROPERTY_DEPLOY_DIR, deployDir);
- }
-
- /**
- * @see ITomcatServerWorkingCopy#setServeModulesWithoutPublish(boolean)
- */
- public void setServeModulesWithoutPublish(boolean b) {
- setAttribute(PROPERTY_SERVE_MODULES_WITHOUT_PUBLISH, b);
- }
-
- /**
- * @see ITomcatServerWorkingCopy#setSaveSeparateContextFiles(boolean)
- */
- public void setSaveSeparateContextFiles(boolean b) {
- setAttribute(PROPERTY_SAVE_SEPARATE_CONTEXT_FILES, 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";
- }
-}
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 e6e81024d..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java
+++ /dev/null
@@ -1,1182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-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.IJ2EEModule;
-import org.eclipse.jst.server.core.IWebModule;
-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.PublishHelper;
-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";
-
- private static final String[] JMX_EXCLUDE_ARGS = new String [] {
- "-Dcom.sun.management.jmxremote",
- "-Dcom.sun.management.jmxremote.port=",
- "-Dcom.sun.management.jmxremote.ssl=",
- "-Dcom.sun.management.jmxremote.authenticate="
- };
-
- // the thread used to ping the server to check for startup
- protected transient PingThread ping = null;
- protected transient IDebugEventSetListener processListener;
-
- /**
- * 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() {
- return getTomcatServer().getTomcatVersionHandler();
- }
-
- 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 getTomcatServer().getRuntimeBaseDirectory();
- }
-
- /**
- * Return the program's runtime arguments to start or stop.
- *
- * @param starting true if starting
- * @return an array of runtime program arguments
- */
- protected String[] getRuntimeProgramArguments(boolean starting) {
- IPath configPath = null;
- if (getTomcatServer().isTestEnvironment())
- configPath = getRuntimeBaseDirectory();
- return getTomcatVersionHandler().getRuntimeProgramArguments(configPath, getTomcatServer().isDebug(), starting);
- }
-
- protected String[] getExcludedRuntimeProgramArguments(boolean starting) {
- return getTomcatVersionHandler().getExcludedRuntimeProgramArguments(getTomcatServer().isDebug(), starting);
- }
-
- /**
- * Return the runtime (VM) arguments.
- *
- * @return an array of runtime arguments
- */
- protected String[] getRuntimeVMArguments() {
- IPath installPath = getServer().getRuntime().getLocation();
- // If installPath is relative, convert to canonical path and hope for the best
- if (!installPath.isAbsolute()) {
- try {
- String installLoc = (new File(installPath.toOSString())).getCanonicalPath();
- installPath = new Path(installLoc);
- } catch (IOException e) {
- // Ignore if there is a problem
- }
- }
- IPath configPath = getRuntimeBaseDirectory();
- IPath deployPath;
- // If serving modules without publishing, use workspace path as the deploy path
- if (getTomcatServer().isServeModulesWithoutPublish()) {
- deployPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- }
- // Else normal publishing for modules
- else {
- deployPath = getServerDeployDirectory();
- // If deployPath is relative, convert to canonical path and hope for the best
- if (!deployPath.isAbsolute()) {
- try {
- String deployLoc = (new File(deployPath.toOSString())).getCanonicalPath();
- deployPath = new Path(deployLoc);
- } catch (IOException e) {
- // Ignore if there is a problem
- }
- }
- }
- return getTomcatVersionHandler().getRuntimeVMArguments(installPath, configPath,
- deployPath, getTomcatServer().isTestEnvironment());
- }
-
- protected String getRuntimePolicyFile() {
- IPath configPath = getRuntimeBaseDirectory();
- 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();
- }
-
- protected void addProcessListener(final IProcess newProcess) {
- if (processListener != null || newProcess == null)
- return;
-
- processListener = new IDebugEventSetListener() {
- public void handleDebugEvents(DebugEvent[] events) {
- if (events != null) {
- int size = events.length;
- for (int i = 0; i < size; i++) {
- if (newProcess != null && newProcess.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) {
- stopImpl();
- }
- }
- }
- }
- };
- DebugPlugin.getDefault().addDebugEventListener(processListener);
- }
-
- protected void setServerStarted() {
- setServerState(IServer.STATE_STARTED);
- }
-
- protected void stopImpl() {
- if (ping != null) {
- ping.stop();
- ping = null;
- }
- if (processListener != null) {
- DebugPlugin.getDefault().removeDebugEventListener(processListener);
- processListener = null;
- }
- setServerState(IServer.STATE_STOPPED);
- }
-
- protected void publishServer(int kind, IProgressMonitor monitor) throws CoreException {
- if (getServer().getRuntime() == null)
- return;
-
- IPath installDir = getServer().getRuntime().getLocation();
- IPath confDir = null;
- if (getTomcatServer().isTestEnvironment()) {
- confDir = getRuntimeBaseDirectory();
- IStatus status = getTomcatVersionHandler().prepareRuntimeDirectory(confDir);
- if (status != null && !status.isOK())
- throw new CoreException(status);
- } else
- confDir = installDir;
- IStatus status = getTomcatVersionHandler().prepareDeployDirectory(getServerDeployDirectory());
- if (status != null && !status.isOK())
- throw new CoreException(status);
-
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishServerTask, 600);
-
- status = getTomcatConfiguration().cleanupServer(confDir, installDir,
- !getTomcatServer().isSaveSeparateContextFiles(), 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);
-
- status = getTomcatConfiguration().localizeConfiguration(confDir, getServerDeployDirectory(),
- getTomcatServer(), ProgressUtil.getSubMonitorFor(monitor, 100));
- if (status != null && !status.isOK())
- throw new CoreException(status);
-
- 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;
-
- Properties p = loadModulePublishLocations();
-
- PublishHelper helper = new PublishHelper(getRuntimeBaseDirectory().append("temp").toFile());
- // If parent web module
- if (moduleTree.length == 1) {
- publishDir(deltaKind, p, moduleTree, helper, monitor);
- }
- // Else a child module
- else {
- // Try to determine the URI for the child module
- IWebModule webModule = (IWebModule)moduleTree[0].loadAdapter(IWebModule.class, monitor);
- String childURI = null;
- if (webModule != null) {
- childURI = webModule.getURI(moduleTree[1]);
- }
- // Try to determine if child is binary
- IJ2EEModule childModule = (IJ2EEModule)moduleTree[1].loadAdapter(IJ2EEModule.class, monitor);
- boolean isBinary = false;
- if (childModule != null) {
- isBinary = childModule.isBinary();
- }
-
- if (isBinary) {
- publishArchiveModule(childURI, kind, deltaKind, p, moduleTree, helper, monitor);
- }
- else {
- publishJar(childURI, kind, deltaKind, p, moduleTree, helper, monitor);
- }
- }
-
- setModulePublishState(moduleTree, IServer.PUBLISH_STATE_NONE);
-
- saveModulePublishLocations(p);
- }
-
- /**
- * Publish a web module.
- *
- * @param deltaKind
- * @param p
- * @param module
- * @param monitor
- * @throws CoreException
- */
- private void publishDir(int deltaKind, Properties p, IModule module[], PublishHelper helper, IProgressMonitor monitor) throws CoreException {
- List<IStatus> status = new ArrayList<IStatus>();
- // Remove if requested or if previously published and are now serving without publishing
- if (deltaKind == REMOVED || getTomcatServer().isServeModulesWithoutPublish()) {
- String publishPath = (String) p.get(module[0].getId());
- if (publishPath != null) {
- try {
- File f = new File(publishPath);
- if (f.exists()) {
- IStatus[] stat = PublishHelper.deleteDirectory(f, monitor);
- PublishOperation2.addArrayToList(status, stat);
- }
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorPublishCouldNotRemoveModule,module[0].getName()), e));
- }
- p.remove(module[0].getId());
- }
- } else {
- IPath path = getModuleDeployDirectory(module[0]);
- IModuleResource[] mr = getResources(module);
- IPath [] jarPaths = null;
- IWebModule webModule = (IWebModule)module[0].loadAdapter(IWebModule.class, monitor);
- IModule [] childModules = getServer().getChildModules(module, monitor);
- if (childModules != null && childModules.length > 0) {
- jarPaths = new IPath[childModules.length];
- for (int i = 0; i < childModules.length; i++) {
- if (webModule != null) {
- jarPaths[i] = new Path(webModule.getURI(childModules[i]));
- }
- else {
- IJ2EEModule childModule = (IJ2EEModule)childModules[i].loadAdapter(IJ2EEModule.class, monitor);
- if (childModule != null && childModule.isBinary()) {
- jarPaths[i] = new Path("WEB-INF/lib").append(childModules[i].getName());
- }
- else {
- jarPaths[i] = new Path("WEB-INF/lib").append(childModules[i].getName() + ".jar");
- }
- }
- }
- }
- IStatus[] stat = helper.publishSmart(mr, path, jarPaths, monitor);
- PublishOperation2.addArrayToList(status, stat);
- p.put(module[0].getId(), path.toOSString());
- }
- PublishOperation2.throwException(status);
- }
-
- /**
- * Publish a jar file.
- *
- * @param deltaKind
- * @param p
- * @param module
- * @param monitor
- * @throws CoreException
- */
- private void publishJar(String jarURI, int kind, int deltaKind, Properties p, IModule[] module, PublishHelper helper, IProgressMonitor monitor) throws CoreException {
- // Remove if requested or if previously published and are now serving without publishing
- if (deltaKind == REMOVED || getTomcatServer().isServeModulesWithoutPublish()) {
- try {
- String publishPath = (String) p.get(module[1].getId());
- if (publishPath != null) {
- new File(publishPath).delete();
- p.remove(module[1].getId());
- }
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, "Could not remove module", e));
- }
- } else {
- IPath path = getModuleDeployDirectory(module[0]);
- if (jarURI == null) {
- jarURI = "WEB-INF/lib" + module[1].getName() + ".jar";
- }
- IPath jarPath = path.append(jarURI);
- path = jarPath.removeLastSegments(1);
- if (!path.toFile().exists()) {
- path.toFile().mkdirs();
- } else {
- // If file still exists and we are not forcing a new one to be built
- if (jarPath.toFile().exists() && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
- }
-
- IModuleResource[] mr = getResources(module);
- IStatus[] stat = helper.publishZip(mr, jarPath, monitor);
- List<IStatus> status = new ArrayList<IStatus>();
- PublishOperation2.addArrayToList(status, stat);
- PublishOperation2.throwException(status);
- p.put(module[1].getId(), jarPath.toOSString());
- }
- }
-
- private void publishArchiveModule(String jarURI, int kind, int deltaKind, Properties p, IModule[] module, PublishHelper helper, IProgressMonitor monitor) throws CoreException {
- // Remove if requested or if previously published and are now serving without publishing
- if (deltaKind == REMOVED || getTomcatServer().isServeModulesWithoutPublish()) {
- try {
- String publishPath = (String) p.get(module[1].getId());
- if (publishPath != null) {
- new File(publishPath).delete();
- p.remove(module[1].getId());
- }
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, "Could not remove archive module", e));
- }
- } else {
- List<IStatus> status = new ArrayList<IStatus>();
- IPath path = getModuleDeployDirectory(module[0]);
- if (jarURI == null) {
- jarURI = "WEB-INF/lib" + module[1].getName();
- }
- IPath jarPath = path.append(jarURI);
- path = jarPath.removeLastSegments(1);
- if (!path.toFile().exists()) {
- path.toFile().mkdirs();
- } else {
- // If file still exists and we are not forcing a new one to be built
- if (jarPath.toFile().exists() && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) {
- // avoid changes if no changes to module since last publish
- IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
- if (delta == null || delta.length == 0)
- return;
- }
- }
-
- IModuleResource[] mr = getResources(module);
- IStatus[] stat = helper.publishToPath(mr, jarPath, monitor);
- PublishOperation2.addArrayToList(status, stat);
- PublishOperation2.throwException(status);
- p.put(module[1].getId(), jarPath.toOSString());
- }
- }
-
- protected void publishFinish(IProgressMonitor monitor) throws CoreException {
- IStatus status;
- IPath baseDir = getRuntimeBaseDirectory();
- TomcatServer ts = getTomcatServer();
- ITomcatVersionHandler tvh = getTomcatVersionHandler();
- String serverTypeID = getServer().getServerType().getId();
- String tomcatVersion = TomcatVersionHelper.getCatalinaVersion(getServer().getRuntime().getLocation(), serverTypeID);
- // Include or remove loader jar depending on state of serving directly
- status = tvh.prepareForServingDirectly(baseDir, getTomcatServer(), tomcatVersion);
- if (status.isOK()) {
- // If serving modules directly, update server.xml accordingly (includes project context.xmls)
- if (ts.isServeModulesWithoutPublish()) {
- status = getTomcatConfiguration().updateContextsToServeDirectly(
- baseDir, tomcatVersion, tvh.getSharedLoader(baseDir), monitor);
- }
- // Else serving normally. Add project context.xmls to server.xml
- else {
- // Publish context configuration for servers that support META-INF/context.xml
- status = getTomcatConfiguration().publishContextConfig(
- baseDir, getServerDeployDirectory(), monitor);
- }
- if (status.isOK() && ts.isSaveSeparateContextFiles()) {
- // Determine if context's path attribute should be removed
- boolean noPath = serverTypeID.indexOf("55") > 0 || serverTypeID.indexOf("60") > 0;
- boolean serverStopped = getServer().getServerState() == IServer.STATE_STOPPED;
- // TODO Add a monitor
- TomcatVersionHelper.moveContextsToSeparateFiles(baseDir, noPath, serverStopped, null);
- }
- }
- 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<ServerPort> usedPorts = new ArrayList<ServerPort>();
- 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 = 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<String> contextRoots = new ArrayList<String>();
- 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://" + getServer().getHost();
- int port = configuration.getMainPort().getPort();
- if (port != 80)
- url += ":" + port;
- ping = new PingThread(getServer(), url, -1, this);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Can't ping for 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 stopped or stopping, no need to run stop command again
- if (state == IServer.STATE_STOPPED || state == IServer.STATE_STOPPING)
- return;
- else if (state == IServer.STATE_STARTING) {
- terminate();
- return;
- }
-
- try {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Stopping 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), " ");
- // Remove JMX arguments if present
- String existingVMArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null);
- if (existingVMArgs.indexOf(JMX_EXCLUDE_ARGS[0]) >= 0) {
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- mergeArguments(existingVMArgs, new String [] {}, JMX_EXCLUDE_ARGS, false));
- }
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
- wc.setAttribute("org.eclipse.debug.ui.private", true);
- wc.setAttribute(ATTR_STOP, "true");
- wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error stopping Tomcat", e);
- }
- }
-
- /**
- * Terminates the server.
- */
- protected void terminate() {
- if (getServer().getServerState() == IServer.STATE_STOPPED)
- return;
-
- try {
- setServerState(IServer.STATE_STOPPING);
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Killing the Tomcat process");
- ILaunch launch = getServer().getLaunch();
- if (launch != null) {
- launch.terminate();
- stopImpl();
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error killing the process", e);
- }
- }
-
- public IPath getTempDirectory() {
- return super.getTempDirectory(false);
- }
-
- /**
- * 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. Special handling is provided
- * if the keepActionLast argument is true and the last vmArg is a simple
- * string. The vmArgs will be merged such that the last vmArg is guaranteed
- * to be the last argument in the merged string.
- *
- * @param originalArg String of original arguments.
- * @param vmArgs Arguments to merge into the original arguments string
- * @param excludeArgs Arguments to exclude from the original arguments string
- * @param keepActionLast If <b>true</b> the vmArguments are assumed to be Tomcat
- * program arguments, the last of which is the action to perform which must
- * remain the last argument. This only has an impact if the last vmArg is
- * a simple string argument, like &quot;start&quot;.
- * @return merged argument string
- */
- public static String mergeArguments(String originalArg, String[] vmArgs, String[] excludeArgs, boolean keepActionLast) {
- if (vmArgs == null)
- return originalArg;
-
- if (originalArg == null)
- originalArg = "";
-
- // replace and null out all vmargs that already exist
- int size = vmArgs.length;
- for (int i = 0; i < size; i++) {
- int ind = vmArgs[i].indexOf(" ");
- int ind2 = vmArgs[i].indexOf("=");
- if (ind >= 0 && (ind2 == -1 || ind < ind2)) { // -a bc style
- int index = originalArg.indexOf(vmArgs[i].substring(0, ind + 1));
- if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1)))) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index + ind + 1);
- if (index2 >= 0)
- originalArg = s + vmArgs[i] + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- }
- } else if (ind2 >= 0) { // a=b style
- int index = originalArg.indexOf(vmArgs[i].substring(0, ind2 + 1));
- if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1)))) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (index2 >= 0)
- originalArg = s + vmArgs[i] + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- }
- } else { // abc style
- int index = originalArg.indexOf(vmArgs[i]);
- if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1)))) {
- // replace
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (!keepActionLast || i < (size - 1)) {
- if (index2 >= 0)
- originalArg = s + vmArgs[i] + originalArg.substring(index2);
- else
- originalArg = s + vmArgs[i];
- vmArgs[i] = null;
- }
- else {
- // The last VM argument needs to remain last,
- // remove original arg and append the vmArg later
- if (index2 >= 0)
- originalArg = s + originalArg.substring(index2);
- else
- originalArg = s;
- }
- }
- }
- }
-
- // remove excluded arguments
- if (excludeArgs != null && excludeArgs.length > 0) {
- for (int i = 0; i < excludeArgs.length; i++) {
- int ind = excludeArgs[i].indexOf(" ");
- int ind2 = excludeArgs[i].indexOf("=");
- if (ind >= 0 && (ind2 == -1 || ind < ind2)) { // -a bc style
- int index = originalArg.indexOf(excludeArgs[i].substring(0, ind + 1));
- if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1)))) {
- // remove
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index + ind + 1);
- if (index2 >= 0) {
- // If remainder will become the first argument, remove leading blanks
- while (index2 < originalArg.length() && Character.isWhitespace(originalArg.charAt(index2)))
- index2 += 1;
- originalArg = s + originalArg.substring(index2);
- }
- else
- originalArg = s;
- }
- } else if (ind2 >= 0) { // a=b style
- int index = originalArg.indexOf(excludeArgs[i].substring(0, ind2 + 1));
- if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1)))) {
- // remove
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (index2 >= 0) {
- // If remainder will become the first argument, remove leading blanks
- while (index2 < originalArg.length() && Character.isWhitespace(originalArg.charAt(index2)))
- index2 += 1;
- originalArg = s + originalArg.substring(index2);
- }
- else
- originalArg = s;
- }
- } else { // abc style
- int index = originalArg.indexOf(excludeArgs[i]);
- if (index == 0 || (index > 0 && Character.isWhitespace(originalArg.charAt(index - 1)))) {
- // remove
- String s = originalArg.substring(0, index);
- int index2 = getNextToken(originalArg, index);
- if (index2 >= 0) {
- // Remove leading blanks
- while (index2 < originalArg.length() && Character.isWhitespace(originalArg.charAt(index2)))
- index2 += 1;
- originalArg = s + originalArg.substring(index2);
- }
- else
- originalArg = s;
- }
- }
- }
- }
-
- // 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<IRuntimeClasspathEntry> cp, IRuntimeClasspathEntry entry) {
- int size = cp.size();
- for (int i = 0; i < size; i++) {
- IRuntimeClasspathEntry entry2 = 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<IRuntimeClasspathEntry> 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), getExcludedRuntimeProgramArguments(true), true));
-
- String existingVMArgs = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null);
- String[] parsedVMArgs = null;
- if (null != existingVMArgs) {
- parsedVMArgs = DebugPlugin.parseArguments(existingVMArgs);
- }
- String [] configVMArgs = getRuntimeVMArguments();
- if (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, null, false));
-
- ITomcatRuntime runtime = getTomcatRuntime();
- IVMInstall vmInstall = runtime.getVMInstall();
- if (vmInstall != null)
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
-
- // update classpath
- IRuntimeClasspathEntry[] originalClasspath = JavaRuntime.computeUnresolvedRuntimeClasspath(workingCopy);
- int size = originalClasspath.length;
- List<IRuntimeClasspathEntry> oldCp = new ArrayList<IRuntimeClasspathEntry>(originalClasspath.length + 2);
- for (int i = 0; i < size; i++)
- oldCp.add(originalClasspath[i]);
-
- List cp2 = runtime.getRuntimeClasspath(getRuntimeBaseDirectory());
- 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 = 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<String> list = new ArrayList<String>();
- 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;
- }
-
- /**
- * Cleans the entire work directory for this server. This involves
- * deleting all subdirectories of the server's work directory.
- *
- * @param monitor a progress monitor
- * @return results of the clean operation
- * @throws CoreException
- */
- public IStatus cleanServerWorkDir(IProgressMonitor monitor) throws CoreException {
- IStatus result;
- IPath basePath = getRuntimeBaseDirectory();
- IPath workPath = getTomcatConfiguration().getServerWorkDirectory(basePath);
- if (workPath != null) {
- File workDir = workPath.toFile();
- result = Status.OK_STATUS;
- if (workDir.exists() && workDir.isDirectory()) {
- // Delete subdirectories of the server's work dir
- File[] files = workDir.listFiles();
- if (files != null && files.length > 0) {
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, "Problem occurred deleting work directory for module.", null);
- int size = files.length;
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(NLS.bind("Cleaning Server Work Directory", new String[] { workDir.getAbsolutePath() }), size * 10);
-
- for (int i = 0; i < size; i++) {
- File current = files[i];
- if (current.isDirectory()) {
- IStatus [] results = PublishHelper.deleteDirectory(current, ProgressUtil.getSubMonitorFor(monitor, 10));
- if (results != null && results.length > 0) {
- for (int j = 0; j < results.length; j++) {
- ms.add(results[j]);
- }
- }
- }
- }
- monitor.done();
- result = ms;
- }
- }
- }
- else {
- result = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, "Could not determine work directory for module", null);
- }
- return result;
- }
-
- /**
- * Cleans the work directory associated with the specified module on this
- * server.
- *
- * @param module module whose work directory should be cleaned
- * @param monitor a progress monitor
- * @return result of the clean operation
- * @throws CoreException
- */
- public IStatus cleanContextWorkDir(ITomcatWebModule module, IProgressMonitor monitor) throws CoreException {
- IStatus result;
- IPath basePath = getRuntimeBaseDirectory();
- IPath workPath = getTomcatConfiguration().getContextWorkDirectory(basePath, module);
- if (workPath != null) {
- File workDir = workPath.toFile();
- result = Status.OK_STATUS;
- if (workDir.exists() && workDir.isDirectory()) {
- IStatus [] results = PublishHelper.deleteDirectory(workDir, monitor);
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, "Problem occurred deleting work directory for module.", null);
- if (results != null && results.length > 0) {
- for (int i = 0; i < results.length; i++) {
- ms.add(results[i]);
- }
- }
- result = ms;
- }
- }
- else {
- result = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, "Could not determine work directory for module", null);
- }
- return result;
- }
-
- /**
- * Gets the directory to which modules should be deployed for
- * this server.
- *
- * @return full path to deployment directory for the server
- */
- public IPath getServerDeployDirectory() {
- return getTomcatServer().getServerDeployDirectory();
- }
-
- /**
- * Gets the directory to which to deploy a module's web application.
- *
- * @param module a module
- * @return full path to deployment directory for the module
- */
- public IPath getModuleDeployDirectory(IModule module) {
- return getServerDeployDirectory().append(module.getName());
- }
-
- /**
- * Temporary method to help web services team. Returns the path that the module is
- * published to.
- *
- * @param module a module on the server
- * @return the path that the module is published to when in test environment mode,
- * or null if the module is not a web module
- */
- public IPath getPublishDirectory(IModule[] module) {
- if (module == null || module.length != 1)
- return null;
-
- return getModuleDeployDirectory(module[0]);
- }
-
- public void setModulePublishState2(IModule[] module, int state) {
- setModulePublishState(module, state);
- }
-
- public Properties loadModulePublishLocations() {
- Properties p = new Properties();
- IPath path = getTempDirectory().append("publish.txt");
- FileInputStream fin = null;
- try {
- fin = new FileInputStream(path.toFile());
- p.load(fin);
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- fin.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- return p;
- }
-
- public void saveModulePublishLocations(Properties p) {
- IPath path = getTempDirectory().append("publish.txt");
- FileOutputStream fout = null;
- try {
- fout = new FileOutputStream(path.toFile());
- p.store(fout, "Tomcat publish data");
- } catch (Exception e) {
- // ignore
- }
- finally {
- try {
- fout.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- }
-
- public void setTomcatServerPublishState(int state) {
- setServerPublishState(state);
- }
-
- public void setTomcatServerRestartState(boolean state) {
- setServerRestartState(state);
- }
-}
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 585b6bdf1..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 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.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-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.jdt.core.IClasspathEntry;
-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.jst.server.tomcat.core.internal.wst.IModuleVisitor;
-import org.eclipse.jst.server.tomcat.core.internal.wst.ModuleTraverser;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-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 {
-
- /**
- * {@inheritDoc}
- */
- public ISourceContainer[] computeSourceContainers(
- ILaunchConfiguration configuration, IProgressMonitor monitor)
- throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
-
- SourcePathComputerVisitor visitor = new SourcePathComputerVisitor(
- configuration);
-
- IModule[] modules = server.getModules();
- for (int i = 0; i < modules.length; i++) {
- ModuleTraverser.traverse(modules[i], visitor, monitor);
- }
-
- return visitor.getSourceContainers();
- }
-
- class SourcePathComputerVisitor implements IModuleVisitor {
-
- final ILaunchConfiguration configuration;
-
- /**
- * List<IRuntimeClasspathEntry> of unresolved IRuntimeClasspathEntries
- */
- List<IRuntimeClasspathEntry> runtimeClasspath = new ArrayList<IRuntimeClasspathEntry>();
-
- SourcePathComputerVisitor(ILaunchConfiguration configuration) {
- this.configuration = configuration;
- }
-
- /**
- * {@inheritDoc}
- */
- public void visitWebComponent(IVirtualComponent component)
- throws CoreException {
- IProject project = component.getProject();
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IJavaProject javaProject = JavaCore.create(project);
- runtimeClasspath.add(JavaRuntime
- .newDefaultProjectClasspathEntry(javaProject));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void endVisitWebComponent(IVirtualComponent component)
- throws CoreException {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void visitArchiveComponent(IPath runtimePath, IPath workspacePath) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void visitDependentJavaProject(IJavaProject javaProject) {
- // Ensure dependent projects are listed directly in the classpath list.
- // This is needed because JavaRuntime.getSourceContainers() won't resolve them
- // correctly if they have non-default output folders. In this case, they resolve to
- // binary archive folders with no associated source folder for some reason.
- runtimeClasspath.add(JavaRuntime
- .newDefaultProjectClasspathEntry(javaProject));
- }
- /**
- * {@inheritDoc}
- */
- public void visitDependentComponent(IPath runtimePath,
- IPath workspacePath) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void visitWebResource(IPath runtimePath, IPath workspacePath) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void visitDependentContentResource(IPath runtimePath, IPath workspacePath) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void visitEarResource(IPath runtimePath, IPath workspacePath) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void endVisitEarComponent(IVirtualComponent component)
- throws CoreException {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public void visitClasspathEntry(IPath rtFolder, IClasspathEntry entry) {
- // do nothing
- }
-
- ISourceContainer[] getSourceContainers() throws CoreException {
- runtimeClasspath.addAll(Arrays.asList(JavaRuntime
- .computeUnresolvedSourceLookupPath(configuration)));
- IRuntimeClasspathEntry[] entries = runtimeClasspath
- .toArray(new IRuntimeClasspathEntry[runtimeClasspath.size()]);
- IRuntimeClasspathEntry[] resolved = JavaRuntime
- .resolveSourceLookupPath(entries, configuration);
- return JavaRuntime.getSourceContainers(resolved);
- }
-
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java
deleted file mode 100644
index 0675afa60..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java
+++ /dev/null
@@ -1,1253 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2011 SAS Institute, Inc and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAS Institute, Inc - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import javax.xml.parsers.DocumentBuilder;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.server.tomcat.core.internal.wst.ModuleTraverser;
-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.Context;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server;
-import org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.util.PublishHelper;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-/**
- * Utility class for methods that are used by more that one version
- * of Tomcat. Use of these methods makes it clear that more than
- * one version will be impacted by changes.
- *
- */
-public class TomcatVersionHelper {
-
- /**
- * Sting containing contents for a default web.xml for Servlet 2.2.
- */
- public static final String DEFAULT_WEBXML_SERVLET22 =
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
- "<!DOCTYPE web-app PUBLIC \"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN\" \"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd\">\n" +
- "<web-app>\n</web-app>";
-
- /**
- * Default web.xml contents for a Servlet 2.3 web application.
- */
- public static final String DEFAULT_WEBXML_SERVLET23 =
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\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>";
-
- /**
- * Default web.xml contents for a Servlet 2.4 web application.
- */
- public static final String DEFAULT_WEBXML_SERVLET24 =
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
- "<web-app 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\" version=\"2.4\">\n" +
- "</web-app>";
-
- /**
- * Default web.xml contents for a Servlet 2.5 web application.
- */
- public static final String DEFAULT_WEBXML_SERVLET25 =
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
- "<web-app 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_5.xsd\" version=\"2.5\">\n" +
- "</web-app>";
-
- /**
- * Map of server type ID to expected version string fragment for version checking.
- */
- private static final Map<String, String> versionStringMap = new HashMap<String, String>();
-
- static {
- versionStringMap.put(TomcatPlugin.TOMCAT_41, "4.1.");
- versionStringMap.put(TomcatPlugin.TOMCAT_50, "5.0.");
- versionStringMap.put(TomcatPlugin.TOMCAT_55, "5.5.");
- versionStringMap.put(TomcatPlugin.TOMCAT_60, "6.0.");
- versionStringMap.put(TomcatPlugin.TOMCAT_70, "7.0.");
- }
-
- /**
- * Reads the from the specified InputStream and returns
- * the result as a String. Each line is terminated by
- * &quot;\n&quot;. Returns whatever is read regardless
- * of any errors that occurs while reading.
- *
- * @param stream InputStream for the contents to be read
- * @return contents read
- * @throws IOException if error occurs closing the stream
- */
- public static String getFileContents(InputStream stream) throws IOException {
- BufferedReader br = null;
- StringBuffer sb = new StringBuffer();
- try {
- br = new BufferedReader(new InputStreamReader(stream));
- String temp = br.readLine();
- while (temp != null) {
- sb.append(temp).append("\n");
- temp = br.readLine();
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load file contents.", e);
- } finally {
- if (br != null)
- br.close();
- }
- return sb.toString();
- }
-
- /**
- * Gets the base directory for this server. This directory
- * is used as the "base" property for the server.
- *
- * @param ts TomcatServer from which to derive the base directory
- * directory. Only used to get the temp directory if needed.
- * @return path to base directory
- */
- public static IPath getStandardBaseDirectory(TomcatServer ts) {
- if (ts.isTestEnvironment()) {
- String baseDir = ts.getInstanceDirectory();
- // If test mode and no instance directory specified, use temporary directory
- if (baseDir == null) {
- TomcatServerBehaviour tsb = (TomcatServerBehaviour)ts.getServer().loadAdapter(TomcatServerBehaviour.class, null);
- return tsb.getTempDirectory();
- }
- IPath path = new Path(baseDir);
- if (!path.isAbsolute()) {
- IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- path = rootPath.append(path);
- }
- // Return specified instance directory
- return path;
- }
- // Return runtime path
- return ts.getServer().getRuntime().getLocation();
- }
-
- /**
- * Gets the startup VM arguments for the Catalina server.
- *
- * @param installPath installation path for the server
- * @param instancePath instance path for the server
- * @param deployPath deploy path for the server
- * @param isTestEnv test environment flag
- * @return array of strings containing VM arguments
- */
- public static String[] getCatalinaVMArguments(IPath installPath, IPath instancePath, IPath deployPath, String endorsedDirs, boolean isTestEnv) {
- List<String> list = new ArrayList<String>();
- if (isTestEnv)
- list.add("-Dcatalina.base=\"" + instancePath.toOSString() + "\"");
- else
- list.add("-Dcatalina.base=\"" + installPath.toOSString() + "\"");
- list.add("-Dcatalina.home=\"" + installPath.toOSString() + "\"");
- // Include a system property for the configurable deploy location
- list.add("-Dwtp.deploy=\"" + deployPath.toOSString() + "\"");
- list.add("-Djava.endorsed.dirs=\"" + endorsedDirs + "\"");
-
- String[] s = new String[list.size()];
- list.toArray(s);
- return s;
- }
-
-
- /**
- * Gets a ServerInstance for the specified server.xml, Service name,
- * and Host name. Returns null if server.xml does not exist
- * or an error occurs.
- *
- * @param serverXml path to previously published server.xml
- * @param serviceName name of Service to be used by this instance or null
- * @param hostName name of Host to be used by this instance or null
- * @return ServerInstance for specified server.xml using specified
- * Service and Host names. null if server.xml does not exist.
- * @throws FileNotFoundException should not occur since existence is tested
- * @throws IOException if there is an error reading server.xml
- * @throws SAXException if there is a syntax error in server.xml
- */
- public static ServerInstance getCatalinaServerInstance(IPath serverXml, String serviceName, String hostName) throws FileNotFoundException, IOException, SAXException {
- ServerInstance serverInstance = null;
- Factory factory = new Factory();
- factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- File serverFile = serverXml.toFile();
- if (serverFile.exists()) {
- Server server = (Server) factory.loadDocument(new FileInputStream(serverFile));
- serverInstance = new ServerInstance(server, serviceName, hostName);
-
- IPath contextPath = serverInstance.getContextXmlDirectory(serverXml.removeLastSegments(1));
- File contextDir = contextPath.toFile();
- if (contextDir.exists()) {
- Map<File, Context> projectContexts = new HashMap<File, Context>();
- loadSeparateContextFiles(contextPath.toFile(), factory, projectContexts);
-
- // add any separately saved contexts
- Host host = serverInstance.getHost();
- Collection contexts = projectContexts.values();
- Iterator iter = contexts.iterator();
- while (iter.hasNext()) {
- Context context = (Context)iter.next();
- host.importNode(context.getElementNode(), true);
- }
- // TODO Add handling for non-project contexts when there removal can be addressed
- }
- }
- return serverInstance;
- }
-
- /**
- * Gets the paths for Contexts that are being removed in the
- * next server publish. Reads the old server.xml to determine
- * what Contexts were previously servered and returns those
- * that are not included in the specified list of modules.
- *
- * @param oldServerInstance for server.xml from previous server publish
- * @param modules list of currently added modules
- * @param removedContextsMap Map to receive removed contexts mapped by path
- * @param keptContextsMap Map to receive kept contexts mapped by path
- */
- public static void getRemovedKeptCatalinaContexts(ServerInstance oldServerInstance,
- List modules, Map<String, Context> removedContextsMap, Map<String, Context> keptContextsMap) {
- // Collect paths of old web modules managed by WTP
- Context [] contexts = oldServerInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- String source = contexts[i].getSource();
- if (source != null && source.length() > 0 ) {
- removedContextsMap.put(contexts[i].getPath(), contexts[i]);
- }
- }
- }
-
- // Remove paths for web modules that are staying around
- int size = modules.size();
- for (int i = 0; i < size; i++) {
- WebModule module = (WebModule) modules.get(i);
- Context context = removedContextsMap.remove(module.getPath());
- if (context != null)
- keptContextsMap.put(context.getPath(), context);
- }
- }
-
- /**
- * Cleanup server instance location in preparation for next server publish.
- * This currently involves deleting work directories for currently
- * existing Contexts which will not be included in the next publish.
- * In addition, Context XML files which may have been created for these
- * Contexts are also deleted. If requested, Context XML files for
- * kept Contexts will be deleted since they will be kept in server.xml.
- *
- * @param baseDir path to server instance directory, i.e. catalina.base
- * @param installDir path to server installation directory (not currently used)
- * @param removeKeptContextFiles true if kept contexts should have a separate
- * context XML file removed
- * @param modules list of currently added modules
- * @param monitor a progress monitor or null
- * @return MultiStatus containing results of the cleanup operation
- */
- public static IStatus cleanupCatalinaServer(IPath baseDir, IPath installDir, boolean removeKeptContextFiles, List modules, IProgressMonitor monitor) {
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, Messages.cleanupServerTask, null);
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.cleanupServerTask, 200);
- monitor.subTask(Messages.detectingRemovedProjects);
-
- IPath serverXml = baseDir.append("conf").append("server.xml");
- ServerInstance oldInstance = TomcatVersionHelper.getCatalinaServerInstance(serverXml, null, null);
- if (oldInstance != null) {
- Map<String, Context> removedContextsMap = new HashMap<String, Context>();
- Map<String, Context> keptContextsMap = new HashMap<String, Context>();
- TomcatVersionHelper.getRemovedKeptCatalinaContexts(oldInstance, modules, removedContextsMap, keptContextsMap);
- monitor.worked(100);
- if (removedContextsMap.size() > 0) {
- // Delete context files and work directories for managed web modules that have gone away
- IProgressMonitor subMonitor = ProgressUtil.getSubMonitorFor(monitor, 100);
- subMonitor.beginTask(Messages.deletingContextFilesTask, removedContextsMap.size() * 200);
-
- Iterator iter = removedContextsMap.keySet().iterator();
- while (iter.hasNext()) {
- String oldPath = (String)iter.next();
- Context ctx = removedContextsMap.get(oldPath);
-
- // Delete the corresponding context file, if it exists
- IPath ctxFilePath = oldInstance.getContextFilePath(baseDir, ctx);
- if (ctxFilePath != null) {
- File ctxFile = ctxFilePath.toFile();
- if (ctxFile.exists()) {
- subMonitor.subTask(NLS.bind(Messages.deletingContextFile, ctxFile.getName()));
- if (ctxFile.delete()) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Leftover context file " + ctxFile.getName() + " deleted.");
- ms.add(new Status(IStatus.OK, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.deletedContextFile, ctxFile.getName()), null));
- } else {
- Trace.trace(Trace.SEVERE, "Could not delete obsolete context file " + ctxFilePath.toOSString());
- ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorCouldNotDeleteContextFile, ctxFilePath.toOSString()), null));
- }
- }
- }
- subMonitor.worked(100);
-
- // Delete work directory associated with the removed context if it is within confDir.
- // If it is outside of confDir, assume user is going to manage it.
- IPath ctxWorkPath = oldInstance.getContextWorkDirectory(baseDir, ctx);
- if (baseDir.isPrefixOf(ctxWorkPath)) {
- File ctxWorkDir = ctxWorkPath.toFile();
- if (ctxWorkDir.exists() && ctxWorkDir.isDirectory()) {
- IStatus [] results = PublishHelper.deleteDirectory(ctxWorkDir, ProgressUtil.getSubMonitorFor(monitor, 100));
- if (results.length > 0) {
- Trace.trace(Trace.SEVERE, "Could not delete work directory " + ctxWorkDir.getPath() + " for removed context " + oldPath);
- for (int i = 0; i < results.length; i++) {
- ms.add(results[i]);
- }
- }
- }
- else
- subMonitor.worked(100);
- }
- else
- subMonitor.worked(100);
- }
- subMonitor.done();
- }
- monitor.worked(100);
-
- // If requested, remove any separate context XML files for contexts being kept
- if (removeKeptContextFiles && keptContextsMap.size() > 0) {
- // Delete context files and work directories for managed web modules that have gone away
- IProgressMonitor subMonitor = ProgressUtil.getSubMonitorFor(monitor, 100);
- // TODO Improve task name
- subMonitor.beginTask(Messages.deletingContextFilesTask, keptContextsMap.size() * 100);
-
- Iterator iter = keptContextsMap.keySet().iterator();
- while (iter.hasNext()) {
- String keptPath = (String)iter.next();
- Context ctx = keptContextsMap.get(keptPath);
-
- // Delete the corresponding context file, if it exists
- IPath ctxFilePath = oldInstance.getContextFilePath(baseDir, ctx);
- if (ctxFilePath != null) {
- File ctxFile = ctxFilePath.toFile();
- if (ctxFile.exists()) {
- subMonitor.subTask(NLS.bind(Messages.deletingContextFile, ctxFile.getName()));
- if (ctxFile.delete()) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Leftover context file " + ctxFile.getName() + " deleted.");
- ms.add(new Status(IStatus.OK, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.deletedContextFile, ctxFile.getName()), null));
- } else {
- Trace.trace(Trace.SEVERE, "Could not delete obsolete context file " + ctxFilePath.toOSString());
- ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorCouldNotDeleteContextFile, ctxFilePath.toOSString()), null));
- }
- }
- }
- subMonitor.worked(100);
- }
- subMonitor.done();
- }
- }
- // Else no server.xml. Assume first publish to new temp directory
- else {
- monitor.worked(200);
- }
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Server cleaned");
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not cleanup server at " + baseDir.toOSString() + ": " + e.getMessage());
- ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorCleanupServer, new String[] {e.getLocalizedMessage()}), e));
- }
- finally {
- monitor.done();
- }
-
- return ms;
- }
-
- /**
- * Creates a Catalina instance directory at the specified
- * path. This involves creating the set of subdirectories
- * uses by a Catalina instance.
- *
- * @param baseDir directory at which to create Catalina instance
- * directories.
- * @return result status of the operation
- */
- public static IStatus createCatalinaInstanceDirectory(IPath baseDir) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Creating runtime directory at " + baseDir.toOSString());
- // TODO Add more error handling.
- // Prepare a catalina.base directory structure
- File temp = baseDir.append("conf").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = baseDir.append("logs").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = baseDir.append("temp").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = baseDir.append("webapps").toFile();
- if (!temp.exists())
- temp.mkdirs();
- temp = baseDir.append("work").toFile();
- if (!temp.exists())
- temp.mkdirs();
-
- return Status.OK_STATUS;
- }
-
- /**
- * Creates the specified deployment directory if it does not already exist.
- * It will include a default ROOT web application using the specified web.xml.
- *
- * @param deployDir path to deployment directory to create
- * @param webxml web.xml context to use for the ROOT web application.
- * @return result status of the operation
- */
- public static IStatus createDeploymentDirectory(IPath deployDir, String webxml) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Creating deployment directory at " + deployDir.toOSString());
-
- // TODO Add more error handling.
- File temp = deployDir.toFile();
- if (!temp.exists())
- temp.mkdirs();
-
- IPath tempPath = deployDir.append("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(webxml);
- fw.close();
- } catch (IOException e) {
- Trace.trace(Trace.WARNING, "Unable to create web.xml for ROOT context.", e);
- }
- }
-
- return Status.OK_STATUS;
- }
-
- /**
- * Add context configuration found in META-INF/context.xml files
- * present in projects to published server.xml. Used by
- * Tomcat 4.1, 5.0, and 5.5 which support use of META-INF/context.xml
- * in some form.
- *
- * @param baseDir absolute path to catalina instance directory
- * @param webappsDir absolute path to deployment directory
- * @param monitor a progress monitor or null
- * @return result of operation
- */
- public static IStatus publishCatalinaContextConfig(IPath baseDir, IPath webappsDir, IProgressMonitor monitor) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Apply context configurations");
- IPath confDir = baseDir.append("conf");
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishConfigurationTask, 300);
-
- 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()));
- ServerInstance publishedInstance = new ServerInstance(publishedServer, null, null);
- monitor.worked(100);
-
- boolean modified = false;
-
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, Messages.publishContextConfigTask, null);
- Context [] contexts = publishedInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[i];
- monitor.subTask(NLS.bind(Messages.checkingContextTask,
- new String[] {context.getPath()}));
- if (addCatalinaContextConfig(webappsDir, context, ms)) {
- modified = true;
- }
- }
- }
- monitor.worked(100);
- if (modified) {
- monitor.subTask(Messages.savingContextConfigTask);
- factory.save(confDir.append("server.xml").toOSString());
- }
-
- // If problem(s) occurred adding context configurations, return error status
- if (ms.getChildren().length > 0) {
- return ms;
- }
- if (Trace.isTraceEnabled())
- 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 configuration from " + confDir.toOSString() + ": " + e.getMessage());
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- }
- finally {
- monitor.done();
- }
- }
-
- /**
- * 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.
- */
- private static boolean addCatalinaContextConfig(IPath webappsDir, Context context, MultiStatus ms) {
- boolean modified = false;
- String source = context.getSource();
- if (source != null && source.length() > 0 )
- {
- File docBase = new File(context.getDocBase());
- if (!docBase.isAbsolute())
- docBase = new File(webappsDir.toOSString(), docBase.getPath());
- try {
- Context contextConfig = loadCatalinaContextConfig(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 docBase File with absolute 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.
- */
- private static Context loadCatalinaContextConfig(File docBase) throws IOException, SAXException {
- File contextXML = new File(docBase, "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;
- }
-
- /**
- * If modules are not being deployed to the "webapps" directory, the
- * context for the published modules is updated to contain the
- * corrected docBase.
- *
- * @param baseDir runtime base directory for the server
- * @param deployDir deployment directory for the server
- * @param server server being localized
- * @param monitor a progress monitor
- * @return result of operation
- */
- public static IStatus localizeConfiguration(IPath baseDir, IPath deployDir, TomcatServer server, IProgressMonitor monitor) {
- try {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Localizing configuration at " + baseDir);
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishConfigurationTask, 300);
-
- IPath serverXml = baseDir.append("conf/server.xml");
- Factory factory = new Factory();
- factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- Server publishedServer = (Server)factory.loadDocument(
- new FileInputStream(serverXml.toFile()));
- ServerInstance publishedInstance = new ServerInstance(publishedServer, null, null);
- monitor.worked(100);
-
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
-
- boolean modified = false;
-
- // Only add root module if running in a test env (i.e. not on the installation)
- boolean addRootWebapp = server.isTestEnvironment();
-
- // If not deploying to "webapps", context docBase attributes need updating
- // TODO Improve to compare with appBase value instead of hardcoded "webapps"
- boolean deployingToAppBase = "webapps".equals(server.getDeployDirectory());
-
- Map<String, String> pathMap = new HashMap<String, String>();
-
- MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorPublishServer, server.getServer().getName()), null);
- Context [] contexts = publishedInstance.getContexts();
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- Context context = contexts[i];
- // Normalize path and check for duplicates
- String path = context.getPath();
- if (path != null) {
- // Save a copy of original in case it's "/"
- String origPath = path;
- // Normalize "/" to ""
- if ("/".equals(path)) {
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Context path is being changed from \"/\" to \"\".");
- path = "";
- context.setPath(path);
- modified = true;
- }
-
- // Context paths that are the same or differ only in case are not allowed
- String lcPath = path.toLowerCase();
- if (!pathMap.containsKey(lcPath)) {
- pathMap.put(lcPath, origPath);
- }
- else {
- String otherPath = pathMap.get(lcPath);
- IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID,
- origPath.equals(otherPath) ? NLS.bind(Messages.errorPublishPathDup, origPath)
- : NLS.bind(Messages.errorPublishPathConflict, origPath, otherPath));
- ms.add(s);
- }
- }
- else {
- IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID,
- Messages.errorPublishPathMissing);
- ms.add(s);
- }
-
- // If default webapp has not been found, check this one
- // TODO Need to add a root context if deploying to webapps but with auto-deploy off
- if (addRootWebapp && "".equals(context.getPath())) {
- // A default webapp is being deployed, don't add one
- addRootWebapp = false;
- }
-
- // If not deploying to appBase, convert to absolute path under deploy dir
- if (!deployingToAppBase) {
- String source = context.getSource();
- if (source != null && source.length() > 0 ) {
- context.setDocBase(deployDir.append(context.getDocBase()).toOSString());
- modified = true;
- }
- }
- }
- }
- // If errors are present, return status
- if (!ms.isOK())
- return ms;
-
- if (addRootWebapp) {
- // Add a context for the default webapp
- Context rootContext = publishedInstance.createContext(0);
- rootContext.setPath("");
- rootContext.setDocBase(deployDir.append("ROOT").toOSString());
- rootContext.setReloadable("false");
- modified = true;
- }
- monitor.worked(100);
-
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
-
- if (modified) {
- monitor.subTask(Messages.savingContextConfigTask);
- factory.save(serverXml.toOSString());
- }
- monitor.worked(100);
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Context docBase settings updated in server.xml.");
- }
- catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not localize server configuration published to " + baseDir.toOSString() + ": " + e.getMessage());
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- }
- finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- /**
- * Copies the custom loader jar required to serve projects without
- * publishing to the specified destination directory.
- *
- * @param destDir destination directory for the loader jar
- * @param serverId ID of the server receiving the jar
- * @return result of copy operation
- */
- public static IStatus copyLoaderJar(IPath destDir, String serverId, String tomcatVersion) {
- String loaderJar = getLoaderJarFile(serverId, tomcatVersion);
- URL installURL = TomcatPlugin.getInstance().getBundle().getEntry(loaderJar);
- if (installURL == null) {
- Trace.trace(Trace.SEVERE, "Loader jar not found for server ID " + serverId);
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishLoaderJarNotFound, serverId), null);
- }
-
- URL localURL;
- try {
- localURL = FileLocator.toFileURL(installURL);
- } catch (IOException e) {
- Trace.trace(Trace.SEVERE, "Could not convert " + installURL.toString() + " to file URL: " + e.getMessage());
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishURLConvert,
- new String[] {installURL.toString(), e.getLocalizedMessage()}), e);
- }
-
- destDir.toFile().mkdirs();
- IStatus status = FileUtil.copyFile(localURL, destDir.append(loaderJar).toString());
-
- return status;
- }
-
- /**
- * Tries to delete the custom loader jar added to support serving projects directly
- * without publishing. Returns a warning if not successful.
- *
- * @param destDir destination directory containing the loader jar
- * @param serverId ID of the server from which to delete the jar
- * @return result of copy operation
- */
- public static IStatus removeLoaderJar(IPath destDir, String serverId, String tomcatVersion) {
- String loaderJar = getLoaderJarFile(serverId, tomcatVersion);
- File loaderFile = destDir.append(loaderJar).toFile();
- // If Tomcat 7, see if jar to remove exists. If not, ensure default jar is not present
- if ("org.eclipse.jst.server.tomcat.runtime.70".equals(serverId) && tomcatVersion != null) {
- if (!loaderFile.exists()) {
- loaderJar = getLoaderJarFile(serverId, "");
- loaderFile = destDir.append(loaderJar).toFile();
- }
- }
- // If loader jar exists but is not successfully deleted, return warning
- if (loaderFile.exists() && !loaderFile.delete())
- return new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0,
- NLS.bind(Messages.errorPublishCantDeleteLoaderJar, loaderFile.getPath()), null);
-
- return Status.OK_STATUS;
- }
-
- public static String getLoaderJarFile(String serverId, String tomcatVersion) {
- String loaderJar = "/" + serverId + ".loader.jar";
- // If Tomcat 7.0, we need to determine if an older jar should be used
- if ("org.eclipse.jst.server.tomcat.runtime.70".equals(serverId) && tomcatVersion != null) {
- int index = tomcatVersion.indexOf('.');
- if (index >= 0 && tomcatVersion.length() > index + 1) {
- String versionStr = tomcatVersion.substring(0, index);
- try {
- int version = Integer.parseInt(versionStr);
- if (version == 7) {
- int index2 = tomcatVersion.indexOf('.', index + 1);
- if (index2 >= 0 && tomcatVersion.length() > index2 + 1) {
- versionStr = tomcatVersion.substring(index + 1, index2);
- try {
- version = Integer.parseInt(versionStr);
- if (version == 0) {
- int index3 = tomcatVersion.indexOf('.', index2 + 1);
- if (index3 >= 0 && tomcatVersion.length() > index3 + 1) {
- versionStr = tomcatVersion.substring(index2 + 1, index3);
- }
- else {
- versionStr = tomcatVersion.substring(index2 + 1);
- for (int i = 0; i < versionStr.length(); i++) {
- if (!Character.isDigit(versionStr.charAt(i))) {
- versionStr = versionStr.substring(0, i);
- break;
- }
- }
- }
- try {
- version = Integer.parseInt(versionStr);
- if (version <= 6) {
- // Use this jar for Tomcat 7.0.6 or earlier.
- loaderJar = "/" + serverId + "6.loader.jar";
- }
- else if (version <= 8) {
- // Use this jar for Tomcat 7.0.8 (7.0.7 didn't release)
- loaderJar = "/" + serverId + "8.loader.jar";
- }
- }
- catch (NumberFormatException e) {
- // Ignore and copy default jar
- }
- }
- }
- catch (NumberFormatException e) {
- // Ignore and copy default jar
- }
- }
- }
- }
- catch (NumberFormatException e) {
- // Ignore and copy default jar
- }
- }
- }
- return loaderJar;
- }
-
- /**
- * Updates the catalina.properties file to include a extra entry in the
- * specified loader property to pickup the loader jar.
- *
- * @param baseDir directory where the Catalina instance is found
- * @param jarLoc location of loader jar relative to baseDir
- * @param loader loader in catalina.properties to use
- * @return result of update operation
- */
- public static IStatus updatePropertiesToServeDirectly(IPath baseDir, String jarLoc, String loader) {
- File catalinaProperties = baseDir.append(
- "conf/catalina.properties").toFile();
- try {
- CatalinaPropertiesUtil.addGlobalClasspath(catalinaProperties, loader,
- new String[] { "${catalina.base}/" + jarLoc + "/*.jar" });
-
- } catch (IOException e) {
- return new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorPublishCatalinaProps, e.getLocalizedMessage()), e);
- }
- return Status.OK_STATUS;
- }
-
- /**
- * Update Contexts to serve web projects directly.
- *
- * @param baseDir directory where the Catalina instance is found
- * @param loader name of the catalina.properties loader to use for global
- * classpath entries
- * @param monitor a progress monitor
- * @return result of update operation
- */
- public static IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, boolean enableMetaInfResources, IProgressMonitor monitor) {
-
- IPath confDir = baseDir.append("conf");
- IPath serverXml = confDir.append("server.xml");
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishConfigurationTask, 300);
-
- 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(serverXml.toFile()));
- ServerInstance publishedInstance = new ServerInstance(publishedServer, null, null);
- monitor.worked(100);
-
- boolean modified = false;
-
- // care about top-level modules only
- TomcatPublishModuleVisitor visitor = new TomcatPublishModuleVisitor(
- baseDir, tomcatVersion, publishedInstance, loader, enableMetaInfResources);
- Context [] contexts = publishedInstance.getContexts();
- for (int i = 0; i < contexts.length; i++) {
- String moduleId = contexts[i].getSource();
- if (moduleId != null && moduleId.length() > 0) {
- IModule module = ServerUtil.getModule(moduleId);
- ModuleTraverser.traverse(module, visitor, monitor);
- modified = true;
- }
- }
-
- if (modified) {
- monitor.subTask(Messages.savingContextConfigTask);
- factory.save(serverXml.toOSString());
- }
- monitor.worked(100);
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Context docBase settings updated in server.xml.");
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not modify context configurations to serve directly for Tomcat configuration " + confDir.toOSString() + ": " + e.getMessage());
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- }
- finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- /**
- * Moves contexts out of current published server.xml and into individual
- * context XML files.
- *
- * @param baseDir directory where the Catalina instance is found
- * @param noPath true if path attribute should be removed from the context
- * @param serverStopped true if the server is stopped
- * @param monitor a progress monitor
- * @return result of operation
- */
- public static IStatus moveContextsToSeparateFiles(IPath baseDir, boolean noPath, boolean serverStopped, IProgressMonitor monitor) {
- IPath confDir = baseDir.append("conf");
- IPath serverXml = confDir.append("server.xml");
- try {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.beginTask(Messages.publishConfigurationTask, 300);
-
- 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(serverXml.toFile()));
- ServerInstance publishedInstance = new ServerInstance(publishedServer, null, null);
- monitor.worked(100);
-
- boolean modified = false;
-
- Host host = publishedInstance.getHost();
- Context[] wtpContexts = publishedInstance.getContexts();
- if (wtpContexts != null && wtpContexts.length > 0) {
- IPath contextPath = publishedInstance.getContextXmlDirectory(serverXml.removeLastSegments(1));
- File contextDir = contextPath.toFile();
- if (!contextDir.exists()) {
- contextDir.mkdirs();
- }
- // Process in reverse order, since contexts may be removed
- for (int i = wtpContexts.length - 1; i >= 0; i--) {
- Context context = wtpContexts[i];
- // TODO Handle non-project contexts when their removal can be addressed
- if (context.getSource() == null)
- continue;
-
- String name = context.getPath();
- if (name.startsWith("/")) {
- name = name.substring(1);
- }
- // If the default context, adjust the file name
- if (name.length() == 0) {
- name = "ROOT";
- }
- // Update name if multi-level path. For 5.5 and later the "#" has been
- // "reserved" as a legal file name placeholder for "/". For Tomcat 5.0,
- // we just need a legal unique file name since "/" will fail. Prior to
- // 5.0, this feature is not supported.
- name = name.replace('/', '#');
-
- // TODO Determine circumstances, if any, where setting antiResourceLocking true can cause the original docBase content to be deleted.
- if (Boolean.valueOf(context.getAttributeValue("antiResourceLocking")).booleanValue())
- context.setAttributeValue("antiResourceLocking", "false");
-
- File contextFile = new File(contextDir, name + ".xml");
- Context existingContext = loadContextFile(contextFile);
- // If server is stopped or if contexts are not the equivalent, write the context file
- if (serverStopped || !context.isEquivalent(existingContext)) {
- // If requested, remove path attribute
- if (noPath)
- context.removeAttribute("path");
-
- DocumentBuilder builder = XMLUtil.getDocumentBuilder();
- Document contextDoc = builder.newDocument();
- contextDoc.appendChild(contextDoc.importNode(context.getElementNode(), true));
- XMLUtil.save(contextFile.getAbsolutePath(), contextDoc);
- }
-
- host.removeElement("Context", i);
- modified = true;
- }
- }
- monitor.worked(100);
- if (modified) {
- monitor.subTask(Messages.savingContextConfigTask);
- factory.save(serverXml.toOSString());
- }
- monitor.worked(100);
- if (Trace.isTraceEnabled())
- Trace.trace(Trace.FINER, "Context docBase settings updated in server.xml.");
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not modify context configurations to serve directly for Tomcat configuration " + confDir.toOSString() + ": " + e.getMessage());
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e);
- }
- finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- private static void loadSeparateContextFiles(File contextDir, Factory factory, Map<File, Context> projectContexts) {
- File[] contextFiles = contextDir.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.toLowerCase().endsWith(".xml");
- }
- });
-
- for (int j = 0; j < contextFiles.length; j++) {
- File ctx = contextFiles[j];
-
- Context context = loadContextFile(ctx);
- if (context != null) {
- // TODO Handle non-project contexts when their removal can be addressed
- String memento = context.getSource();
- if (memento != null) {
- projectContexts.put(ctx, context);
- }
- }
- }
- }
-
- private static Context loadContextFile(File contextFile) {
- FileInputStream fis = null;
- Context context = null;
- if (contextFile != null && contextFile.exists()) {
- try {
- Factory factory = new Factory();
- factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
- fis = new FileInputStream(contextFile);
- context = (Context)factory.loadDocument(fis);
- if (context != null) {
- String path = context.getPath();
- // If path attribute is not set, derive from file name
- if (path == null) {
- String fileName = contextFile.getName();
- path = fileName.substring(0, fileName.length() - ".xml".length());
- if ("ROOT".equals(path))
- path = "";
- // Assuming this use for "#" since Tomcat has "reserved" this use of "#" since 5.5.
- path = path.replace('#', '/');
- context.setPath("/" + path);
- }
- }
- } catch (Exception e) {
- // may be a spurious xml file in the host dir?
- Trace.trace(Trace.FINER, "Unable to read context "
- + contextFile.getAbsolutePath());
- } finally {
- try {
- fis.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- return context;
- }
-
- private static Map<IPath, String> catalinaJarVersion = new ConcurrentHashMap<IPath, String>();
- private static Map<IPath, Long> catalinaJarLastModified = new ConcurrentHashMap<IPath, Long>();
- private static volatile long lastCheck = 0;
-
- /**
- * Checks if the version of Tomcat installed at the specified location matches
- * the specified server type. The return status indicates if the version matches
- * or not, or can't be determined.
- *
- * Because this can get called repeatedly for certain operations, some caching
- * is provided. The first check for an installPath in the current Eclipse
- * session will query the catalina.jar for its version. Any additional
- * checks will compare the catalina.jar's time stamp and will use the previously
- * cached version if it didn't change. Additional checks that occur within
- * 2 seconds of the last check, regardless of Tomcat version, don't bother with
- * checking the jar time stamp and just use the cached values.
- *
- * @param installPath Path to Tomcat installation
- * @param serverType The server type ID for the desired version of Tomcat
- * @return Returns Status.OK_Status if check succeeds, or an error status
- * if the check fails. If the check can't determine if the version matches,
- * Status.CANCEL_STATUS is returned.
- */
- public static IStatus checkCatalinaVersion(IPath installPath, String serverType) {
- String versionSubString = null;
- IPath catalinaJarPath = null;
- File jarFile = null;
-
- if (TomcatPlugin.TOMCAT_60.equals(serverType) || TomcatPlugin.TOMCAT_70.equals(serverType)) {
- catalinaJarPath = installPath.append("lib").append("catalina.jar");
- jarFile = catalinaJarPath.toFile();
- // If jar is not at expected location, try alternate location
- if (!jarFile.exists()) {
- catalinaJarPath = installPath.append("server/lib").append("catalina.jar");
- jarFile = catalinaJarPath.toFile();
- // If not here either, discard path
- if (!jarFile.exists()) {
- catalinaJarPath = null;
- }
- }
- }
- else if (TomcatPlugin.TOMCAT_50.equals(serverType) || TomcatPlugin.TOMCAT_55.equals(serverType)
- || TomcatPlugin.TOMCAT_41.equals(serverType)) {
- catalinaJarPath = installPath.append("server/lib").append("catalina.jar");
- jarFile = catalinaJarPath.toFile();
- // If jar is not at expected location, try alternate location
- if (!jarFile.exists()) {
- catalinaJarPath = installPath.append("lib").append("catalina.jar");
- jarFile = catalinaJarPath.toFile();
- // If not here either, discard path
- if (!jarFile.exists()) {
- catalinaJarPath = null;
- }
- }
- }
- if (catalinaJarPath != null) {
- versionSubString = catalinaJarVersion.get(catalinaJarPath);
- long checkTime = System.currentTimeMillis();
- // Use some logic to try to determine if a cached value is stale
- // If last check was more than a couple of seconds ago, check the jar time stamp
- if (versionSubString != null && (checkTime - lastCheck > 2000)) {
- long curLastModified = jarFile.lastModified();
- Long oldLastModified = catalinaJarLastModified.get(catalinaJarPath);
- // If jar time stamps differ, discard the cached version string
- if (oldLastModified == null || curLastModified != oldLastModified.longValue()) {
- versionSubString = null;
- }
- }
- lastCheck = checkTime;
- // If a version string needs to be acquired
- if (versionSubString == null) {
- InputStream is = null;
- try {
- // Read version string from catalina.jar
- JarFile jar = new JarFile(jarFile);
- JarEntry entry = jar.getJarEntry("org/apache/catalina/util/ServerInfo.properties");
- if (entry != null) {
- is = jar.getInputStream(entry);
- if (is != null) {
- Properties props = new Properties();
- props.load(is);
- String serverVersion = props.getProperty("server.info");
- if (serverVersion != null) {
- int index = serverVersion.indexOf("/");
- if (index > 0) {
- versionSubString = serverVersion.substring(index + 1);
- catalinaJarVersion.put(catalinaJarPath, versionSubString);
- catalinaJarLastModified.put(catalinaJarPath, new Long(jarFile.lastModified()));
- }
- }
- }
- }
- } catch (IOException e) {
- // Ignore and handle as unknown version
- }
- finally {
- if (is != null) {
- try {
- is.close();
- }
- catch (IOException e) {
- // Ignore
- }
- }
- }
- }
- if (versionSubString != null) {
- // If we have an actual version, test the version
- if (versionSubString.length() > 0) {
- String versionTest = versionStringMap.get(serverType);
- if (versionTest != null && !versionSubString.startsWith(versionTest)) {
- return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorInstallDirWrongVersion2,
- versionSubString, versionTest.substring(0, versionTest.length() -1)));
- }
- }
- // Else we have an unknown version
- else {
- return Status.CANCEL_STATUS;
- }
- }
- else {
- // Cache blank version string for unknown version
- catalinaJarVersion.put(catalinaJarPath, "");
- catalinaJarLastModified.put(catalinaJarPath, new Long(jarFile.lastModified()));
- return Status.CANCEL_STATUS;
- }
- }
- // Else server type is not supported or jar doesn't exist
- else {
- return Status.CANCEL_STATUS;
- }
-
- return Status.OK_STATUS;
- }
-
- public static String getCatalinaVersion(IPath installPath, String serverType) {
- for (Map.Entry<IPath, String> entry : catalinaJarVersion.entrySet()) {
- IPath jarPath = entry.getKey();
- if (installPath.isPrefixOf(jarPath)) {
- return entry.getValue();
- }
- }
- // If not found, we need to initialize the data for this server
- IStatus result = checkCatalinaVersion(installPath, serverType);
- // If successful, search again
- if (result.isOK()) {
- for (Map.Entry<IPath, String> entry : catalinaJarVersion.entrySet()) {
- IPath jarPath = entry.getKey();
- if (installPath.isPrefixOf(jarPath)) {
- return entry.getValue();
- }
- }
- }
- // Return unknown version
- return "";
- }
-}
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 2d002cc7b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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 final byte CONFIG = 0;
- public static final byte WARNING = 1;
- public static final byte SEVERE = 2;
- public static final byte FINEST = 3;
- public static final byte FINER = 4;
-
- private static final String[] levelNames = new String[] {
- "CONFIG ", "WARNING ", "SEVERE ", "FINER ", "FINEST "};
- private static final String spacer = " ";
-
- private static final 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();
- }
-
- /**
- * Gets state of debug flag for the plug-in.
- *
- * @return true if tracing is enabled
- */
- public static boolean isTraceEnabled() {
- return TomcatPlugin.getInstance().isDebugging();
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/VerifyResourceSpec.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/VerifyResourceSpec.java
deleted file mode 100644
index bcf20d1fd..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/VerifyResourceSpec.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 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 org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-
-public class VerifyResourceSpec {
- private String spec;
- private String [] paths;
- private String otherNames;
- private int lastSuccess = -1;
- private IStatus errorStatus;
-
- public VerifyResourceSpec(String spec) {
- this.spec = spec;
- int altIndex = spec.indexOf('|');
- if (altIndex < 0) {
- paths = new String[1];
- paths[0] = spec.trim();
- }
- else {
- String file1 = spec.substring(0, altIndex).trim();
- String altSpec = spec.substring(altIndex + 1);
- if (altSpec.length() > 0) {
- int index = file1.lastIndexOf(File.separatorChar);
- String dir = index >= 0 ? file1.substring(0, index + 1) : "";
- String [] altNames = altSpec.split("\\|");
- paths = new String[altNames.length + 1];
- paths[0] = file1;
- for (int i = 0; i < altNames.length; i++) {
- paths[i + 1] = dir + altNames[i].trim();
- }
- otherNames = altSpec.replace('|', ',');
- }
- else {
- paths = new String[1];
- paths[0] = file1;
- }
- }
- }
-
- public String [] getPaths() {
- return paths;
- }
-
- public IStatus checkResource(String installDir) {
- if (lastSuccess >= 0 ) {
- File file = new File(installDir, paths[lastSuccess]);
- if (file.exists())
- return Status.OK_STATUS;
- }
- for (int i = 0; i < paths.length; i++) {
- if (i != lastSuccess) {
- File file = new File(installDir, paths[i]);
- if (file.exists()) {
- lastSuccess = i;
- return Status.OK_STATUS;
- }
- }
- }
- // Resource was not found, return error status
- if (errorStatus == null) {
- // Construct error status on first use
- if (paths.length == 1 || otherNames == null) {
- errorStatus = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorInstallDirMissingFile, paths[0]), null);
- }
- else if (paths.length == 2) {
- errorStatus = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorInstallDirMissingFile2, paths[0], otherNames), null);
- }
- else {
- errorStatus = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorInstallDirMissingFile3, paths[0], otherNames), null);
- }
- }
- return errorStatus;
- }
-
- public String toString() {
- return spec;
- }
-}
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 40c5098fa..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/WebAppDocument.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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<MimeMapping> map = new ArrayList<MimeMapping>();
-
- 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 {
- if (file.exists() && !isWebAppDirty)
- return;
-
- 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
- }
- }
- isWebAppDirty = false;
- }
-}
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 8c139113d..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, 2006 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);
- }
-}
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 78935334f..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, 2006 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;
- }
-}
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 fda8245b5..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, 2006 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);
- }
-}
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/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 0235921b1..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, 2006 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;
- }
-}
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/SetDeployDirectoryCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetDeployDirectoryCommand.java
deleted file mode 100644
index 0d10e146f..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetDeployDirectoryCommand.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 SAS Institute, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Larry Isaacs - 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 deploy directory
- */
-public class SetDeployDirectoryCommand extends ServerCommand {
- protected String deployDir;
- protected String oldDeployDir;
-
- /**
- * Constructs command to set the deploy directory.
- *
- * @param server a Tomcat server
- * @param deployDir deployment directory to set
- */
- public SetDeployDirectoryCommand(ITomcatServerWorkingCopy server,
- String deployDir) {
- super(server, Messages.serverEditorActionSetDeployDirectory);
- this.deployDir = deployDir;
- }
-
- /**
- * Execute setting the deploy directory
- */
- public void execute() {
- oldDeployDir = server.getDeployDirectory();
- server.setDeployDirectory(deployDir);
- }
-
- /**
- * Restore prior deploy directory
- */
- public void undo() {
- server.setDeployDirectory(oldDeployDir);
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetInstanceDirectoryCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetInstanceDirectoryCommand.java
deleted file mode 100644
index 5ce46197c..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetInstanceDirectoryCommand.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 SAS Institute, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Larry Isaacs - 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 deploy directory
- */
-public class SetInstanceDirectoryCommand extends ServerCommand {
- protected String instanceDir;
- protected String oldInstanceDir;
- protected boolean oldTestEnvironment;
-
- /**
- * Constructs command to set the instance directory. Setting
- * the instance directory also sets testEnvironment true;
- *
- * @param server a Tomcat server
- * @param instanceDir instance directory to set
- */
- public SetInstanceDirectoryCommand(ITomcatServerWorkingCopy server, String instanceDir) {
- super(server, Messages.serverEditorActionSetServerDirectory);
- this.instanceDir = instanceDir;
- }
-
- /**
- * Execute setting the deploy directory
- */
- public void execute() {
- oldTestEnvironment = server.isTestEnvironment();
- oldInstanceDir = server.getInstanceDirectory();
- if (!oldTestEnvironment)
- server.setTestEnvironment(true);
- server.setInstanceDirectory(instanceDir);
- }
-
- /**
- * Restore prior deploy directory
- */
- public void undo() {
- if (!oldTestEnvironment)
- server.setTestEnvironment(false);
- server.setInstanceDirectory(oldInstanceDir);
- }
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetSaveSeparateContextFilesCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetSaveSeparateContextFilesCommand.java
deleted file mode 100644
index 2c67a058c..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetSaveSeparateContextFilesCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 enable or disable serving modules without publishing
- */
-public class SetSaveSeparateContextFilesCommand extends ServerCommand {
- protected boolean sscf;
- protected boolean oldSscf;
-
- /**
- * SetSeparateContextFilesCommand constructor comment.
- *
- * @param server a Tomcat server
- * @param sscf <code>true</code> to enable saving separate context XML
- * files. Otherwise contexts are kept in server.xml when published.
- */
- public SetSaveSeparateContextFilesCommand(ITomcatServerWorkingCopy server, boolean sscf) {
- super(server, Messages.serverEidtorActionSetSeparateContextFiles);
- this.sscf = sscf;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldSscf = server.isSaveSeparateContextFiles();
- server.setSaveSeparateContextFiles(sscf);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- server.setSaveSeparateContextFiles(oldSscf);
- }
-} \ 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/SetServeModulesWithoutPublishCommand.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetServeModulesWithoutPublishCommand.java
deleted file mode 100644
index a9e0e210e..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetServeModulesWithoutPublishCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.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 enable or disable serving modules without publishing
- */
-public class SetServeModulesWithoutPublishCommand extends ServerCommand {
- protected boolean smwp;
- protected boolean oldSmwp;
-
- /**
- * SetServeModulesWithoutPublishCommand constructor comment.
- *
- * @param server a Tomcat server
- * @param smwp <code>true</code> to enable serving modules without
- * publishing. Otherwise modules are served with standard publishing.
- */
- public SetServeModulesWithoutPublishCommand(ITomcatServerWorkingCopy server, boolean smwp) {
- super(server, Messages.serverEditorActionSetServeWithoutPublish);
- this.smwp = smwp;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldSmwp = server.isServeModulesWithoutPublish();
- server.setServeModulesWithoutPublish(smwp);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- server.setServeModulesWithoutPublish(oldSmwp);
- }
-} \ 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 ae5d1603f..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/command/SetTestEnvironmentCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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 test mode. The server instance directory
- * is cleared in conjunction with this command for legacy support.
- */
-public class SetTestEnvironmentCommand extends ServerCommand {
- protected boolean te;
- protected boolean oldTe;
- protected String oldInstanceDir;
-
- /**
- * 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.serverEditorActionSetServerDirectory);
- this.te = te;
- }
-
- /**
- * Execute the command.
- */
- public void execute() {
- oldTe = server.isTestEnvironment();
- // save old instance directory
- oldInstanceDir = server.getInstanceDirectory();
- server.setTestEnvironment(te);
- // ensure instance directory is cleared
- server.setInstanceDirectory(null);
- }
-
- /**
- * Undo the command.
- */
- public void undo() {
- server.setTestEnvironment(oldTe);
- server.setInstanceDirectory(oldInstanceDir);
- }
-}
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/wst/IModuleVisitor.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/wst/IModuleVisitor.java
deleted file mode 100644
index 46664715b..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/wst/IModuleVisitor.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2011 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:
- * Igor Fedorenko & Fabrizio Giustina - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.wst;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-
-/**
- * Visitor interface to process module components
- */
-public interface IModuleVisitor {
-
- /**
- * Process web component
- * @param component web component to process
- * @throws CoreException
- */
- void visitWebComponent(IVirtualComponent component) throws CoreException;
-
- /**
- * Post process web component
- * @param component web component to process
- * @throws CoreException
- */
- void endVisitWebComponent(IVirtualComponent component) throws CoreException;
-
- /**
- * Process archive component.
- * @param runtimePath path for component at runtime
- * @param workspacePath path to component in workspace
- */
- void visitArchiveComponent(IPath runtimePath, IPath workspacePath);
-
- /**
- * Process Dependent Java project. Useful for determining
- * source paths.
- * @param IJavaProject dependent Java project
- */
- void visitDependentJavaProject(IJavaProject javaProject);
-
- /**
- * Process dependent component.
- * @param runtimePath path for component at runtime
- * @param workspacePath path to component in workspace
- */
- void visitDependentComponent(IPath runtimePath, IPath workspacePath);
-
- /**
- * Process web resource.
- * @param runtimePath path for resource at runtime
- * @param workspacePath path to resource in workspace
- */
- void visitWebResource(IPath runtimePath, IPath workspacePath);
-
- /**
- * Process a content resource from dependent component.
- * @param runtimePath path for resource at runtime
- * @param workspacePath path to resource in workspace
- */
- void visitDependentContentResource(IPath runtimePath, IPath workspacePath);
-
- /**
- * Process EAR resource.
- * @param runtimePath path for resource at runtime
- * @param workspacePath path to resource in workspace
- */
- void visitEarResource(IPath runtimePath, IPath workspacePath);
-
- /**
- * Post process EAR resource.
- * @param component EAR component to process
- * @throws CoreException
- */
- void endVisitEarComponent(IVirtualComponent component) throws CoreException;
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/wst/ModuleTraverser.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/wst/ModuleTraverser.java
deleted file mode 100644
index 9c1366df8..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/wst/ModuleTraverser.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2011 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:
- * Igor Fedorenko & Fabrizio Giustina - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.wst;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.server.tomcat.core.internal.TomcatPlugin;
-import org.eclipse.jst.server.tomcat.core.internal.Trace;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.UnresolveableURIException;
-import org.eclipse.wst.common.componentcore.internal.ComponentResource;
-import org.eclipse.wst.common.componentcore.internal.ReferencedComponent;
-import org.eclipse.wst.common.componentcore.internal.StructureEdit;
-import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
-import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil;
-import org.eclipse.wst.common.componentcore.internal.impl.PlatformURLModuleConnection;
-import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.server.core.IModule;
-
-/**
- * Temporary solution for https://bugs.eclipse.org/bugs/show_bug.cgi?id=103888
- */
-@SuppressWarnings("restriction")
-public class ModuleTraverser {
-
- /**
- * Facet type for EAR modules
- */
- public static final String EAR_MODULE = IModuleConstants.JST_EAR_MODULE;
-
- /**
- * Facet type for Web modules
- */
- public static final String WEB_MODULE = IModuleConstants.JST_WEB_MODULE;
-
- /**
- * Facet type for utility modules
- */
- public static final String UTILITY_MODULE = IModuleConstants.JST_UTILITY_MODULE;
-
- /**
- * Name of the custom Java classpath entry attribute that is used to flag entries
- * which should be exposed as module dependencies via the virtual component API.
- */
- public static final String CLASSPATH_COMPONENT_DEPENDENCY = "org.eclipse.jst.component.dependency"; //$NON-NLS-1
-
- /**
- * Name of the custom Java classpath entry attribute that is used to flag
- * the resolved entries of classpath containers that should not be exposed
- * via the virtual component API.
- */
- public static final String CLASSPATH_COMPONENT_NON_DEPENDENCY = "org.eclipse.jst.component.nondependency"; //$NON-NLS-1
-
- /**
- * Argument values that are used to select component dependency attribute type.
- */
- private static final int DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY = 0;
- private static final int DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY = 1;
- private static final int DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_NONDEPENDENCY = 2;
-
- /**
- * Scans the module using the specified visitor.
- *
- * @param module module to traverse
- * @param visitor visitor to handle resources
- * @param monitor a progress monitor
- * @throws CoreException
- */
- public static void traverse(IModule module, IModuleVisitor visitor,
- IProgressMonitor monitor) throws CoreException {
- if (module == null || module.getModuleType() == null)
- return;
-
- String typeId = module.getModuleType().getId();
- IVirtualComponent component = ComponentCore.createComponent(module.getProject());
-
- if (component == null) {
- // can happen if project has been closed
- Trace.trace(Trace.WARNING, "Unable to create component for module "
- + module.getName());
- return;
- }
-
- if (EAR_MODULE.equals(typeId)) {
- traverseEarComponent(component, visitor, monitor);
- } else if (WEB_MODULE.equals(typeId)) {
- traverseWebComponent(component, visitor, monitor);
- }
- }
-
- private static void traverseEarComponent(IVirtualComponent component,
- IModuleVisitor visitor, IProgressMonitor monitor)
- throws CoreException {
- // Currently the JST Server portion of WTP may not depend on the JST Enterprise portion of WTP
-/* EARArtifactEdit earEdit = EARArtifactEdit
- .getEARArtifactEditForRead(component);
- if (earEdit != null) {
- IVirtualReference[] j2eeComponents = earEdit.getJ2EEModuleReferences();
- for (int i = 0; i < j2eeComponents.length; i++) {
- traverseWebComponent(
- j2eeComponents[i].getReferencedComponent(), visitor,
- monitor);
- }
- IVirtualReference[] jarComponents = earEdit.getUtilityModuleReferences();
- for (int i = 0; i < jarComponents.length; i++) {
- IVirtualReference jarReference = jarComponents[i];
- IVirtualComponent jarComponent = jarReference
- .getReferencedComponent();
- IProject dependentProject = jarComponent.getProject();
- if (!dependentProject.hasNature(JavaCore.NATURE_ID))
- continue;
- IJavaProject project = JavaCore.create(dependentProject);
- IClasspathEntry cpe = getClasspathEntry(project, jarComponent
- .getRootFolder().getProjectRelativePath());
- visitor.visitEarResource(null, getOSPath(dependentProject,
- project, cpe.getOutputLocation()));
- }
- }*/
- visitor.endVisitEarComponent(component);
- }
-
- private static void traverseWebComponent(IVirtualComponent component,
- IModuleVisitor visitor, IProgressMonitor monitor)
- throws CoreException {
-
- visitor.visitWebComponent(component);
-
- IProject proj = component.getProject();
- StructureEdit warStruct = StructureEdit.getStructureEditForRead(proj);
- try {
- WorkbenchComponent comp = warStruct.getComponent();
- if (comp == null) {
- Trace.trace(Trace.SEVERE,
- "Error getting WorkbenchComponent from war project. IProject=\""
- + proj + "\" StructureEdit=\"" + warStruct
- + "\" WorkbenchComponent=\"" + comp + "\"");
- return;
- }
- traverseWebComponentLocalEntries(comp, visitor, monitor);
-
- // traverse referenced components
- List children = comp.getReferencedComponents();
- for (Iterator itor = children.iterator(); itor.hasNext();) {
- ReferencedComponent childRef = (ReferencedComponent) itor.next();
- IPath rtFolder = childRef.getRuntimePath();
- URI refHandle = childRef.getHandle();
-
- if (PlatformURLModuleConnection.CLASSPATH.equals(
- refHandle.segment(ModuleURIUtil.ModuleURI.SUB_PROTOCOL_INDX))) {
- IPath refPath = getResolvedPathForArchiveComponent(refHandle);
- // If an archive component, add to list
- if (refPath != null) {
- if (!refPath.isAbsolute()) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(refPath);
- IPath refPath2 = file.getLocation();
- if (refPath2 != null) {
- visitor.visitArchiveComponent(rtFolder, refPath2);
- }
- else {
- Trace.trace(Trace.WARNING, NLS.bind(
- "Could not get the location of a referenced component. It may not exist. Project={0}, Parent Component={1}, Referenced Component Path={2}",
- new Object[] { proj.getName(), comp.getName(), refPath}));
- }
- }
- else {
- visitor.visitArchiveComponent(rtFolder, refPath);
- }
- }
- else {
- // TODO Determine if any use case would arrive here.
- }
- } else {
- try {
- WorkbenchComponent childCom = warStruct.findComponentByURI(refHandle);
- if (childCom == null) {
- continue;
- }
-
- traverseDependentEntries(visitor, rtFolder, childCom,
- monitor);
- } catch (UnresolveableURIException e) {
- TomcatPlugin.log(e);
- }
- }
- }
- } finally {
- warStruct.dispose();
- }
-
- visitor.endVisitWebComponent(component);
- }
-
- private static void traverseWebComponentLocalEntries(
- WorkbenchComponent comp, IModuleVisitor visitor,
- IProgressMonitor monitor) throws CoreException {
- IProject warProject = StructureEdit.getContainingProject(comp);
- if (warProject == null || !warProject.hasNature(JavaCore.NATURE_ID)) {
- return;
- }
- IJavaProject project = JavaCore.create(warProject);
-
- List res = comp.getResources();
- for (Iterator itorRes = res.iterator(); itorRes.hasNext();) {
- ComponentResource childComp = (ComponentResource) itorRes.next();
- IClasspathEntry cpe = getClasspathEntry(project, childComp.getSourcePath());
- if (cpe == null)
- continue;
- visitor.visitWebResource(childComp.getRuntimePath(), getOSPath(
- warProject, project, cpe.getOutputLocation()));
- }
-
- // Include tagged classpath entries
- Map classpathDeps = getComponentClasspathDependencies(project, true);
- for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext();) {
- IClasspathEntry entry = (IClasspathEntry)iterator.next();
- IClasspathAttribute attrib = (IClasspathAttribute)classpathDeps.get(entry);
- boolean isClassFolder = isClassFolderEntry(entry);
- String rtFolder = attrib.getValue();
- if (rtFolder == null) {
- if (isClassFolder) {
- rtFolder = "/WEB-INF/classes";
- } else {
- rtFolder = "/WEB-INF/lib";
- }
- }
- IPath entryPath = entry.getPath();
- IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
- if (entryRes != null) {
- entryPath = entryRes.getLocation();
- }
- // TODO Determine if different handling is needed for some use cases
- if (isClassFolder) {
- visitor.visitWebResource(new Path(rtFolder),
- getOSPath(warProject, project, entry.getPath()));
- } else {
- visitor.visitArchiveComponent(new Path(rtFolder), entryPath);
- }
- }
- }
-
- private static void traverseDependentEntries(IModuleVisitor visitor,
- IPath runtimeFolder, WorkbenchComponent component,
- IProgressMonitor monitor) throws CoreException {
- IProject dependentProject = StructureEdit.getContainingProject(component);
- if (!dependentProject.hasNature(JavaCore.NATURE_ID))
- return;
- IJavaProject project = JavaCore.create(dependentProject);
- visitor.visitDependentJavaProject(project);
-
- String name = component.getName(); // assume it is the same as URI
-
- // go thru all entries
- List res = component.getResources();
- for (Iterator itorRes = res.iterator(); itorRes.hasNext();) {
- ComponentResource childComp = (ComponentResource) itorRes.next();
- IPath rtPath = childComp.getRuntimePath();
- IPath srcPath = childComp.getSourcePath();
- IClasspathEntry cpe = getClasspathEntry(project, srcPath);
- if (cpe != null) {
- visitor.visitDependentComponent(runtimeFolder.append(rtPath)
- .append(name + ".jar"), getOSPath(dependentProject,
- project, cpe.getOutputLocation()));
- }
- // Handle META-INF/resources
- String path = rtPath.toString();
- IFolder resFolder = null;
- String targetPath = "";
- if ("/".equals(path)) {
- resFolder = dependentProject.getFolder(srcPath.append("META-INF/resources"));
- }
- else if ("/META-INF".equals(path)) {
- resFolder = dependentProject.getFolder(srcPath.append("resources"));
- }
- else if ("/META-INF/resources".equals(path)) {
- resFolder = dependentProject.getFolder(srcPath);
- }
- else if (path.startsWith("/META-INF/resources/")) {
- resFolder = dependentProject.getFolder(srcPath);
- targetPath = path.substring("/META-INF/resources".length());
- }
- if (resFolder != null && resFolder.exists()) {
- visitor.visitDependentContentResource(new Path(targetPath), resFolder.getLocation());
- }
- }
-
- // Include tagged classpath entries
- Map classpathDeps = getComponentClasspathDependencies(project, false);
- for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext();) {
- IClasspathEntry entry = (IClasspathEntry)iterator.next();
- boolean isClassFolder = isClassFolderEntry(entry);
- String rtFolder = null;
- if (isClassFolder) {
- rtFolder = "/";
- } else {
- rtFolder = "/WEB-INF/lib";
- }
- IPath entryPath = entry.getPath();
- IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
- if (entryRes != null) {
- entryPath = entryRes.getLocation();
- }
- // TODO Determine if different handling is needed for some use cases
- if (isClassFolder) {
- visitor.visitDependentComponent(runtimeFolder.append(rtFolder)
- .append(name + ".jar"), getOSPath(dependentProject,
- project, entry.getPath()));
- } else {
- visitor.visitArchiveComponent(new Path(rtFolder), entryPath);
- }
- }
- }
-
- private static IClasspathEntry getClasspathEntry(IJavaProject project,
- IPath sourcePath) throws JavaModelException {
- sourcePath = project.getPath().append(sourcePath);
- IClasspathEntry[] cp = project.getRawClasspath();
- for (int i = 0; i < cp.length; i++) {
- if (sourcePath.equals(cp[i].getPath()))
- return JavaCore.getResolvedClasspathEntry(cp[i]);
- }
- return null;
- }
-
- private static IPath getOSPath(IProject project, IJavaProject javaProject,
- IPath outputPath) throws JavaModelException {
- if (outputPath == null)
- outputPath = javaProject.getOutputLocation();
- // If we have the root of a project, return project location
- if (outputPath.segmentCount() == 1) {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(outputPath.lastSegment())
- .getLocation();
- }
- // Otherwise return project folder location
- return ResourcesPlugin.getWorkspace().getRoot().getFolder(outputPath)
- .getLocation();
- }
-
- /*
- * Derived from J2EEProjectUtilities.getResolvedPathForArchiveComponent()
- */
- private static IPath getResolvedPathForArchiveComponent(URI uri) {
-
- String resourceType = uri.segment(1);
- URI contenturi = ModuleURIUtil.trimToRelativePath(uri, 2);
- String contentName = contenturi.toString();
-
- if (resourceType.equals("lib")) { //$NON-NLS-1$
- // module:/classpath/lib/D:/foo/foo.jar
- return Path.fromOSString(contentName);
-
- } else if (resourceType.equals("var")) { //$NON-NLS-1$
-
- // module:/classpath/var/<CLASSPATHVAR>/foo.jar
- String classpathVar = contenturi.segment(0);
- URI remainingPathuri = ModuleURIUtil.trimToRelativePath(contenturi, 1);
- String remainingPath = remainingPathuri.toString();
-
- String[] classpathvars = JavaCore.getClasspathVariableNames();
- boolean found = false;
- for (int i = 0; i < classpathvars.length; i++) {
- if (classpathVar.equals(classpathvars[i])) {
- found = true;
- break;
- }
- }
- if (found) {
- IPath path = JavaCore.getClasspathVariable(classpathVar);
- if (path != null) {
- URI finaluri = URI.createURI(path.toOSString() + IPath.SEPARATOR + remainingPath);
- return Path.fromOSString(finaluri.toString());
- }
- }
- Trace.trace(Trace.WARNING,
- NLS.bind("Tomcat publishing could not resolve dependency URI \"{0}\". A value for classpath variable {1} was not found.", uri, classpathVar));
- }
- return null;
- }
-
- /*
- * Derived from ClasspathDependencyUtil.getComponentClasspathDependencies()
- */
- private static Map getComponentClasspathDependencies(final IJavaProject javaProject, final boolean isWebApp) throws CoreException {
-
- // get the raw entries
- final Map referencedRawEntries = getRawComponentClasspathDependencies(javaProject);
- final Map<IClasspathEntry, IClasspathAttribute> validRawEntries = new HashMap<IClasspathEntry, IClasspathAttribute>();
-
- // filter out non-valid referenced raw entries
- final Iterator i = referencedRawEntries.keySet().iterator();
- while (i.hasNext()) {
- final IClasspathEntry entry = (IClasspathEntry) i.next();
- final IClasspathAttribute attrib = (IClasspathAttribute) referencedRawEntries.get(entry);
- if (isValid(entry, attrib, isWebApp, javaProject.getProject())) {
- validRawEntries.put(entry, attrib);
- }
- }
-
- // if we have no valid raw entries, return empty map
- if (validRawEntries.isEmpty()) {
- return Collections.EMPTY_MAP;
- }
-
- // XXX Would like to replace the code below with use of a public JDT API that returns
- // the raw IClasspathEntry for a given resolved IClasspathEntry (see see https://bugs.eclipse.org/bugs/show_bug.cgi?id=183995)
- // The code must currently leverage IPackageFragmentRoot to determine this
- // mapping and, because IPackageFragmentRoots do not maintain IClasspathEntry data, a prior
- // call is needed to getResolvedClasspath() and the resolved IClasspathEntries have to be stored in a Map from IPath-to-IClasspathEntry to
- // support retrieval using the resolved IPackageFragmentRoot
-
- // retrieve the resolved classpath
- final IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
- final Map<IPath, IClasspathEntry> pathToResolvedEntry = new HashMap<IPath, IClasspathEntry>();
-
- // store in a map from path to entry
- for (int j = 0; j < entries.length; j++) {
- pathToResolvedEntry.put(entries[j].getPath(), entries[j]);
- }
-
- final Map<IClasspathEntry, IClasspathAttribute> referencedEntries = new LinkedHashMap<IClasspathEntry, IClasspathAttribute>();
-
- // grab all IPackageFragmentRoots
- final IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
- for (int j = 0; j < roots.length; j++) {
- final IPackageFragmentRoot root = roots[j];
- final IClasspathEntry rawEntry = root.getRawClasspathEntry();
-
- // is the raw entry valid?
- IClasspathAttribute attrib = validRawEntries.get(rawEntry);
- if (attrib == null) {
- continue;
- }
-
- final IPath pkgFragPath = root.getPath();
- final IClasspathEntry resolvedEntry = pathToResolvedEntry.get(pkgFragPath);
- final IClasspathAttribute resolvedAttrib = checkForComponentDependencyAttribute(resolvedEntry,
- DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY);
- // attribute for the resolved entry must either be unspecified or it must be the
- // dependency attribute for it to be included
- if (resolvedAttrib == null || resolvedAttrib.getName().equals(CLASSPATH_COMPONENT_DEPENDENCY)) {
- // filter out resolved entry if it doesn't pass the validation rules
- if (isValid(resolvedEntry, resolvedAttrib != null ? resolvedAttrib : attrib, isWebApp, javaProject.getProject())) {
- if (resolvedAttrib != null) {
- // if there is an attribute on the sub-entry, use that
- attrib = resolvedAttrib;
- }
- referencedEntries.put(resolvedEntry, attrib);
- }
- }
- }
-
- return referencedEntries;
- }
-
- /*
- * Derived from ClasspathDependencyUtil.getRawComponentClasspathDependencies()
- */
- private static Map getRawComponentClasspathDependencies(final IJavaProject javaProject) throws CoreException {
- if (javaProject == null) {
- return Collections.EMPTY_MAP;
- }
- final Map<IClasspathEntry, IClasspathAttribute> referencedRawEntries = new HashMap<IClasspathEntry, IClasspathAttribute>();
- final IClasspathEntry[] entries = javaProject.getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
- final IClasspathEntry entry = entries[i];
- final IClasspathAttribute attrib = checkForComponentDependencyAttribute(entry,
- DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY);
- if (attrib != null) {
- referencedRawEntries.put(entry, attrib);
- }
- }
- return referencedRawEntries;
- }
-
- /*
- * Derived from ClasspathDependencyUtil.checkForComponentDependencyAttribute()
- */
- private static IClasspathAttribute checkForComponentDependencyAttribute(final IClasspathEntry entry, final int attributeType) {
- if (entry == null) {
- return null;
- }
- final IClasspathAttribute[] attributes = entry.getExtraAttributes();
- for (int i = 0; i < attributes.length; i++) {
- final IClasspathAttribute attribute = attributes[i];
- final String name = attribute.getName();
- if (name.equals(CLASSPATH_COMPONENT_DEPENDENCY)) {
- if (attributeType == DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY
- || attributeType == DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY) {
- return attribute;
- }
- } else if (name.equals(CLASSPATH_COMPONENT_NON_DEPENDENCY)) {
- if (attributeType == DEPENDECYATTRIBUTETYPE_DEPENDENCY_OR_NONDEPENDENCY
- || attributeType == DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_NONDEPENDENCY) {
- return attribute;
- }
- }
- }
- return null;
- }
-
- /*
- * Derived from ClasspathDependencyValidator.validateVirtualComponentEntry()
- */
- private static boolean isValid(final IClasspathEntry entry, final IClasspathAttribute attrib, boolean isWebApp, final IProject project) {
- int kind = entry.getEntryKind();
- boolean isClassFolder = isClassFolderEntry(entry);
-
- if (kind == IClasspathEntry.CPE_PROJECT || kind == IClasspathEntry.CPE_SOURCE) {
- return false;
- }
-
- String runtimePath = getRuntimePath(attrib, isWebApp, isClassFolder);
- if (!isWebApp) {
- if (!runtimePath.equals("../") && !runtimePath.equals("/")) {
- return false;
- }
- if (isClassFolder && !runtimePath.equals("/")) {
- return false;
- }
- }
- else {
- if (runtimePath != null && !runtimePath.equals("/WEB-INF/lib")
- && !runtimePath.equals("/WEB-INF/classes")
- && !runtimePath.equals("../")) {
- return false;
- }
- if (isClassFolder && !runtimePath.equals("/WEB-INF/classes")) {
- return false;
- }
- }
- return true;
- }
-
- /*
- * Derived from ClasspathDependencyUtil.isClassFolderEntry()
- */
- private static boolean isClassFolderEntry(final IClasspathEntry entry) {
- if (entry == null || entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY) {
- return false;
- }
- // does the path refer to a file or a folder?
- final IPath entryPath = entry.getPath();
- IPath entryLocation = entryPath;
- final IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
- if (resource != null) {
- entryLocation = resource.getLocation();
- }
- boolean isFile = true; // by default, assume a jar file
- if (entryLocation.toFile().isDirectory()) {
- isFile = false;
- }
- return !isFile;
- }
-
- /*
- * Derived from ClasspathDependencyUtil.getRuntimePath()
- */
- private static String getRuntimePath(final IClasspathAttribute attrib, final boolean isWebApp, final boolean isClassFolder) {
- if (attrib != null && !attrib.getName().equals(CLASSPATH_COMPONENT_DEPENDENCY)) {
- return null;
- }
- if (attrib == null || attrib.getValue()== null || attrib.getValue().length() == 0) {
- if (isWebApp) {
- return isClassFolder ? "/WEB_INF/classes" : "WEB-INF/lib";
- }
- return isClassFolder ? "/" : "../";
- }
- return attrib.getValue();
- }
-}
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 005e98555..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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();
- while (child != null && !s.equals(child.getNodeName())) {
- child = child.getNextSibling();
- }
- for (int i = 0; child != null && i < index; i++) {
- child = child.getNextSibling();
- while (child != null && !s.equals(child.getNodeName())) {
- child = child.getNextSibling();
- }
- }
- // TODO Try to improve formating, maybe dup an appropriate text node
- if (child != null)
- node.insertBefore(element, child);
- else
- node.appendChild(element);
- } catch (Exception e) {
- node.appendChild(element);
- }
- return newInstance(element);
- }
-
- protected XMLElement createElement(String s, Node node) {
- Element element = document.createElement(s);
- node.appendChild(element);
- return newInstance(element);
- }
-
- public byte[] getContents() throws IOException {
- return XMLUtil.getContents(document);
- }
-
- /**
- *
- * @return org.w3c.dom.Document
- */
- public Document getDocument() {
- return document;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public XMLElement loadDocument(InputStream in) throws IOException, SAXException {
- try {
- document = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
- Element element = document.getDocumentElement();
- return newInstance(element);
- } catch (IllegalArgumentException exception) {
- Trace.trace(Trace.WARNING, "Error loading document", exception);
- throw new IOException("Could not load document");
- }
- }
-
- protected XMLElement newInstance(Element element) {
- String s = element.getNodeName();
- try {
- // change "web-app:test" to "WebAppTest"
- s = s.substring(0, 1).toUpperCase() + s.substring(1);
- int i = s.indexOf("-");
- while (i >= 0) {
- s = s.substring(0, i) + s.substring(i+1, i+2).toUpperCase() + s.substring(i+2);
- i = s.indexOf("-");
- }
- i = s.indexOf(":");
- while (i >= 0) {
- s = s.substring(0, i) + s.substring(i+1, i+2).toUpperCase() + s.substring(i+2);
- i = s.indexOf(":");
- }
-
- // add package name
- if (packageName != null)
- s = packageName + "." + s;
- Class class1 = Class.forName(s);
-
- XMLElement xmlElement = (XMLElement) class1.newInstance();
- xmlElement.setElement(element);
- xmlElement.setFactory(this);
- return xmlElement;
- } catch (Exception exception) {
- // ignore
- }
- return null;
- }
-
- public void save(String filename) throws IOException {
- XMLUtil.save(filename, document);
- }
-
- public void setDocument(Document d) {
- document = d;
- }
-
- public void setPackageName(String s) {
- packageName = s;
- }
-}
diff --git a/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 cb5eff922..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLElement.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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 Element getElementNode() {
- return xmlElement;
- }
-
- 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<String, String> attributes = new LinkedHashMap<String, String>();
- 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);
- }
- }
-
- public void importNode(Node node, boolean deep) {
- xmlElement.appendChild(xmlElement.getOwnerDocument().importNode(node, deep));
- }
-
- /**
- * This method tries to compare two XMLElements for equivalence. Due to
- * the lack of normalization, they aren't compared for equality. Elements
- * are required to have the same attributes or the same node value
- * if attributes aren't present. Attributes and node value are assumed
- * to be mutually exclusive for Tomcat configuration XML files. The
- * same non-text child nodes are required to be present in an element
- * and appear in the same order. If a node type other than element or
- * comment is encountered, this method punts and returns false.
- *
- * @param obj XMLElement to compare
- * @return true if the elements are equivalent
- */
- public boolean isEquivalent(XMLElement obj) {
- if (obj != null) {
- try {
- return elementsAreEquivalent(xmlElement, obj.getElementNode());
- }
- catch (Exception e) {
- // Catch and ignore just to be safe
- }
- }
- return false;
- }
-
- /**
- * Same as isEquivalent() but doesn't ignore exceptions for test purposes.
- * This avoids hiding an expected mismatch behind an unexpected exception.
- *
- * @param obj XMLElement to compare
- * @return true if the elements are equivalent
- */
- public boolean isEquivalentTest(XMLElement obj) {
- if (obj != null) {
- return elementsAreEquivalent(xmlElement, obj.getElementNode());
- }
- return false;
- }
-
- private static boolean elementsAreEquivalent(Element element, Element otherElement) {
- if (element == otherElement)
- return true;
-
- if (!element.getNodeName().equals(otherElement.getNodeName()))
- return false;
-
- if (element.hasChildNodes()) {
- if (otherElement.hasChildNodes() && attributesAreEqual(element, otherElement)) {
- // Compare child nodes
- NodeList nodelist = element.getChildNodes();
- NodeList otherNodelist = otherElement.getChildNodes();
- if (nodelist.getLength() == otherNodelist.getLength()) {
- Node node = nextNonTextNode(element.getFirstChild());
- Node otherNode = nextNonTextNode(otherElement.getFirstChild());
- while (node != null) {
- if (otherNode == null)
- return false;
- short nextNodeType = node.getNodeType();
- if (nextNodeType != otherNode.getNodeType())
- return false;
- // If elements, compare
- if (nextNodeType == Node.ELEMENT_NODE) {
- if (!elementsAreEquivalent((Element)node, (Element)otherNode))
- return false;
- }
- // Else if comment, compare
- else if (nextNodeType == Node.COMMENT_NODE) {
- if (!nodeValuesAreEqual(node, otherNode))
- return false;
- }
- // Else punt on other node types
- else {
- return false;
- }
- node = nextNonTextNode(node.getNextSibling());
- otherNode = nextNonTextNode(otherNode.getNextSibling());
- }
- // If also at end of other children, return equal
- if (otherNode == null)
- return true;
- }
- }
- }
- else if (!otherElement.hasChildNodes()) {
- return attributesAreEqual(element, otherElement);
- }
- return false;
- }
-
- private static Node nextNonTextNode(Node node) {
- while (node != null && node.getNodeType() == Node.TEXT_NODE)
- node = node.getNextSibling();
- return node;
- }
-
- private static boolean attributesAreEqual(Element element, Element otherElement) {
- NamedNodeMap attrs = element.getAttributes();
- NamedNodeMap otherAttrs = otherElement.getAttributes();
- if (attrs == null && otherAttrs == null) {
- // Return comparison of element values if there are no attributes
- return nodeValuesAreEqual(element, otherElement);
- }
-
- if (attrs.getLength() == otherAttrs.getLength()) {
- if (attrs.getLength() == 0)
- // Return comparison of element values if there are no attributes
- return nodeValuesAreEqual(element, otherElement);
-
- for (int i = 0; i < attrs.getLength(); i++) {
- Node attr = attrs.item(i);
- Node otherAttr = otherAttrs.getNamedItem(attr.getNodeName());
- if (!nodeValuesAreEqual(attr, otherAttr))
- return false;
- }
- return true;
- }
- return false;
- }
-
- private static boolean nodeValuesAreEqual(Node node, Node otherNode) {
- String value = node.getNodeValue();
- String otherValue = otherNode.getNodeValue();
- if (value != null && otherValue != null) {
- if (value.equals(otherValue))
- return true;
- }
- else if (value == null && otherValue == null)
- return true;
- return false;
- }
-}
diff --git a/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 140eb9df2..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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 javax.xml.parsers.ParserConfigurationException;
-
-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);
- // In case we happen to have a Xerces parser, try to set the feature that allows Java encodings to be used
- try {
- factory.setFeature("http://apache.org/xml/features/allow-java-encodings", true);
- }
- catch (ParserConfigurationException e) {
- // Ignore if feature isn't supported
- }
- //factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd", new Boolean(false));
- documentBuilder = factory.newDocumentBuilder();
- documentBuilder.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- return new InputSource(new ByteArrayInputStream(new byte[0]));
- }
- });
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "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<Node> list = new ArrayList<Node>();
- 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
- }
- }
- }
-
- public static void save(String filename, Node node) throws IOException {
- PrintStream out = null;
- try {
- out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)), true, "UTF-8");
- print(out, node);
- } catch (Exception ex) {
- throw new IOException(ex.getLocalizedMessage());
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
-
- /*
- * Set the value of the subnode
- *
- * @param name java.lang.String
- * @param value java.lang.String
- */
- public static void setNodeValue(Node node, String name, String value) {
- String s = node.getNodeValue();
- if (s != null) {
- node.setNodeValue(value);
- return;
- }
- NodeList nodelist = node.getChildNodes();
- for (int i = 0; i < nodelist.getLength(); i++) {
- if (nodelist.item(i) instanceof Text) {
- Text text = (Text) nodelist.item(i);
- text.setData(value);
- return;
- }
- }
- return;
- }
-
- public static String toString(Document document) {
- PrintStream out = null;
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
- out = new PrintStream(baos);
- print(out, document);
- return new String(baos.toByteArray(), "UTF-8");
- } catch (Exception ex) {
- // ignore
- } finally {
- if (out != null)
- try {
- out.close();
- } catch (Exception e) {
- // ignore
- }
- }
- return null;
- }
-}
diff --git a/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/server32/ServerInstance.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/ServerInstance.java
deleted file mode 100644
index 8972637aa..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server32/ServerInstance.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 SAS Institute, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Larry Isaacs - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server32;
-
-import java.net.URLEncoder;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.TomcatPlugin;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * This class represents an instance of a Tomcat 3.2, or later, server as
- * defined a server.xml configuration file.
- */
-public class ServerInstance {
-
- protected Server server;
- protected ContextManager contextManager;
-
- protected IStatus status = Status.OK_STATUS;
-
- /**
- * Constructs a ServerInstance using the specified Server configuration.
- * The ServerInstance provides access to Connectors and Contexts. It does
- * not support interacting with Host elements under the ContextManager
- * element.
- *
- * @param server Server configuration on which to base this instance.
- */
- public ServerInstance(Server server) {
- if (server == null)
- throw new IllegalArgumentException("Server argument may not be null.");
- this.server = server;
- }
-
- /**
- * This method is used to get the problem status following
- * a method call that returned <b>null</b> due to an error.
- * @return Status of last method call.
- */
- public IStatus getStatus() {
- return status;
- }
-
- /**
- * Gets the ContextManager element if one exists or will
- * create a new one if it does not currently exist.
- * @return Returns an existing or new ContextManger.
- */
- public ContextManager getContextManager() {
- status = Status.OK_STATUS;
- if (contextManager == null)
- contextManager = server.getContextManager();
- return contextManager;
- }
-
- /**
- * Gets the connector at the specified index. If a Connector
- * does not exist at that index a new Connector is appended
- * and returned.
- *
- * @param index Index of the Connector to return.
- * @return Returns the Connecter at the specified index or
- * a new Connector if one at that index doesn't exist.
- */
- public Connector getConnector(int index) {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return null; // Note: Can't currently occur
-
- return contextManager.getConnector(index);
- }
-
- /**
- * Gets the Connectors found in the ContextManager in the
- * server configuration.
- *
- * @return Array of Connectors found in the ContextManger in the
- * server configuration.
- */
- public Connector [] getConnectors() {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return null; // Note: Can't currently occur
-
- int size = contextManager.getConnectorCount();
- Connector [] connectors = new Connector [size];
- for (int i = 0; i < size; i++) {
- connectors[i] = contextManager.getConnector(i);
- }
- return connectors;
- }
-
- /**
- * Gets the Context that has the specified path within the selected
- * Host. This method will return <b>null</b> if the Context with the
- * required path is not found in the server configuration.
- *
- * @param contextPath Path of the Context to be returned. A leading '/' is optional.
- * @return Returns the Context whose <b>path</b> attribute matches
- * the specified contextPath. Returns <b>null</b> if the Context with
- * the required path is not found.
- */
- public Context getContext(String contextPath) {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return null; // Note: Can't currently occur
-
- if (contextPath != null && contextPath.length() > 0 && !contextPath.startsWith("/"))
- contextPath = "/" + contextPath;
-
- int size = contextManager.getContextCount();
- for (int i = 0; i < size; i++) {
- Context ctx = contextManager.getContext(i);
- if (ctx.getPath().equals(contextPath)) {
- return ctx;
- }
- }
- status = new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorXMLContextNotFoundPath32, contextPath));
- return null;
- }
-
- /**
- * Gets the Context at the specified index. If a Connector does not
- * exist at the specified index, a new Context will be appended and
- * returned.
- *
- * @param index Index of the Context to return.
- * @return Returns the Context at the specified index, or
- * a new appended Context if the index is beyond any existing
- * Contexts.
- */
- public Context getContext(int index) {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return null; // Note: Can't currently occur
-
- return contextManager.getContext(index);
- }
-
- /**
- * Gets the Contexts contained in the ContextManager.
- *
- * @return Array of Contexts contained in the ContextManager.
- */
- public Context [] getContexts() {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return null; // Note: Can't currently occur
-
- int size = contextManager.getContextCount();
- Context [] contexts = new Context [size];
- for (int i = 0; i < size; i++) {
- contexts[i] = contextManager.getContext(i);
- }
- return contexts;
- }
-
- /**
- * Creates a new Context and inserts it before the specifed index
- * or appends it if the index is beyond any existing Contexts in the
- * ContextManager.
- *
- * @param index Index prior to which to insert the new Contexts.
- * @return Returns the created Context.
- */
- public Context createContext(int index) {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return null; // Note: Can't currently occur
-
- return (Context)contextManager.createElement(index, "Context");
- }
-
- /**
- * Removes the Context with the specified path, if it can be found.
- *
- * @param contextPath Path of the Context to be removed. A leading '/' is optional.
- * @return Returns <b>true</b> if the Context was removed. Returns <b>false</b>
- * if the Context is not found.
- */
- public boolean removeContext(String contextPath) {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return false; // Note: Can't currently occur
-
- if (contextPath != null && contextPath.length() > 0 && !contextPath.startsWith("/"))
- contextPath = "/" + contextPath;
-
- int size = contextManager.getContextCount();
- for (int i = 0; i < size; i++) {
- Context ctx = contextManager.getContext(i);
- if (ctx.getPath().equals(contextPath)) {
- contextManager.removeElement("Context", i);
- return true;
- }
- }
- status = new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorXMLContextNotFoundPath32, contextPath));
- return false;
- }
-
- /**
- * @param index Index of the Context to remove.
- * @return Returns <b>true</b> if a Context is removed at the specified
- * index. Returns <b>false</b> no Context exists at that index.
- */
- public boolean removeContext(int index) {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return false; // Note: Can't currently occur
-
- return contextManager.removeElement("Context", index);
- }
-
- /**
- * Gets the work directory associated with the specified
- * Context. If the work directory obtained is relative,
- * it is appended to the specified base path. This method does
- * not verify if the specified Context currently exists.
- *
- * @param basePath Path to the base directory for the server.
- * @param context Context whose work directory to return.
- * @return Returns the path to the work directory for the specifed
- * Context.
- */
- public IPath getContextWorkDirectory(IPath basePath, Context context) {
- if (context == null)
- throw new IllegalArgumentException("Context argument may not be null.");
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return null; // Note: Can't currently occur
-
- StringBuffer sb=new StringBuffer();
- String workDir = contextManager.getWorkDir();
- if (workDir == null)
- workDir = "work";
- sb.append(workDir);
- sb.append("/");
- String hostName = contextManager.getAttributeValue("hostName");
- if (hostName == null)
- hostName = "localhost";
- sb.append(hostName);
- sb.append("_");
- String legacyPort = contextManager.getAttributeValue("port");
- if (legacyPort == null)
- legacyPort = "8080";
- sb.append(legacyPort);
- // Duplicate URLEncoder.encode() used in Tomcat 3.2
- sb.append(URLEncoder.encode(context.getPath()));
-
- IPath workPath = new Path(sb.toString());
- if (!workPath.isAbsolute()) {
- if (basePath == null)
- basePath = new Path("");
- workPath = basePath.append(workPath);
- }
- return workPath;
- }
-
- /**
- * Gets the work directory associated with the server.
- * If the work directory obtained is relative,
- * it is appended to the specified base path.
- *
- * @param basePath Path to the base directory for the server.
- * @return Returns the path to the work directory for the server.
- */
- public IPath getServerWorkDirectory(IPath basePath) {
- status = Status.OK_STATUS;
- if (contextManager == null && getContextManager() == null)
- return null; // Note: Can't currently occur
-
- String workDir = contextManager.getWorkDir();
- if (workDir == null)
- workDir = "work";
- IPath workPath = new Path(workDir);
- if (!workPath.isAbsolute()) {
- if (basePath == null)
- basePath = new Path("");
- workPath = basePath.append(workPath);
- }
- return workPath;
- }
-}
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 67a8df812..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Context.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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 {
- /**
- * Default constructor
- */
- public Context() {
- // do nothing
- }
-
- /**
- * Get debug attribute.
- * @return debug attribute value
- */
- public String getDebug() {
- return getAttributeValue("debug");
- }
-
- /**
- * Get docBase attribute.
- * @return docBase attribute value
- */
- public String getDocBase() {
- return getAttributeValue("docBase");
- }
-
- /**
- * Get path attribute.
- * @return path attribute value
- */
- public String getPath() {
- return getAttributeValue("path");
- }
-
- /**
- * Get reloadable attribute.
- * @return reloadable attribute value
- */
- public String getReloadable() {
- return getAttributeValue("reloadable");
- }
-
- /**
- * Get WTP source attribute. Links the context
- * to a project module.
- * @return source attribute value
- */
- public String getSource() {
- return getAttributeValue("source");
- }
-
- /**
- * Get context Resources element. Will create
- * the element if it does not already exist.
- * @return resources element.
- */
- public Resources getResources() {
- return (Resources) findElement("Resources");
- }
-
- /**
- * Get context Loader element. Will create
- * the element if it does not already exist.
- * @return loader element.
- */
- public Loader getLoader() {
- return (Loader) findElement("Loader");
- }
-
- /**
- * Set debug attribute
- * @param debug value to set
- */
- public void setDebug(String debug) {
- setAttributeValue("debug", debug);
- }
-
- /**
- * Set docBase attribute.
- * @param docBase value to set
- */
- public void setDocBase(String docBase) {
- setAttributeValue("docBase", docBase);
- }
-
- /**
- * Set path attribute.
- * @param path value to set
- */
- public void setPath(String path) {
- setAttributeValue("path", path);
- }
-
- /**
- * Set reloadable attribute.
- * @param reloadable value to set
- */
- public void setReloadable(String reloadable) {
- setAttributeValue("reloadable", reloadable);
- }
-
- /**
- * Set WTP source attribute. Links the context
- * to a project module.
- * @param source value to set
- */
- public void setSource(String source) {
- setAttributeValue("source", source);
- }
-
-
-}
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 a209f8bc7..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Engine.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * 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 Host getHost(int index) {
- return (Host) findElement("Host", index);
- }
-
- public int getHostCount() {
- return sizeOfElement("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);
- }
-}
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/JarScanner.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/JarScanner.java
deleted file mode 100644
index d5abafca9..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/JarScanner.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 SAS Institute Inc and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAS Institute Inc - 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 JarScanner extends XMLElement {
- public JarScanner() {
- // do nothing
- }
-
- public String getClassName() {
- return getAttributeValue("className");
- }
-
- public String getScanClassPath() {
- return getAttributeValue("scanClassPath");
- }
-
- public String getScanAllFiles() {
- return getAttributeValue("scanAllFiles");
- }
-
- public String getScanAllDirectories() {
- return getAttributeValue("scanAllDirectories");
- }
-
- public void setClassName(String className) {
- setAttributeValue("className", className);
- }
-
- public void setScanClassPath(String scanClassPath) {
- setAttributeValue("scanClassPath", scanClassPath);
- }
-
- public void setScanAllFiles(String scanAllFiles) {
- setAttributeValue("scanAllFiles", scanAllFiles);
- }
-
- public void setScanAllDirectories(String scanAllDirectories) {
- setAttributeValue("scanAllDirectories", scanAllDirectories);
- }
-} \ 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/Loader.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Loader.java
deleted file mode 100644
index 55b7ccb82..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Loader.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Fabrizio Giustina - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.XMLElement;
-
-/**
- * Loader element, optional in Context.
- */
-public class Loader extends XMLElement {
-
- /**
- * Get className attribute.
- * @return className attribute value
- */
- public String getClassName() {
- return getAttributeValue("className");
- }
-
- /**
- * Set className attribute.
- * @param className value to set
- */
- public void setClassName(String className) {
- setAttributeValue("className", className);
- }
-
- /**
- * Get WTP virtualClasspath attribute.
- * @return virtualClasspath value
- */
- public String getVirtualClasspath() {
- return getAttributeValue("virtualClasspath");
- }
-
- /**
- * Set WTP virtualClasspath attribute.
- * @param virtualClasspath value to set
- */
- public void setVirtualClasspath(String virtualClasspath) {
- setAttributeValue("virtualClasspath", virtualClasspath);
- }
-
- /**
- * Get useSystemClassLoaderAsParent attribute
- * @return useSystemClassLoaderAsParent value
- */
- public String getUseSystemClassLoaderAsParent() {
- return getAttributeValue("useSystemClassLoaderAsParent");
- }
-
- /**
- * Set useSystemClassLoaderAsParent attribute.
- * @param useSystemClassLoaderAsParent value to set
- */
- public void setUseSystemClassLoaderAsParent(
- String useSystemClassLoaderAsParent) {
- setAttributeValue("useSystemClassLoaderAsParent",
- useSystemClassLoaderAsParent);
- }
-
-}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Resources.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Resources.java
deleted file mode 100644
index 52ea79934..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/Resources.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2010 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:
- * Fabrizio Giustina - Initial API and implementation
- * Matteo TURRA - Support for multiple web resource paths
- **********************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.jst.server.tomcat.core.internal.xml.XMLElement;
-
-/**
- * Resources element, optional in Context.
- */
-public class Resources extends XMLElement {
-
- /**
- * Get className attribute
- * @return className attribute value
- */
- public String getClassName() {
- return getAttributeValue("className");
- }
-
- /**
- * Get virtualClasspath attribute.
- * @return virtualClasspath attribute value
- */
- public String getVirtualClasspath() {
- return getAttributeValue("virtualClasspath");
- }
-
- /**
- * Set className attribute.
- * @param className value to set
- */
- public void setClassName(String className) {
- setAttributeValue("className", className);
- }
-
- /**
- * Set virtualClasspath attribute.
- * @param virtualClasspath value to set
- */
- public void setVirtualClasspath(String virtualClasspath) {
- setAttributeValue("virtualClasspath", virtualClasspath);
- }
-
- /**
- * Get extraResourcePaths attribute. These are resource
- * paths in addition to the path specified by docBase.
- * @return extraResourcePaths attribute value
- */
- public String getExtraResourcePaths() {
- return getAttributeValue("extraResourcePaths");
- }
-
- /**
- * Set extraResourcePaths attribute.
- * @param extraResourcePaths A semicolon separated list
- * of absolute resource paths not including the path
- * specified by docBase.
- */
- public void setExtraResourcePaths(String extraResourcePaths) {
- setAttributeValue("extraResourcePaths", extraResourcePaths);
- }
-}
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/ServerInstance.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/ServerInstance.java
deleted file mode 100644
index 3af36e13d..000000000
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/server40/ServerInstance.java
+++ /dev/null
@@ -1,535 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 SAS Institute, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Larry Isaacs - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.tomcat.core.internal.xml.server40;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.server.tomcat.core.internal.Messages;
-import org.eclipse.jst.server.tomcat.core.internal.TomcatPlugin;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * This class represents an instance of a Tomcat 4.0, or later, server as
- * defined by a specific Service, Engine, and Host defined in a server.xml
- * configuration file.
- */
-public class ServerInstance {
- protected static final String DEFAULT_SERVICE = "Catalina";
- protected static final String DEFAULT_SERVICE2 = "Tomcat-Standalone";
- protected static final String DEFAULT_HOST = "localhost";
-
- protected Server server;
- protected Service service;
- protected Engine engine;
- protected Host host;
-
- protected String serviceName;
- protected String engineName;
- protected String hostName;
-
- protected String hostWorkDir;
-
- protected IStatus status = Status.OK_STATUS;
-
- /**
- * Constructs a ServerInstance using the specified Server configuration.
- * The ServerInstance provides access to a selected Service, Engine, and Host
- * as determined by the supplied service and host name or their defaults.
- *
- * @param server Server configuration on which to base this instance.
- * @param serviceName Name of the service the instance should use. Defaults
- * to &quot;Catalina&quot; if <b>null</b> or any empty string is specified.
- * @param hostName Name of the host the instance should use. Defaults to
- * the defaultHost setting on the Engine element found under the service.
- * If the defaultHost is not set, defaults to &quot;localhost&quot;.
- */
- public ServerInstance(Server server, String serviceName, String hostName) {
- if (server == null)
- throw new IllegalArgumentException("Server argument may not be null.");
- this.server = server;
- this.serviceName = serviceName;
- this.hostName = hostName;
- }
-
- /**
- * This method is used to get the problem status following
- * a method call that returned <b>null</b> due to an error.
- * @return Status of last method call.
- */
- public IStatus getStatus() {
- return status;
- }
-
- /**
- * Gets the array of Listeners found in the Server configuration
- * of this ServerInstance.
- *
- * @return Array of Listeners found in the Server configuration.
- */
- public Listener [] getListeners() {
- status = Status.OK_STATUS;
- int size = server.getListenerCount();
- Listener [] listeners = new Listener [size];
- for (int i = 0; i < size; i++) {
- listeners[i] = server.getListener(i);
- }
- return listeners;
- }
-
- /**
- * Gets the selected Service in the server configuration of
- * this ServerInstance. The method will return <b>null</b> if the
- * server configuration does not contain a Service with the name
- * selected in this ServerInstance. If no name is selected, then
- * a service is chosen as follows. If there is only one Service,
- * it is returned. If there are multiple Services, the first one
- * with the name &quot;Catalina&quot; or &quot;Tomcat-Standalone&quot;
- * is returned. If none is found with either name, the first
- * Service is returned.
- *
- * @return Returns the selected Service for this ServerInstance. Returns <b>null</b>
- * if the server configuration does not contain a Service with the selected name
- * or does not contain a Service.
- */
- public Service getService() {
- status = Status.OK_STATUS;
- if (service != null)
- return service;
-
- int serviceCount = server.getServiceCount();
- // If service name is specified, require that name
- if (serviceName != null) {
- for (int i = 0; i < serviceCount; i++) {
- Service svc = server.getService(i);
- if (serviceName.equalsIgnoreCase(svc.getName())) {
- service = svc;
- return service;
- }
- }
- status = new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorXMLServiceNotFound, serviceName));
- return null;
- }
- // If there is only one service, return that one
- if (serviceCount == 1) {
- service = server.getService(0);
- serviceName = service.getName();
- return service;
- }
- // If there are multiple services, try to find a default name
- if (serviceCount > 1) {
- for (int i = 0; i < serviceCount; i++) {
- Service svc = server.getService(i);
- String svcName = svc.getName();
- if (DEFAULT_SERVICE.equalsIgnoreCase(svc.getName())) {
- service = svc;
- serviceName = svcName;
- return service;
- }
- if (DEFAULT_SERVICE2.equalsIgnoreCase(svc.getName())) {
- service = svc;
- serviceName = svcName;
- return service;
- }
- }
- // If not found, use the first service
- service = server.getService(0);
- serviceName = service.getName();
- return service;
- }
- status = new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- Messages.errorXMLNoService);
- return null;
- }
-
- /**
- * Gets the connector at the specified index. If a Connector
- * does not exist at that index a new Connector is appended
- * and returned. This method call will return <b>null</b>
- * if the selected Service does not exist in the server
- * configuration.
- *
- * @param index Index of the Connector to return.
- * @return Returns the Connecter at the specified index or
- * a new Connector if one at that index doesn't exist.
- * Returns <b>null</b> if the selected Service is not found.
- */
- public Connector getConnector(int index) {
- status = Status.OK_STATUS;
- if (service == null && getService() == null)
- return null;
-
- return service.getConnector(index);
- }
-
- /**
- * Gets the Connectors found in the selected Service in the
- * server configuration.
- *
- * @return Array of Connectors found in the selected Service in the
- * server configuration. Returns <b>null</b> if the selected
- * Service can not be found.
- */
- public Connector [] getConnectors() {
- status = Status.OK_STATUS;
- if (service == null && getService() == null)
- return null;
-
- int size = service.getConnectorCount();
- Connector [] connectors = new Connector [size];
- for (int i = 0; i < size; i++) {
- connectors[i] = service.getConnector(i);
- }
- return connectors;
- }
-
- /**
- * Gets the selected Engine in the server configuration of
- * this ServerInstance. The Engine is selected by being the
- * one child Engine of the selected Service. The method will
- * return <b>null</b> if the selected Service is not found
- * in the server configuration or the selected Service
- * does not contain a child Engine.
- *
- * @return Returns the one Engine that is a child of the
- * selected Service. Returns <b>null</b> if the selected
- * Service is not found or it contains no child Engine.
- */
- public Engine getEngine() {
- status = Status.OK_STATUS;
- if (engine != null)
- return engine;
-
- if (service == null && getService() == null)
- return null;
-
- engine = service.getEngine();
- if (engine == null || engine.getName() == null) {
- status = new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorXMLEngineNotFound, serviceName));
- return null;
- }
- engineName = engine.getName();
- if (hostName == null || hostName.length() == 0) {
- hostName = engine.getDefaultHost();
- if (hostName == null)
- hostName = DEFAULT_HOST;
- }
- return engine;
- }
-
- /**
- * Gets the selected Host in the server configuration of
- * this ServerInstance. This method will return <b>null</b>
- * if selected Engine is not found or the selected Engine
- * does not contain a Host with the name specified in this
- * ServerInstance.
- *
- * @return Returns the selected Host for this ServerInstance.
- * Returns <b>null</b> if the selected Engine is not found
- * or it does not contain a Host with the expected name.
- */
- public Host getHost() {
- status = Status.OK_STATUS;
- if (host != null)
- return host;
-
- if (engine == null && getEngine() == null)
- return null;
-
- int size = engine.getHostCount();
- for (int i = 0; i < size; i++) {
- Host h = engine.getHost(i);
- if (hostName.equals(h.getName())) {
- host = h;
- return host;
- }
- }
- status = new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorXMLHostNotFound, new String [] { hostName, engineName, serviceName }));
- return null;
- }
-
- /**
- * Gets the Context that has the specified path within the selected
- * Host. This method will return <b>null</b> if the selected Host or
- * Context with the required path is not found in the server configuration.
- *
- * @param contextPath Path of the Context to be returned. A leading '/' is optional.
- * @return Returns the Context whose <b>path</b> attribute matches
- * the specified contextPath. Returns <b>null</b> if the selected
- * Host or a Context with the required path is not found.
- */
- public Context getContext(String contextPath) {
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return null;
-
- if (contextPath != null && contextPath.length() > 0 && !contextPath.startsWith("/"))
- contextPath = "/" + contextPath;
-
- int size = host.getContextCount();
- for (int i = 0; i < size; i++) {
- Context ctx = host.getContext(i);
- if (ctx.getPath().equals(contextPath)) {
- return ctx;
- }
- }
- status = new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorXMLContextNotFoundPath,
- new String [] { contextPath, serviceName, engineName, hostName }));
- return null;
- }
-
- /**
- * Gets the Context at the specified index within the selected
- * Host. If a Connector does not exist at the specified index,
- * a new Context will be appended and returned. This method will
- * return <b>null</b> if the selected Host can not be found in the
- * server configuration.
- *
- * @param index Index of the Context to return.
- * @return Returns the Context at the specified index, or
- * a new appended Context if the index is beyond any existing
- * Contexts. Returns <b>null</b> if the selected Host can not
- * be found.
- */
- public Context getContext(int index) {
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return null;
-
- return host.getContext(index);
- }
-
- /**
- * Gets the Contexts contained in the selected Host. This
- * method will return <b>null</b> if the selected Host can
- * not be found in the server configuration.
- *
- * @return Array of Contexts contained in the selected Host.
- * Returns <b>null</b> if the selected Host is not found.
- */
- public Context [] getContexts() {
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return null;
-
- int size = host.getContextCount();
- Context [] contexts = new Context [size];
- for (int i = 0; i < size; i++) {
- contexts[i] = host.getContext(i);
- }
- return contexts;
- }
-
- /**
- * Creates a new Context and inserts it before the specifed index
- * or appends it if the index is beyond any existing Contexts in the
- * selected Host. This method will return <b>null</b> if the selected
- * Host is not found in the server configuration.
- *
- * @param index Index prior to which to insert the new Contexts.
- * @return Returns the created Context. Returns <b>null</b> if the
- * selected Host is not found.
- */
- public Context createContext(int index) {
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return null;
-
- return (Context)host.createElement(index, "Context");
- }
-
- /**
- * Removes the Context with the specified path, if it can be found.
- *
- * @param contextPath Path of the Context to be removed. A leading '/' is optional.
- * @return Returns <b>true</b> if the Context was removed. Returns <b>false</b>
- * if the Context or the selected Host is not found.
- */
- public boolean removeContext(String contextPath) {
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return false;
-
- if (contextPath != null && contextPath.length() > 0 && !contextPath.startsWith("/"))
- contextPath = "/" + contextPath;
-
- int size = host.getContextCount();
- for (int i = 0; i < size; i++) {
- Context ctx = host.getContext(i);
- if (ctx.getPath().equals(contextPath)) {
- host.removeElement("Context", i);
- return true;
- }
- }
- status = new Status(IStatus.ERROR,TomcatPlugin.PLUGIN_ID,
- NLS.bind(Messages.errorXMLContextNotFoundPath,
- new String [] { contextPath, serviceName, engineName, hostName }));
- return false;
- }
-
- /**
- * @param index Index of the Context to remove.
- * @return Returns <b>true</b> if a Context is removed at the specified
- * index. Returns <b>false</b> no Context exists at that index or
- * the selected Host is not found.
- */
- public boolean removeContext(int index) {
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return false;
-
- return host.removeElement("Context", index);
- }
-
- /**
- * Gets the directory where the context XML files are stored
- * for the selected Service, Engine, and Host found in the
- * server configuration. This method will return <b>null</b>
- * if the selected Host is not found in the server configuration.
- *
- * @param confDir Path to the &quot;conf&quot; directory for
- * the server.
- * @return Returns the path to the context XML directory.
- * Returns <b>null</b> if the selected Host can not be found.
- */
- public IPath getContextXmlDirectory(IPath confDir) {
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return null;
-
- return confDir.append(engineName).append(hostName);
- }
-
-
- /**
- * Gets the path for the context XML file that would be used
- * if this context were written to a separate files. This
- * method will return <b>null</b> if the selected Host is
- * not found in the server configuration. This method does
- * not verify if the specified Context currently exists
- * within the selected Host.
- *
- * @param baseDir Path to the base directory for the server.
- * @param context Context whose context XML file path to return.
- * @return Returns the path to the context XML file for the specifed
- * Context. Returns <b>null</b> if the selected Host can not be
- * found or the context has no path attribute.
- */
- public IPath getContextFilePath(IPath baseDir, Context context) {
- if (context == null)
- throw new IllegalArgumentException(Messages.errorXMLNullContextArg);
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return null;
-
- IPath contextFilePath = null;
- IPath contextDir = getContextXmlDirectory(baseDir.append("conf"));
- String name = context.getPath();
- if (name != null) {
- if (name.startsWith("/"))
- name = name.substring(1);
- if (name.length() == 0)
- name = "ROOT";
- contextFilePath = contextDir.append(name + ".xml");
- }
- else {
- // TODO Set error status
- }
- return contextFilePath;
- }
-
- /**
- * Gets the work directory associated with the specified
- * Context. If the work directory obtained is relative,
- * it is appended to the specified base path. This method
- * will return <b>null</b> if the selected Host is not
- * found in the server configuration. This method does
- * not verify if the specified Context currently exists
- * within the selected Host.
- *
- * @param basePath Path to the base directory for the server.
- * @param context Context whose work directory to return.
- * @return Returns the path to the work directory for the specifed
- * Context. Returns <b>null</b> if the selected Host can not be
- * found.
- */
- public IPath getContextWorkDirectory(IPath basePath, Context context) {
- if (context == null)
- throw new IllegalArgumentException(Messages.errorXMLNullContextArg);
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return null;
-
- // If the work directory is specified on the context, use that one
- String workDir = context.getAttributeValue("workDir");
- if (workDir == null) {
- // If context doesn't specify the work directory, check the host
- if (hostWorkDir == null) {
- hostWorkDir = host.getAttributeValue("workDir");
- if (hostWorkDir == null || hostWorkDir.length() == 0)
- // If host doesn't specify the work directory, build the default
- hostWorkDir = "work/" + engineName + "/" + hostName;
- }
- String ctxName = context.getPath();
- if (ctxName.startsWith("/"))
- ctxName = ctxName.substring(1);
- ctxName = ctxName.replace('/', '_');
- ctxName = ctxName.replace('\\', '_');
- if (ctxName.length() == 0)
- ctxName = "_";
- workDir = hostWorkDir + "/" + ctxName;
- }
- IPath workPath = new Path(workDir);
- if (!workPath.isAbsolute()) {
- if (basePath == null)
- basePath = new Path("");
- workPath = basePath.append(workPath);
- }
- return workPath;
- }
-
- /**
- * Gets the work directory associated with the selected
- * Host. If the work directory obtained is relative,
- * it is appended to the specified base path. This method
- * will return <b>null</b> if the selected Host is not
- * found in the server configuration.
- *
- * @param basePath Path to the base directory for the server.
- * @return Returns the path to the work directory for the selected
- * Host. Returns <b>null</b> if the selected Host can not be
- * found.
- */
- public IPath getHostWorkDirectory(IPath basePath) {
- status = Status.OK_STATUS;
- if (host == null && getHost() == null)
- return null;
- // If context doesn't specify the work directory, check the host
- if (hostWorkDir == null) {
- hostWorkDir = host.getAttributeValue("workDir");
- if (hostWorkDir == null || hostWorkDir.length() == 0)
- // If host doesn't specify the work directory, build the default
- hostWorkDir = "work/" + engineName + "/" + hostName;
- }
- IPath workPath = new Path(hostWorkDir);
- if (!workPath.isAbsolute()) {
- if (basePath == null)
- basePath = new Path("");
- workPath = basePath.append(workPath);
- }
- return workPath;
- }
-}
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