Index: .classpath
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.tomcat/.classpath,v
retrieving revision 1.20
diff -u -r1.20 .classpath
--- .classpath 21 Apr 2005 23:31:58 -0000 1.20
+++ .classpath 6 Mar 2006 21:10:23 -0000
@@ -1,29 +1,36 @@
February 24, 2005
+February 24, 2005 (modified June 14, 2005 with update to Tomcat 5.0.30)
The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the @@ -23,7 +23,7 @@
The Content includes items that have been sourced from third parties as follows:
-Tomcat 4.1.30
+Tomcat 5.0.30
The plug-in is based on software developed by The Apache Software Foundation as part of the Jakarta project. Therefore:
@@ -35,24 +35,31 @@
- bootstrap.jar
- catalina.jar
-- commons-beanutils.jar
-- commons-collections.jar
-- commons-digester.jar
-- commons-logging.jar
-- commons-logging-api.jar
-- commons-modeler.jar
-- jakarta-regexp-1.3.jar
-- jasper-compiler.jar
-- jasper-runtime.jar
+- catalina-optional.jar
+- jakarta-commons-beanutils.jar
+- jakarta-commons-collections.jar
+- jakarta-commons-dbcp.jar
+- jakarta-commons-digester.jar
+- jakarta-commons-digester-rss.jar
+- jakarta-commons-el.jar
+- jakarta-commons-fileupload.jar
+- jakarta-commons-launcher.jar
+- jakarta-commons-logging.jar
+- jakarta-commons-modeler.jar
+- jakarta-commons-pool.jar
+- jasper5-compiler.jar
+- jasper5-runtime.jar
+- mx4j.jar
+- mx4j-impl.jar
- mx4j-jmx.jar
- naming-common.jar
- naming-factory.jar
- naming-resources.jar
-- servlet.jar
+- regexp.jar
+- servletapi5.jar
- servlets-common.jar
- servlets-default.jar
- servlets-invoker.jar
-- servlets-manager.jar
- tomcat-coyote.jar
- tomcat-http11.jar
- tomcat-util.jar
@@ -66,10 +73,10 @@Tomcat is:
-Copyright (c) 1999, 2000 The Apache Software Foundation. All rights reserved.+Copyright (c) 1999-2003 The Apache Software Foundation. All rights reserved.-Your use of the Tomcat code is subject to the terms and conditions of the Apache Software License 1.1 which is available at -http://www.apache.org/licenses/LICENSE-1.1. More specifically:
+Your use of the Tomcat code is subject to the terms and conditions of the Apache Software License 2.0 which is available at +http://www.apache.org/licenses/LICENSE-2.0. More specifically:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
@@ -107,11 +114,11 @@Source code for Tomcat is available at http://jakarta.apache.org/tomcat/.
-MX4J 1.1.1 +MX4J 2.1.0 -Tomcat 4.1.30 includes mx4j-jmx.jar from MX4J 1.1.1. MX4J is: +Tomcat 5.0.30 includes mx4j.jar, mx4j-jmx.jar and mx4j-impl.jar from MX4J 2.1.0. MX4J is: -Copyright (c) 2001 MX4J. All rights reserved.+Copyright (c) 2001-2004 MX4J contributors. All rights reserved.Your use of the MX4J code is subject to the terms and conditions of the MX4J License, Version 1.0, a copy of which is included with the Content in the file mx4j.license. More specifically:
Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.tomcat/META-INF/MANIFEST.MF,v retrieving revision 1.14 diff -u -r1.14 MANIFEST.MF --- META-INF/MANIFEST.MF 19 May 2005 04:05:11 -0000 1.14 +++ META-INF/MANIFEST.MF 6 Mar 2006 21:10:40 -0000 @@ -2,30 +2,34 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tomcat; singleton:=true -Bundle-Version: 4.1.30.1 -Bundle-ClassPath: tomcatwrapper.jar, +Bundle-Version: 5.5.15 +Bundle-ClassPath: catalina-optional.jar, catalina.jar, - bootstrap.jar, commons-beanutils.jar, commons-collections.jar, + commons-digester-rss.jar, commons-digester.jar, + commons-el.jar, + commons-logging.jar, commons-logging-api.jar, commons-modeler.jar, - jakarta-regexp-1.3.jar, + regexp-1.3.jar, jasper-compiler.jar, jasper-runtime.jar, + jspapi.jar, + mx4j-impl.jar, mx4j-jmx.jar, - naming-common.jar, + mx4j.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 + tomcat-http.jar, + tomcat-util.jar, + regexp-1.3.jar, + servletapi5.jar, + log4j.jar Bundle-Activator: org.eclipse.tomcat.internal.TomcatPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -54,8 +58,7 @@ mx4j.util;x-internal:=true, org.apache.catalina;x-internal:=true, org.apache.catalina.connector;x-internal:=true, - org.apache.catalina.connector.http;x-internal:=true, - org.apache.catalina.connector.http10;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, @@ -69,7 +72,6 @@ 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, @@ -79,13 +81,11 @@ org.apache.coyote.http11;x-internal:=true, org.apache.coyote.http11.filters;x-internal:=true, org.apache.coyote.memory;x-internal:=true, - org.apache.coyote.tomcat4;x-internal:=true, org.apache.jasper;x-internal:=true, org.apache.jasper.compiler;x-internal:=true, - org.apache.jasper.logging;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.util, org.apache.jasper.xmlparser;x-internal:=true, org.apache.naming;x-internal:=true, org.apache.naming.factory;x-internal:=true, @@ -95,12 +95,9 @@ 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.compat;x-internal:=true, - org.apache.tomcat.util.handler;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.mx;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, 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.8 diff -u -r1.8 EclipseErrorReportValve.java --- src/org/eclipse/tomcat/internal/EclipseErrorReportValve.java 23 May 2005 03:58:04 -0000 1.8 +++ src/org/eclipse/tomcat/internal/EclipseErrorReportValve.java 6 Mar 2006 21:10:40 -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,18 +157,18 @@ * @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; + ServletRequest sreq = request; Throwable throwable = (Throwable) sreq.getAttribute(Globals.EXCEPTION_ATTR); - ServletResponse sresp = (ServletResponse) response; + ServletResponse sresp = response; if (sresp.isCommitted()) { return; } @@ -173,7 +185,7 @@ ; } - ServletResponse sresponse = (ServletResponse) response; + ServletResponse sresponse = response; if (sresponse instanceof HttpServletResponse) ((HttpServletResponse) sresponse).sendError (HttpServletResponse.SC_INTERNAL_SERVER_ERROR); @@ -219,15 +231,9 @@ Throwable throwable) 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()); + HttpServletResponse hres = response; + int statusCode = response.getStatus(); + String message = RequestUtil.filter(response.getMessage()); if (message == null) message = ""; @@ -373,9 +379,9 @@ */ protected void log(String message) { - Logger logger = container.getLogger(); + Logger logger = (Logger) container.getLogger(); if (logger != null) - logger.log(this.toString() + ": " + message); + logger.info(this.toString() + ": " + message); else System.out.println(this.toString() + ": " + message); @@ -390,9 +396,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); + logger.info(this.toString() + ": " + message, throwable); else { System.out.println(this.toString() + ": " + message); throwable.printStackTrace(System.out); 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.43 diff -u -r1.43 TomcatAppServer.java --- src/org/eclipse/tomcat/internal/TomcatAppServer.java 22 Jun 2005 15:29:56 -0000 1.43 +++ src/org/eclipse/tomcat/internal/TomcatAppServer.java 6 Mar 2006 21:10:40 -0000 @@ -11,27 +11,29 @@ package org.eclipse.tomcat.internal; import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; 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.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.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.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; @@ -91,27 +93,40 @@ * java.lang.String) */ public synchronized void start(int port, String hostAddress) throws CoreException { - this.hostAddress = hostAddress; + // if null passed for hostAddress, use local host + if (hostAddress == null) { + this.hostAddress = "127.0.0.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; + 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 = 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$ + embedded = new Embedded(new MemoryRealm()); + embedded.setRedirectStreams(true); + 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( @@ -119,14 +134,32 @@ 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; + } + }); + + // Install the assembled container hierarchy + PrintStream sysErr = System.err; + // reassign standard error to prevent Tomcat from writing + // its version message there. + PrintStream newOutput = new PrintStream(new FileOutputStream( + TomcatPlugin.getDefault().getStateLocation().toOSString() + + IPath.SEPARATOR + "tomcat.log")); //$NON-NLS-1$ + System.setErr(newOutput); + + embedded.setRedirectStreams(true); // 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$ + host = embedded.createHost(hostname, home + "/webapps"); //$NON-NLS-1$ //$NON-NLS-2$ // all request go to our only host engine.setDefaultHost(host.getName()); @@ -136,123 +169,112 @@ .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); - } - + System.setErr(sysErr); + } + // 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$ + StandardContext standardContext = (StandardContext) root; + standardContext.setWorkDir(getWorkingDirectory("ROOT")); //$NON-NLS-1$ + standardContext.setSaveConfig(false); } + 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 - } - } + host.addChild(root); + contexts.add(root); + updateSslPort(iAddress); if (this.port == 0) { - this.port = SocketUtil.findUnusedLocalPort(iAddress); //$NON-NLS-1$ + 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, //$NON-NLS-1$ + 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; - } - }); + 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); + } + + int maxProcessors = pref + .getInt(TomcatPlugin.PREF_MAX_PROCESSORS); + if (maxProcessors > 0) { + connector.setProperty("maxThreads",""+maxProcessors); + } + + int minProcessors = pref + .getInt(TomcatPlugin.PREF_MIN_PROCESSORS); + if (minProcessors > 0) { + connector.setProperty("minSpareThreads",""+minProcessors); + } + + if (this.sslPort > 0) { + connector.setRedirectPort(this.sslPort); + connector.setEnableLookups(true); + connector.setProperty("soTimeout",""+20000); + // 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); + } } + + // 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())); + System.setErr(newOutput); try { - embedded.addConnector(connector); - httpConnector = connector; + this.httpConnector = connector; + embedded.addConnector(this.httpConnector); + httpConnector.start(); } 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( @@ -306,91 +328,145 @@ * @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 - */ + 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); + } + String protocols = pref.getString(TomcatPlugin.PREF_SSL_PROTOCOLS); + if ((protocols != null) && (!("".equals(protocols.trim())))) { //$NON-NLS-1$ + connector.setProperty("protocols", protocols); + } + String protocolClassName = Http11Protocol.class.getName(); + connector.setProtocol(protocolClassName); + + String JSSEImplementationName = JSSEImplementation.class.getName(); + connector.setProperty("sslImplementation", JSSEImplementationName); + + String disableUploadTimeout = pref + .getString(TomcatPlugin.DISABLE_UPLOAD_TIMEOUT); + if ((disableUploadTimeout != null) + && (!("".equals(disableUploadTimeout.trim())))) { //$NON-NLS-1$ + connector.setProperty("disableUploadTimeout", disableUploadTimeout); + } + + String algorithm = pref.getString(TomcatPlugin.PREF_SSL_ALGORITHM); + if ((algorithm != null) && (!("".equals(algorithm.trim())))) { //$NON-NLS-1$ + connector.setProperty("algorithm", algorithm); + } + int maxProcessors = pref.getInt(TomcatPlugin.PREF_MAX_PROCESSORS); + if (maxProcessors > 0) { + // connector.setMaxProcessors(maxProcessors); + connector.setProperty("maxThreads", "" + maxProcessors); + } + int minProcessors = pref.getInt(TomcatPlugin.PREF_MIN_PROCESSORS); + if (minProcessors > 0) { + // connector.setMinProcessors(minProcessors); + connector.setProperty("minSpareThreads", "" + minProcessors); + } + // this is making use of org.apache.tomcat.util.IntrospectionUtils + connector.setProperty("disableUploadTimeout", "" + true); + String clientauth = pref + .getString(TomcatPlugin.PREF_CLIENT_AUTHENTICATION); + if ((clientauth != null) && (!("".equals(clientauth.trim())))) { //$NON-NLS-1$ + connector.setProperty("clientauth", clientauth); + } + + int acceptCount = pref.getInt(TomcatPlugin.PREF_ACCEPT_COUNT); + if (acceptCount > 0) { + connector.setProperty("backlog", "" + acceptCount); + } + + String keyStoreFile = pref.getString(TomcatPlugin.PREF_KEY_STORE_FILE); + if ((keyStoreFile != null) && (!("".equals(keyStoreFile.trim())))) { //$NON-NLS-1$ + connector.setProperty("keystore", keyStoreFile); + } + String keyStorePassword = pref + .getString(TomcatPlugin.PREF_KEY_STORE_PASSWORD); + if ((keyStorePassword != null) + && (!("".equals(keyStorePassword.trim())))) { //$NON-NLS-1$ + connector.setProperty("keypass", keyStorePassword); + } + // 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 = System.err; + // reassign standard error to prevent Coyote from writing + // its version message there. +// System.setErr(new PrintStream(new ByteArrayOutputStream())); + PrintStream newOutput; + try { + newOutput = new PrintStream(new FileOutputStream( + TomcatPlugin.getDefault().getStateLocation().toOSString() + + IPath.SEPARATOR + "tomcat.log")); + System.setErr(newOutput); + } catch (SecurityException e1) { + e1.printStackTrace(); + System.setErr(new PrintStream(new ByteArrayOutputStream())); + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + System.setErr(new PrintStream(new ByteArrayOutputStream())); + } catch (IllegalStateException e1) { + e1.printStackTrace(); + System.setErr(new PrintStream(new ByteArrayOutputStream())); + } //$NON-NLS-1$ + 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( @@ -477,10 +553,11 @@ } try { Context context = embedded.createContext(contextPath, path - .toOSString()); + .toOSString()); if (context instanceof StandardContext) { - ((StandardContext) context) - .setWorkDir(getWorkingDirectory(webappName)); + StandardContext standardContext = (StandardContext) context; + standardContext.setWorkDir(getWorkingDirectory(webappName)); + standardContext.setSaveConfig(false); } WebAppClassLoader webappLoader = new WebAppClassLoader(customLoader); 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 6 Mar 2006 21:10:40 -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; @@ -63,6 +66,9 @@ } public static TomcatPlugin getDefault() { + if (plugin == null) { + plugin = new TomcatPlugin(); + } return plugin; }