eclipse/eclipse-tomcat55.patch
2006-08-17 18:26:52 +00:00

1602 lines
66 KiB
Diff

Index: .classpath
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.tomcat/.classpath,v
retrieving revision 1.21
diff -u -r1.21 .classpath
--- .classpath 9 May 2006 18:51:41 -0000 1.21
+++ .classpath 4 Jul 2006 18:42:40 -0000
@@ -1,28 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="catalina.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="bootstrap.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="commons-beanutils.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="commons-collections.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="commons-digester.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="commons-logging-api.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="commons-modeler.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="jakarta-regexp-1.3.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="jasper-compiler.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="jasper-runtime.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="mx4j-jmx.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="naming-common.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="naming-factory.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="naming-resources.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="servlet.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="servlets-common.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="servlets-default.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="servlets-invoker.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="servlets-manager.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="tomcat-coyote.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="tomcat-http11.jar"/>
- <classpathentry exported="true" sourcepath="D:/tomcat4.1.30src" kind="lib" path="tomcat-util.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/catalina.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/catalina-optional.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-el.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-modeler.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/mx4j.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/mx4j-jmx.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/mx4j-impl.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jspapi.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/naming-factory.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/naming-resources.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/servletapi5.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/servlets-default.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/tomcat-coyote.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/tomcat-http.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/tomcat-util.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-beanutils.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-collections.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-digester.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-logging-api.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/regexp.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-digester-rss.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jasper-compiler.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jasper-runtime.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
Index: build.properties
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.tomcat/build.properties,v
retrieving revision 1.16
diff -u -r1.16 build.properties
--- build.properties 10 May 2006 17:51:19 -0000 1.16
+++ build.properties 4 Jul 2006 18:42:40 -0000
@@ -11,7 +11,7 @@
bin.includes = conf/,\
webapps/,\
plugin.xml,\
- *.jar,\
+ lib/*.jar,\
plugin.properties,\
preferences.ini,\
about.html,\
Index: src/org/eclipse/tomcat/internal/TomcatPlugin.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.tomcat/src/org/eclipse/tomcat/internal/TomcatPlugin.java,v
retrieving revision 1.24
diff -u -r1.24 TomcatPlugin.java
--- src/org/eclipse/tomcat/internal/TomcatPlugin.java 23 May 2005 03:58:20 -0000 1.24
+++ src/org/eclipse/tomcat/internal/TomcatPlugin.java 4 Jul 2006 18:42:41 -0000
@@ -24,13 +24,16 @@
public final static String PREF_ACCEPT_COUNT = "acceptCount"; //$NON-NLS-1$
public final static String PREF_MAX_PROCESSORS = "maxProcessors"; //$NON-NLS-1$
public final static String PREF_MIN_PROCESSORS = "minProcessors"; //$NON-NLS-1$
+ public final static String DISABLE_UPLOAD_TIMEOUT = "disableUploadTimeout"; //$NON-NLS-1$
public final static String PREF_SSL_PORT = "sslPort"; //$NON-NLS-1$
public final static String PREF_SSL_PROTOCOL = "sslProtocol"; //$NON-NLS-1$
+ public final static String PREF_SSL_PROTOCOLS = "sslProtocols"; //$NON-NLS-1$
public final static String PREF_SSL_SCHEME = "sslScheme"; //$NON-NLS-1$
public final static String PREF_SSL_ALGORITHM = "sslAlgorithm"; //$NON-NLS-1$
public final static String PREF_KEY_STORE_FILE = "keyStoreFile"; //$NON-NLS-1$
public final static String PREF_KEY_STORE_PASSWORD = "keyStorePassword"; //$NON-NLS-1$
+ public final static String PREF_CLIENT_AUTHENTICATION = "clientauth"; //$NON-NLS-1$
private static TomcatPlugin plugin;
// private static BundleContext bundleContext;
Index: src/org/eclipse/tomcat/internal/TomcatAppServer.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.tomcat/src/org/eclipse/tomcat/internal/TomcatAppServer.java,v
retrieving revision 1.46
diff -u -r1.46 TomcatAppServer.java
--- src/org/eclipse/tomcat/internal/TomcatAppServer.java 17 Apr 2006 15:24:57 -0000 1.46
+++ src/org/eclipse/tomcat/internal/TomcatAppServer.java 4 Jul 2006 18:42:41 -0000
@@ -1,604 +1,650 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.tomcat.internal;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.net.InetAddress;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-
-import org.apache.catalina.Connector;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Host;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Realm;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.logger.FileLogger;
-import org.apache.catalina.realm.MemoryRealm;
-import org.apache.catalina.startup.Embedded;
-import org.apache.coyote.tomcat4.CoyoteConnector;
-import org.apache.coyote.tomcat4.CoyoteServerSocketFactory;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.help.internal.appserver.IWebappServer;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tomcat.internal.extensions.IRealmFactory;
-
-/**
- * Single engine, single host, single connector Tomcat Application Server.
- */
-public class TomcatAppServer implements IWebappServer {
- /**
- * Specify this reserved value for the SSL port # to indicate that SSL
- * should not be used
- */
- public final static int SSL_DISABLED = -1;
-
- private String hostAddress;
-
- private int port;
-
- private int sslPort = SSL_DISABLED;
-
- // false until an attempt to start Tomcat
- private boolean isStarted = false;
-
- // true after started without problems
- private boolean running = false;
-
- private Embedded embedded = null;
-
- private Engine engine = null;
-
- private Host host = null;
-
- private Connector httpConnector = null;
- private Connector sslConnector = null;
- // Con
- private ArrayList contexts = new ArrayList();
-
- /**
- * Constructs this class, but does not instantiates or start Tomcat classes
- * until webapp are added.
- */
- public TomcatAppServer() {
- }
-
- /**
- * @see org.eclipse.help.internal.appserver.IWebappServer#start(int,
- * java.lang.String)
- */
- public synchronized void start(int port, String hostAddress) throws CoreException {
- this.hostAddress = hostAddress;
- this.port = port;
-
- if (isStarted) {
- return;
- }
- isStarted = true;
- try {
- FileLogger logger = new FileLogger();
- logger.setDirectory(TomcatPlugin.getDefault().getStateLocation()
- .toOSString());
- embedded = new Embedded(logger, new MemoryRealm());
- embedded.setDebug(0);
- embedded.setLogger(logger);
- URL installURL = TomcatPlugin.getDefault().getBundle()
- .getEntry("/"); //$NON-NLS-1$
- URL resolvedURL = FileLocator.resolve(installURL);
- String home = FileLocator.toFileURL(resolvedURL).getFile();
- System.setProperty("catalina.home", home); //$NON-NLS-1$
- String base = home;
- System.setProperty("catalina.base", base); //$NON-NLS-1$
-
- // Set up realm if one found
- if (TomcatPlugin.getDefault().getPluginPreferences().getInt(
- TomcatPlugin.PREF_SSL_PORT) >= 0) {
- Realm realm = getRealm();
- embedded.setRealm(realm);
- }
-
- // start now, and then add all the contexts..
- embedded.start();
-
- // Create a very basic container hierarchy
- engine = embedded.createEngine();
-
- host = embedded.createHost("localhost", home + "/webapps"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // all request go to our only host
- engine.setDefaultHost(host.getName());
-
- if (host instanceof StandardHost) {
- ((StandardHost) host)
- .setErrorReportValveClass("org.eclipse.tomcat.internal.EclipseErrorReportValve"); //$NON-NLS-1$
- }
- engine.addChild(host);
-
- // Install the assembled container hierarchy
- PrintStream sysOut = System.out;
- // reassign standard output to prevent Tomcat from writing
- // its version message there.
- System.setOut(new PrintStream(new ByteArrayOutputStream()));
- try {
- embedded.addEngine(engine);
- } finally {
- System.setOut(sysOut);
- }
-
- // Root context
- Context root = embedded.createContext("", home + "/webapps/ROOT"); //$NON-NLS-1$ //$NON-NLS-2$
- // this line should be replaced once tomcat provides support
- // for setting the working directory
- if (root instanceof StandardContext) {
- ((StandardContext) root)
- .setWorkDir(getWorkingDirectory("ROOT")); //$NON-NLS-1$
- }
- root.setLoader(embedded.createLoader(this.getClass()
- .getClassLoader()));
- contexts.add(root);
- host.addChild(root);
-
- InetAddress iAddress = null;
- if (this.hostAddress != null) {
- try {
- iAddress = InetAddress.getByName(this.hostAddress);
- } catch (UnknownHostException uhe) {
- // will default to all interfaces
- }
- }
- updateSslPort(iAddress);
- if (this.port == 0) {
- this.port = SocketUtil.findUnusedLocalPort(iAddress);
- if (this.port == -1) {
- throw new CoreException(
- new Status(
- IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID,
- IStatus.OK,
- TomcatResources.TomcatAppServer_start_CannotObtainPort,
- null));
- }
- }
-
- // Create Connector
- Connector connector = embedded.createConnector(null, this.port,
- false);
- // Override defaults on CoyoteConnector
- if (connector instanceof CoyoteConnector) {
- CoyoteConnector connectorImpl = (CoyoteConnector) connector;
- if (iAddress != null) {
- // bug in Embedded that incorrectly sets host on connector.
- // pass null when creating connector, and set host here if
- // it is specified
- connectorImpl.setAddress(iAddress.getHostAddress());
- }
- Preferences pref = TomcatPlugin.getDefault()
- .getPluginPreferences();
- int acceptCount = pref.getInt(TomcatPlugin.PREF_ACCEPT_COUNT);
- if (acceptCount > 0) {
- connectorImpl.setAcceptCount(acceptCount);
- }
- int maxProcessors = pref
- .getInt(TomcatPlugin.PREF_MAX_PROCESSORS);
- if (maxProcessors > 0) {
- connectorImpl.setMaxProcessors(maxProcessors);
- }
- int minProcessors = pref
- .getInt(TomcatPlugin.PREF_MIN_PROCESSORS);
- if (minProcessors > 0) {
- connectorImpl.setMinProcessors(minProcessors);
- }
- if (this.sslPort > 0) {
- connectorImpl.setRedirectPort(this.sslPort);
- connectorImpl.setEnableLookups(true);
- connectorImpl.setConnectionTimeout(20000);
- connectorImpl.setUseURIValidationHack(false);
- connectorImpl.setDisableUploadTimeout(true);
- }
- // connectorImpl.setDebug(0);
- // If there is problem in embedded.addConnector()
- // there is no exception, so add a listener
- connectorImpl.addLifecycleListener(new LifecycleListener() {
- public void lifecycleEvent(LifecycleEvent event) {
- if ("start".equals(event.getType())) //$NON-NLS-1$
- running = true;
- }
- });
- }
-
- // add Connector to Tomcat
- PrintStream sysErr = System.err;
- // reassign standard error to prevent Coyote from writing
- // its version message there.
- System.setErr(new PrintStream(new ByteArrayOutputStream()));
- try {
- embedded.addConnector(connector);
- httpConnector = connector;
- } finally {
- System.setErr(sysErr);
- }
-
- if (this.sslPort > 0) {
- createSSLConnector(iAddress, this.sslPort);
- }
-
- // if null passed for hostAddress, use local host
- if (this.hostAddress == null) {
- this.hostAddress = "127.0.0.1"; //$NON-NLS-1$
- }
-
- // running = true;
- TomcatPlugin.getDefault().setAppserver(this);
-
- } catch (Exception exc) {
- TomcatPlugin
- .logError(
- "Exception occurred starting the embedded application server.", //$NON-NLS-1$
- exc);
- if (exc instanceof CoreException) {
- throw (CoreException) exc;
- }
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK,
- TomcatResources.TomcatAppServer_start,
- exc));
- }
- if (!running) {
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK,
- TomcatResources.TomcatAppServer_start, null));
- }
- }
-
- /**
- * Update {@link sslPort} to refer an appropriate port. If the user set
- * sslPort to 0, an arbitrary free port will be used.
- *
- * @param iAddress
- * {@link InetAddress} object representing the machine hosting
- * the help system
- * @return port number of use for the SSL connection
- * @throws CoreException
- */
- private int updateSslPort(InetAddress iAddress) throws CoreException {
- this.sslPort = TomcatPlugin.getDefault().getPluginPreferences().getInt(
- TomcatPlugin.PREF_SSL_PORT);
- if (this.sslPort == 0) {
- this.sslPort = SocketUtil.findUnusedLocalPort(iAddress);
- if (this.sslPort == -1) {
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK,
- TomcatResources.TomcatAppServer_start_CannotObtainPort,
- null));
- }
- }
- return this.sslPort;
- }
-
- /**
- * @param iAddress
- * InetAddress representing the machine hosting the help system.
- * @param sslport
- * port # to use for the SSL connection
- * @throws CoreException
- */
- private void createSSLConnector(InetAddress iAddress, int sslport)
- throws CoreException {
- // Create Connector
- this.sslConnector = embedded.createConnector(null, sslport, false);
- // Override defaults on CoyoteConnector
- if (this.sslConnector instanceof CoyoteConnector) {
- CoyoteConnector connectorImpl = (CoyoteConnector) this.sslConnector;
- if (iAddress != null) {
- // bug in Embedded that incorrectly sets host on connector.
- // pass null when creating connector, and set host here if
- // it is specified
- connectorImpl.setAddress(iAddress.getHostAddress());
- }
- Preferences pref = TomcatPlugin.getDefault().getPluginPreferences();
- int acceptCount = pref.getInt(TomcatPlugin.PREF_ACCEPT_COUNT);
- if (acceptCount > 0) {
- connectorImpl.setAcceptCount(acceptCount);
- }
- int maxProcessors = pref.getInt(TomcatPlugin.PREF_MAX_PROCESSORS);
- if (maxProcessors > 0) {
- connectorImpl.setMaxProcessors(maxProcessors);
- }
- int minProcessors = pref.getInt(TomcatPlugin.PREF_MIN_PROCESSORS);
- if (minProcessors > 0) {
- connectorImpl.setMinProcessors(minProcessors);
- }
- connectorImpl.setUseURIValidationHack(false);
- connectorImpl.setDisableUploadTimeout(true);
- connectorImpl.setSecure(true);
- String scheme = pref.getString(TomcatPlugin.PREF_SSL_SCHEME);
- if ((scheme != null) && (!("".equals(scheme.trim())))) { //$NON-NLS-1$
- connectorImpl.setScheme(scheme);
- }
- connectorImpl.setEnableLookups(true);
- CoyoteServerSocketFactory factory = new CoyoteServerSocketFactory();
- factory.setClientAuth(false);
- String protocol = pref.getString(TomcatPlugin.PREF_SSL_PROTOCOL);
- if ((protocol != null) && (!("".equals(protocol.trim())))) { //$NON-NLS-1$
- factory.setProtocol(protocol);
- }
- String algorithm = pref.getString(TomcatPlugin.PREF_SSL_ALGORITHM);
- if ((algorithm != null) && (!("".equals(algorithm.trim())))) { //$NON-NLS-1$
- factory.setAlgorithm(algorithm);
- }
- String keyStoreFile = pref
- .getString(TomcatPlugin.PREF_KEY_STORE_FILE);
- if ((keyStoreFile != null) && (!("".equals(keyStoreFile.trim())))) { //$NON-NLS-1$
- factory.setKeystoreFile(keyStoreFile);
- }
- String keyStorePassword = pref
- .getString(TomcatPlugin.PREF_KEY_STORE_PASSWORD);
- if ((keyStorePassword != null)
- && (!("".equals(keyStorePassword.trim())))) { //$NON-NLS-1$
- factory.setKeystorePass(keyStorePassword);
- }
- connectorImpl.setFactory(factory);
- connectorImpl.setDebug(0);
- // If there is problem in embedded.addConnector()
- // there is no exception, so add a listener
- connectorImpl.addLifecycleListener(new LifecycleListener() {
- public void lifecycleEvent(LifecycleEvent event) {
- if ("start".equals(event.getType())) //$NON-NLS-1$
- running = true;
- }
- });
- }
-
- // add Connector to Tomcat
- PrintStream sysErr = System.err;
- // reassign standard error to prevent Coyote from writing
- // its version message there.
- System.setErr(new PrintStream(new ByteArrayOutputStream()));
- try {
- embedded.addConnector(this.sslConnector);
- } finally {
- System.setErr(sysErr);
- }
- }
-
- /**
- * Creates a {@link Realm}object using the information contained in
- * extensions of the type org.eclipse.tomcat.realmfactory in the plugin
- * registry.
- *
- * @return the {@link Realm}object created
- */
- private Realm getRealm() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry.getExtensionPoint(
- TomcatPlugin.PLUGIN_ID, "realmfactory"); //$NON-NLS-1$
- Realm realm = null;
- if (extensionPoint != null) {
- IExtension[] extensions = extensionPoint.getExtensions();
- if ((extensions != null) && (extensions.length == 1)) {
- IConfigurationElement[] factoryElements = extensions[0]
- .getConfigurationElements();
- if ((factoryElements != null) && (factoryElements.length == 1)) {
- try {
- IRealmFactory realmFactory = (IRealmFactory) factoryElements[0]
- .createExecutableExtension("class"); //$NON-NLS-1$
- realm = realmFactory.createRealm();
- } catch (CoreException e) {
- logError(
- TomcatResources.TomcatAppServer_getRealmFactoryFailed,
- e);
- }
- } else {
- if ((factoryElements == null)
- || (factoryElements.length == 0)) {
- logError(TomcatResources.TomcatAppServer_missingFactoryElement);
- } else {
- logError(TomcatResources.TomcatAppServer_multipleFactoryElements);
- }
- }
- } else {
- if ((extensions == null) || (extensions.length == 0)) {
- logError(TomcatResources.TomcatAppServer_missingRealmExtension);
- } else {
- logError(TomcatResources.TomcatAppServer_multipleRealmExtensions);
- }
- }
- } else {
- logError(TomcatResources.TomcatAppServer_missingRealmExtensionPoint);
- }
- return realm;
- }
-
- /**
- * Create an error entry in the log
- *
- * @param msg
- * error message
- */
- private void logError(String msg) {
- logError(msg, null);
- }
-
- /**
- * Create an error entry in the log
- *
- * @param msg
- * error message
- * @param cause
- * {@link Throwable} associated with this error message
- */
- private void logError(String msg, Throwable cause) {
- TomcatPlugin.logError(msg, cause);
- }
-
- /**
- * @see org.eclipse.help.internal.appserver.IWebappServer#start(java.lang.String,
- * org.eclipse.core.runtime.IPath, java.lang.ClassLoader)
- */
- public synchronized void start(String webappName, IPath path, ClassLoader customLoader)
- throws CoreException {
-
- if (!isStarted) {
- start(port, hostAddress);
- }
- if (!running) {
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK, NLS.bind(
- TomcatResources.TomcatAppServer_addingWebapp,
- webappName, path.toOSString()), null));
- }
-
- String contextPath = webappName;
- if (!contextPath.startsWith("/")) { //$NON-NLS-1$
- contextPath = "/" + contextPath; //$NON-NLS-1$
- }
- try {
- Context context = embedded.createContext(contextPath, path
- .toOSString());
- if (context instanceof StandardContext) {
- ((StandardContext) context)
- .setWorkDir(getWorkingDirectory(webappName));
- }
-
- WebAppClassLoader webappLoader = new WebAppClassLoader(customLoader);
- context.setLoader(embedded.createLoader(webappLoader));
-
- host.addChild(context);
- contexts.add(context);
- } catch (Exception exc) {
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK, NLS.bind(
- "TomcatAppServer.addingWebapp", webappName, path //$NON-NLS-1$
- .toOSString()), exc));
- }
- }
-
- /**
- * @see org.eclipse.help.internal.appserver.IWebappServer#stop(java.lang.String)
- */
- public synchronized void stop(String webappName) throws CoreException {
- if (!running) {
- return;
- }
- Context context = (Context) host.findChild("/" + webappName); //$NON-NLS-1$
- if (context != null) {
- contexts.remove(context);
- embedded.removeContext(context);
- }
- }
-
- /**
- * @see org.eclipse.help.internal.appserver.IWebappServer#getHost()
- */
- public String getHost() {
- if (!running) {
- return null;
- }
- return hostAddress;
- }
-
- /**
- * @see org.eclipse.help.internal.appserver.IWebappServer#getPort()
- */
- public int getPort() {
- if (!running) {
- return 0;
- }
- return port;
- }
-
- /**
- * @see org.eclipse.help.internal.appserver.IWebappServer#isRunning()
- */
- public boolean isRunning() {
- return running;
- }
-
- /**
- * @see org.eclipse.help.internal.appserver.IWebappServer#stop()
- */
- public synchronized void stop() throws CoreException {
- if (!running) {
- return;
- }
- running = false;
- // Remove all contexts
- for(int i = 0; i< contexts.size(); i++){
- embedded.removeContext((Context)contexts.get(i));
- contexts.remove(contexts.get(i));
- }
-
- // Remove the sslConnector, if present.
- try {
- if (sslConnector != null) {
- embedded.removeConnector(this.sslConnector);
- }
- } catch (Exception exc) {
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK,
- TomcatResources.TomcatAppServer_sslConnectorRemove,
- exc));
- }
-
- // Remove the HTTP Connector, if present.
- try {
- if (httpConnector != null) {
- embedded.removeConnector(this.httpConnector);
- }
- } catch (Exception exc) {
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK,
- TomcatResources.TomcatAppServer_httpConnectorRemove,
- exc));
- }
-
- // Remove the engine (which should trigger removing the connector)
- try {
- embedded.removeEngine(engine);
- } catch (Exception exc) {
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK,
- TomcatResources.TomcatAppServer_engineRemove,
- exc));
- }
- // Shut down this tomcat server (should have nothing left to do)
- try {
- embedded.stop();
- } catch (LifecycleException e) {
- throw new CoreException(new Status(IStatus.ERROR,
- TomcatPlugin.PLUGIN_ID, IStatus.OK,
- TomcatResources.TomcatAppServer_embeddedStop,
- e));
- }
- isStarted = false;
- }
-
- private String getWorkingDirectory(String webApp) {
- return TomcatPlugin.getDefault().getStateLocation().append(webApp)
- .toOSString();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2000, 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.tomcat.internal;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+
+import mx4j.log.FileLogger;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Realm;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.realm.MemoryRealm;
+import org.apache.catalina.startup.Embedded;
+import org.apache.coyote.http11.Http11Protocol;
+import org.apache.tomcat.util.net.jsse.JSSEImplementation;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.help.internal.appserver.IWebappServer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tomcat.internal.extensions.IRealmFactory;
+
+/**
+ * Single engine, single host, single connector Tomcat Application Server.
+ */
+public class TomcatAppServer implements IWebappServer {
+ /**
+ * Specify this reserved value for the SSL port # to indicate that SSL
+ * should not be used
+ */
+ public final static int SSL_DISABLED = -1;
+
+ private final static String NULL = null;
+
+ private String hostAddress;
+
+ private int port;
+
+ private int sslPort = SSL_DISABLED;
+
+ // false until an attempt to start Tomcat
+ private boolean isStarted = false;
+
+ // true after started without problems
+ private boolean running = false;
+
+ private Embedded embedded = null;
+
+ private Engine engine = null;
+
+ private Host host = null;
+
+ private Connector httpConnector = null;
+ private boolean hasConnection = false;
+ private Connector sslConnector = null;
+ private boolean hasSSLConnection = false;
+ // Con
+ private ArrayList contexts = new ArrayList();
+
+ /**
+ * Constructs this class, but does not instantiates or start Tomcat classes
+ * until webapp are added.
+ */
+ public TomcatAppServer() {
+ }
+
+ /**
+ * @see org.eclipse.help.internal.appserver.IWebappServer#start(int,
+ * java.lang.String)
+ */
+ public synchronized void start(int port, String hostAddress) throws CoreException {
+ // if null passed for hostAddress, use local host
+ if (hostAddress == null) {
+ this.hostAddress = "127.0.0.1"; //$NON-NLS-1$
+ } else {
+ this.hostAddress = hostAddress;
+ }
+ InetAddress iAddress = null;
+
+ //Defaults to LOCALHOST
+ try{
+ iAddress = InetAddress.getByName(this.hostAddress);
+ } catch (UnknownHostException uhe) {
+ // will default to all interfaces
+ }
+
+ String hostname = iAddress.getHostName();
+
+ this.port = port;
+ if (isStarted) {
+ return;
+ }
+ isStarted = true;
+ try {
+ embedded = new Embedded(new MemoryRealm());
+ URL installURL = TomcatPlugin.getDefault().getBundle()
+ .getEntry("/"); //$NON-NLS-1$
+ URL resolvedURL = Platform.resolve(installURL);
+ String home = Platform.asLocalURL(resolvedURL).getFile();
+ System.setProperty("catalina.home", home); //$NON-NLS-1$
+ String base = home;
+ System.setProperty("catalina.base", base); //$NON-NLS-1$
+
+ // Set up realm if one found
+ if (TomcatPlugin.getDefault().getPluginPreferences().getInt(
+ TomcatPlugin.PREF_SSL_PORT) >= 0) {
+ Realm realm = getRealm();
+ embedded.setRealm(realm);
+ }
+ //the embedded application is now started by using embedded.start()
+ embedded.addLifecycleListener(new LifecycleListener(){
+ public void lifecycleEvent(LifecycleEvent event) {
+ if (Lifecycle.START_EVENT.equals(event.getType()))
+ running = true;
+ }
+
+ });
+ // start now, and then add all the contexts..
+ embedded.start();
+
+ // Create a very basic container hierarchy
+ engine = embedded.createEngine();
+
+ host = embedded.createHost(hostname, home + "webapps"); //$NON-NLS-1$
+
+ // all request go to our only host
+ engine.setDefaultHost(host.getName());
+
+ if (host instanceof StandardHost) {
+ ((StandardHost) host)
+ .setErrorReportValveClass("org.eclipse.tomcat.internal.EclipseErrorReportValve"); //$NON-NLS-1$
+ }
+
+ engine.addChild(host);
+
+ // Install the assembled container hierarchy
+ PrintStream sysOut = System.out;
+ // reassign standard output to prevent Tomcat from writing
+ // its version message there.
+ System.setOut(new PrintStream(new ByteArrayOutputStream()));
+ try {
+ embedded.addEngine(engine);
+ } finally {
+ System.setOut(sysOut);
+ }
+
+ // Root context
+ Context root = embedded.createContext("", home + "webapps/ROOT"); //$NON-NLS-1$ //$NON-NLS-2$
+ // this line should be replaced once tomcat provides support
+ // for setting the working directory
+ if (root instanceof StandardContext) {
+ ((StandardContext) root)
+ .setWorkDir(getWorkingDirectory("ROOT")); //$NON-NLS-1$
+ }
+ root.setLoader(embedded.createLoader(this.getClass()
+ .getClassLoader()));
+
+ host.addChild(root);
+ contexts.add(root);
+
+ updateSslPort(iAddress);
+ if (this.port == 0) {
+ this.port = SocketUtil.findUnusedLocalPort(iAddress);
+ if (this.port == -1) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID,
+ IStatus.OK,
+ TomcatResources.TomcatAppServer_start_CannotObtainPort,
+ null));
+ }
+ }
+
+ // Create Connector
+ Connector connector = embedded.createConnector(iAddress.getHostAddress(), this.port,false);;
+
+ Preferences pref = TomcatPlugin.getDefault()
+ .getPluginPreferences();
+ /**
+ * To extend additional properties, make use of org.apache.tomcat.util.IntrospectionUtils
+ * A Connector will initialize a protocolhandler defaults to org.apache.coyote.http11.Http11Protocol
+ * format : connector.setProperty("STRING_PROP_NAME","STRING_PROP_VALUE");
+ *
+ */
+
+ int acceptCount = pref.getInt(TomcatPlugin.PREF_ACCEPT_COUNT);
+ if (acceptCount > 0) {
+ connector.setProperty("backlog",""+acceptCount); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ int maxProcessors = pref
+ .getInt(TomcatPlugin.PREF_MAX_PROCESSORS);
+ if (maxProcessors > 0) {
+ connector.setProperty("maxThreads",""+maxProcessors); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ int minProcessors = pref
+ .getInt(TomcatPlugin.PREF_MIN_PROCESSORS);
+ if (minProcessors > 0) {
+ connector.setProperty("minSpareThreads",""+minProcessors); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (this.sslPort > 0) {
+ connector.setRedirectPort(this.sslPort);
+ connector.setEnableLookups(true);
+ connector.setProperty("soTimeout",""+20000); //$NON-NLS-1$ //$NON-NLS-2$
+ //connector.setUseURIValidationHack(false); no longer available
+ connector.setUseBodyEncodingForURI(false);
+ String disableUploadTimeout = pref.getString(TomcatPlugin.DISABLE_UPLOAD_TIMEOUT);
+ if ((disableUploadTimeout != null) && (!("".equals(disableUploadTimeout.trim())))) { //$NON-NLS-1$
+ connector.setProperty("disableUploadTimeout", disableUploadTimeout); //$NON-NLS-1$
+ }
+ }
+ // connectorImpl.setDebug(0);
+ // If there is problem in embedded.addConnector()
+ // there is no exception, so add a listener
+ connector.addLifecycleListener(new LifecycleListener() {
+ public void lifecycleEvent(LifecycleEvent event) {
+ if (Lifecycle.START_EVENT.equals(event.getType()))
+ hasConnection = true;
+ }
+ });
+
+ // add Connector to Tomcat
+ PrintStream sysErr = System.err;
+ // reassign standard error to prevent Coyote from writing
+ // its version message there.
+ System.setErr(new PrintStream(new ByteArrayOutputStream()));
+ try {
+ this.httpConnector = connector;
+ embedded.addConnector(this.httpConnector);
+ httpConnector.start();
+ } finally {
+ System.setErr(sysErr);
+ }
+ if (this.sslPort > 0) {
+ createSSLConnector(iAddress, this.sslPort);
+ }
+
+ // running = true;
+ TomcatPlugin.getDefault().setAppserver(this);
+
+ } catch (Exception exc) {
+ TomcatPlugin
+ .logError(
+ "Exception occurred starting the embedded application server.", //$NON-NLS-1$
+ exc);
+ if (exc instanceof CoreException) {
+ throw (CoreException) exc;
+ }
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK,
+ TomcatResources.TomcatAppServer_start,
+ exc));
+ }
+ if (!running) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK,
+ TomcatResources.TomcatAppServer_start, null));
+ }
+ }
+
+ /**
+ * Update {@link sslPort} to refer an appropriate port. If the user set
+ * sslPort to 0, an arbitrary free port will be used.
+ *
+ * @param iAddress
+ * {@link InetAddress} object representing the machine hosting
+ * the help system
+ * @return port number of use for the SSL connection
+ * @throws CoreException
+ */
+ private int updateSslPort(InetAddress iAddress) throws CoreException {
+ this.sslPort = TomcatPlugin.getDefault().getPluginPreferences().getInt(
+ TomcatPlugin.PREF_SSL_PORT);
+ if (this.sslPort == 0) {
+ this.sslPort = SocketUtil.findUnusedLocalPort(iAddress);
+ if (this.sslPort == -1) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK,
+ TomcatResources.TomcatAppServer_start_CannotObtainPort,
+ null));
+ }
+ }
+ return this.sslPort;
+ }
+
+ /**
+ * @param iAddress
+ * InetAddress representing the machine hosting the help system.
+ * @param sslport
+ * port # to use for the SSL connection
+ * @throws CoreException
+ */
+ private void createSSLConnector(InetAddress iAddress, int sslport)
+ throws CoreException {
+
+ // Create Connector
+ //Defaults to local if IAddress is null
+ Connector connector = embedded.createConnector(iAddress.getHostAddress(), this.port,false);
+
+ //--------------------create the Protocol-----------------------//
+ Preferences pref = TomcatPlugin.getDefault().getPluginPreferences();
+ /**
+ * To extend additional properties, make use of org.apache.tomcat.util.IntrospectionUtils
+ * A Connector will initialize a protocolhandler which initialize a SSLImplementation which initialize
+ * a ServerSocketFactory
+ * format : connector.setProperty("STRING_PROP_NAME","STRING_PROP_VALUE");
+ *
+ */
+ //----------------configure connector -------------------------------//
+ // by looking at the code, it seems like the protocol go in first
+ String protocol = pref.getString(TomcatPlugin.PREF_SSL_PROTOCOL);
+ if ((protocol != null) && (!("".equals(protocol.trim())))) { //$NON-NLS-1$
+ connector.setProperty("protocol",protocol); //$NON-NLS-1$
+ }
+ String protocols = pref.getString(TomcatPlugin.PREF_SSL_PROTOCOLS);
+ if ((protocols != null) && (!("".equals(protocols.trim())))) { //$NON-NLS-1$
+ connector.setProperty("protocols",protocols); //$NON-NLS-1$
+ }
+ String protocolClassName = Http11Protocol.class.getName();
+ connector.setProtocol(protocolClassName);
+
+ String JSSEImplementationName = JSSEImplementation.class.getName();
+ connector.setProperty("sslImplementation",JSSEImplementationName); //$NON-NLS-1$
+
+ String disableUploadTimeout = pref.getString(TomcatPlugin.DISABLE_UPLOAD_TIMEOUT);
+ if ((disableUploadTimeout != null) && (!("".equals(disableUploadTimeout.trim())))) { //$NON-NLS-1$
+ connector.setProperty("disableUploadTimeout", disableUploadTimeout); //$NON-NLS-1$
+ }
+
+ String algorithm = pref.getString(TomcatPlugin.PREF_SSL_ALGORITHM);
+ if ((algorithm != null) && (!("".equals(algorithm.trim())))) { //$NON-NLS-1$
+ connector.setProperty("algorithm", algorithm); //$NON-NLS-1$
+ }
+ int maxProcessors = pref.getInt(TomcatPlugin.PREF_MAX_PROCESSORS);
+ if (maxProcessors > 0) {
+ //connector.setMaxProcessors(maxProcessors);
+ connector.setProperty("maxThreads",""+maxProcessors); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ int minProcessors = pref.getInt(TomcatPlugin.PREF_MIN_PROCESSORS);
+ if (minProcessors > 0) {
+ //connector.setMinProcessors(minProcessors);
+ connector.setProperty("minSpareThreads",""+minProcessors); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ //this is making use of org.apache.tomcat.util.IntrospectionUtils
+ connector.setProperty("disableUploadTimeout",""+true); //$NON-NLS-1$ //$NON-NLS-2$
+ String clientauth = pref.getString(TomcatPlugin.PREF_CLIENT_AUTHENTICATION);
+ if ((clientauth != null) && (!("".equals(clientauth.trim())))) { //$NON-NLS-1$
+ connector.setProperty("clientauth",clientauth); //$NON-NLS-1$
+ }
+
+ int acceptCount = pref.getInt(TomcatPlugin.PREF_ACCEPT_COUNT);
+ if (acceptCount > 0) {
+ connector.setProperty("backlog",""+acceptCount); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ String keyStoreFile = pref
+ .getString(TomcatPlugin.PREF_KEY_STORE_FILE);
+ if ((keyStoreFile != null) && (!("".equals(keyStoreFile.trim())))) { //$NON-NLS-1$
+ connector.setProperty("keystore", keyStoreFile); //$NON-NLS-1$
+ }
+ String keyStorePassword = pref
+ .getString(TomcatPlugin.PREF_KEY_STORE_PASSWORD);
+ if ((keyStorePassword != null)
+ && (!("".equals(keyStorePassword.trim())))) { //$NON-NLS-1$
+ connector.setProperty("keypass", keyStorePassword); //$NON-NLS-1$
+ }
+ //connector.setUseURIValidationHack(false); --no longer avaliable, hope they fixed the bug
+ connector.setUseBodyEncodingForURI(false);
+ // connector.setSecure(true); ---setting ssLImplementation set secure to true
+ String scheme = pref.getString(TomcatPlugin.PREF_SSL_SCHEME);
+ if ((scheme != null) && (!("".equals(scheme.trim())))) { //$NON-NLS-1$
+ connector.setScheme(scheme);
+ }
+ connector.setEnableLookups(true);
+
+ //connector.setFactory(factory); --no longer needed, now handled by SSLImplemenatation
+ // If there is problem in embedded.addConnector()
+ // there is no exception, so add a listener
+ connector.addLifecycleListener(new LifecycleListener() {
+ public void lifecycleEvent(LifecycleEvent event) {
+ if (Lifecycle.START_EVENT.equals(event.getType())||Lifecycle.PERIODIC_EVENT.equals(event.getType()))
+ hasSSLConnection = true;
+ }
+ });
+ // add Connector to Tomcat
+ PrintStream sysErr = (PrintStream) System.err;
+ // reassign standard error to prevent Coyote from writing
+ // its version message there.
+ System.setErr(new PrintStream(new ByteArrayOutputStream()));
+ try{
+ sslConnector = connector;
+ embedded.addConnector(this.sslConnector);
+ sslConnector.start();
+ } catch(LifecycleException e){
+ TomcatPlugin
+ .logError(
+ "Exception occurred while establishing secure connection.", //$NON-NLS-1$
+ e);
+ }
+ finally {
+ System.setErr(sysErr);
+ }
+ }
+
+ /**
+ * Creates a {@link Realm}object using the information contained in
+ * extensions of the type org.eclipse.tomcat.realmfactory in the plugin
+ * registry.
+ *
+ * @return the {@link Realm}object created
+ */
+ private Realm getRealm() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(
+ TomcatPlugin.PLUGIN_ID, "realmfactory"); //$NON-NLS-1$
+ Realm realm = null;
+ if (extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if ((extensions != null) && (extensions.length == 1)) {
+ IConfigurationElement[] factoryElements = extensions[0]
+ .getConfigurationElements();
+ if ((factoryElements != null) && (factoryElements.length == 1)) {
+ try {
+ IRealmFactory realmFactory = (IRealmFactory) factoryElements[0]
+ .createExecutableExtension("class"); //$NON-NLS-1$
+ realm = realmFactory.createRealm();
+ } catch (CoreException e) {
+ logError(
+ TomcatResources.TomcatAppServer_getRealmFactoryFailed,
+ e);
+ }
+ } else {
+ if ((factoryElements == null)
+ || (factoryElements.length == 0)) {
+ logError(TomcatResources.TomcatAppServer_missingFactoryElement);
+ } else {
+ logError(TomcatResources.TomcatAppServer_multipleFactoryElements);
+ }
+ }
+ } else {
+ if ((extensions == null) || (extensions.length == 0)) {
+ logError(TomcatResources.TomcatAppServer_missingRealmExtension);
+ } else {
+ logError(TomcatResources.TomcatAppServer_multipleRealmExtensions);
+ }
+ }
+ } else {
+ logError(TomcatResources.TomcatAppServer_missingRealmExtensionPoint);
+ }
+ return realm;
+ }
+
+ /**
+ * Create an error entry in the log
+ *
+ * @param msg
+ * error message
+ */
+ private void logError(String msg) {
+ logError(msg, null);
+ }
+
+ /**
+ * Create an error entry in the log
+ *
+ * @param msg
+ * error message
+ * @param cause
+ * {@link Throwable} associated with this error message
+ */
+ private void logError(String msg, Throwable cause) {
+ TomcatPlugin.logError(msg, cause);
+ }
+
+ /**
+ * @see org.eclipse.help.internal.appserver.IWebappServer#start(java.lang.String,
+ * org.eclipse.core.runtime.IPath, java.lang.ClassLoader)
+ */
+ public synchronized void start(String webappName, IPath path, ClassLoader customLoader)
+ throws CoreException {
+
+ if (!isStarted) {
+ start(port, hostAddress);
+ }
+ if (!running) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK, NLS.bind(
+ TomcatResources.TomcatAppServer_addingWebapp,
+ webappName, path.toOSString()), null));
+ }
+ String contextPath = webappName;
+ if (!contextPath.startsWith("/")) { //$NON-NLS-1$
+ contextPath = "/" + contextPath; //$NON-NLS-1$
+ }
+ try {
+ Context context = embedded.createContext(contextPath, path
+ .toOSString());
+ if (context instanceof StandardContext) {
+ ((StandardContext) context)
+ .setWorkDir(getWorkingDirectory(webappName));
+ }
+
+ WebAppClassLoader webappLoader = new WebAppClassLoader(customLoader);
+ context.setLoader(embedded.createLoader(webappLoader));
+ host.addChild(context);
+ contexts.add(context);
+ } catch (Exception exc) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK, NLS.bind(
+ "TomcatAppServer.addingWebapp", webappName, path //$NON-NLS-1$
+ .toOSString()), exc));
+ }
+ }
+
+ /**
+ * @see org.eclipse.help.internal.appserver.IWebappServer#stop(java.lang.String)
+ */
+ public synchronized void stop(String webappName) throws CoreException {
+ if (!running) {
+ return;
+ }
+ Context context = (Context) host.findChild("/" + webappName); //$NON-NLS-1$
+ if (context != null) {
+ contexts.remove(context);
+ embedded.removeContext(context);
+ }
+ }
+
+ /**
+ * @see org.eclipse.help.internal.appserver.IWebappServer#getHost()
+ */
+ public String getHost() {
+ if (!running) {
+ return null;
+ }
+ return hostAddress;
+ }
+
+ /**
+ * @see org.eclipse.help.internal.appserver.IWebappServer#getPort()
+ */
+ public int getPort() {
+ if (!running) {
+ return 0;
+ }
+ return port;
+ }
+
+ /**
+ * @see org.eclipse.help.internal.appserver.IWebappServer#isRunning()
+ */
+ public boolean isRunning() {
+ return running;
+ }
+
+ /**
+ * @see org.eclipse.help.internal.appserver.IWebappServer#stop()
+ */
+ public synchronized void stop() throws CoreException {
+ if (!running) {
+ return;
+ }
+ running = false;
+ // Remove all contexts
+ for(int i = 0; i< contexts.size(); i++){
+ embedded.removeContext((Context)contexts.get(i));
+ contexts.remove(contexts.get(i));
+ }
+
+ // Remove the sslConnector, if present.
+ try {
+ if (sslConnector != null) {
+ embedded.removeConnector(this.sslConnector);
+ }
+ } catch (Exception exc) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK,
+ TomcatResources.TomcatAppServer_sslConnectorRemove,
+ exc));
+ }
+
+ // Remove the HTTP Connector, if present.
+ try {
+ if (httpConnector != null) {
+ embedded.removeConnector(this.httpConnector);
+ }
+ } catch (Exception exc) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK,
+ TomcatResources.TomcatAppServer_httpConnectorRemove,
+ exc));
+ }
+
+ // Remove the engine (which should trigger removing the connector)
+ try {
+ embedded.removeEngine(engine);
+ } catch (Exception exc) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK,
+ TomcatResources.TomcatAppServer_engineRemove,
+ exc));
+ }
+ // Shut down this tomcat server (should have nothing left to do)
+ try {
+ embedded.stop();
+ } catch (LifecycleException e) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ TomcatPlugin.PLUGIN_ID, IStatus.OK,
+ TomcatResources.TomcatAppServer_embeddedStop,
+ e));
+ }
+ isStarted = false;
+ }
+
+ private String getWorkingDirectory(String webApp) {
+ return TomcatPlugin.getDefault().getStateLocation().append(webApp)
+ .toOSString();
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/tomcat/internal/EclipseErrorReportValve.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.tomcat/src/org/eclipse/tomcat/internal/EclipseErrorReportValve.java,v
retrieving revision 1.9
diff -u -r1.9 EclipseErrorReportValve.java
--- src/org/eclipse/tomcat/internal/EclipseErrorReportValve.java 23 Feb 2006 22:51:14 -0000 1.9
+++ src/org/eclipse/tomcat/internal/EclipseErrorReportValve.java 4 Jul 2006 18:42:41 -0000
@@ -69,15 +69,27 @@
package org.eclipse.tomcat.internal;
-import java.io.*;
-import java.util.*;
-
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-import org.apache.catalina.*;
-import org.apache.catalina.util.*;
-import org.apache.catalina.valves.*;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Locale;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+import mx4j.log.Logger;
+
+import org.apache.catalina.Globals;
+import org.apache.catalina.Valve;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.util.RequestUtil;
+import org.apache.catalina.util.StringManager;
+import org.apache.catalina.valves.Constants;
+import org.apache.catalina.valves.ValveBase;
import org.eclipse.core.runtime.Platform;
@@ -145,12 +157,12 @@
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
- public void invoke(Request request, Response response,
- ValveContext context)
+ public void invoke(Request request, Response response)
throws IOException, ServletException {
// Perform the request
- context.invokeNext(request, response);
+ Valve nextValve = getNext();
+ nextValve.invoke(request, response);
ServletRequest sreq = (ServletRequest) request;
Throwable throwable =
@@ -220,14 +232,11 @@
throws IOException {
// Do nothing on non-HTTP responses
- if (!(response instanceof HttpResponse))
- return;
- HttpResponse hresponse = (HttpResponse) response;
if (!(response instanceof HttpServletResponse))
return;
HttpServletResponse hres = (HttpServletResponse) response;
- int statusCode = hresponse.getStatus();
- String message = RequestUtil.filter(hresponse.getMessage());
+ int statusCode = response.getStatus();
+ String message = RequestUtil.filter(response.getMessage());
if (message == null)
message = ""; //$NON-NLS-1$
@@ -373,9 +382,9 @@
*/
protected void log(String message) {
- Logger logger = container.getLogger();
+ Logger logger = (Logger) container.getLogger();
if (logger != null)
- logger.log(this.toString() + ": " + message); //$NON-NLS-1$
+ logger.info(this.toString() + ": " + message); //$NON-NLS-1$
else
System.out.println(this.toString() + ": " + message); //$NON-NLS-1$
@@ -390,9 +399,9 @@
*/
protected void log(String message, Throwable throwable) {
- Logger logger = container.getLogger();
+ Logger logger = (Logger) container.getLogger();
if (logger != null)
- logger.log(this.toString() + ": " + message, throwable); //$NON-NLS-1$
+ logger.info(this.toString() + ": " + message, throwable); //$NON-NLS-1$
else {
System.out.println(this.toString() + ": " + message); //$NON-NLS-1$
throwable.printStackTrace(System.out);
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.tomcat/META-INF/MANIFEST.MF,v
retrieving revision 1.21
diff -u -r1.21 MANIFEST.MF
--- META-INF/MANIFEST.MF 9 May 2006 20:26:52 -0000 1.21
+++ META-INF/MANIFEST.MF 4 Jul 2006 18:42:40 -0000
@@ -2,30 +2,32 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tomcat; singleton:=true
-Bundle-Version: 4.1.130.qualifier
+Bundle-Version: 5.5.17.qualifier
Bundle-ClassPath: tomcatwrapper.jar,
- catalina.jar,
- bootstrap.jar,
- commons-beanutils.jar,
- commons-collections.jar,
- commons-digester.jar,
- commons-logging-api.jar,
- commons-modeler.jar,
- jakarta-regexp-1.3.jar,
- jasper-compiler.jar,
- jasper-runtime.jar,
- mx4j-jmx.jar,
- naming-common.jar,
- naming-factory.jar,
- naming-resources.jar,
- servlet.jar,
- servlets-common.jar,
- servlets-default.jar,
- servlets-invoker.jar,
- servlets-manager.jar,
- tomcat-coyote.jar,
- tomcat-http11.jar,
- tomcat-util.jar
+ lib/catalina.jar,
+ lib/catalina-optional.jar,
+ lib/commons-beanutils.jar,
+ lib/commons-collections.jar,
+ lib/commons-digester.jar,
+ lib/commons-digester-rss.jar,
+ lib/commons-el.jar,
+ lib/commons-logging-api.jar,
+ lib/commons-modeler.jar,
+ lib/jasper-compiler.jar,
+ lib/jasper-runtime.jar,
+ lib/mx4j.jar,
+ lib/mx4j-jmx.jar,
+ lib/mx4j-impl.jar,
+ lib/jspapi.jar,
+ lib/naming-factory.jar,
+ lib/naming-resources.jar,
+ lib/regexp.jar,
+ lib/servletapi5.jar,
+ lib/servlets-default.jar,
+ lib/tomcat-coyote.jar,
+ lib/tomcat-http.jar,
+ lib/tomcat-util.jar,
+ lib/servlets-invoker.jar
Bundle-Activator: org.eclipse.tomcat.internal.TomcatPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -33,6 +35,73 @@
org.apache.ant;bundle-version="[1.6.5,1.7.0)";resolution:=optional,
org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)"
Eclipse-LazyStart: true
-Export-Package: org.eclipse.tomcat.internal;x-internal:=true,
+Export-Package: javax.management;x-internal:=true,
+ javax.management.loading;x-internal:=true,
+ javax.management.modelmbean;x-internal:=true,
+ javax.management.monitor;x-internal:=true,
+ javax.management.openmbean;x-internal:=true,
+ javax.management.relation;x-internal:=true,
+ javax.management.timer;x-internal:=true,
+ javax.servlet;x-internal:=true,
+ javax.servlet.http;x-internal:=true,
+ javax.servlet.jsp;x-internal:=true,
+ javax.servlet.jsp.tagext;x-internal:=true,
+ mx4j;x-internal:=true,
+ mx4j.loading;x-internal:=true,
+ mx4j.log;x-internal:=true,
+ mx4j.persist;x-internal:=true,
+ mx4j.server;x-internal:=true,
+ mx4j.server.interceptor;x-internal:=true,
+ mx4j.timer;x-internal:=true,
+ mx4j.util;x-internal:=true,
+ org.apache.catalina;x-internal:=true,
+ org.apache.catalina.connector;x-internal:=true,
+ org.apache.catalina.core;x-internal:=true,
+ org.apache.catalina.realm;x-internal:=true,
+ org.apache.catalina.servlets;x-internal:=true,
+ org.apache.commons.beanutils;x-internal:=true,
+ org.apache.commons.beanutils.converters;x-internal:=true,
+ org.apache.commons.beanutils.locale;x-internal:=true,
+ org.apache.commons.beanutils.locale.converters;x-internal:=true,
+ org.apache.commons.collections;x-internal:=true,
+ org.apache.commons.collections.comparators;x-internal:=true,
+ org.apache.commons.collections.iterators;x-internal:=true,
+ org.apache.commons.digester;x-internal:=true,
+ org.apache.commons.digester.rss;x-internal:=true,
+ org.apache.commons.digester.xmlrules;x-internal:=true,
+ org.apache.commons.logging;x-internal:=true,
+ org.apache.commons.logging.impl;x-internal:=true,
+ org.apache.commons.modeler;x-internal:=true,
+ org.apache.commons.modeler.ant;x-internal:=true,
+ org.apache.commons.modeler.mbeans;x-internal:=true,
+ org.apache.commons.modeler.modules;x-internal:=true,
+ org.apache.commons.modeler.util;x-internal:=true,
+ org.apache.coyote;x-internal:=true,
+ org.apache.coyote.http11;x-internal:=true,
+ org.apache.coyote.http11.filters;x-internal:=true,
+ org.apache.coyote.memory;x-internal:=true,
+ org.apache.jasper;x-internal:=true,
+ org.apache.jasper.compiler;x-internal:=true,
+ org.apache.jasper.runtime;x-internal:=true,
+ org.apache.jasper.servlet;x-internal:=true,
+ org.apache.jasper.util;x-internal:=true,
+ org.apache.jasper.xmlparser;x-internal:=true,
+ org.apache.naming;x-internal:=true,
+ org.apache.naming.factory;x-internal:=true,
+ org.apache.naming.java;x-internal:=true,
+ org.apache.naming.resources;x-internal:=true,
+ org.apache.regexp;x-internal:=true,
+ org.apache.tomcat.util;x-internal:=true,
+ org.apache.tomcat.util.buf;x-internal:=true,
+ org.apache.tomcat.util.collections;x-internal:=true,
+ org.apache.tomcat.util.http;x-internal:=true,
+ org.apache.tomcat.util.http.mapper;x-internal:=true,
+ org.apache.tomcat.util.log;x-internal:=true,
+ org.apache.tomcat.util.net;x-internal:=true,
+ org.apache.tomcat.util.net.jsse;x-internal:=true,
+ org.apache.tomcat.util.res;x-internal:=true,
+ org.apache.tomcat.util.threads;x-internal:=true,
+ org.eclipse.tomcat.internal;x-internal:=true,
+ org.eclipse.tomcat.internal;x-internal:=true,
org.eclipse.tomcat.internal.extensions;x-internal:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.4