diff --git a/eclipse-tomcat55.patch b/eclipse-tomcat55.patch index a63fbd1..25bff35 100644 --- a/eclipse-tomcat55.patch +++ b/eclipse-tomcat55.patch @@ -104,170 +104,160 @@ 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 +@@ -4,7 +4,7 @@ + * 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; -- ++ * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +@@ -17,23 +17,24 @@ + 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 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.logger.FileLogger; --import org.apache.catalina.realm.MemoryRealm; --import org.apache.catalina.startup.Embedded; + 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.apache.coyote.http11.Http11Protocol; ++import org.apache.tomcat.util.net.jsse.JSSEImplementation; + 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 { + import org.eclipse.core.runtime.IConfigurationElement; + import org.eclipse.core.runtime.IExtension; + import org.eclipse.core.runtime.IExtensionPoint; +@@ -56,6 +57,8 @@ + * should not be used + */ + public final static int SSL_DISABLED = -1; ++ ++ private final static String NULL = null; + + private String hostAddress; + +@@ -76,7 +79,9 @@ + 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(); + +@@ -92,24 +97,34 @@ + * 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 { ++ // 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 { - 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$ ++ embedded = new Embedded(new MemoryRealm()); + 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(); -- ++ 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$ +@@ -120,14 +135,21 @@ + 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("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 ++ host = embedded.createHost(hostname, home + "webapps"); //$NON-NLS-1$ + + // all request go to our only host + engine.setDefaultHost(host.getName()); +@@ -136,8 +158,9 @@ + ((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 +@@ -150,7 +173,7 @@ + } + + // 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())); ++ 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) { +@@ -159,20 +182,13 @@ + } + root.setLoader(embedded.createLoader(this.getClass() + .getClassLoader())); - contexts.add(root); -- host.addChild(root); ++ + host.addChild(root); - - InetAddress iAddress = null; - if (this.hostAddress != null) { @@ -277,20 +267,19 @@ diff -u -r1.46 TomcatAppServer.java - // will default to all interfaces - } - } -- updateSslPort(iAddress); -- if (this.port == 0) { ++ 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)); -- } -- } -- ++ this.port = SocketUtil.findUnusedLocalPort(iAddress); + if (this.port == -1) { + throw new CoreException( + new Status( +@@ -184,51 +200,55 @@ + } + } + - // Create Connector - Connector connector = embedded.createConnector(null, this.port, - false); @@ -325,7 +314,45 @@ diff -u -r1.46 TomcatAppServer.java - connectorImpl.setConnectionTimeout(20000); - connectorImpl.setUseURIValidationHack(false); - connectorImpl.setDisableUploadTimeout(true); -- } ++ // 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 @@ -335,87 +362,52 @@ diff -u -r1.46 TomcatAppServer.java - 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 { + } ++ // 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; +@@ -236,21 +256,16 @@ + // 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); -- } -- ++ 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( -- "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) + // running = true; + TomcatPlugin.getDefault().setAppserver(this); + +@@ -307,82 +322,115 @@ + * @throws CoreException + */ + private void createSSLConnector(InetAddress iAddress, int sslport) - throws CoreException { -- // Create Connector ++ throws CoreException { ++ + // Create Connector - this.sslConnector = embedded.createConnector(null, sslport, false); - // Override defaults on CoyoteConnector - if (this.sslConnector instanceof CoyoteConnector) { @@ -479,7 +471,9 @@ diff -u -r1.46 TomcatAppServer.java - } - }); - } -- ++ //Defaults to local if IAddress is null ++ Connector connector = embedded.createConnector(iAddress.getHostAddress(), this.port,false); + - // add Connector to Tomcat - PrintStream sysErr = System.err; - // reassign standard error to prevent Coyote from writing @@ -489,875 +483,145 @@ diff -u -r1.46 TomcatAppServer.java - 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)); -- } ++ //--------------------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); ++ } + } + + /** +@@ -461,17 +509,16 @@ + */ + public synchronized void start(String webappName, IPath path, ClassLoader customLoader) + throws CoreException { - -- // 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)); ++ + if (!isStarted) { + start(port, hostAddress); - } -- // 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(); -- } ++ } + 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$ +@@ -486,7 +533,6 @@ + + WebAppClassLoader webappLoader = new WebAppClassLoader(customLoader); + context.setLoader(embedded.createLoader(webappLoader)); +- + host.addChild(context); + contexts.add(context); + } catch (Exception exc) { +@@ -601,4 +647,4 @@ + 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 @@ -1472,8 +736,7 @@ diff -u -r1.21 MANIFEST.MF 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-Version: 4.1.130.qualifier Bundle-ClassPath: tomcatwrapper.jar, - catalina.jar, - bootstrap.jar, diff --git a/eclipse.spec b/eclipse.spec index 154cd71..125ff48 100644 --- a/eclipse.spec +++ b/eclipse.spec @@ -19,7 +19,7 @@ Epoch: 1 Summary: An open, extensible IDE Name: eclipse Version: %{eclipse_majmin}.%{eclipse_micro} -Release: 3%{?dist} +Release: 4%{?dist} License: Eclipse Public License Group: Text Editors/Integrated Development Environments (IDE) URL: http://www.eclipse.org/ @@ -143,9 +143,9 @@ BuildRequires: ant-javamail ant-jdepend ant-junit ant-nodeps ant-swing ant-trax BuildRequires: jsch >= 0:0.1.28-1jpp BuildRequires: jakarta-commons-beanutils jakarta-commons-collections jakarta-commons-digester jakarta-commons-dbcp jakarta-commons-el jakarta-commons-fileupload jakarta-commons-launcher jakarta-commons-logging jakarta-commons-modeler jakarta-commons-pool BuildRequires: mx4j >= 2.1 -BuildRequires: tomcat5 >= 5.5.17 -BuildRequires: tomcat5-jasper >= 5.5.17 -BuildRequires: tomcat5-servlet-2.4-api >= 5.5.17 +BuildRequires: tomcat5 = 5.5.20 +BuildRequires: tomcat5-jasper = 5.5.20 +BuildRequires: tomcat5-servlet-2.4-api = 5.5.20 BuildRequires: lucene BuildRequires: lucene-devel BuildRequires: regexp @@ -241,9 +241,9 @@ Requires: ant-antlr ant-apache-bcel ant-apache-log4j ant-apache-oro ant-apache-r Requires: ant-javamail ant-jdepend ant-junit ant-nodeps ant-swing ant-trax ant-jsch Requires: jakarta-commons-beanutils jakarta-commons-collections jakarta-commons-digester jakarta-commons-dbcp jakarta-commons-el jakarta-commons-fileupload jakarta-commons-launcher jakarta-commons-logging jakarta-commons-modeler jakarta-commons-pool Requires: mx4j >= 2.1 -Requires: tomcat5 >= 5.5.17 -Requires: tomcat5-jasper >= 5.5.17 -Requires: tomcat5-servlet-2.4-api >= 5.5.17 +Requires: tomcat5 = 5.5.20 +Requires: tomcat5-jasper = 5.5.20 +Requires: tomcat5-servlet-2.4-api = 5.5.20 Requires: lucene, lucene-devel Requires: regexp @@ -390,9 +390,10 @@ pushd plugins/org.eclipse.tomcat %patch6 -p0 %patch7 -p0 popd -sed --in-place "s/4.1.130/5.5.17/g" \ +sed --in-place "s/4.1.130/5.5.20/g" \ features/org.eclipse.platform/build.xml \ plugins/org.eclipse.tomcat/build.xml \ + plugins/org.eclipse.tomcat/META-INF/MANIFEST.MF \ assemble.*.xml pushd plugins/org.eclipse.help.webapp %patch8 -p0 @@ -1739,6 +1740,9 @@ fi %{_libdir}/%{name}/plugins/org.eclipse.sdk_* %changelog +* Thu Mar 15 2007 Ben Konrath 3.2.2-4 +- Update to tomcat 5.5.20. + * Fri Mar 02 2007 Ben Konrath 3.2.2-3 - Uncomment 'this.generatePackagesStructure = true;' in ecj-gcj patch.