cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java EnableAdmin.java Jspc.java Main.java Property.java StopTomcat.java Tomcat.java
billbarker2004/02/24 23:25:49 Modified:src/share/org/apache/tomcat/resources LocalStrings.properties LocalStrings_es.properties LocalStrings_fr.properties LocalStrings_ja.properties web.dtd src/share/org/apache/tomcat/startup EmbededTomcat.java EnableAdmin.java Jspc.java Main.java Property.java StopTomcat.java Tomcat.java Log: Updating to the Apache License v2.0. Revision ChangesPath 1.17 +16 -1 jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings.properties Index: LocalStrings.properties === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings.properties,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- LocalStrings.properties 3 Nov 2001 03:50:50 - 1.16 +++ LocalStrings.properties 25 Feb 2004 07:25:48 - 1.17 @@ -1,5 +1,20 @@ # $Id$ # +# +# Copyright 1999-2004 The Apache Sofware Foundation. +# +# Licensed under the Apache License, Version 2.0 (the License); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an AS IS BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # Localized strings for package org.apache.tomcat.core # This is the default locale and is en_US 1.19 +15 -1 jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings_es.properties Index: LocalStrings_es.properties === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings_es.properties,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- LocalStrings_es.properties3 Nov 2001 03:50:50 - 1.18 +++ LocalStrings_es.properties25 Feb 2004 07:25:48 - 1.19 @@ -1,5 +1,19 @@ # $Id$ # +# +# Copyright 1999-2004 The Apache Sofware Foundation. +# +# Licensed under the Apache License, Version 2.0 (the License); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an AS IS BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Localized strings for package org.apache.tomcat.core # This is the Spanish locale and is es 1.8 +15 -1 jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings_fr.properties Index: LocalStrings_fr.properties === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings_fr.properties,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- LocalStrings_fr.properties29 Sep 2003 07:41:10 - 1.7 +++ LocalStrings_fr.properties25 Feb 2004 07:25:48 - 1.8 @@ -1,5 +1,19 @@ # $Id$ # +# +# Copyright 1999-2004 The Apache Sofware Foundation. +# +# Licensed under the Apache License, Version 2.0 (the License); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an AS IS BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Localized strings for package org.apache.tomcat.core # This is the French locale and is fr_FR 1.2 +15 -1 jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings_ja.properties Index: LocalStrings_ja.properties === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings_ja.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LocalStrings_ja.properties
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
billbarker2004/02/14 18:08:42 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Add a command line option to specify the 'modules.xml' file. Fix for bug #8634 Revision ChangesPath 1.68 +13 -0 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- EmbededTomcat.java12 Feb 2004 08:24:03 - 1.67 +++ EmbededTomcat.java15 Feb 2004 02:08:41 - 1.68 @@ -156,6 +156,7 @@ boolean help; boolean blocking=false; +String modulesFile = null; // prevent tomcat from starting. boolean nostart=false; @@ -220,6 +221,14 @@ attributes.put(config, s); } +/** + * Set the location of the codemodules.xml/code file, to be used by + * ServXml reader. code-modulesFile foo/code on the command line. + */ +public void setModulesFile(String mf) { + modulesFile = mf; +} + /** Tomcat will run in a sandboxed environment, under SecurityManager. * -sandbox on the command line */ @@ -412,6 +421,10 @@ if( null!=conf ) { if( dL0) debug( Using config file + conf); setModuleProperty( mid, config,conf ); + } + if( null != modulesFile ) { +if( dL 0 ) debug(Using modules file + modulesFile); + setModuleProperty(mid,moduleConfig, modulesFile); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java Main.java
billbarker2004/02/12 00:24:03 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Main.java Log: Adding a 'startb' option to start and block. Primarily for use with procrun. Revision ChangesPath 1.67 +32 -0 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- EmbededTomcat.java22 Sep 2003 09:18:58 - 1.66 +++ EmbededTomcat.java12 Feb 2004 08:24:03 - 1.67 @@ -154,6 +154,7 @@ boolean serverXml=true; boolean help; +boolean blocking=false; // prevent tomcat from starting. boolean nostart=false; @@ -182,6 +183,12 @@ debug( Debugging enabled ); } +/** + * set if we need to block. + */ +public void setStartb(boolean b) { + blocking = b; +} boolean noClassLoaders=false; @@ -611,6 +618,25 @@ contextM.start(); long time4=System.currentTimeMillis(); debug(Startup time + ( time4-time3 )); + if(blocking) { + await(); + } +} + +/** + * Wait for a shutdown. + */ +void await() { + while(blocking) { + synchronized(this) { + try{ + wait(); + blocking = false; + }catch(Exception ex) { + contextM.log(Error in await,ex); + } + } + } } /** Shutdown contextM - emmay/em exit the VM. @@ -621,12 +647,18 @@ */ public void shutdown() throws TomcatException { contextM.shutdown(); + if(blocking) { + notify(); + } } /** Stop contextM - will not exit the VM. */ public void stop() throws TomcatException { contextM.stop(); + if(blocking) { + notify(); + } } // Helpers and shortcuts 1.44 +2 -1 jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java Index: Main.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- Main.java 22 Sep 2003 09:18:58 - 1.43 +++ Main.java 12 Feb 2004 08:24:03 - 1.44 @@ -231,6 +231,7 @@ tasks.put(stop, org.apache.tomcat.startup.StopTomcat); tasks.put(enableAdmin, org.apache.tomcat.startup.EnableAdmin); tasks.put(start, org.apache.tomcat.startup.EmbededTomcat); +tasks.put(startb, org.apache.tomcat.startup.EmbededTomcat); tasks.put(run, org.apache.tomcat.startup.EmbededTomcat); tasks.put(jspc, org.apache.tomcat.startup.Jspc); tasks.put(estart, org.apache.tomcat.startup.EmbededTomcat); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 02/05/06 14:38:22 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Allow 'mini' to start with a configurable port. ( I use this to play with my Zaurus, and to get tomcat started in the smallest amount of time - that's about 2 secs ) Revision ChangesPath 1.65 +24 -3 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- EmbededTomcat.java24 Feb 2002 03:39:58 - 1.64 +++ EmbededTomcat.java6 May 2002 21:38:22 - 1.65 @@ -132,6 +132,9 @@ String home=null; String installDir=null; + +int httpPort=8080; +int ajpPort=0; Hashtable attributes=new Hashtable(); @@ -241,6 +244,20 @@ serverXml=false; } +/** Used from estart ( i.e. no server.xml, minimal config ) + */ +public void setHttpPort( int port ) { +httpPort=port; +} + +/** Set the port for ajp connections. + * If not set, ajp will not be enabled. + * Used for estart. + */ +public void setAjpPort( int port ) { +ajpPort=port; +} + /** Dummy, -run on the command line. */ public void setRun(boolean b) { @@ -670,8 +687,10 @@ public void addDefaultConnectors() throws TomcatException { - addEndpoint( 8080, null, null ); - addAjpEndpoint( 8007, null, null ); +if( httpPort 0 ) +addEndpoint( httpPort, null, null ); +if( ajpPort 0 ) +addAjpEndpoint( ajpPort, null, null ); } // execute() @@ -1073,13 +1092,15 @@ out.println(-config file (or -f file) Use this file instead of server.xml); out.println(-debug level Sets specified debug level on EmbeddedTomcat,); out.println( ContextManager, \Xml\ modules, and contexts); -out.println(-estartStarts Tomcat without reading server.xml); out.println(-help Show this usage report); out.println(-home dir Use this directory as tomcat.home); out.println(-install dir (or -i dir) Use this directory as tomcat.install); out.println(-jkconfWrite mod_jk configuration files, without); out.println( starting Tomcat); out.println(-sandbox Enable security manager (includes java.policy)); +out.println(-estartStarts Tomcat without reading server.xml); +out.println(-httpPort HTTP port to use in 'estart' mode); +out.println(-ajpPort AJP port to use in 'estart' mode); out.println(Note: the '-' on the options is optional.); out.println(); } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
larryi 02/02/23 19:39:58 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: If using server.xml, verify that some interceptors were added. If not, don't start since modules.xml or server.xml are likely missing. Revision ChangesPath 1.64 +13 -2 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- EmbededTomcat.java11 Jan 2002 07:24:17 - 1.63 +++ EmbededTomcat.java24 Feb 2002 03:39:58 - 1.64 @@ -552,6 +552,15 @@ contextM.addInterceptor( (BaseInterceptor) modules.elementAt( i ) ); } + +// if using server.xml and no new interceptors found, then quit +if( serverXml (modules.size() == +contextM.getContainer().getInterceptors().length)) { +debug(No configuration found.); +debug(The modules and/or server configuration files are missing.); +return; +} + contextM.init(); } catch( Throwable ex ) { if( ex instanceof InvocationTargetException ) { @@ -696,8 +705,10 @@ debug(Init time + (time2-time1)); } - // Start - start(); +if( initialized ) { +// Start +start(); +} } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
billbarker02/01/10 23:24:17 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Remove dependency on URLClassLoader that was preventing running under 1.1 Revision ChangesPath 1.63 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- EmbededTomcat.java9 Jan 2002 07:03:58 - 1.62 +++ EmbededTomcat.java11 Jan 2002 07:24:17 - 1.63 @@ -836,7 +836,7 @@ if( noClassLoaders ) { commonCL=this.getClass().getClassLoader(); if( commonCL == null ) { -commonCL=new java.net.URLClassLoader( new URL[] {}, null ); +commonCL=jdk11Compat.newClassLoaderInstance(new URL [] {}, null); } parentCL=commonCL; containerCL=commonCL; -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
billbarker02/01/08 23:03:58 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Remove setting of StreamHandlerFactory, since it's not there anymore. It will come back as a module, since it does nothing for Tomcat itself. It only provides a service to e.g. SOAP users. Revision ChangesPath 1.62 +0 -4 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- EmbededTomcat.java17 Dec 2001 05:27:05 - 1.61 +++ EmbededTomcat.java9 Jan 2002 07:03:58 - 1.62 @@ -553,10 +553,6 @@ modules.elementAt( i ) ); } contextM.init(); - Class shfc = containerCL.loadClass( - org.apache.tomcat.util.net.StreamHandlerFactory); - URL.setURLStreamHandlerFactory( - (URLStreamHandlerFactory)shfc.newInstance()); } catch( Throwable ex ) { if( ex instanceof InvocationTargetException ) { ex=((InvocationTargetException)ex).getTargetException(); -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 01/12/16 21:27:06 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Added few more comments, have been sitting in my workspace for a while. Revision ChangesPath 1.61 +160 -22 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- EmbededTomcat.java2001/11/18 06:20:57 1.60 +++ EmbededTomcat.java2001/12/17 05:27:05 1.61 @@ -81,6 +81,42 @@ * * All file paths _should_ be absolute. If not, you should set home and * make sure you include the PathSetter module before anything else. + * + * bExample1/b + * pre +// Assume EmbededTomcat and all common jars are in CLASSPATH +EmbededTomcat tomcat=new EmbededTomcat(); +tomcat.setInstallDir( installDir ); + +// tomcat.setDebug( debug ); +// tomcat.setAutoDeploy( false ); // no webapps/ is used +// tomcat.setEstart(true ); // server.xml will not be used + +tomcat.initClassLoaders(); + +if( explicitModules ) { + // For each module you want to add ( you must include a minimal set ) + int mid=tomcat.addModule( org.apache.tomcat.modules. ); + tomcat.setModuleProperty( mid, property, value ); +} else { + // Nothing - server.xml will be used if setEstart(false) ( default ) + // the default set will be used if setEstart(true) +} + +// If you don't add one explicitely, the defaults are used ( HTTP/8080, +// Ajp12/8007 for shutdown ) +// tomcat.addEndpoint( port, null, null ); +// You can add other connectors using addModule() + +// tomcat.addApplicationAdapter( myModule ); + +// If you also want webapps/ ( if you don addContext this is automatic ) +// tomcat.addAutoDeploy(); +// tomcat.addContext( path, docBase, null); + +tomcat.execute(); + + /pre * * @author Costin Manolache */ @@ -112,18 +148,22 @@ boolean nostart=false; public EmbededTomcat() { - // setDebug( 10 ); } // - + +/** Access to the ContextManager. + */ public ContextManager getContextManager() { return contextM; } // Properties - set before start -/** Debug for EmbededTomcat. +/** + * Debug for EmbededTomcat, enable debugging on tomcat + * and the LogEvents module. + * -debug debug on the command line */ public void setDebug( int debug ) { this.dL=debug; @@ -131,45 +171,85 @@ debug( Debugging enabled ); } + +boolean noClassLoaders=false; + +public void setNoClassloaders( boolean b ) { +noClassLoaders=b; +} + +/** Set the home dir for tomcat, where webapps/ will be located. + * -home dir on the command line. + */ public void setHome( String s ) { home=s; } +/** Set install dir for tomcat, where libs will be located. + * -install dir on the command line. + */ public void setInstall(String install) { this.installDir=install; - contextM.setInstallDir( install ); + contextM.setInstallDir( install ); if( dL 0 ) debug( setInstall + install); } +/** Set location of the server.xml file, to be used by ServerXml reader. + * Not used if EStart() is used. + * -config foo on the command line. + */ public void setConfig( String s ) { attributes.put(config, s); } -/** Tomcat will run in a sandboxed environment, under SecurityManager +/** Tomcat will run in a sandboxed environment, under SecurityManager. + * -sandbox on the command line */ public void setSandbox(boolean b) { attributes.put(sandbox, true); } +/** Generate Jk configuration, without running tomcat. + * Equivalent with -jkconf on the command line. + */ public void setJkconf(boolean b ) { attributes.put(jkconf, true); nostart=true; } -// First param +/** Dummy, -start on the command line. + */ public void setStart(boolean b) { // nothing, default mode } +/** Use 'embeded' configuration to start tomcat. + * + * If Estart is false ( the default ), we'll load server.xml and all + * the modules inside. + * + * If it is set to true, we'll load the a hard-coded set of modules. + * + * If you add explicitely your own set of module it
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
billbarker01/11/17 22:20:57 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Set the URLStreamHandlerFactory to allow webapps to create https URLS. With this servlets can create a java.net.URL(https:/...) with JSSE/OpenTLS either installed not on the system ClassLoader, or missing altogether. I also added a (very dangerous) shutdown method, to aid developers who want the advanced features. It is never called from a normal Tomcat. It is only for people that embed Tomcat in other applications. I'm agreeing with Remy here that adding an API that should have been there all along is not that big of a deal. Revision ChangesPath 1.60 +14 -0 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- EmbededTomcat.java2001/10/13 04:26:54 1.59 +++ EmbededTomcat.java2001/11/18 06:20:57 1.60 @@ -441,6 +441,10 @@ modules.elementAt( i ) ); } contextM.init(); + Class shfc = containerCL.loadClass( + org.apache.tomcat.util.net.StreamHandlerFactory); + URL.setURLStreamHandlerFactory( + (URLStreamHandlerFactory)shfc.newInstance()); } catch( Throwable ex ) { if( ex instanceof InvocationTargetException ) { ex=((InvocationTargetException)ex).getTargetException(); @@ -462,6 +466,16 @@ contextM.start(); long time4=System.currentTimeMillis(); debug(Startup time + ( time4-time3 )); +} + +/** Shutdown contextM - emmay/em exit the VM. + * This method is bintrinsically dangerous/b, so use at your own + * risk. It is very possible that the entire VM will shut down after + * calling this method. You should only call this method if you need + * to implement emadvanced/em functionality. + */ +public void shutdown() throws TomcatException { + contextM.shutdown(); } /** Stop contextM - will not exit the VM. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 01/09/22 15:03:47 Modified:src/share/org/apache/tomcat/core ContextManager.java src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Fixes from Johannes Brodwall [EMAIL PROTECTED] on EmbededTomcat and message for non-initialized contexts. Revision ChangesPath 1.194 +6 -5 jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java Index: ContextManager.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v retrieving revision 1.193 retrieving revision 1.194 diff -u -r1.193 -r1.194 --- ContextManager.java 2001/09/10 06:43:01 1.193 +++ ContextManager.java 2001/09/22 22:03:47 1.194 @@ -946,14 +946,15 @@ } req.setState(Request.STATE_CONTEXT_MAPPED ); - if( req.getContext() == null || - req.getContext().getState() != Context.STATE_READY ) { + if( req.getContext() == null) { + req.setAttribute(javax.servlet.error.message, + No context found); + } + if( req.getContext().getState() != Context.STATE_READY ) { // the context is not fully initialized. req.setAttribute(javax.servlet.error.message, - Application not available); + Context + req.getContext() + not ready); // return error code - the caller will handle it - // handleStatus( req, req.getResponse(), 503 ); - // service unavailable return 503; } 1.57 +5 -1 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- EmbededTomcat.java2001/09/20 03:44:06 1.56 +++ EmbededTomcat.java2001/09/22 22:03:47 1.57 @@ -317,6 +317,9 @@ public Context addContext( String ctxPath, URL docRoot, String hosts[] ) throws TomcatException { + if( ROOT.equals( ctxPath ) ) { + ctxPath=; + } if(dL0) debug( add context \ + hosts[0] + : + ctxPath + \ + docRoot ); @@ -345,6 +348,7 @@ } contextM.addContext( ctx ); + ctx.init(); return ctx; } catch( Exception ex ) { debug(exception adding context + ctxPath + / + docRoot, ex); @@ -494,7 +498,7 @@ setModuleProperty( mid, port, Integer.toString( port )) ; if( addr != null ) - setModuleProperty( mid, address, addr.toString()); + setModuleProperty( mid, address, addr.getHostAddress()); if( hostname != null ) setModuleProperty( mid, hostName, hostname ); return mid;
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
larryi 01/09/09 14:57:32 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: To better support separate install and home directories, establish install first, then default home if necessary. Revision ChangesPath 1.55 +7 -3 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- EmbededTomcat.java2001/09/09 02:01:56 1.54 +++ EmbededTomcat.java2001/09/09 21:57:32 1.55 @@ -386,16 +386,20 @@ throws TomcatException { if( initialized ) return; - if( home==null ) - home = System.getProperty(tomcat.home); if( installDir==null ) { installDir=IntrospectionUtils.guessInstall(tomcat.install, tomcat.home,tomcat.jar); if( dL 0 ) debug( Guessed installDir + installDir ); } + if( home==null ) { + home = System.getProperty(tomcat.home); +if( home == null ) +home = installDir; + if( dL 0 ) debug( Using homeDir + installDir ); +} - if( installDir==null ) installDir=home; contextM.setInstallDir( installDir ); +contextM.setHome( home ); try { setTomcatProperties();
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java Main.java
costin 01/09/08 17:46:28 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Main.java Log: Bug 3498 - revert to the documented system properties for the classpath. Thanks [EMAIL PROTECTED] (Arun Katkere) for noticing this. Revision ChangesPath 1.53 +5 -2 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- EmbededTomcat.java2001/09/07 04:25:20 1.52 +++ EmbededTomcat.java2001/09/09 00:46:28 1.53 @@ -668,10 +668,13 @@ // Class loader methods static final Jdk11Compat jdk11Compat=Jdk11Compat.getJdkCompat(); +/** System property used to set the application class loader, which + will be the parent of all webapps. +*/ public static final String PROPERTY_APPS_LOADER = - org.apache.tomcat.apps.loader; + org.apache.tomcat.apps.classpath; public static final String PROPERTY_CONTAINER_LOADER = - org.apache.tomcat.container.loader; + org.apache.tomcat.container.classpath; /** Initialize class loaders with the defaults, if not set 1.41 +8 -2 jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java Index: Main.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- Main.java 2001/09/07 04:25:20 1.40 +++ Main.java 2001/09/09 00:46:28 1.41 @@ -1,4 +1,4 @@ -/* $Id: Main.java,v 1.40 2001/09/07 04:25:20 costin Exp $ +/* $Id: Main.java,v 1.41 2001/09/09 00:46:28 costin Exp $ * * * The Apache Software License, Version 1.1 @@ -94,8 +94,14 @@ * @author Mel Martinez [EMAIL PROTECTED] */ public class Main{ +/** System property that can be used to pass additional classpath + to the 'common' loader, used to load EmbededTomcat and the + core. EmbededTomcat will load the container int a separate + loader, and each applications will be set up int its own loader. + The loader configurator module may use additional properties +*/ public static final String PROPERTY_COMMON_LOADER = - org.apache.tomcat.common.loader; + org.apache.tomcat.common.classpath; String installDir; String libDir;
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 01/09/08 19:01:56 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Bug 3483: install.dir and home.dir not working as expected ( however setting tomcat.home in server.xml did work fine - and is the best way to set multi-homed tomcat ). Bug reported by Ben Kelley Submitted by: [EMAIL PROTECTED] Revision ChangesPath 1.54 +6 -7 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- EmbededTomcat.java2001/09/09 00:46:28 1.53 +++ EmbededTomcat.java2001/09/09 02:01:56 1.54 @@ -22,7 +22,7 @@ lib/common, and without lib/container. It'll deal with setting a separate class loader for container and applications. - - home property must be set, or TOMCAT_HOME env. + - tomcat.install or tomcat.home property must be set ( from TOMCAT_HOME env.) */ @@ -388,15 +388,14 @@ if( initialized ) return; if( home==null ) home = System.getProperty(tomcat.home); - if( home==null ) { - IntrospectionUtils.guessInstall(tomcat.install, - tomcat.home,tomcat.jar); - home = System.getProperty(tomcat.home); - if( dL 0 ) debug( Guessed home + home ); + if( installDir==null ) { + installDir=IntrospectionUtils.guessInstall(tomcat.install, +tomcat.home,tomcat.jar); + if( dL 0 ) debug( Guessed installDir + installDir ); } - contextM.setHome( home ); if( installDir==null ) installDir=home; + contextM.setInstallDir( installDir ); try { setTomcatProperties();
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
larryi 01/09/01 08:03:36 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Update usage information. Add help option that displays the usage information. Revision ChangesPath 1.51 +16 -6 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- EmbededTomcat.java2001/08/23 15:13:47 1.50 +++ EmbededTomcat.java2001/09/01 15:03:36 1.51 @@ -106,6 +106,7 @@ boolean autoDeploy=true; boolean serverXml=true; +boolean help; // prevent tomcat from starting. boolean nostart=false; @@ -168,6 +169,10 @@ public void setRun(boolean b) { setStart(true); } + +public void setHelp(boolean b) { + help=b; +} // Generic properties @@ -531,6 +536,10 @@ public void execute1() throws Exception { if( args!=null ) processArgs( args ); +if( help ) { +printUsage(); +return; +} // Init if( ! initialized ) { long time1=System.currentTimeMillis(); @@ -827,17 +836,18 @@ PrintStream out=System.out; out.println(Usage: java org.apache.tomcat.startup.EmbeddedTomcat {options}); out.println( Options are:); -out.println(-ajpid fileUse this file instead of conf/ajp12.id); -out.println( Use with -stop option); out.println(-config file (or -f file) Use this file instead of server.xml); -out.println(-enableAdmin Updates admin webapp config to \trusted\); - out.println(-help (or help)Show this usage report); +out.println(-debug level Sets specified debug level on EmbeddedTomcat,); +out.println( ContextManager, \Xml\ modules, and contexts); +out.println(-estartStarts Tomcat without reading server.xml); +out.println(-help Show this usage report); out.println(-home dir Use this directory as tomcat.home); out.println(-install dir (or -i dir) Use this directory as tomcat.install); +out.println(-jkconfWrite mod_jk configuration files, without); +out.println( starting Tomcat); out.println(-sandbox Enable security manager (includes java.policy)); - out.println(-stop Shut down currently running Tomcat); +out.println(Note: the '-' on the options is optional.); out.println(); -out.println(In the absence of \-enableAdmin\ and \-stop\, Tomcat will be started); } // Override
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 01/08/23 08:13:47 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Added the -jkconf option. Revision ChangesPath 1.50 +13 -0 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- EmbededTomcat.java2001/08/22 04:55:33 1.49 +++ EmbededTomcat.java2001/08/23 15:13:47 1.50 @@ -106,6 +106,9 @@ boolean autoDeploy=true; boolean serverXml=true; + +// prevent tomcat from starting. +boolean nostart=false; public EmbededTomcat() { // setDebug( 10 ); @@ -147,6 +150,11 @@ attributes.put(sandbox, true); } +public void setJkconf(boolean b ) { + attributes.put(jkconf, true); + nostart=true; +} + // First param public void setStart(boolean b) { // nothing, default mode @@ -422,6 +430,11 @@ } public void start() throws TomcatException { + if( nostart ) { + debug(Tomcat will not start - configuration only mode ); + contextM.shutdown(); + return; + } long time3=System.currentTimeMillis(); contextM.start(); long time4=System.currentTimeMillis();
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java Main.java
costin 01/08/21 21:43:24 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Main.java Log: Enable Main to set the right policy, in case we don't use scripts or the scripts are broken ( bad path, etc - it happens to me, it may happen to someone else ). Java -jar is now closer to the sh/bat scripts. Also clean up more messages. Revision ChangesPath 1.48 +19 -5 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- EmbededTomcat.java2001/08/21 05:29:27 1.47 +++ EmbededTomcat.java2001/08/22 04:43:23 1.48 @@ -143,7 +143,6 @@ /** Tomcat will run in a sandboxed environment, under SecurityManager */ public void setSandbox(boolean b) { - debug(Sandbox enabled); attributes.put(sandbox, true); } @@ -254,13 +253,15 @@ /** Init tomcat using server.xml-style configuration */ public void addServerXmlModules() throws TomcatException { - debug( Using server.xml + attributes.get( config )); + String conf=(String)attributes.get( config ); + addModule( org.apache.tomcat.modules.config.PathSetter); int mid=addModule( org.apache.tomcat.modules.config.ServerXmlReader); - if( null!=attributes.get( config ) ) - setModuleProperty( mid, config, -(String)attributes.get(config) ); + if( null!=conf ) { + if( dL0) debug( Using config file + conf); + setModuleProperty( mid, config,conf ); + } } public void addDefaultModules() @@ -408,6 +409,9 @@ modules.elementAt( i ) ); } contextM.init(); + } catch( InvocationTargetException rex ) { + debug(exception initializing ContextManager, rex.getTargetException()); + throw new TomcatException( EmbededTomcat.initContextManager, ex.getTargetExeption() ); } catch( Exception ex ) { debug(exception initializing ContextManager, ex); throw new TomcatException( EmbededTomcat.initContextManager, ex ); @@ -501,6 +505,16 @@ directly the methods you need. */ public void execute() throws Exception { + final EmbededTomcat et=this; + jdk11Compat.doPrivileged( new Action() { + public Object run() throws Exception { + et.execute1(); + return null; + } + }, jdk11Compat.getAccessControlContext()); +} + +public void execute1() throws Exception { if( args!=null ) processArgs( args ); // Init 1.38 +17 -14jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java Index: Main.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- Main.java 2001/08/21 05:35:05 1.37 +++ Main.java 2001/08/22 04:43:23 1.38 @@ -1,4 +1,4 @@ -/* $Id: Main.java,v 1.37 2001/08/21 05:35:05 costin Exp $ +/* $Id: Main.java,v 1.38 2001/08/22 04:43:23 costin Exp $ * * * The Apache Software License, Version 1.1 @@ -178,6 +178,10 @@ IntrospectionUtils.displayClassPath(Main classpath: , commonCP ); } +// initSecurityFile is intended to simplify sandbox config, the shell +// script can't normalize the path. We also want java -jar to behave the same, +// without requiring anything difficult. + /** If -sandbox parameter is found ( the first after the action ), we'll * load a sandbox with the policy in install/conf/tomcat.policy. This * has to happen before loading any class or constructing the loader, or @@ -190,20 +194,19 @@ * so that all system classes have permissions. */ public void initSecurityFile() { -// if( args.length 1 -// -sandbox.equals( args[1] ) ) { -// if( null == System.getProperty(java.security.policy)) { -// File f=null; -// String policyFile=installDir + File.separator + conf + -// File.separator + tomcat.policy; + if( args.length 1 + -sandbox.equals( args[1] ) ) { + if( null == System.getProperty(java.security.policy)) { + File f=null; + String policyFile=installDir + File.separator + conf + + File.separator +
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java Main.java
costin 01/08/21 21:55:33 Modified:src/shell shutdown.sh startup.sh tomcat.sh src/share/org/apache/tomcat/startup EmbededTomcat.java Main.java Log: Fix few mistakes, let user override the policy ( but check if the file exists). That can be improved, but it should be enough for now. Revision ChangesPath 1.3 +1 -9 jakarta-tomcat/src/shell/shutdown.sh Index: shutdown.sh === RCS file: /home/cvs/jakarta-tomcat/src/shell/shutdown.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- shutdown.sh 1999/12/05 17:02:42 1.2 +++ shutdown.sh 2001/08/22 04:55:33 1.3 @@ -1,16 +1,8 @@ #! /bin/sh # -# $Id: shutdown.sh,v 1.2 1999/12/05 17:02:42 harishp Exp $ +# $Id: shutdown.sh,v 1.3 2001/08/22 04:55:33 costin Exp $ # Shell script to shutdown the server - -# There are other, simpler commands to shutdown the runner. The two -# commented commands good replacements. The first works well with -# Java Platform 1.1 based runtimes. The second works well with -# Java2 Platform based runtimes. - -#jre -cp runner.jar:servlet.jar:classes org.apache.tomcat.shell.Shutdown $* -#java -cp runner.jar:servlet.jar:classes org.apache.tomcat.shell.Shutdown $* BASEDIR=`dirname $0` 1.3 +1 -9 jakarta-tomcat/src/shell/startup.sh Index: startup.sh === RCS file: /home/cvs/jakarta-tomcat/src/shell/startup.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- startup.sh1999/12/05 17:02:42 1.2 +++ startup.sh2001/08/22 04:55:33 1.3 @@ -1,16 +1,8 @@ #! /bin/sh # -# $Id: startup.sh,v 1.2 1999/12/05 17:02:42 harishp Exp $ +# $Id: startup.sh,v 1.3 2001/08/22 04:55:33 costin Exp $ # Shell script to startup the server - -# There are other, simpler commands to startup the runner. The two -# commented commands good replacements. The first works well with -# Java Platform 1.1 based runtimes. The second works well with -# Java2 Platform based runtimes. - -#jre -cp runner.jar:servlet.jar:classes org.apache.tomcat.shell.Startup $* -#java -cp runner.jar:servlet.jar:classes org.apache.tomcat.shell.Startup $* BASEDIR=`dirname $0` 1.27 +2 -2 jakarta-tomcat/src/shell/tomcat.sh Index: tomcat.sh === RCS file: /home/cvs/jakarta-tomcat/src/shell/tomcat.sh,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- tomcat.sh 2001/08/21 05:55:50 1.26 +++ tomcat.sh 2001/08/22 04:55:33 1.27 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: tomcat.sh,v 1.26 2001/08/21 05:55:50 costin Exp $ +# $Id: tomcat.sh,v 1.27 2001/08/22 04:55:33 costin Exp $ # Shell script to start and stop the server @@ -122,7 +122,7 @@ ## Process options # add tomcat.policy - even if we don't use sandbox, it doesn't hurt -TOMCAT_OPTS=$TOMCAT_OPTS -Djava.security.policy==${TOMCAT_HOME}/lib/tomcat.policy +TOMCAT_OPTS=$TOMCAT_OPTS -Djava.security.policy==${TOMCAT_HOME}/conf/tomcat.policy # We start the server up in the background for a couple of reasons: 1.49 +5 -4 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- EmbededTomcat.java2001/08/22 04:43:23 1.48 +++ EmbededTomcat.java2001/08/22 04:55:33 1.49 @@ -9,6 +9,7 @@ import org.apache.tomcat.util.IntrospectionUtils; import java.security.*; import java.util.*; +import java.lang.reflect.*; /* EmbededTomcat is the bean you use to embed tomcat in your application. Main is a wrapper that will guess TOMCAT_HOME and dispatch to @@ -409,10 +410,10 @@ modules.elementAt( i ) ); } contextM.init(); - } catch( InvocationTargetException rex ) { - debug(exception initializing ContextManager, rex.getTargetException()); - throw new TomcatException( EmbededTomcat.initContextManager, ex.getTargetExeption() ); - } catch( Exception ex ) { + } catch( Throwable ex ) { + if( ex instanceof InvocationTargetException ) { + ex=((InvocationTargetException)ex).getTargetException(); + } debug(exception initializing ContextManager, ex); throw new TomcatException( EmbededTomcat.initContextManager, ex ); }
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 01/08/20 22:29:27 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Ok, this is the big one ! I did a lot of work on this area, now things should be much cleaner and simpler ( by my taste ). First, most of the settings from Main.java are now part of EmbededTomcat. We expect people to use EmbededTomcat to include tomcat in other apps, not Main - since we need to provide a reach interface and more control. Main.java is now reduced to the same role as java -jar ( and is equivalent with it - or should be ). It just create a simple class loader including all the classes in common, and then pass control to EmbededTomcat, which does all the real work. In other words, to embed tomcat you need to include all the common in a classpath, then use EmbeddedTomcat as a regular bean - set properties and call the methods you need. EmbededTomcat will set the container environment ( which must be separated in another class loader - security and isolation ). I also added a bit more documentation. An important change - there is no dependency between ET and container classes ( see 2 lines above ). EmbededTomcat now works in both modes - if setEstart is used ( equivalent with java -jar tomcat.jar estart ), it'll use the hardcoded modules ( or an alternate set, depending on your code ). The default, or if start command is used on the command line, is to load tomcat using server.xml, as before. Revision ChangesPath 1.47 +586 -225 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- EmbededTomcat.java2001/08/17 04:23:00 1.46 +++ EmbededTomcat.java2001/08/21 05:29:27 1.47 @@ -5,35 +5,83 @@ import org.apache.tomcat.core.*; import org.apache.tomcat.util.log.*; -import org.apache.tomcat.modules.server.*; +import org.apache.tomcat.util.compat.*; +import org.apache.tomcat.util.IntrospectionUtils; import java.security.*; import java.util.*; +/* EmbededTomcat is the bean you use to embed tomcat in your application. + Main is a wrapper that will guess TOMCAT_HOME and dispatch to + tasks performing different actions, including EmbededTomcat. + +*/ + +/* Required setup: + - EmbededTomcat is assumed to be loaded in the same class loader with + lib/common, and without lib/container. It'll deal with setting a separate + class loader for container and applications. + + - home property must be set, or TOMCAT_HOME env. + +*/ + /** + * + * Use this class to embed tomcat in your application. If all you want is to + * start/stop tomcat, with minimal customization, you can use Main.main() * - * Wrapper around ContextManager. Use this class to embed tomcat in your - * application if you want to use API-based configuration ( instead - * or in addition to server.xml ). + * This class is designed as a java bean, where you set different properties, + * then call methods to perform actions. The main method is execute, that + * will start tomcat. Few other methods allow to perform different other tasks. + * + * EmbededTomcat is usable as an ant task as well, using the TaskAdapter. + * ( see sample - TODO XXX ). + * + * Adding tomcat to your application: + * + * - Create a java class that will act as adapter and start tomcat ( and + *hold your customization code ). The class and all the files in + *TOMCAT_HOME/lib/common must be available in the class loader. + *lib/container and lib/apps should _not_ be visible, EmbededTomcat + *will handle that. All the application files you want visible from + *tomcat must be included as well. + *ADVANCED1. Completely separated classloader * - * The order is important: + * - In your adapter, create an instance of EmbededTomcat. * - * 1. set properties like workDir and debug - * 2. add all interceptors including your application-specific - * 3. add the endpoints - * 4. add at least the root context ( you can add more if you want ) - * 5. call start(). The web service will be operational. - * 6. You can add/remove contexts - * 7. stop(). + * - set properties you want to customize. * - * You can add more contexts after start, but interceptors and - * endpoints must be set before the first context and root must be - * set before start(). + * - add all interceptors including your application-specific. That includes + * the connector modules ( shortcuts are provided for common sets of + * modules and for common connector configuration ). + * + * - add
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 01/06/08 20:28:50 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: A bit of cleanup and reorganization. EmbededTomcat is the main entry point and starter for tomcat. Tomcat.java is a nice program that can execute a number of tasks, process the command line, etc. It delegates to EmbededTomcat whatever is related with starting tomcat, and to other objects to stop, etc. Main is a java wrapper that sets the class paths for clean separation and executes Tomcat. With a bit of time, we should refactor Main in a general-purpose application starter ( in tomcat/util ), and play a bit more with command line processing and introspection ( maybe with a simple properties file that would drive Main ). Tomcat.java can disapear if Main can take over the dispatching and command line processing. The original idea was to use patterns like in ant for Main - only with command line options instead of XML attributes. A services-like properties file could allow Main to work with any application following the setXXX and execute() patterns. No time for that right now - but if anyone wants to try I would be happy to help. Revision ChangesPath 1.44 +242 -16 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- EmbededTomcat.java2001/02/01 06:24:34 1.43 +++ EmbededTomcat.java2001/06/09 03:28:50 1.44 @@ -46,18 +46,29 @@ protected Vector requestInt=null; protected Vector connectors=new Vector(); +ClassLoader parentClassLoader; +ClassLoader appsClassLoader; +ClassLoader commonClassLoader; +ClassLoader containerClassLoader; +String home=.; +String install=null; + +boolean sandbox=false; + // configurable properties protected int debug=0; public EmbededTomcat() { } - -// Properties - set before start +// + public ContextManager getContextManager() { return contextM; } +// Properties - set before start + /** Set debugging - must be called before anything else */ public void setDebug( int debug ) { @@ -65,7 +76,49 @@ contextM.setDebug( debug ); } +public void setParentClassLoader( ClassLoader cl ) { + this.parentClassLoader=cl; +} + +public void setCommonClassLoader( ClassLoader cl ) { + this.commonClassLoader=cl; +} + +public void setAppsClassLoader( ClassLoader cl ) { + this.appsClassLoader=cl; +} + +public void setContainerClassLoader( ClassLoader cl ) { + this.containerClassLoader=cl; +} + + + +public void setHome( String s ) { + home=s; + //System.getProperties().put(ContextManager.TOMCAT_HOME, s); + contextM.setHome( s ); +} + +public void setInstall(String install) { + this.install=install; + //System.getProperties().put( ContextManager.TOMCAT_INSTALL, install); + contextM.setInstallDir( install ); +} + +/** Tomcat will run in a sandboxed environment, under SecurityManager + */ +public void setSandbox( boolean b ) { + sandbox=b; +} + +// Access tomcat state +public boolean isInitialized() { + return initialized; +} + + // Application Modules /** This is an adapter object that provides callbacks into the @@ -146,7 +199,7 @@ // Context add/remove -boolean initialized=false; +protected boolean initialized=false; /** Add and init a context. Must be called after all modules are added. */ @@ -234,6 +287,18 @@ protected void initContextManager() throws TomcatException { + if( initialized ) return; + if ( sandbox ) + contextM.setProperty( sandbox, true); + + ClassLoader cl=parentClassLoader; + + if (cl==null) cl=this.getClass().getClassLoader(); + contextM.setParentLoader(cl); + contextM.setCommonLoader(commonClassLoader); + contextM.setContainerLoader(containerClassLoader); + contextM.setAppsLoader(appsClassLoader); + if(requestInt==null) initDefaultInterceptors(); for( int i=0; i requestInt.size() ; i++ ) { @@ -250,16 +315,172 @@ initialized=true; } -// no AutoSetup ! +
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 01/06/08 20:33:24 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Ops, commited a bit too much... Removed the serialization/deserialization of tomcat snapshots ( it doesn't work anyway without the additional transient and Serializable), better to keep things simple. Revision ChangesPath 1.45 +1 -76 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- EmbededTomcat.java2001/06/09 03:28:50 1.44 +++ EmbededTomcat.java2001/06/09 03:33:24 1.45 @@ -330,7 +330,7 @@ processArgs(args); // Configure the server - tryConfigSnapshot(); + // tryConfigSnapshot(); // tryProperties(); // tryServerXml(); // tryDefault(); @@ -341,84 +341,12 @@ if( ! initialized ) { initContextManager(); - // Save config for later use - writeSnapshot(); } // Start start(); } -// Snapshot -String confSnap=tomcatconfig.snapshot; -boolean modified=true; -protected boolean fastStart=false; // default - -/** Save a snapshot of the server config, for fast start - */ -public void writeSnapshot() throws TomcatException { - if( fastStart modified ) { - try { - long time1=System.currentTimeMillis(); - OutputStream out= - new BufferedOutputStream(new FileOutputStream( confSnap )); - ObjectOutputStream oos=new ObjectOutputStream( out ); - oos.writeObject( contextM ); - oos.close(); - long time2=System.currentTimeMillis(); - log( Snapshot save time + ( time2-time1)); - } catch( IOException ex ) { - log(Error saving state , ex ); - } - } -} - -public void tryConfigSnapshot() { - if( fastStart ) { // ! modified - try { - long time1=System.currentTimeMillis(); - - File f=new File( confSnap ); - if( ! f.exists() ) { - return; - } - // Check if f is newer than server.xml, etc - - InputStream in= - new BufferedInputStream(new FileInputStream( confSnap )); - ObjectInputStream ois=new ObjectInputStream( in ); - contextM=(ContextManager)ois.readObject(); - - // check dependencies - - // Post read fixes - ois.close(); - long time2=System.currentTimeMillis(); - System.out.println( Snapshot read time + ( time2-time1)); - initialized=true; - } catch( Exception ex ) { - ex.printStackTrace(); - log( Error reading snapshot , ex ); - } - } -} - -private boolean isFastStart() { - return fastStart ! modified; -} - -private void checkConfigSnapshot() { - try { - FileInputStream in=new FileInputStream( confSnap ); - ObjectInputStream ois=new ObjectInputStream( in ); - ContextManager cm=(ContextManager)ois.readObject(); - } catch( Exception ex ) { - log(Error reading state , ex ); - } - modified=true; -} - - // Main protected String args[]=null; @@ -433,8 +361,6 @@ if (arg.equals(-sandbox)) { sandbox=true; - } else if (arg.equals(-fastStart)) { - fastStart=true; } else if (arg.equals(-h) || arg.equals(-home)) { i++; if (i args.length) @@ -454,7 +380,6 @@ public static void main(String args[] ) { EmbededTomcat tomcat=new EmbededTomcat(); - tomcat.fastStart=true; try { tomcat.setArgs( args ); tomcat.execute();
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java Tomcat.java
costin 01/01/31 22:24:35 Modified:src/etc server.xml src/share/org/apache/tomcat/startup EmbededTomcat.java Tomcat.java Log: Use ServerXmlReader and ContextXmlReader. Revision ChangesPath 1.65 +3 -0 jakarta-tomcat/src/etc/server.xml Index: server.xml === RCS file: /home/cvs/jakarta-tomcat/src/etc/server.xml,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- server.xml2001/02/01 06:08:48 1.64 +++ server.xml2001/02/01 06:24:34 1.65 @@ -37,6 +37,9 @@ -- ContextInterceptor +className="org.apache.tomcat.modules.config.ContextXmlReader" / + +ContextInterceptor className="org.apache.tomcat.modules.config.AutoSetup" / !-- Generate includeable Apache configuration files for mod_jserv 1.43 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- EmbededTomcat.java2001/02/01 05:27:34 1.42 +++ EmbededTomcat.java2001/02/01 06:24:34 1.43 @@ -274,7 +274,7 @@ protected String moduleSet2[] = { "org.apache.tomcat.modules.config.PathSetter", - "org.apache.tomcat.modules.config.ServerXmlInterceptor", + "org.apache.tomcat.modules.config.ServerXmlReader", }; protected void initDefaultInterceptors() { 1.50 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java Index: Tomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- Tomcat.java 2001/02/01 05:27:33 1.49 +++ Tomcat.java 2001/02/01 06:24:34 1.50 @@ -70,7 +70,7 @@ PathSetter pS=new PathSetter(); tcat.addInterceptor( pS ); - ServerXmlInterceptor sxmlConf=new ServerXmlInterceptor(); + ServerXmlReader sxmlConf=new ServerXmlReader(); sxmlConf.setConfig( configFile ); tcat.addInterceptor( sxmlConf ); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 00/12/31 17:58:39 Modified:src/share/org/apache/tomcat/startup EmbededTomcat.java Added: src/share/org/apache/tomcat/modules/config AutoSetup.java DefaultCMSetter.java LoaderInterceptor11.java LoaderInterceptor12.java PolicyInterceptor.java src/share/org/apache/tomcat/modules/generators ErrorHandler.java src/share/org/apache/tomcat/modules/loggers LogEvents.java Removed: src/share/org/apache/tomcat/context AutoSetup.java DefaultCMSetter.java ErrorHandler.java LoaderInterceptor11.java LoaderInterceptor12.java LogEvents.java PolicyInterceptor.java Log: Reorganized modules in tomcat.context, based on module type ( config, generators, loggers ) Revision ChangesPath 1.1 jakarta-tomcat/src/share/org/apache/tomcat/modules/config/AutoSetup.java Index: AutoSetup.java === /* * * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in *the documentation and/or other materials provided with the *distribution. * * 3. The end-user documentation included with the redistribution, if *any, must include the following acknowlegement: * "This product includes software developed by the *Apache Software Foundation (http://www.apache.org/)." *Alternately, this acknowlegement may appear in the software itself, *if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software *Foundation" must not be used to endorse or promote products derived *from this software without prior written permission. For written *permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" *nor may "Apache" appear in their names without prior written *permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * http://www.apache.org/. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.context; import org.apache.tomcat.core.*; import org.apache.tomcat.util.*; import java.io.*; import java.net.*; import java.util.*; /** * Prepare a context manager - expand wars in webapps and * automaticly install contexts * * This happens _before_ Context.init() * * @author [EMAIL PROTECTED] */ public class AutoSetup extends BaseInterceptor { int debug=0; Hashtable definedContexts=new Hashtable(); public AutoSetup() { } /** This will add all contexts to the default host. *We need a mechanism ( or convention ) to configure * virtual hosts too */ public void engineStart(ContextManager cm) throws TomcatException { String home=cm.getHome(); File webappD=new File(home + "/webapps"); if (! webappD.exists() || ! webappD.isDirectory()) { log("No webapps/ directory " + webappD ); return ; // nothing to set up } Enumeration en=cm.getContexts();
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 00/12/31 18:07:24 Modified:src/etc server.xml src/share/org/apache/tomcat/modules/aaa AccessInterceptor.java src/share/org/apache/tomcat/modules/config DefaultCMSetter.java LoaderInterceptor11.java LoaderInterceptor12.java PolicyInterceptor.java RelativePathFix.java src/share/org/apache/tomcat/modules/generators ErrorHandler.java StaticInterceptor.java src/share/org/apache/tomcat/startup EmbededTomcat.java Log: Fixed import statements. Revision ChangesPath 1.59 +25 -21jakarta-tomcat/src/etc/server.xml Index: server.xml === RCS file: /home/cvs/jakarta-tomcat/src/etc/server.xml,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- server.xml2000/12/29 01:34:40 1.58 +++ server.xml2001/01/01 02:07:23 1.59 @@ -99,13 +99,15 @@ !-- Interceptors -- ContextInterceptor -className="org.apache.tomcat.context.DefaultCMSetter" / +className="org.apache.tomcat.modules.config.DefaultCMSetter" / !-- - ContextInterceptor className="org.apache.tomcat.context.LogEvents" + ContextInterceptor +className="org.apache.tomcat.modules.loggers.LogEvents" -- -ContextInterceptor className="org.apache.tomcat.context.AutoSetup" / +ContextInterceptor +className="org.apache.tomcat.modules.config.AutoSetup" / ContextInterceptor className="org.apache.tomcat.facade.WebXmlReader" / @@ -113,21 +115,21 @@ !-- Uncomment out if you have JDK1.2 and want to implement the Java SecurityManager ContextInterceptor -className="org.apache.tomcat.context.PolicyInterceptor" / +className="org.apache.tomcat.modules.config.PolicyInterceptor" / -- !-- For JDK1.2 and URLClassLoader ContextInterceptor -className="org.apache.tomcat.context.LoaderInterceptor12" / +className="org.apache.tomcat.modules.config.LoaderInterceptor12" / -- ContextInterceptor -className="org.apache.tomcat.context.LoaderInterceptor11" / +className="org.apache.tomcat.modules.config.LoaderInterceptor11" / !-- Default Error handler -- ContextInterceptor -className="org.apache.tomcat.context.ErrorHandler" / +className="org.apache.tomcat.modules.generators.ErrorHandler" / ContextInterceptor @@ -137,26 +139,27 @@ !-- Session interceptor will extract the session id from cookies and deal with URL rewriting ( by fixing the URL ) -- -RequestInterceptor className="SessionId" / +RequestInterceptor +className="org.apache.tomcat.modules.session.SessionId" / !-- Find the container ( context and prefix/extension map ) for a request. -- RequestInterceptor -className="org.apache.tomcat.request.SimpleMapper1" +className="org.apache.tomcat.modules.mappers.SimpleMapper1" debug="0" / !-- fix the context class loader, other JDK1.2 specific code RequestInterceptor -className="org.apache.tomcat.request.Jdk12Interceptor" +className="org.apache.tomcat.modules.mappers.Jdk12Interceptor" debug="0" / -- !-- Non-standard invoker, for backward compat. ( /servlet/* ) -- RequestInterceptor -className="org.apache.tomcat.request.InvokerInterceptor" -debug="0" / + className="org.apache.tomcat.modules.generators.InvokerInterceptor" + debug="0" / !-- "jsp" handler -- @@ -167,30 +170,31 @@ !-- "default" handler - static files and dirs -- RequestInterceptor -className="org.apache.tomcat.request.StaticInterceptor" +className="org.apache.tomcat.modules.generators.StaticInterceptor" debug="0" listings="true" / !-- Handle reloads - will be moved to per/context -- RequestInterceptor -className="org.apache.tomcat.request.ReloadInterceptor" +className="org.apache.tomcat.modules.mappers.ReloadInterceptor" debug="0" / !-- Plug a session manager. You can plug in more advanced session modules.
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 00/12/27 09:15:09 Modified:.build.xml src/etc server.xml src/facade22/org/apache/tomcat/facade ServletHandler.java ServletInfo.java ServletInputStreamFacade.java ServletWriterFacade.java src/share/org/apache/tomcat/startup EmbededTomcat.java Added: src/build manifest.facade22 src/facade22/org/apache/tomcat/facade JspInterceptor.java LoadOnStartupInterceptor.java Removed: src/facade22/org/apache/tomcat/modules/facade22 JspInterceptor.java LoadOnStartupInterceptor.java Log: - Changed class protection from "public" to "package" in facade. - added a "Sealed" manifest for facade - moved LoadOnStartup and JspInterceptor in the same package - they need access to package methods ( are specific to the facade ) I read the "facade" package few times, I see no way to cast a facade to the implementation object or to access any method except what the API provides. More review is needed, and a class loader mechanism to double the protection. Trusted applications can still call getAttribute("org.apache.tomcat.request") or getAttribute("org.apache.tomcat.context") to access the "internal" objects. Revision ChangesPath 1.98 +3 -1 jakarta-tomcat/build.xml Index: build.xml === RCS file: /home/cvs/jakarta-tomcat/build.xml,v retrieving revision 1.97 retrieving revision 1.98 diff -u -r1.97 -r1.98 --- build.xml 2000/12/25 04:43:15 1.97 +++ build.xml 2000/12/27 17:14:57 1.98 @@ -180,7 +180,9 @@ include name="org/apache/tomcat/facade/**"/ include name="org/apache/tomcat/modules/facade22/**"/ /javac -jar jarfile="${tomcat.build}/lib/facade22.jar" basedir="${tomcat.build}/classes" +jar jarfile="${tomcat.build}/lib/facade22.jar" + basedir="${tomcat.build}/classes" + manifest="src/build/manifest.facade22" include name="org/apache/tomcat/facade/**"/ include name="org/apache/tomcat/modules/facade22/**"/ /jar 1.1 jakarta-tomcat/src/build/manifest.facade22 Index: manifest.facade22 === Manifest-Version: 1.0 Name: org/apache/tomcat/facade/ Sealed: true 1.55 +2 -2 jakarta-tomcat/src/etc/server.xml Index: server.xml === RCS file: /home/cvs/jakarta-tomcat/src/etc/server.xml,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- server.xml2000/12/12 20:21:18 1.54 +++ server.xml2000/12/27 17:15:00 1.55 @@ -161,7 +161,7 @@ !-- "jsp" handler -- RequestInterceptor -className="org.apache.tomcat.modules.facade22.JspInterceptor" +className="org.apache.tomcat.facade.JspInterceptor" debug="0" / !-- "default" handler - static files and dirs @@ -226,7 +226,7 @@ !-- Loaded last since JSP's that load-on-startup use request handling -- ContextInterceptor -className="org.apache.tomcat.modules.facade22.LoadOnStartupInterceptor" / +className="org.apache.tomcat.facade.LoadOnStartupInterceptor" / !-- Loaded last since JSP's that load-on-startup use request handling -- RequestInterceptor 1.10 +1 -1 jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletHandler.java Index: ServletHandler.java === RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletHandler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ServletHandler.java 2000/12/20 15:25:50 1.9 +++ ServletHandler.java 2000/12/27 17:15:03 1.10 @@ -85,7 +85,7 @@ * @author Harish Prabandham * @author Costin Manolache */ -public final class ServletHandler extends Handler { +final class ServletHandler extends Handler { /** * If init() fails or preInit() detects the handler is still 1.5 +8 -8 jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletInfo.java Index: ServletInfo.java === RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletInfo.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ServletInfo.java 2000/12/27 07:18:46 1.4 +++ ServletInfo.java 2000/12/27 17:15:04 1.5 @@ -85,25 +85,25 @@ * @author Harish Prabandham * @author [EMAIL
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
costin 00/12/26 23:20:22 Modified:src/share/org/apache/tomcat/core ContextManager.java src/share/org/apache/tomcat/startup EmbededTomcat.java Log: First rewrite of EmbededTomcat. Updated to use the new modules, tested, refactored a bit. Revision ChangesPath 1.159 +1 -0 jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java Index: ContextManager.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v retrieving revision 1.158 retrieving revision 1.159 diff -u -r1.158 -r1.159 --- ContextManager.java 2000/12/26 23:23:29 1.158 +++ ContextManager.java 2000/12/27 07:20:21 1.159 @@ -553,6 +553,7 @@ } } + /** Shut down and removes a context from service. */ public final void removeContext( Context context ) throws TomcatException { 1.34 +46 -147 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- EmbededTomcat.java2000/12/26 23:35:36 1.33 +++ EmbededTomcat.java2000/12/27 07:20:22 1.34 @@ -6,6 +6,7 @@ import org.apache.tomcat.core.*; import org.apache.tomcat.request.*; import org.apache.tomcat.modules.server.*; +import org.apache.tomcat.modules.facade22.*; import org.apache.tomcat.modules.session.*; import org.apache.tomcat.context.*; import org.apache.tomcat.util.log.*; @@ -36,16 +37,12 @@ * * @author [EMAIL PROTECTED] */ -public class EmbededTomcat { // extends WebService -ContextManager contextM = null; +public class EmbededTomcat { +ContextManager contextM = new ContextManager(); Object application; + // null == not set up Vector requestInt=null; -/** Right now we assume all web apps use the same - servlet API version. This will change after we - finish the FacadeManager implementation -*/ -//FacadeManager facadeM=null; Vector connectors=new Vector(); String workDir; @@ -59,6 +56,10 @@ } // Properties - set before start + +public ContextManager getContextManager() { + return contextM; +} /** Set debugging - must be called before anything else */ @@ -98,8 +99,8 @@ // Endpoints -/** Add a web service on the specified address. You must add all the - * endpoints before calling start(). +/** Add a HTTP listener. + * You must add all the endpoints before calling start(). */ public void addEndpoint( int port, InetAddress addr , String hostname) throws TomcatException @@ -114,12 +115,10 @@ if( addr != null ) sc.setAddress( addr ); if( hostname != null ) sc.setHostName( hostname ); - // sc.setTcpConnectionHandler( new HttpConnectionHandler()); - contextM.addInterceptor( sc ); } -/** Add a secure web service. +/** Add a secure HTTP listener. */ public void addSecureEndpoint( int port, InetAddress addr, String hostname, String keyFile, String keyPass ) @@ -134,26 +133,25 @@ if( addr != null ) sc.setAddress( addr ); if( hostname != null ) sc.setHostName( hostname ); - sc.setSocketFactory("org.apache.tomcat.net.SSLSocketFactory"); - // log("XXX " + keyFile + " " + keyPass); - // HttpConnectionHandler hc=new HttpConnectionHandler(); + sc.setSocketFactory("org.apache.tomcat.util.net.SSLSocketFactory"); sc.setSecure(true); - // sc.setTcpConnectionHandler( hc ); - // XXX add the secure socket - + contextM.addInterceptor( sc ); } // Context add/remove + +boolean initialized=false; /** Add and init a context */ -public Object addContext( String ctxPath, URL docRoot ) +public Context addContext( String ctxPath, URL docRoot ) throws TomcatException { if(debug0) log( "add context \"" + ctxPath + "\" " + docRoot ); - if( contextM == null ) + if( ! initialized ) { initContextManager(); + } // tomcat supports only file-based contexts if( ! "file".equals( docRoot.getProtocol()) ) { @@ -178,51 +176,6 @@ return null; } -/** Remove a context - */ -public void removeContext( Object
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup EmbededTomcat.java
craigmcc00/11/17 13:16:21 Modified:src/share/org/apache/tomcat/service Tag: tomcat_32 PoolTcpConnector.java src/share/org/apache/tomcat/startup Tag: tomcat_32 EmbededTomcat.java Log: When using the EmbededTomcat approach to starting Tomcat, properly pass the keystore, keystore password, and requirement for client authentication to the underlying SSL socket factory. Also, support the ability to provide your own custom socket factory object, rather than just a classname. PR: BugRat Bug Report #404 Submitted by: Stefan F. Stefansson [EMAIL PROTECTED] (Sorry about not being able to get the accented letters right) Revision ChangesPath No revision No revision 1.8.2.2 +8 -0 jakarta-tomcat/src/share/org/apache/tomcat/service/PoolTcpConnector.java Index: PoolTcpConnector.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/PoolTcpConnector.java,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -r1.8.2.1 -r1.8.2.2 --- PoolTcpConnector.java 2000/10/06 20:42:00 1.8.2.1 +++ PoolTcpConnector.java 2000/11/17 21:16:21 1.8.2.2 @@ -394,6 +394,14 @@ loghelper.setLogger(logger); } +/** + * Set a socket factory explicitly. This is used + * by the EmbededTomcat class to create custom endpoints. + */ +public void setSocketFactory(ServerSocketFactory socketFactory) { +this.socketFactory = socketFactory; +} + // Implementation methods No revision No revision 1.13.2.3 +50 -4 jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java Index: EmbededTomcat.java === RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v retrieving revision 1.13.2.2 retrieving revision 1.13.2.3 diff -u -r1.13.2.2 -r1.13.2.3 --- EmbededTomcat.java2000/08/16 22:24:27 1.13.2.2 +++ EmbededTomcat.java2000/11/17 21:16:21 1.13.2.3 @@ -4,6 +4,7 @@ import java.io.*; import org.apache.tomcat.core.*; +import org.apache.tomcat.net.*; import org.apache.tomcat.request.*; import org.apache.tomcat.service.*; import org.apache.tomcat.service.http.*; @@ -33,6 +34,7 @@ * "expensive" as code complexity and will be deprecated ). * * @author [EMAIL PROTECTED] + * @author Stefan Freyr Stafansson [[EMAIL PROTECTED]] */ public class EmbededTomcat { // extends WebService ContextManager contextM = null; @@ -112,11 +114,23 @@ contextM.addServerConnector( sc ); } -/** Add a secure web service. +/** Add a secure web service without client authentication using the + * default server socket factory. */ public void addSecureEndpoint( int port, InetAddress addr, String hostname, String keyFile, String keyPass ) { +addSecureEndpoint(port, addr, hostname, keyFile, keyPass, false); +} + +/** Add a secure web service using the + * org.apache.tomcat.net.SSLSocketFactory. clientAuth specifies whether + * client authentication is required or not. + */ +public void addSecureEndpoint(int port, InetAddress addr, String hostname, + String keyStore, String keyPass, + boolean clientAuth) +{ if(debug0) log( "addSecureConnector " + port + " " + addr + " " + hostname ); @@ -126,9 +140,13 @@ sc.setAttribute( "vhost_port" , new Integer( port ) ); if( addr != null ) sc.setAttribute( "vhost_address", addr ); if( hostname != null ) sc.setAttribute( "vhost_name", hostname ); - - sc.setAttribute( "socketFactory", - "org.apache.tomcat.net.SSLSocketFactory"); +if (keyStore != null) +sc.setAttribute("keystore", keyStore); +if (keyPass != null) +sc.setAttribute("keypass", keyPass); +if (clientAuth) +sc.setAttribute("clientAuth", "true"); +sc.setSocketFactory(new org.apache.tomcat.net.SSLSocketFactory()); // System.out.println("XXX " + keyFile + " " + keyPass); HttpConnectionHandler ch=new HttpConnectionHandler(); ch.setSecure(true); @@ -136,6 +154,34 @@ // XXX add the secure socket contextM.addServerConnector( sc ); +} + +/** Add a custom web service using the specified socket factory. + * + * @param