avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-apps/sevak/src/conf manifest.mf sevak-assembly.xml sevak-config.xml sevak-environment.xml
Date Mon, 30 Sep 2002 22:03:13 GMT
hammant     2002/09/30 15:03:12

  Modified:    sevak    ant.properties.sample build.xml catalina.xml
               sevak/src/demo/conf catalina-assembly.xml
                        catalina-config.xml catalina-environment.xml
               sevak/src/demo/java/org/apache/avalon/apps/sevak/demo
                        MultihostSevakTest.java SevakTest.java
               sevak/src/java/org/apache/avalon/apps/sevak Sevak.java
               sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina
                        CatalinaSevak.java CatalinaSevakBootstrap.java
                        CatalinaSevakClassLoaderFactory.java
                        CatalinaSevakServer.java
  Added:       sevak/src/demo/conf tomcat-users.xml
               sevak/src/demo/webapps/sevak-test/WEB-INF/classes/num
                        NumberGuessBean.class NumberGuessBean.java
               sevak/src/demo/webapps/sevak-test/WEB-INF web.xml
               sevak/src/demo/webapps/sevak-test index.jsp
  Removed:     sevak/src/conf manifest.mf sevak-assembly.xml
                        sevak-config.xml sevak-environment.xml
  Log:
  More patches for Catalina Sevak from Daniel Krieg.
  
  Revision  Changes    Path
  1.2       +7 -1      jakarta-avalon-apps/sevak/ant.properties.sample
  
  Index: ant.properties.sample
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/ant.properties.sample,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ant.properties.sample	29 Sep 2002 11:38:42 -0000	1.1
  +++ ant.properties.sample	30 Sep 2002 22:03:11 -0000	1.2
  @@ -30,4 +30,10 @@
   checkstyle.lib=${checkstyle.home}
   checkstyle.jar=${checkstyle.lib}/checkstyle-all-2.3.jar
   
  +# -----------------------------------------------------------------------------
  +#                 CATALINA SEVAK PROPERTIES
  +#  Uncomment catalina-zip-suffix to build using JDK 1.4 LE
  +#  (lightweight binary distribution of Tomcat 4, designed to be run on JDK 1.4.)
  +# -----------------------------------------------------------------------------
  +#catalina-zip-suffix=-LE-jdk14
   
  
  
  
  1.15      +56 -0     jakarta-avalon-apps/sevak/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/build.xml,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- build.xml	29 Sep 2002 11:38:42 -0000	1.14
  +++ build.xml	30 Sep 2002 22:03:11 -0000	1.15
  @@ -275,6 +275,62 @@
   
   
     </target>
  +  
  +  <target name="compile-demo" depends="compile" description="Compiles the Demo Block">
  +    <delete dir="${build.demoClasses}"/>
  +    <delete dir="${build.demoXdoclet}"/>
  +
  +
  +    <mkdir dir="${build.demoClasses}"/>
  +    <javac srcdir="${java.demo.dir}"
  +            destdir="${build.demoClasses}"
  +            debug="${build.debug}"
  +            optimize="${build.optimize}"
  +            deprecation="${build.deprecation}">
  +       <classpath refid="test.class.path" />
  +       <include name="**"/>
  +    </javac>
  +  </target>
  +
  +  <target name="phoenix-demo-xdoclet" depends="compile-demo" >
  +    <mkdir dir="${build.demoXdoclet}"/>
  +
  +    <taskdef name="phoenix-blocks"
  +             classname="org.apache.avalon.phoenix.tools.xdoclet.PhoenixXDoclet"
  +             classpathref="test.class.path"/>
  +
  +    <phoenix-blocks
  +        destdir="${build.demoXdoclet}"
  +        classpathref="test.class.path">
  +      <fileset dir="${java.demo.dir}">
  +        <include name="**/*.java" />
  +      </fileset>
  +      <blockinfo/>
  +      <manifest manifestFile="manifest.mf" />
  +    </phoenix-blocks>
  +
  +  </target>
  +
  +  <target name="demo-jar" depends="phoenix-demo-xdoclet" description="Makes a jar file out of the Demo classes">
  +    <mkdir dir="${build.lib}"/>
  +    <war destfile="${build.lib}/sevak-demo.war" webxml="${src.dir}/demo/webapps/sevak-test/WEB-INF/web.xml" >
  +      <fileset dir="${src.dir}/demo/webapps/sevak-test">
  +          <excludesfile name="${src.dir}/demo/webapps/sevak-test/WEB-INF/web.xml"/>
  +      </fileset>
  +    </war>
  +
  +
  +    <jar jarfile="${build.lib}/sevak-demo.jar"
  +         manifest="${build.demoXdoclet}/manifest.mf">
  +      <fileset dir="${build.demoClasses}">
  +        <include name="org/apache/avalon/apps/sevak/**"/>
  +      </fileset>
  +     <fileset dir="${build.demoXdoclet}">
  +        <include name="org/apache/avalon/apps/sevak/**/*.xinfo"/>
  +      </fileset>
  +    </jar>
  +
  +  </target>
   
     <!-- Jars project for Merlin -->
     <target name="merlin" depends="compile" >
  
  
  
  1.4       +14 -21    jakarta-avalon-apps/sevak/catalina.xml
  
  Index: catalina.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/catalina.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- catalina.xml	22 Sep 2002 21:39:12 -0000	1.3
  +++ catalina.xml	30 Sep 2002 22:03:11 -0000	1.4
  @@ -45,7 +45,9 @@
     <property name="context.dir" value="../../jakarta-avalon/src/documentation"/>  
     <property name="xdocs.dir" value="${src.dir}/xdocs"/>  
     <property name="tools.dir" location="../../jakarta-avalon/tools"/>
  -   
  +  <!--<property name="demo.dir" location="${java.dir}/demo"/>-->
  +  <property name="demo.conf.dir" location="${demo.dir}/conf"/>
  +
     <property name="junit.jar" value="${tools.dir}/lib/junit-3.7.jar"/>
     <property name="tools.jar" value="${java.home}/../lib/tools.jar"/>  
     <property name="dist.base" value="dist"/>
  @@ -55,13 +57,15 @@
     <property name="test.dir" value="${src.dir}/test"/>
     <property name="demo.dir" value="${src.dir}/demo"/>
     <property name="java.demo.dir" value="${demo.dir}/java"/>
  -  <property name="conf.demo.dir" value="${demo.dir}/conf"/>  
  -  
  +  <property name="conf.demo.dir" value="${demo.dir}/conf"/>
  +
     <!-- Tomcat Stuff -->
  -  <property name="catalina-version" value="4.1.10"/>
  +  <property name="catalina-version" value="4.1.12"/>
     <property name="catalina-zip-suffix" value=""/>
     <property name="catalina-dir-suffix" value=""/>
  -  
  +  <property name="catalina.download" value="catalina-download/jakarta-tomcat-${catalina-version}${catalina-zip-suffix}"/>
  +  <property name="common.lib.dir" value="${catalina.download}/common/lib"/>
  +  <property name="catalina.conf.dir" value="${catalina.download}/conf"/>
     <property name="tomcat.jars.dir" value="${lib.dir}/tomcat-jars"/>
   
     <path id="project.class.path">
  @@ -119,7 +123,6 @@
     
     <!-- Get catalina jars from apache repository -->
     <target name="get-catalina">
  - 
       <mkdir  dir="catalina-download"/>
       <mkdir dir="${lib.dir}"/>
       <mkdir dir="${tomcat.jars.dir}"/>
  @@ -177,8 +180,8 @@
    
    <!--- Build Test SAR Archive -->
    <target name="sar" depends="prepare" description="Builds a Demo block which uses Sevak Service">
  - 
  - 
  +    <copy file="${tools.jar}" todir="${common.lib.dir}"/>
  +    <copy file="${conf.demo.dir}/tomcat-users.xml" tofile="${catalina.conf.dir}/tomcat-users.xml"/>
       <ant antfile="build.xml" target="jars"/>
       <ant antfile="build.xml" target="demo-jar"/>
    
  @@ -191,23 +194,13 @@
           <include name="sevak-catalina.jar"/>
           <include name="sevak-demo.jar"/>
           <include name="sevak-api.jar"/>
  +        <include name="sevak-demo.war"/>
         </lib>
  -
  +      <!--  FIXME: Do we need this? -->
         <lib dir="../../jakarta-avalon-apps/common/lib">
           <include name="cornerstone.jar"/>
         </lib>
  -    
  -      <lib dir="${tomcat.jars.dir}">
  -        <include name="*.jar"/>
  -      </lib>
  -      
  -
  -      <zipfileset dir="catalina-download/jakarta-tomcat-${catalina-version}${catalina-zip-suffix}/webapps" prefix="webapps"/>
  -      
  -      <zipfileset dir="catalina-download/jakarta-tomcat-${catalina-version}${catalina-zip-suffix}/conf" prefix="conf">
  -        <include name="tomcat-users.xml"/>
  -      </zipfileset>
  -
  +      <zipfileset dir="catalina-download/jakarta-tomcat-${catalina-version}${catalina-zip-suffix}"  />
       </sar>
   
       <!-- Copy build/lib contents to dist/ folder -->
  
  
  
  1.3       +2 -3      jakarta-avalon-apps/sevak/src/demo/conf/catalina-assembly.xml
  
  Index: catalina-assembly.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/demo/conf/catalina-assembly.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- catalina-assembly.xml	29 Sep 2002 11:38:42 -0000	1.2
  +++ catalina-assembly.xml	30 Sep 2002 22:03:11 -0000	1.3
  @@ -3,9 +3,8 @@
                     "http://jakarta.apache.org/phoenix/assembly_1_0.dtd">
   
   <assembly>
  -    <block class="org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevakBootstrap" name="catalina"/>
  -    
  +    <block class="org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevakBootstrap" name="sevak"/>
       <block class="org.apache.avalon.apps.sevak.demo.MultihostSevakTest" name="multihost-sevak-test">
  -        <provide name="catalina" role="org.apache.avalon.apps.sevak.MultihostSevak"/>
  +        <provide name="sevak" role="org.apache.avalon.apps.sevak.MultihostSevak"/>
       </block>
   </assembly>
  
  
  
  1.3       +3 -4      jakarta-avalon-apps/sevak/src/demo/conf/catalina-config.xml
  
  Index: catalina-config.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/demo/conf/catalina-config.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- catalina-config.xml	29 Sep 2002 11:38:42 -0000	1.2
  +++ catalina-config.xml	30 Sep 2002 22:03:11 -0000	1.3
  @@ -7,12 +7,11 @@
   -->
   <config>
   
  -    <catalina>
  -        <use-naming>true</use-naming>
  +    <sevak>
           <config-file>conf/server-noexamples.xml.config</config-file>
  -    </catalina>
  +    </sevak>
       <multihost-sevak-test>
  -      <Context docBase="/multihost-sevak" path="/local/test.war"/>
  +      <Context docBase="/multihost-sevak" path="sevak-demo.war"/>
       </multihost-sevak-test>
   
   </config>
  
  
  
  1.3       +1 -2      jakarta-avalon-apps/sevak/src/demo/conf/catalina-environment.xml
  
  Index: catalina-environment.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/demo/conf/catalina-environment.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- catalina-environment.xml	29 Sep 2002 11:38:42 -0000	1.2
  +++ catalina-environment.xml	30 Sep 2002 22:03:11 -0000	1.3
  @@ -8,12 +8,11 @@
   <environment>
   
       <logs>
  -
         <category name="" target="default"
                   priority="DEBUG" />
   
         <log-target name="default"
  -                  location="/logs/multihost-sevak-demo.log" />
  +                  location="/logs/avalon-sevak.log" />
       </logs>
   
       <policy>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/conf/tomcat-users.xml
  
  Index: tomcat-users.xml
  ===================================================================
  <!--
    NOTE:  By default, no user is included in the "manager" role required
    to operate the "/manager" web application.  If you wish to use this app,
    you must define such a user - the username and password are arbitrary.
  -->
  <tomcat-users>
    <role name="admin"/>
    <role name="manager"/>
    <user name="tomcat" password="tomcat" roles="tomcat" />
    <user name="role1"  password="tomcat" roles="role1"  />
    <user name="both"   password="tomcat" roles="tomcat,role1" />
    <user name="root" password="root" roles="admin,manager"/>
  </tomcat-users>
  
  
  
  1.2       +3 -2      jakarta-avalon-apps/sevak/src/demo/java/org/apache/avalon/apps/sevak/demo/MultihostSevakTest.java
  
  Index: MultihostSevakTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/demo/java/org/apache/avalon/apps/sevak/demo/MultihostSevakTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultihostSevakTest.java	29 Sep 2002 11:38:43 -0000	1.1
  +++ MultihostSevakTest.java	30 Sep 2002 22:03:12 -0000	1.2
  @@ -58,9 +58,10 @@
               String ctxPath = contexts[ i ].getAttribute( "path" );
               ctxPath = ctxPath.replace( '/', File.separatorChar );
               ctxPath = ctxPath.replace( '\\', File.separatorChar );
  -            String ctxFullPath = m_context.getBaseDirectory().getAbsolutePath() + File.separatorChar + ctxPath;
  +            String ctxFullPath = m_context.getBaseDirectory().getAbsolutePath() + File.separatorChar + "SAR-INF"
  +                     + File.separatorChar + "lib" + File.separatorChar + ctxPath;
               //System.out.println("Ctx = " + ctx + ", path = " + ctxFullPath);
  -            m_mulihostSevak.deploy( "loclhost", ctx, new File( ctxFullPath ) );
  +            m_mulihostSevak.deploy( "localhost", ctx, new File( ctxFullPath ) );
           }
       }
   }
  
  
  
  1.3       +25 -31    jakarta-avalon-apps/sevak/src/demo/java/org/apache/avalon/apps/sevak/demo/SevakTest.java
  
  Index: SevakTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/demo/java/org/apache/avalon/apps/sevak/demo/SevakTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SevakTest.java	29 Jun 2002 13:20:21 -0000	1.2
  +++ SevakTest.java	30 Sep 2002 22:03:12 -0000	1.3
  @@ -33,53 +33,47 @@
    */
   public class SevakTest
           extends AbstractLogEnabled
  -        implements Contextualizable, Serviceable, Configurable, Initializable
  -{
  +        implements Contextualizable, Serviceable, Configurable, Initializable {
       private BlockContext m_context;
  -	private Configuration m_configuration;
  -	private Sevak m_sevak;
  -    
  -    public void contextualize(final Context context)
  -    {
  -        getLogger().info("SevakTest.contextualize()");
  +    private Configuration m_configuration;
  +    private Sevak m_sevak;
  +
  +    public void contextualize( final Context context ) {
  +        getLogger().info( "SevakTest.contextualize()" );
           m_context = (BlockContext) context;
       }
   
  -    public void configure(final Configuration configuration)
  -            throws ConfigurationException
  -    {
  -		
  -		m_configuration=configuration;	
  -		
  +    public void configure( final Configuration configuration )
  +            throws ConfigurationException {
  +
  +        m_configuration = configuration;
  +
       }
   
       /**
        * @see org.apache.avalon.framework.service.Serviceable
        * @phoenix:dependency name="org.apache.avalon.apps.sevak.Sevak"
        */
  -    public void service(final ServiceManager serviceManager)
  -            throws ServiceException
  -    {
  -        getLogger().info("SevakTest.service()");
  -		m_sevak=(Sevak)serviceManager.lookup(Sevak.class.getName());
  +    public void service( final ServiceManager serviceManager )
  +            throws ServiceException {
  +        getLogger().info( "SevakTest.service()" );
  +        m_sevak = (Sevak) serviceManager.lookup( Sevak.class.getName() );
       }
   
       public void initialize()
  -            throws Exception
  -    {
  -        getLogger().info("SevakTest.initialize()");
  -        Configuration[] contexts=m_configuration.getChildren("Context");
  -        for(int i=0;i<contexts.length;i++)
  -        {
  -            String ctx = contexts[i].getAttribute("docBase");
  -            String ctxPath = contexts[i].getAttribute("path");
  -            ctxPath = ctxPath.replace('/',File.separatorChar);
  -            ctxPath = ctxPath.replace('\\',File.separatorChar);
  +            throws Exception {
  +        getLogger().info( "SevakTest.initialize()" );
  +        Configuration[] contexts = m_configuration.getChildren( "Context" );
  +        for( int i = 0; i < contexts.length; i++ ) {
  +            String ctx = contexts[ i ].getAttribute( "docBase" );
  +            String ctxPath = contexts[ i ].getAttribute( "path" );
  +            ctxPath = ctxPath.replace( '/', File.separatorChar );
  +            ctxPath = ctxPath.replace( '\\', File.separatorChar );
               String ctxFullPath = m_context.getBaseDirectory().getAbsolutePath() + File.separatorChar + ctxPath;
               //System.out.println("Ctx = " + ctx + ", path = " + ctxFullPath);
  -   	     	m_sevak.deploy(ctx,new File(ctxFullPath));
  +            m_sevak.deploy( ctx, new File( ctxFullPath ) );
           }
  -		
  +
       }
   
   
  
  
  
  1.3       +1 -7      jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/Sevak.java
  
  Index: Sevak.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/Sevak.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Sevak.java	29 Sep 2002 11:38:42 -0000	1.2
  +++ Sevak.java	30 Sep 2002 22:03:12 -0000	1.3
  @@ -20,12 +20,6 @@
       String ROLE = Sevak.class.getName();
   
       /**
  -     * A constant for localhost
  -     */
  -    String LOCALHOST = "localhost";
  -
  -
  -    /**
        * Deploy the given Web Application
        * @param context Context for the the webapp
        * @param pathToWebAppFolder path can be a war-archive or exploded directory
  @@ -34,7 +28,7 @@
       void deploy(String context, File pathToWebAppFolder) throws SevakException;
   
       /**
  -     * Undeploy the given WebApp 
  +     * Undeploy the given WebApp
        * @param context Context for the the webapp
        * @throws SevakException Thrown if context does NOT exist
        */
  
  
  
  1.3       +184 -297  jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevak.java
  
  Index: CatalinaSevak.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevak.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CatalinaSevak.java	29 Sep 2002 11:38:42 -0000	1.2
  +++ CatalinaSevak.java	30 Sep 2002 22:03:12 -0000	1.3
  @@ -8,7 +8,6 @@
   package org.apache.avalon.apps.sevak.blocks.catalina;
   
   import java.security.Security;
  -
   import org.apache.catalina.Container;
   import org.apache.catalina.Lifecycle;
   import org.apache.catalina.LifecycleException;
  @@ -19,148 +18,103 @@
   import org.apache.catalina.startup.EngineRuleSet;
   import org.apache.catalina.startup.HostRuleSet;
   import org.apache.catalina.startup.NamingRuleSet;
  -
   import org.apache.commons.digester.Digester;
  -
  +import org.apache.commons.digester.Rule;
  +import org.xml.sax.Attributes;
   import org.xml.sax.InputSource;
   
   import java.io.File;
   import java.io.FileInputStream;
   
   /**
  - * Tomcat Wrapper.  This is the true CatalinaSevak service.  It must be dynamically loaded
  - * through a bootstrap approach because it directly manipulates Tomcat libraries.  The bootstrap
  - * abstraction layer separates Tomcat from Phoenix, thus allowing them to coexist.  This class
  - * contains a Tomcat-specific ClassLoader i.e. org.apache.catalina.loader.StandardClassLoader that
  - * handles the true bootstrapping of Tomcat.
  + * Tomcat Wrapper.  This is the true CatalinaSevak service.  It must be dynamically loaded through a bootstrap
  + * approach because it directly manipulates Tomcat libraries.  The bootstrap abstraction layer separates Tomcat
  + * from Phoenix, thus allowing them to coexist.  This class contains a Tomcat-specific ClassLoader
  + * i.e. org.apache.catalina.loader.StandardClassLoader that handles the true bootstrapping of Tomcat.
    *
    * @see <a href="http://jakarta.apache.org/tomcat">Tomcat Project Page</a>
    *
    * @author  Daniel Krieg<dkrieg@kc.rr.com>
  - * @version $Revision$ $Date$
  + * @version 1.0
    */
  -public class CatalinaSevak
  -{
  +public class CatalinaSevak {
       private ClassLoader m_parentLoader = ClassLoader.getSystemClassLoader();
       private Server m_server = null;
       private String m_configFile;
       private boolean m_useNaming = true;
   
  -    /**
  -     * Set the parent classloader
  -     * @param parentLoader the parent classloader
  -     */
  -    public void setParentClassLoader(ClassLoader parentLoader)
  -    {
  +    public void setParentClassLoader( ClassLoader parentLoader ) {
           m_parentLoader = parentLoader;
       }
   
  -    /**
  -     * set the configuration file
  -     * @param configFile the config file
  -     */
  -    public void setConfigFile(String configFile)
  -    {
  +    public void setConfigFile( String configFile ) {
           m_configFile = configFile;
       }
   
  -    /**
  -     * Set the use naming
  -     * @param useNaming the use naming
  -     */
  -    public void setUseNaming(boolean useNaming)
  -    {
  +    public void setUseNaming( boolean useNaming ) {
           m_useNaming = useNaming;
       }
   
  -    /**
  -     * Set the server
  -     * @param server the server
  -     */
  -    public void setServer(Server server)
  -    {
  +    public void setServer( Server server ) {
           this.m_server = server;
       }
   
  -    /**
  -     * Initialize
  -     * @throws Exception if a problem
  -     */
  -    public void initialize() throws Exception
  -    {
  +    public void initialize() throws Exception {
           Digester digester = createStartDigester();
  -        File file = getConfigFile();
  -        try
  -        {
  +        File file = configFile();
  +        try {
               InputSource is =
  -                    new InputSource("file://" + file.getAbsolutePath());
  -            FileInputStream fis = new FileInputStream(file);
  -            is.setByteStream(fis);
  -            digester.push(this);
  -            digester.parse(is);
  +                    new InputSource( "file://" + file.getAbsolutePath() );
  +            FileInputStream fis = new FileInputStream( file );
  +            is.setByteStream( fis );
  +            digester.push( this );
  +            digester.parse( is );
               fis.close();
  -        }
  -        catch (Exception e)
  -        {
  +        } catch( Exception e ) {
               e.printStackTrace();
               return;
           }
   
  -        if (!m_useNaming)
  -        {
  -            System.setProperty("catalina.useNaming", "false");
  -        }
  -        else
  -        {
  -            System.setProperty("catalina.useNaming", "true");
  +        if( !m_useNaming ) {
  +            System.setProperty( "catalina.useNaming", "false" );
  +        } else {
  +            System.setProperty( "catalina.useNaming", "true" );
               String value = "org.apache.naming";
               String oldValue =
  -                    System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
  -            if (oldValue != null)
  -            {
  +                    System.getProperty( javax.naming.Context.URL_PKG_PREFIXES );
  +            if( oldValue != null ) {
                   value = value + ":" + oldValue;
               }
  -            System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value);
  +            System.setProperty( javax.naming.Context.URL_PKG_PREFIXES, value );
               value = System.getProperty
  -                    (javax.naming.Context.INITIAL_CONTEXT_FACTORY);
  -            if (value == null)
  -            {
  +                    ( javax.naming.Context.INITIAL_CONTEXT_FACTORY );
  +            if( value == null ) {
                   System.setProperty
  -                        (javax.naming.Context.INITIAL_CONTEXT_FACTORY,
  -                                "org.apache.naming.java.javaURLContextFactory");
  +                        ( javax.naming.Context.INITIAL_CONTEXT_FACTORY,
  +                          "org.apache.naming.java.javaURLContextFactory" );
               }
           }
   
  -        if (System.getSecurityManager() != null)
  -        {
  -            String access = Security.getProperty("package.access");
  -            if (access != null && access.length() > 0)
  -            {
  +        if( System.getSecurityManager() != null ) {
  +            String access = Security.getProperty( "package.access" );
  +            if( access != null && access.length() > 0 )
                   access += ",";
  -            }
               else
  -            {
                   access = "sun.,";
  -            }
  -            Security.setProperty("package.access",
  -                    access + "org.apache.catalina.,org.apache.jasper.");
  -            String definition = Security.getProperty("package.definition");
  -            if (definition != null && definition.length() > 0)
  -            {
  +            Security.setProperty( "package.access",
  +                                  access + "org.apache.catalina.,org.apache.jasper." );
  +            String definition = Security.getProperty( "package.definition" );
  +            if( definition != null && definition.length() > 0 )
                   definition += ",";
  -            }
               else
  -            {
                   definition = "sun.,";
  -            }
  -            Security.setProperty("package.definition",
  -                    // FIX ME package "javax." was removed to prevent HotSpot
  -                    // fatal internal errors
  -                    definition + "java.,org.apache.catalina.,org.apache.jasper.");
  +            Security.setProperty( "package.definition",
  +                                  // FIX ME package "javax." was removed to prevent HotSpot
  +                                  // fatal internal errors
  +                                  definition + "java.,org.apache.catalina.,org.apache.jasper." );
           }
   
  -        if (m_server instanceof Lifecycle)
  -        {
  +        if( m_server instanceof Lifecycle ) {
               m_server.initialize();
           }
   //        Service[] services = m_server.findServices();
  @@ -177,260 +131,193 @@
   //            }
   //            System.out.println();
   //        }
  -        System.out.println("CatalinaSevak Server initialized");
  +        System.out.println( "CatalinaSevak Server initialized" );
       }
   
  -    /**
  -     * Start the server
  -     * @throws Exception if a problem
  -     */
  -    public void start() throws Exception
  -    {
  -        if (m_server instanceof Lifecycle)
  -        {
  -            try
  -            {
  -                ((Lifecycle) m_server).start();
  +    public void start() throws Exception {
  +        if( m_server instanceof Lifecycle ) {
  +            try {
  +                ( (Lifecycle) m_server ).start();
                   m_server.await();
  -            }
  -            catch (LifecycleException e)
  -            {
  -                System.out.println("Catalina.start: " + e);
  -                e.printStackTrace(System.out);
  -                if (e.getThrowable() != null)
  -                {
  -                    System.out.println("----- Root Cause -----");
  -                    e.getThrowable().printStackTrace(System.out);
  +            } catch( LifecycleException e ) {
  +                System.out.println( "Catalina.start: " + e );
  +                e.printStackTrace( System.out );
  +                if( e.getThrowable() != null ) {
  +                    System.out.println( "----- Root Cause -----" );
  +                    e.getThrowable().printStackTrace( System.out );
                   }
  -            }
  -            catch (Throwable throwable)
  -            {
  +            } catch( Throwable throwable ) {
                   throwable.printStackTrace();
               }
  -        }
  -        else
  -        {
  -            throw new Exception("Unable to start CatalinSevak Server: "
  -                    + m_server.getClass().getName());
  +        } else {
  +            throw new Exception( "Unable to start CatalinSevak Server: " + m_server.getClass().getName() );
           }
       }
   
  -    /**
  -     * Stop the server
  -     * @throws Exception if a problem
  -     */
  -    public void stop() throws Exception
  -    {
  -        if (m_server instanceof Lifecycle)
  -        {
  -            try
  -            {
  -                ((Lifecycle) m_server).stop();
  -            }
  -            catch (LifecycleException e)
  -            {
  -                System.out.println("Catalina.stop: " + e);
  -                e.printStackTrace(System.out);
  -                if (e.getThrowable() != null)
  -                {
  -                    System.out.println("----- Root Cause -----");
  -                    e.getThrowable().printStackTrace(System.out);
  +    public void stop() throws Exception {
  +        if( m_server instanceof Lifecycle ) {
  +            try {
  +                ( (Lifecycle) m_server ).stop();
  +            } catch( LifecycleException e ) {
  +                System.out.println( "Catalina.stop: " + e );
  +                e.printStackTrace( System.out );
  +                if( e.getThrowable() != null ) {
  +                    System.out.println( "----- Root Cause -----" );
  +                    e.getThrowable().printStackTrace( System.out );
                   }
               }
  -        }
  -        else
  -        {
  -            throw new Exception("Unable to start CatalinSevak Server: "
  -                    + m_server.getClass().getName());
  +        } else {
  +            throw new Exception( "Unable to start CatalinSevak Server: " + m_server.getClass().getName() );
           }
       }
   
  -    /**
  -     * Deploy a webapp
  -     * @param host the host
  -     * @param context the server context
  -     * @param pathToWebAppFolder the path to the war file
  -     * @throws Exception if aproblem
  -     */
  -    public void deploy(String host, String context, File pathToWebAppFolder) throws Exception
  -    {
  +    public void deploy( String host, String context, File pathToWebAppFolder ) throws Exception {
           Service[] services = m_server.findServices();
           Container child = null;
           found_host: {
  -            for (int i = 0; i < services.length; i++)
  -            {
  -                Service service = services[i];
  +            for( int i = 0; i < services.length; i++ ) {
  +                Service service = services[ i ];
                   Container[] children = service.getContainer().findChildren();
  -                for (int j = 0; j < children.length; j++)
  -                {
  -                    child = children[j];
  -                    if (child.getName().equals(host))
  -                    {
  +                for( int j = 0; j < children.length; j++ ) {
  +                    child = children[ j ];
  +                    if( child.getName().equals( host ) ) {
                           break found_host;
                       }
                   }
               }
           }
  -        if (child == null)
  -        {
  -            throw new IllegalArgumentException(host + ": no such host.");
  -        }
  -        if (!(child instanceof Deployer))
  -        {
  -            throw new Exception(host + ": not able to deploy " + context);
  +        if( child == null ) {
  +            throw new IllegalArgumentException( host + ": no such host." );
  +        }
  +        if( !( child instanceof Deployer ) ) {
  +            throw new Exception( host + ": not able to deploy " + context );
           }
   
           final Deployer deployer = (Deployer) child;
  -        if (deployer.findDeployedApp(context) != null)
  -        {
  -            throw new Exception(context + " already deployed to host " + host);
  +        if( deployer.findDeployedApp( context ) != null ) {
  +            throw new Exception( context + " already deployed to host " + host );
           }
  -        deployer.install(context, pathToWebAppFolder.toURL());
  -        deployer.start(context);
  +        deployer.install( context, pathToWebAppFolder.toURL() );
  +//        deployer.start( context );
       }
   
  -    /**
  -     * Undeploy a web app
  -     * @param host the host
  -     * @param context the context
  -     * @throws Exception if a problem
  -     */
  -    public void undeploy(String host, String context) throws Exception
  -    {
  +    public void undeploy( String host, String context ) throws Exception {
           Service[] services = m_server.findServices();
           Container child = null;
           found_host: {
  -            for (int i = 0; i < services.length; i++)
  -            {
  -                Service service = services[i];
  +            for( int i = 0; i < services.length; i++ ) {
  +                Service service = services[ i ];
                   Container[] children = service.getContainer().findChildren();
  -                for (int j = 0; j < children.length; j++)
  -                {
  -                    child = children[j];
  -                    if (child.getName().equals(host))
  -                    {
  +                for( int j = 0; j < children.length; j++ ) {
  +                    child = children[ j ];
  +                    if( child.getName().equals( host ) ) {
                           break found_host;
                       }
                   }
               }
           }
  -        if (child == null)
  -        {
  -            throw new IllegalArgumentException(host + ": no such host.");
  -        }
  -        if (!(child instanceof Deployer))
  -        {
  -            throw new Exception(host + ": not able to undeploy " + context);
  +        if( child == null ) {
  +            throw new IllegalArgumentException( host + ": no such host." );
  +        }
  +        if( !( child instanceof Deployer ) ) {
  +            throw new Exception( host + ": not able to undeploy " + context );
           }
           final Deployer deployer = (Deployer) child;
  -        if (deployer.findDeployedApp(context) == null)
  -        {
  -            throw new Exception(context + " does not exist in host " + host);
  +        if( deployer.findDeployedApp( context ) == null ) {
  +            throw new Exception( context + " does not exist in host " + host );
           }
  -        deployer.start(context);
  -        deployer.remove(context);
  +//        deployer.start( context );
  +        deployer.remove( context );
       }
   
  -    /**
  -     * Create a digester to start with
  -     * @return the digester
  -     */
  -    protected Digester createStartDigester()
  -    {
  +    protected Digester createStartDigester() {
           Digester digester = new Digester();
  -        digester.setValidating(false);
  +        digester.setValidating( false );
   
  -        digester.addObjectCreate("Server",
  -                "org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevakServer");
  -        digester.addSetProperties("Server");
  -        digester.addSetNext("Server",
  -                "setServer",
  -                "org.apache.catalina.Server");
  -
  -        digester.addObjectCreate("Server/GlobalNamingResources",
  -                "org.apache.catalina.deploy.NamingResources");
  -        digester.addSetProperties("Server/GlobalNamingResources");
  -        digester.addSetNext("Server/GlobalNamingResources",
  -                "setGlobalNamingResources",
  -                "org.apache.catalina.deploy.NamingResources");
  -
  -        digester.addObjectCreate("Server/Listener",
  -                null, // MUST be specified in the element
  -                "className");
  -        digester.addSetProperties("Server/Listener");
  -        digester.addSetNext("Server/Listener",
  -                "addLifecycleListener",
  -                "org.apache.catalina.LifecycleListener");
  -
  -        digester.addObjectCreate("Server/Service",
  -                "org.apache.catalina.core.StandardService",
  -                "className");
  -        digester.addSetProperties("Server/Service");
  -        digester.addSetNext("Server/Service",
  -                "addService",
  -                "org.apache.catalina.Service");
  -
  -        digester.addObjectCreate("Server/Service/Listener",
  -                null, // MUST be specified in the element
  -                "className");
  -        digester.addSetProperties("Server/Service/Listener");
  -        digester.addSetNext("Server/Service/Listener",
  -                "addLifecycleListener",
  -                "org.apache.catalina.LifecycleListener");
  -
  -        digester.addObjectCreate("Server/Service/Connector",
  -                "org.apache.catalina.connector.http.HttpConnector",
  -                "className");
  -        digester.addSetProperties("Server/Service/Connector");
  -        digester.addSetNext("Server/Service/Connector",
  -                "addConnector",
  -                "org.apache.catalina.Connector");
  -
  -        digester.addObjectCreate("Server/Service/Connector/Factory",
  -                "org.apache.catalina.net.DefaultServerSocketFactory",
  -                "className");
  -        digester.addSetProperties("Server/Service/Connector/Factory");
  -        digester.addSetNext("Server/Service/Connector/Factory",
  -                "setFactory",
  -                "org.apache.catalina.net.ServerSocketFactory");
  -
  -        digester.addObjectCreate("Server/Service/Connector/Listener",
  -                null, // MUST be specified in the element
  -                "className");
  -        digester.addSetProperties("Server/Service/Connector/Listener");
  -        digester.addSetNext("Server/Service/Connector/Listener",
  -                "addLifecycleListener",
  -                "org.apache.catalina.LifecycleListener");
  -
  -        digester.addRuleSet(new NamingRuleSet("Server/GlobalNamingResources/"));
  -        digester.addRuleSet(new EngineRuleSet("Server/Service/"));
  -        digester.addRuleSet(new HostRuleSet("Server/Service/Engine/"));
  -        digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Default"));
  -        digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/DefaultContext/"));
  -        digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/Default"));
  -        digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/DefaultContext/"));
  -        digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/"));
  -        digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/Context/"));
  -
  -        digester.addRule("Server/Service/Engine",
  -                new ParentClassLoaderRule(digester,
  -                        m_parentLoader));
  -        return (digester);
  +        digester.addObjectCreate( "Server",
  +                                  "org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevakServer" );
  +        digester.addSetProperties( "Server" );
  +        digester.addSetNext( "Server",
  +                             "setServer",
  +                             "org.apache.catalina.Server" );
  +
  +        digester.addObjectCreate( "Server/GlobalNamingResources",
  +                                  "org.apache.catalina.deploy.NamingResources" );
  +        digester.addSetProperties( "Server/GlobalNamingResources" );
  +        digester.addSetNext( "Server/GlobalNamingResources",
  +                             "setGlobalNamingResources",
  +                             "org.apache.catalina.deploy.NamingResources" );
  +
  +        digester.addObjectCreate( "Server/Listener",
  +                                  null, // MUST be specified in the element
  +                                  "className" );
  +        digester.addSetProperties( "Server/Listener" );
  +        digester.addSetNext( "Server/Listener",
  +                             "addLifecycleListener",
  +                             "org.apache.catalina.LifecycleListener" );
  +
  +        digester.addObjectCreate( "Server/Service",
  +                                  "org.apache.catalina.core.StandardService",
  +                                  "className" );
  +        digester.addSetProperties( "Server/Service" );
  +        digester.addSetNext( "Server/Service",
  +                             "addService",
  +                             "org.apache.catalina.Service" );
  +
  +        digester.addObjectCreate( "Server/Service/Listener",
  +                                  null, // MUST be specified in the element
  +                                  "className" );
  +        digester.addSetProperties( "Server/Service/Listener" );
  +        digester.addSetNext( "Server/Service/Listener",
  +                             "addLifecycleListener",
  +                             "org.apache.catalina.LifecycleListener" );
  +
  +        digester.addObjectCreate( "Server/Service/Connector",
  +                                  "org.apache.catalina.connector.http.HttpConnector",
  +                                  "className" );
  +        digester.addSetProperties( "Server/Service/Connector" );
  +        digester.addSetNext( "Server/Service/Connector",
  +                             "addConnector",
  +                             "org.apache.catalina.Connector" );
  +
  +        digester.addObjectCreate( "Server/Service/Connector/Factory",
  +                                  "org.apache.catalina.net.DefaultServerSocketFactory",
  +                                  "className" );
  +        digester.addSetProperties( "Server/Service/Connector/Factory" );
  +        digester.addSetNext( "Server/Service/Connector/Factory",
  +                             "setFactory",
  +                             "org.apache.catalina.net.ServerSocketFactory" );
  +
  +        digester.addObjectCreate( "Server/Service/Connector/Listener",
  +                                  null, // MUST be specified in the element
  +                                  "className" );
  +        digester.addSetProperties( "Server/Service/Connector/Listener" );
  +        digester.addSetNext( "Server/Service/Connector/Listener",
  +                             "addLifecycleListener",
  +                             "org.apache.catalina.LifecycleListener" );
  +
  +        digester.addRuleSet( new NamingRuleSet( "Server/GlobalNamingResources/" ) );
  +        digester.addRuleSet( new EngineRuleSet( "Server/Service/" ) );
  +        digester.addRuleSet( new HostRuleSet( "Server/Service/Engine/" ) );
  +        digester.addRuleSet( new ContextRuleSet( "Server/Service/Engine/Default" ) );
  +        digester.addRuleSet( new NamingRuleSet( "Server/Service/Engine/DefaultContext/" ) );
  +        digester.addRuleSet( new ContextRuleSet( "Server/Service/Engine/Host/Default" ) );
  +        digester.addRuleSet( new NamingRuleSet( "Server/Service/Engine/Host/DefaultContext/" ) );
  +        digester.addRuleSet( new ContextRuleSet( "Server/Service/Engine/Host/" ) );
  +        digester.addRuleSet( new NamingRuleSet( "Server/Service/Engine/Host/Context/" ) );
  +
  +        digester.addRule( "Server/Service/Engine",
  +                          new SetParentClassLoaderRule( digester,
  +                                                        m_parentLoader ) );
  +        return ( digester );
       }
   
  -    /**
  -     * get the config file
  -     * @return the File
  -     */
  -    protected File getConfigFile()
  -    {
  -
  -        File file = new File(m_configFile);
  -        if (!file.isAbsolute())
  -        {
  -            file = new File(System.getProperty("catalina.base"), m_configFile);
  -        }
  -        return (file);
  +    protected File configFile() {
  +
  +        File file = new File( m_configFile );
  +        if( !file.isAbsolute() )
  +            file = new File( System.getProperty( "catalina.base" ), m_configFile );
  +        return ( file );
   
       }
   }
  
  
  
  1.2       +163 -257  jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevakBootstrap.java
  
  Index: CatalinaSevakBootstrap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevakBootstrap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CatalinaSevakBootstrap.java	29 Sep 2002 11:38:42 -0000	1.1
  +++ CatalinaSevakBootstrap.java	30 Sep 2002 22:03:12 -0000	1.2
  @@ -8,6 +8,7 @@
   package org.apache.avalon.apps.sevak.blocks.catalina;
   
   import java.lang.reflect.Method;
  +import java.lang.reflect.InvocationTargetException;
   import org.apache.avalon.apps.sevak.Sevak;
   import org.apache.avalon.apps.sevak.SevakException;
   import org.apache.avalon.apps.sevak.MultihostSevak;
  @@ -20,6 +21,7 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.phoenix.BlockContext;
   
   import java.io.File;
   
  @@ -27,318 +29,222 @@
    * @phoenix:block
    * @phoenix:service name="org.apache.avalon.apps.sevak.MultihostSevak"
    *
  - * Catalina Sevak Bootstrapper.  This class will bootstrap all Tomcat libraries dynamically.
  - * It also acts as a Wrapper around the CatalinaSevak class which directly utilizes Tomcat
  - * libraries and therefore cannot be loaded directly by Phoenix without creating hard linkages
  - * between the two.
  + * Catalina Sevak Bootstrapper.  This class will bootstrap all Tomcat libraries dynamically.  It also acts
  + * as a Wrapper around the CatalinaSevak class which directly utilizes Tomcat libraries and therefore cannot
  + * be loaded directly by Phoenix without creating hard linkages between the two.
    *
  - * Catalina Sevak provides the true service by directly manipulating Tomcat classes.  All Catalina
  - * Sevak clients will call to the CatalinaSevakBootstrap which will delegate the true work to
  - * CatalinaSevak.
  + * Catalina Sevak provides the true service by directly manipulating Tomcat classes.  All Catalina Sevak clients
  + * will call to the CatalinaSevakBootstrap which will delegate the true work to CatalinaSevak.
    *
  - * This bootstrap approach allows Tomcat to be embedded into Phoenix directly and administrated
  - * as a standard installation while providing the ability for other Phoenix services to deploy
  - * and undeploy Web Applications.
  + * This bootstrap approach allows Tomcat to be embedded into Phoenix directly and administrated as a standard
  + * installation while providing the ability for other Phoenix services to deploy and undeploy Web Applications.
    *
    *
    * @see <a href="http://jakarta.apache.org/tomcat">Tomcat Project Page</a>
    *
    * @author  Daniel Krieg<dkrieg@kc.rr.com>
  - * @version $Revision$ $Date$
  + * @version 1.0
    */
   public class CatalinaSevakBootstrap
           extends AbstractLogEnabled
  -        implements Contextualizable, Configurable, Initializable, Startable, Sevak, MultihostSevak
  -{
  -    private Context m_context;
  +        implements Contextualizable, Configurable, Initializable, Startable, Sevak, MultihostSevak {
  +    private BlockContext m_context;
       private Configuration m_configuration;
       private Object m_sevak;
       private String m_catalinaHome;
       private String m_catalinaBase;
       private boolean m_useNaming;
       private String m_configFile;
  +    private final static String C_HOST = "localhost";
   
  -    /**
  -     * Contextualize
  -     * @param context the context
  -     * @throws ContextException if a problem
  -     */
  -    public void contextualize(Context context) throws ContextException
  -    {
  -        getLogger().debug("CatalinaSevakBootstrap.contextualize()");
  -        m_context = context;
  -    }
  -
  -    /**
  -     * Configure block
  -     * @param configuration the configuration
  -     * @throws ConfigurationException if a problem
  -     */
  -    public void configure(Configuration configuration) throws ConfigurationException
  -    {
  -        getLogger().debug("CatalinaSevakBootstrap.configure()");
  +    public void contextualize( Context context ) throws ContextException {
  +        getLogger().debug( "CatalinaSevakBootstrap.contextualize()" );
  +        m_context = (BlockContext)context;
  +    }
  +
  +    public void configure( Configuration configuration ) throws ConfigurationException {
  +        getLogger().debug( "CatalinaSevakBootstrap.configure()" );
           m_configuration = configuration;
   
  -        m_catalinaHome = m_configuration.getChild("catalina-home").getValue("default");
  -        m_catalinaBase = m_configuration.getChild("catalina-base").getValue("default");
  -        m_configFile = m_configuration.getChild("config-file").getValue("conf/server.xml");
  -        m_useNaming = m_configuration.getChild("use-naming").getValueAsBoolean(true);
  +        m_catalinaHome = m_configuration.getChild( "catalina-home" ).getValue( m_context.getBaseDirectory().getAbsolutePath()
  +        );
  +        m_catalinaBase = m_configuration.getChild( "catalina-base" ).getValue( m_context.getBaseDirectory().getAbsolutePath() );
  +        m_configFile = m_configuration.getChild( "config-file" ).getValue( "conf/server.xml" );
  +        m_useNaming = m_configuration.getChild( "use-naming" ).getValueAsBoolean( true );
   
           setCatalinaHome();
           setCatalinaBase();
  -        getLogger().debug("Catalina Home: " + getCatalinaHome());
  -        getLogger().debug("Catalina Base: " + getCatalinaBase());
  +        getLogger().debug( "Catalina Home: " + getCatalinaHome() );
  +        getLogger().debug( "Catalina Base: " + getCatalinaBase() );
       }
   
  -    /**
  -     * Initialize
  -     * @throws Exception if a problem
  -     */
  -    public void initialize() throws Exception
  -    {
  -        getLogger().debug("CatalinaSevakBootstrap.initialize()");
  -        CatalinaSevakClassLoaderFactory catalinaSevakClassLoaderFactory
  -                = new CatalinaSevakClassLoaderFactory();
  -        catalinaSevakClassLoaderFactory.enableLogging(getLogger());
  +    public void initialize() throws Exception {
  +        getLogger().debug( "CatalinaSevakBootstrap.initialize()" );
  +        CatalinaSevakClassLoaderFactory.setLogger( getLogger() );
   
           // Construct the class loaders we will need
           ClassLoader bootstrapLoader = null;
           ClassLoader commonLoader = null;
           ClassLoader sevakLoader = null;
           ClassLoader sharedLoader = null;
  -        File[] unpacked = new File[1];
  -        File[] packed = new File[1];
  -        File[] packed2 = new File[2];
  -
  -        //  load bootstrap classes
  -        packed[0] = new File(getCatalinaHome(), "bin");
  -        bootstrapLoader = catalinaSevakClassLoaderFactory.createClassLoader(null, packed, null);
  -        getLogger().debug("Loaded bin dir...");
  -
  -        //  load common directory
  -        unpacked[0] = new File(getCatalinaHome(), "common" + File.separator + "classes");
  -        packed2[0] = new File(getCatalinaHome(), "common" + File.separator + "endorsed");
  -        packed2[1] = new File(getCatalinaHome(), "common" + File.separator + "lib");
  -        commonLoader = catalinaSevakClassLoaderFactory.createClassLoader(unpacked, packed2,
  -                bootstrapLoader);
  -        getLogger().debug("Loaded common dir...");
  -
  -        //  load server directory
  -        unpacked[0] = new File(getCatalinaHome(), "server" + File.separator + "classes");
  -        packed2[0] = new File(getCatalinaHome(), "server" + File.separator + "lib");
  -        packed2[1] = new File(getStartupDir());
  -        sevakLoader = catalinaSevakClassLoaderFactory.createClassLoader(unpacked, packed2,
  -                commonLoader);
  -        getLogger().debug("Loaded server dir...");
  -        getLogger().debug("Loaded startup dir..." + packed2[1].getAbsoluteFile());
  -
  -        //  load shared directory
  -        unpacked[0] = new File(getCatalinaBase(), "shared" + File.separator + "classes");
  -        packed[0] = new File(getCatalinaBase(), "shared" + File.separator + "lib");
  -        sharedLoader = catalinaSevakClassLoaderFactory.createClassLoader(unpacked, packed,
  -                commonLoader);
  -        getLogger().debug("Loaded shared dir...");
  -
  -        // Load our startup class and run its lifecycle
  -        Thread.currentThread().setContextClassLoader(commonLoader);
  -        catalinaSevakClassLoaderFactory.securityClassLoad(commonLoader);
  -
  -        // Instantiate a startup class instance
  -        getLogger().debug("Loading startup class");
  -        Class startupClass =
  -                sevakLoader.loadClass("org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevak");
  -        getLogger().debug("Startup class loaded: " + startupClass);
  -        m_sevak = startupClass.newInstance();
  -
  -        // Set the shared extensions class loader
  -        Class paramTypes[] = new Class[1];
  -        Object paramValues[] = new Object[1];
  -        getLogger().debug("Setting startup class properties");
  -
  -        String methodName = "setParentClassLoader";
  -        paramTypes[0] = Class.forName("java.lang.ClassLoader");
  -        paramValues[0] = commonLoader;
  -        Method method = m_sevak.getClass().getMethod(methodName, paramTypes);
  -        method.invoke(m_sevak, paramValues);
  -
  -        methodName = "setUseNaming";
  -        paramTypes[0] = Boolean.TYPE;
  -        paramValues[0] = (m_useNaming) ? Boolean.TRUE : Boolean.FALSE;
  -        method = m_sevak.getClass().getMethod(methodName, paramTypes);
  -        method.invoke(m_sevak, paramValues);
  -
  -        methodName = "setConfigFile";
  -        paramTypes[0] = String.class;
  -        paramValues[0] = m_configFile;
  -        method = m_sevak.getClass().getMethod(methodName, paramTypes);
  -        method.invoke(m_sevak, paramValues);
  -
  -        methodName = "initialize";
  -        method = m_sevak.getClass().getMethod(methodName, null);
  -        method.invoke(m_sevak, null);
  -
  -        getLogger().debug("CatalinaSevakBootstrap complete.");
  -    }
  -
  -    /**
  -     * Start the server
  -     * @throws Exception if aproblem
  -     */
  -    public void start() throws Exception
  -    {
  -        getLogger().debug("CatalinaSevakBootstrap.start()");
  -        m_sevak.getClass().getMethod("start", null).invoke(m_sevak, null);
  -    }
  -
  -    /**
  -     * Stop the server
  -     * @throws Exception if a problem
  -     */
  -    public void stop() throws Exception
  -    {
  -        getLogger().debug("CatalinaSevakBootstrap.stop()");
  -        m_sevak.getClass().getMethod("stop", null).invoke(m_sevak, null);
  -    }
  -
  -    /**
  -     * Deploy the a webapp
  -     * @param context the context to use
  -     * @param pathToWebAppFolder the path to the war file
  -     * @throws SevakException if a problem
  -     */
  -    public void deploy(String context, File pathToWebAppFolder) throws SevakException
  -    {
  -        getLogger().debug("CatalinaSevakBootstrap.deploy()");
  -        deploy(LOCALHOST, context, pathToWebAppFolder);
  -    }
  -
  -    /**
  -     * Undeploy a webapp
  -     * @param context the context
  -     * @throws SevakException if a problem
  -     */
  -    public void undeploy(String context) throws SevakException
  -    {
  -        getLogger().debug("CatalinaSevakBootstrap.undeploy()");
  -        undeploy(LOCALHOST, context);
  -    }
  -
  -    /**
  -     * Deploy a webapp
  -     * @param host the host to bind to
  -     * @param context the context to use
  -     * @param pathToWebAppFolder the path to the web app
  -     * @throws SevakException if a problem
  -     */
  -    public void deploy(String host, String context, File pathToWebAppFolder) throws SevakException
  -    {
  +        try {
  +            File[] unpacked = new File[ 1 ];
  +            File[] packed = new File[ 1 ];
  +            File[] packed2 = new File[ 2 ];
  +
  +            //  load bootstrap classes
  +            packed[ 0 ] = new File( getCatalinaHome(), "bin" );
  +            bootstrapLoader = CatalinaSevakClassLoaderFactory.createClassLoader( null, packed, null );
  +            getLogger().debug( "Loaded bin dir..." );
  +
  +            //  load common directory
  +            unpacked[ 0 ] = new File( getCatalinaHome(), "common" + File.separator + "classes" );
  +            packed2[ 0 ] = new File( getCatalinaHome(), "common" + File.separator + "endorsed" );
  +            packed2[ 1 ] = new File( getCatalinaHome(), "common" + File.separator + "lib" );
  +            commonLoader = CatalinaSevakClassLoaderFactory.createClassLoader( unpacked, packed2, bootstrapLoader );
  +            getLogger().debug( "Loaded common dir..." );
  +
  +            //  load server directory
  +            unpacked[ 0 ] = new File( getCatalinaHome(), "server" + File.separator + "classes" );
  +            packed2[ 0 ] = new File( getCatalinaHome(), "server" + File.separator + "lib" );
  +            packed2[ 1 ] = new File( getStartupDir() );
  +            sevakLoader = CatalinaSevakClassLoaderFactory.createClassLoader( unpacked, packed2, commonLoader );
  +            getLogger().debug( "Loaded server dir..." );
  +            getLogger().debug( "Loaded startup dir..." + packed2[ 1 ].getAbsoluteFile() );
  +
  +            //  load shared directory
  +            unpacked[ 0 ] = new File( getCatalinaBase(), "shared" + File.separator + "classes" );
  +            packed[ 0 ] = new File( getCatalinaBase(), "shared" + File.separator + "lib" );
  +            sharedLoader = CatalinaSevakClassLoaderFactory.createClassLoader( unpacked, packed, commonLoader );
  +            getLogger().debug( "Loaded shared dir..." );
  +        } catch( Exception e ) {
  +            getLogger().fatalError( "Class loader creation threw exception", e );
  +            throw e;
  +        }
  +
  +        try {
  +            // Load our startup class and run its lifecycle
  +            Thread.currentThread().setContextClassLoader( sevakLoader );
  +            CatalinaSevakClassLoaderFactory.securityClassLoad( sevakLoader );
  +
  +            // Instantiate a startup class instance
  +            getLogger().debug( "Loading startup class" );
  +            Class startupClass =
  +                    sevakLoader.loadClass( "org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevak" );
  +            getLogger().debug( "Startup class loaded: " + startupClass );
  +            m_sevak = startupClass.newInstance();
  +
  +            // Set the shared extensions class loader
  +            Class paramTypes[] = new Class[ 1 ];
  +            Object paramValues[] = new Object[ 1 ];
  +            getLogger().debug( "Setting startup class properties" );
  +
  +            String methodName = "setParentClassLoader";
  +            paramTypes[ 0 ] = Class.forName( "java.lang.ClassLoader" );
  +            paramValues[ 0 ] = commonLoader;
  +            Method method = m_sevak.getClass().getMethod( methodName, paramTypes );
  +            method.invoke( m_sevak, paramValues );
  +
  +            methodName = "setUseNaming";
  +            paramTypes[ 0 ] = Boolean.TYPE;
  +            paramValues[ 0 ] = ( m_useNaming ) ? Boolean.TRUE : Boolean.FALSE;
  +            method = m_sevak.getClass().getMethod( methodName, paramTypes );
  +            method.invoke( m_sevak, paramValues );
  +
  +            methodName = "setConfigFile";
  +            paramTypes[ 0 ] = String.class;
  +            paramValues[ 0 ] = m_configFile;
  +            method = m_sevak.getClass().getMethod( methodName, paramTypes );
  +            method.invoke( m_sevak, paramValues );
  +
  +            methodName = "initialize";
  +            method = m_sevak.getClass().getMethod( methodName, null );
  +            method.invoke( m_sevak, null );
  +        } catch( Exception e ) {
  +            getLogger().fatalError( "Exception during startup processing", e );
  +            throw e;
  +        }
  +        getLogger().debug( "CatalinaSevakBootstrap complete." );
  +    }
  +
  +    public void start() throws Exception {
  +        getLogger().debug( "CatalinaSevakBootstrap.start()" );
  +        m_sevak.getClass().getMethod( "start", null ).invoke( m_sevak, null );
  +    }
  +
  +    public void stop() throws Exception {
  +        getLogger().debug( "CatalinaSevakBootstrap.stop()" );
  +        m_sevak.getClass().getMethod( "stop", null ).invoke( m_sevak, null );
  +    }
  +
  +    public void deploy( String context, File pathToWebAppFolder ) throws SevakException {
  +        getLogger().debug( "CatalinaSevakBootstrap.deploy()" );
  +        deploy( C_HOST, context, pathToWebAppFolder );
  +    }
  +
  +    public void undeploy( String context ) throws SevakException {
  +        getLogger().debug( "CatalinaSevakBootstrap.undeploy()" );
  +        undeploy( C_HOST, context );
  +    }
  +
  +    public void deploy( String host, String context, File pathToWebAppFolder ) throws SevakException {
           Class[] paramTypes = {String.class, String.class, File.class};
           Object[] paramValues = {host, context, pathToWebAppFolder};
  -        try
  -        {
  -            m_sevak.getClass().getMethod("deploy", paramTypes).invoke(m_sevak, paramValues);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new SevakException("Unable to deploy", e);
  +        try {
  +            m_sevak.getClass().getMethod( "deploy", paramTypes ).invoke( m_sevak, paramValues );
  +        } catch( Exception e ) {
  +            throw new SevakException( "Unable to deploy", e );
           }
       }
   
  -    /**
  -     * Undeploy a webapp
  -     * @param host The host to bind to
  -     * @param context the context for teh webapp
  -     * @throws SevakException if a problem
  -     */
  -    public void undeploy(String host, String context) throws SevakException
  -    {
  +    public void undeploy( String host, String context ) throws SevakException {
           Class[] paramTypes = {String.class, String.class};
           Object[] paramValues = {host, context};
  -        try
  -        {
  -            m_sevak.getClass().getMethod("undeploy", paramTypes).invoke(m_sevak, paramValues);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new SevakException("Unable to undeploy", e);
  +        try {
  +            m_sevak.getClass().getMethod( "undeploy", paramTypes ).invoke( m_sevak, paramValues );
  +        } catch( Exception e ) {
  +            throw new SevakException( "Unable to undeploy", e );
           }
       }
   
  -
  -    /**
  -     * Set the base for catalina
  -     * This a bit dirty for Phoenix but necessary
  -     */
  -    private void setCatalinaBase()
  -    {
  -        if (m_catalinaBase.equals("default"))
  -        {
  -            System.setProperty("catalina.base", getCatalinaHome());
  -        }
  -        else if (m_catalinaBase.equals("user.dir"))
  -        {
  -            System.setProperty("catalina.base", System.getProperty("user.dir"));
  -        }
  -        else
  -        {
  -            System.setProperty("catalina.base", m_catalinaBase);
  +    private void setCatalinaBase() {
  +        if( m_catalinaBase.equals( "default" ) ) {
  +            System.setProperty( "catalina.base", getCatalinaHome() );
  +        } else if( m_catalinaBase.equals( "user.dir" ) ) {
  +            System.setProperty( "catalina.base", System.getProperty( "user.dir" ) );
  +        } else {
  +            System.setProperty( "catalina.base", m_catalinaBase );
           }
       }
   
  -    /**
  -     * Get the Base for Catalina.
  -     * @return Catalina's base.
  -     */
  -    private String getCatalinaBase()
  -    {
  -        if (System.getProperty("catalina.base") == null)
  -        {
  +    private String getCatalinaBase() {
  +        if( System.getProperty( "catalina.base" ) == null ) {
               setCatalinaBase();
           }
  -        return System.getProperty("catalina.base");
  +        return System.getProperty( "catalina.base" );
       }
   
  -    /**
  -     * Set the home for catalina
  -     * This a bit dirty for Phoenix but necessary
  -     */
  -    private void setCatalinaHome()
  -    {
  -        if (m_catalinaHome.equals("default"))
  -        {
  -            System.setProperty("catalina.home", System.getProperty("phoenix.home")
  -                    + File.separator + "catalina");
  -        }
  -        else
  -        {
  -            System.setProperty("catalina.home", m_catalinaHome);
  +    private void setCatalinaHome() {
  +        if( m_catalinaHome.equals( "default" ) ) {
  +            System.setProperty( "catalina.home", System.getProperty( "phoenix.home" ) + File.separator + "catalina" );
  +        } else {
  +            System.setProperty( "catalina.home", m_catalinaHome );
           }
       }
   
  -    /**
  -     * Get the Home for Catalina.
  -     * @return Catalina's home.
  -     */
  -    private String getCatalinaHome()
  -    {
  -        if (System.getProperty("catalina.home") == null)
  -        {
  +    private String getCatalinaHome() {
  +        if( System.getProperty( "catalina.home" ) == null ) {
               setCatalinaHome();
           }
  -        return System.getProperty("catalina.home");
  +        return System.getProperty( "catalina.home" );
       }
   
  -    /**
  -     * Get the directory that this was started in
  -     * @return The directory that jar file for this block was started in.
  -     */
  -    private String getStartupDir()
  -    {
  +    private String getStartupDir() {
           String startup = this.getClass().getClassLoader()
  -                .getResource("org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevak.class")
  +                .getResource( "org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevak.class" )
                   .toExternalForm();
  -        startup = startup.substring("jar:file:/".length(), startup.indexOf("!"));
  -        getLogger().debug("Start up JAR " + startup);
  -        return new File(startup).getParent();
  +        startup = startup.substring( "jar:file:/".length(), startup.indexOf( "!" ) );
  +        getLogger().debug( "Start up JAR " + startup );
  +        return new File( startup ).getParent();
       }
   }
  
  
  
  1.2       +86 -138   jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevakClassLoaderFactory.java
  
  Index: CatalinaSevakClassLoaderFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevakClassLoaderFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CatalinaSevakClassLoaderFactory.java	29 Sep 2002 11:38:42 -0000	1.1
  +++ CatalinaSevakClassLoaderFactory.java	30 Sep 2002 22:03:12 -0000	1.2
  @@ -9,12 +9,9 @@
   
   
   import java.lang.reflect.Method;
  -
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.CascadingRuntimeException;
  +import org.apache.avalon.framework.logger.Logger;
   
   import java.io.File;
  -import java.io.IOException;
   
   import java.net.URL;
   import java.net.URLClassLoader;
  @@ -31,190 +28,141 @@
    * @see <a href="http://jakarta.apache.org/tomcat">Tomcat Project Page</a>
    *
    * @author  Daniel Krieg<dkrieg@kc.rr.com>
  - * @version $Revision$ $Date$
  + * @version 1.0
    */
  -public final class CatalinaSevakClassLoaderFactory extends AbstractLogEnabled
  -{
  +public final class CatalinaSevakClassLoaderFactory {
  +    private static Logger m_logger;
   
  -    /**
  -     * Create a ClassLoader for Catalina
  -     * @param unpacked unpacked files
  -     * @param packed packed files
  -     * @param parent the parent classloader
  -     * @return The classloader
  -     * @throws IOException if a problem
  -     * @throws ClassNotFoundException if a problem
  -     */
  -    public ClassLoader createClassLoader(File unpacked[], File packed[], ClassLoader parent)
  -            throws IOException, ClassNotFoundException
  -    {
  -        getLogger().debug("Creating new class loader");
  +    public static ClassLoader createClassLoader( File unpacked[], File packed[], ClassLoader parent )
  +            throws Exception {
  +        getLogger().debug( "Creating new class loader" );
   
           // Construct the "class path" for this class loader
           ArrayList stringList = new ArrayList();
           ArrayList urlList = new ArrayList();
   
           // Add unpacked directories
  -        if (unpacked != null)
  -        {
  -            for (int i = 0; i < unpacked.length; i++)
  -            {
  -                File file = unpacked[i];
  -                if (!file.isDirectory() || !file.exists() || !file.canRead())
  -                {
  +        if( unpacked != null ) {
  +            for( int i = 0; i < unpacked.length; i++ ) {
  +                File file = unpacked[ i ];
  +                if( !file.isDirectory() || !file.exists() || !file.canRead() )
                       continue;
  -                }
  -                getLogger().debug("  Including directory " + file.getAbsolutePath());
  -                URL url = new URL("file", null,
  -                        file.getCanonicalPath() + File.separator);
  -                stringList.add(url.toString());
  -                urlList.add(url);
  +                getLogger().debug( "  Including directory " + file.getAbsolutePath() );
  +                URL url = new URL( "file", null,
  +                                   file.getCanonicalPath() + File.separator );
  +                stringList.add( url.toString() );
  +                urlList.add( url );
               }
           }
   
           // Add packed directory JAR files
  -        if (packed != null)
  -        {
  -            for (int i = 0; i < packed.length; i++)
  -            {
  -                File directory = packed[i];
  -                if (!directory.isDirectory()
  -                        || !directory.exists()
  -                        || !directory.canRead())
  -                {
  +        if( packed != null ) {
  +            for( int i = 0; i < packed.length; i++ ) {
  +                File directory = packed[ i ];
  +                if( !directory.isDirectory() || !directory.exists() ||
  +                        !directory.canRead() )
                       continue;
  -                }
                   String filenames[] = directory.list();
  -                for (int j = 0; j < filenames.length; j++)
  -                {
  -                    String filename = filenames[j].toLowerCase();
  -                    if (!filename.endsWith(".jar"))
  -                    {
  +                for( int j = 0; j < filenames.length; j++ ) {
  +                    String filename = filenames[ j ].toLowerCase();
  +                    if( !filename.endsWith( ".jar" ) )
                           continue;
  -                    }
  -                    File file = new File(directory, filenames[j]);
  -                    getLogger().debug(("  Including jar file " + file.getAbsolutePath()));
  -                    URL url = new URL("file", null,
  -                            file.getCanonicalPath());
  -                    stringList.add(url.toString());
  -                    urlList.add(url);
  +                    File file = new File( directory, filenames[ j ] );
  +                    getLogger().debug( ( "  Including jar file " + file.getAbsolutePath() ) );
  +                    URL url = new URL( "file", null,
  +                                       file.getCanonicalPath() );
  +                    stringList.add( url.toString() );
  +                    urlList.add( url );
                   }
               }
           }
   
           // Construct the class loader itself
  -        String[] stringArray = (String[]) stringList.toArray(new String[stringList.size()]);
  -        URL[] urlArray = (URL[]) urlList.toArray(new URL[urlList.size()]);
  -        Class loaderClass = (parent == null)
  -                ? URLClassLoader.newInstance(urlArray)
  -                    .loadClass("org.apache.catalina.loader.StandardClassLoader")
  -                : URLClassLoader.newInstance(urlArray, parent)
  -                    .loadClass("org.apache.catalina.loader.StandardClassLoader");
  +        String[] stringArray = (String[]) stringList.toArray( new String[ stringList.size() ] );
  +        URL[] urlArray = (URL[]) urlList.toArray( new URL[ urlList.size() ] );
  +        Class loaderClass = ( parent == null ) ? URLClassLoader.newInstance( urlArray ).loadClass( "org.apache.catalina.loader.StandardClassLoader" )
  +                : URLClassLoader.newInstance( urlArray, parent ).loadClass( "org.apache.catalina.loader.StandardClassLoader" );
   
  -        getLogger().debug(loaderClass.getName() + " successfully loaded.");
  +        getLogger().debug( loaderClass.getName() + " successfully loaded." );
           Object loader = null;
   
  -        if (parent == null)
  -        {
  -            try
  -            {
  -                loader = loaderClass.getConstructor(new Class[]{stringArray.getClass()})
  -                        .newInstance(new Object[]{stringArray});
  -            }
  -            catch (Exception e)
  -            {
  -                throw new CascadingRuntimeException("Some problem constructing using reflection",e);
  -            }
  -        }
  -        else
  -        {
  -            try
  -            {
  -                loader = loaderClass.getConstructor(new Class[]{stringArray.getClass(),
  -                        ClassLoader.class}).newInstance(new Object[]{stringArray, parent});
  -            }
  -            catch (Exception e)
  -            {
  -                throw new CascadingRuntimeException("Some problem constructing using reflection",e);
  -            }
  +        if( parent == null ) {
  +            loader = loaderClass.getConstructor( new Class[]{stringArray.getClass()} )
  +                    .newInstance( new Object[]{stringArray} );
  +        } else {
  +            loader = loaderClass.getConstructor( new Class[]{stringArray.getClass(), ClassLoader.class} )
  +                    .newInstance( new Object[]{stringArray, parent} );
           }
   
  -        getLogger().debug("Setting loader to delegate=true");
  -        try
  -        {
  -            Method delegating = loader.getClass().getMethod("setDelegate",
  -                    new Class[]{Boolean.TYPE});
  -            delegating.invoke(loader, new Object[]{Boolean.TRUE});
  -        }
  -        catch (Exception e)
  -        {
  -            throw new CascadingRuntimeException("Some problem invoking methods using reflection",e);
  -        }
  -        getLogger().debug("Class Loader Intance: " + loader);
  +        getLogger().debug( "Setting loader to delegate=true" );
  +        Method delegating = loader.getClass().getMethod( "setDelegate", new Class[]{Boolean.TYPE} );
  +        delegating.invoke( loader, new Object[]{Boolean.TRUE} );
  +        getLogger().debug( "Class Loader Intance: " + loader );
   
  -        getLogger().debug("ClassLoader creation completed...");
  +        getLogger().debug( "ClassLoader creation completed..." );
           return (ClassLoader) loader;
   
       }
   
  -    /**
  -     * Load some securty stuff for Catalina.
  -     * @param loader the loader
  -     * @throws Exception if a problem
  -     */
  -    public void securityClassLoad(ClassLoader loader) throws Exception
  -    {
  +    public static void securityClassLoad( ClassLoader loader ) throws Exception {
   
  -        if (System.getSecurityManager() == null)
  -        {
  +        if( System.getSecurityManager() == null )
               return;
  -        }
   
           String basePackage = "org.apache.catalina.";
           loader.loadClass
  -                (basePackage
  -                + "core.ApplicationContext$PrivilegedGetRequestDispatcher");
  +                ( basePackage +
  +                  "core.ApplicationContext$PrivilegedGetRequestDispatcher" );
           loader.loadClass
  -                (basePackage
  -                + "core.ApplicationContext$PrivilegedGetResource");
  +                ( basePackage +
  +                  "core.ApplicationContext$PrivilegedGetResource" );
           loader.loadClass
  -                (basePackage
  -                + "core.ApplicationContext$PrivilegedGetResourcePaths");
  +                ( basePackage +
  +                  "core.ApplicationContext$PrivilegedGetResourcePaths" );
           loader.loadClass
  -                (basePackage
  -                + "core.ApplicationContext$PrivilegedLogMessage");
  +                ( basePackage +
  +                  "core.ApplicationContext$PrivilegedLogMessage" );
           loader.loadClass
  -                (basePackage
  -                + "core.ApplicationContext$PrivilegedLogException");
  +                ( basePackage +
  +                  "core.ApplicationContext$PrivilegedLogException" );
           loader.loadClass
  -                (basePackage
  -                + "core.ApplicationContext$PrivilegedLogThrowable");
  +                ( basePackage +
  +                  "core.ApplicationContext$PrivilegedLogThrowable" );
           loader.loadClass
  -                (basePackage
  -                + "core.ApplicationDispatcher$PrivilegedForward");
  +                ( basePackage +
  +                  "core.ApplicationDispatcher$PrivilegedForward" );
           loader.loadClass
  -                (basePackage
  -                + "core.ApplicationDispatcher$PrivilegedInclude");
  +                ( basePackage +
  +                  "core.ApplicationDispatcher$PrivilegedInclude" );
           loader.loadClass
  -                (basePackage
  -                + "core.ContainerBase$PrivilegedAddChild");
  +                ( basePackage +
  +                  "core.ContainerBase$PrivilegedAddChild" );
           loader.loadClass
  -                (basePackage
  -                + "connector.HttpRequestBase$PrivilegedGetSession");
  +                ( basePackage +
  +                  "connector.HttpRequestBase$PrivilegedGetSession" );
           loader.loadClass
  -                (basePackage
  -                + "connector.HttpResponseBase$PrivilegedFlushBuffer");
  +                ( basePackage +
  +                  "connector.HttpResponseBase$PrivilegedFlushBuffer" );
           loader.loadClass
  -                (basePackage
  -                + "loader.WebappClassLoader$PrivilegedFindResource");
  +                ( basePackage +
  +                  "loader.WebappClassLoader$PrivilegedFindResource" );
           loader.loadClass
  -                (basePackage + "session.StandardSession");
  +                ( basePackage + "session.StandardSession" );
           loader.loadClass
  -                (basePackage + "util.CookieTools");
  +                ( basePackage + "util.CookieTools" );
           loader.loadClass
  -                (basePackage + "util.URL");
  -        loader.loadClass(basePackage + "util.Enumerator");
  -        loader.loadClass("javax.servlet.http.Cookie");
  +                ( basePackage + "util.URL" );
  +        loader.loadClass( basePackage + "util.Enumerator" );
  +        loader.loadClass( "javax.servlet.http.Cookie" );
  +
  +    }
  +
  +
  +    public static void setLogger( Logger logger ) {
  +        m_logger = logger;
  +    }
   
  +    private static Logger getLogger() {
  +        return m_logger;
       }
   }
  
  
  
  1.2       +63 -334   jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevakServer.java
  
  Index: CatalinaSevakServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevakServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CatalinaSevakServer.java	29 Sep 2002 11:38:42 -0000	1.1
  +++ CatalinaSevakServer.java	30 Sep 2002 22:03:12 -0000	1.2
  @@ -1,371 +1,100 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE file.
  - */
   package org.apache.avalon.apps.sevak.blocks.catalina;
   
  -import org.apache.catalina.Deployer;
   import org.apache.catalina.Lifecycle;
   import org.apache.catalina.LifecycleException;
   import org.apache.catalina.LifecycleListener;
   import org.apache.catalina.Server;
   import org.apache.catalina.Service;
   import org.apache.catalina.deploy.NamingResources;
  -import org.apache.catalina.util.LifecycleSupport;
  +import org.apache.catalina.core.StandardServer;
   
  -/**
  - * Catalina Sevak Server
  - *
  - * @author  Daniel Krieg<dkrieg@kc.rr.com>
  - * @version $Revision$ $Date$
  - */
  -public class CatalinaSevakServer implements Server, Lifecycle, Runnable
  -{
  -    private static final String C_INFO = CatalinaSevakServer.class.getName();
  -    private LifecycleSupport m_lifecycleSupport = new LifecycleSupport(this);
  -    private String m_shutdown = "SHUTDOWN";
  -    private Service[] m_services = new Service[0];
  -    private int m_port = 8005;
  -    private boolean m_initialized = false;
  -    private boolean m_started = false;
  -    private NamingResources m_globalNamingResources;
  -    private boolean m_serving = false;
  -
  -    /**
  -     * As per runnable
  -     */
  -    public void run()
  -    {
  -        while (m_serving)
  -        {
  -            try
  -            {
  -                Thread.sleep(3 * 1000); // Three seconds
  -            }
  -            catch (InterruptedException e)
  -            {
  -                System.out.println("CatalinaSevakServer.run: " + e);
  -            }
  -        }
  +
  +public class CatalinaSevakServer implements Server, Lifecycle, Runnable {
  +    private final StandardServer m_standardServer = new StandardServer();
  +    private boolean m_serving;
  +
  +    public String getInfo() {
  +        return m_standardServer.getInfo();
       }
   
  -    /**
  -     * Await
  -     */
  -    public void await()
  -    {
  -        Thread t = new Thread(this);
  -        t.start();
  +    public NamingResources getGlobalNamingResources() {
  +        return m_standardServer.getGlobalNamingResources();
       }
   
  -    /**
  -     * Start
  -     * @throws LifecycleException if a problem
  -     */
  -    public void start() throws LifecycleException
  -    {
  -        if (m_started)
  -        {
  -            throw new LifecycleException("This server has already been started");
  -        }
  +    public void setGlobalNamingResources( NamingResources globalNamingResources ) {
  +        m_standardServer.setGlobalNamingResources(globalNamingResources);
  +    }
   
  -        m_lifecycleSupport.fireLifecycleEvent(BEFORE_START_EVENT, null);
  -        m_lifecycleSupport.fireLifecycleEvent(START_EVENT, null);
  -        m_started = true;
  -
  -        synchronized (m_services)
  -        {
  -            for (int i = 0; i < m_services.length; i++)
  -            {
  -                if (m_services[i] instanceof Lifecycle)
  -                {
  -                    ((Lifecycle) m_services[i]).start();
  -                }
  -            }
  -        }
  +    public int getPort() {
  +        return m_standardServer.getPort();
  +    }
   
  -        m_lifecycleSupport.fireLifecycleEvent(AFTER_START_EVENT, null);
  +    public void setPort( int port ) {
  +        m_standardServer.setPort(port);
       }
   
  -    /**
  -     * Stop
  -     * @throws LifecycleException if a problem
  -     */
  -    public void stop() throws LifecycleException
  -    {
  -        if (!m_started)
  -        {
  -            throw new LifecycleException("This server has not yet been started");
  -        }
  +    public String getShutdown() {
  +        return m_standardServer.getShutdown();
  +    }
   
  -        m_lifecycleSupport.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
  -        m_lifecycleSupport.fireLifecycleEvent(STOP_EVENT, null);
  -        m_started = false;
  -
  -        for (int i = 0; i < m_services.length; i++)
  -        {
  -            if (m_services[i] instanceof Lifecycle)
  -            {
  -                ((Lifecycle) m_services[i]).stop();
  -            }
  -        }
  +    public void setShutdown( String shutdown ) {
  +        m_standardServer.setShutdown(shutdown);
  +    }
   
  -        m_lifecycleSupport.fireLifecycleEvent(AFTER_STOP_EVENT, null);
  +    public void addService( Service service ) {
  +        m_standardServer.addService(service);
       }
   
  -    /**
  -     * Initialize
  -     * @throws LifecycleException if a problem
  -     */
  -    public void initialize() throws LifecycleException
  -    {
  -        if (m_initialized)
  -        {
  -            throw new LifecycleException("This server has already been initialized");
  -        }
  -        m_initialized = true;
  +    public void await() {
  +        Thread t = new Thread(this);
  +        t.start();
  +    }
   
  -        for (int i = 0; i < m_services.length; i++)
  -        {
  -            m_services[i].initialize();
  -        }
  +    public Service findService( String name ) {
  +        return m_standardServer.findService(name);
       }
   
  -    /**
  -     * Get the GlobalNamingReources
  -     * @return the naming resources
  -     */
  -    public NamingResources getGlobalNamingResources()
  -    {
  -        return m_globalNamingResources;
  -    }
  -
  -    /**
  -     * Set the global naming resources
  -     * @param globalNamingResources the global naming resources.
  -     */
  -    public void setGlobalNamingResources(NamingResources globalNamingResources)
  -    {
  -        m_globalNamingResources = globalNamingResources;
  -        m_globalNamingResources.setContainer(this);
  -    }
  -
  -    /**
  -     * Add the service
  -     * @param service the service
  -     */
  -    public void addService(final Service service)
  -    {
  -        service.setServer(this);
  -
  -        synchronized (m_services)
  -        {
  -            Service[] services = new Service[m_services.length + 1];
  -            System.arraycopy(m_services, 0, services, 0, m_services.length);
  -            services[m_services.length] = service;
  -            m_services = services;
  -
  -            if (m_initialized)
  -            {
  -                try
  -                {
  -                    service.initialize();
  -                }
  -                catch (LifecycleException e)
  -                {
  -                    e.printStackTrace(System.err);
  -                }
  -            }
  +    public Service[] findServices() {
  +        return m_standardServer.findServices();
  +    }
   
  -            if (m_started && (service instanceof Lifecycle))
  -            {
  -                try
  -                {
  -                    ((Lifecycle) service).start();
  -                }
  -                catch (LifecycleException e)
  -                {
  -                    // nothing?
  -                }
  -            }
  -        }
  +    public void removeService( Service service ) {
  +        m_standardServer.removeService(service);
       }
   
  -    /**
  -     * Find a service
  -     * @param name the service name
  -     * @return the service
  -     */
  -    public Service findService(String name)
  -    {
  -
  -        if (name == null)
  -        {
  -            return (null);
  -        }
  -        synchronized (m_services)
  -        {
  -            for (int i = 0; i < m_services.length; i++)
  -            {
  -                if (name.equals(m_services[i].getName()))
  -                {
  -                    return (m_services[i]);
  -                }
  -            }
  -        }
  -        return (null);
  +    public void initialize() throws LifecycleException {
  +        m_standardServer.initialize();
  +    }
   
  +    public void addLifecycleListener( LifecycleListener listener ) {
  +        m_standardServer.addLifecycleListener(listener);
       }
   
  -    /**
  -     * Find all services
  -     * @return the services
  -     */
  -    public Service[] findServices()
  -    {
  -
  -        return (m_services);
  +    public LifecycleListener[] findLifecycleListeners() {
  +        return m_standardServer.findLifecycleListeners();
  +    }
   
  +    public void removeLifecycleListener( LifecycleListener listener ) {
  +        m_standardServer.removeLifecycleListener(listener);
       }
   
  -    /**
  -     * Remove a service
  -     * @param service the service
  -     */
  -    public void removeService(Service service)
  -    {
  -        synchronized (m_services)
  -        {
  -            int j = -1;
  -            for (int i = 0; i < m_services.length; i++)
  -            {
  -                if (service == m_services[i])
  -                {
  -                    j = i;
  -                    break;
  -                }
  -            }
  -            if (j < 0)
  -            {
  -                return;
  -            }
  -            if (m_services[j] instanceof Lifecycle)
  -            {
  -                try
  -                {
  -                    ((Lifecycle) m_services[j]).stop();
  -                }
  -                catch (LifecycleException e)
  -                {
  -                    // nothing?
  -                }
  -            }
  -            int k = 0;
  -            Service results[] = new Service[m_services.length - 1];
  -            for (int i = 0; i < m_services.length; i++)
  -            {
  -                if (i != j)
  -                {
  -                    results[k++] = m_services[i];
  -                }
  -            }
  -            m_services = results;
  -        }
  +    public void start() throws LifecycleException {
  +        m_serving = true;
  +        m_standardServer.start();
  +    }
  +
  +    public void stop() throws LifecycleException {
  +        m_standardServer.stop();
  +        m_serving = false;
       }
   
  -    /**
  -     * Get the port
  -     * @return the port
  -     */
  -    public int getPort()
  -    {
  -        return m_port;
  -    }
  -
  -    /**
  -     * Set the port
  -     * @param port the port
  -     */
  -    public void setPort(int port)
  -    {
  -        m_port = port;
  -    }
  -
  -    /**
  -     * Get info
  -     * @return info
  -     */
  -    public String getInfo()
  -    {
  -        return C_INFO;
  -    }
  -
  -    /**
  -     * Get shutdown property
  -     * @return the shutdown property
  -     */
  -    public String getShutdown()
  -    {
  -        return m_shutdown;
  -    }
  -
  -    /**
  -     * Set the shutdown property
  -     * @param shutdown the shutdown property
  -     */
  -    public void setShutdown(String shutdown)
  -    {
  -        m_shutdown = shutdown;
  -    }
  -
  -    /**
  -     * Add a lifecycle listener
  -     * @param listener the listener
  -     */
  -    public void addLifecycleListener(LifecycleListener listener)
  -    {
  -        m_lifecycleSupport.addLifecycleListener(listener);
  -    }
  -
  -    /**
  -     * Find lifecycle listeners.
  -     * @return the LifeCycle listeners
  -     */
  -    public LifecycleListener[] findLifecycleListeners()
  -    {
  -        return m_lifecycleSupport.findLifecycleListeners();
  -    }
  -
  -    /**
  -     * Remove lifecycle listeners.
  -     * @param listener the listener
  -     */
  -    public void removeLifecycleListener(LifecycleListener listener)
  -    {
  -        m_lifecycleSupport.removeLifecycleListener(listener);
  -    }
  -
  -    /**
  -     * A string rep of this instance
  -     * @return the string
  -     */
  -    public String toString()
  -    {
  -        StringBuffer sb = new StringBuffer("CatalinaSevakServer[");
  -        sb.append(getPort());
  -        sb.append("]");
  -        return (sb.toString());
  -    }
  -
  -    /**
  -     * Get the deployer
  -     * @return the deployer
  -     */
  -    public Deployer getDeployer()
  -    {
  -        return null;
  +    public void run() {
  +        while(m_serving) {
  +            try {
  +                Thread.sleep(3 * 1000);
  +            } catch( InterruptedException e ) {
  +                //  ignored
  +            }
  +        }
       }
   }
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/webapps/sevak-test/WEB-INF/classes/num/NumberGuessBean.class
  
  	<<Binary file>>
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/webapps/sevak-test/WEB-INF/classes/num/NumberGuessBean.java
  
  Index: NumberGuessBean.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 apache@apache.org.
   *
   * 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/>.
   *
   */
  
  /*
   * Originally written by Jason Hunter, http://www.servlets.com.
   */
  
  package num;
  
  import java.util.*;
  
  public class NumberGuessBean {
  
    int answer;
    boolean success;
    String hint;
    int numGuesses;
  
    public NumberGuessBean() {
      reset();
    }
  
    public void setGuess(String guess) {
      numGuesses++;
  
      int g;
      try {
        g = Integer.parseInt(guess);
      }
      catch (NumberFormatException e) {
        g = -1;
      }
  
      if (g == answer) {
        success = true;
      }
      else if (g == -1) {
        hint = "a number next time";
      }
      else if (g < answer) {
        hint = "higher";
      }
      else if (g > answer) {
        hint = "lower";
      }
    }
  
    public boolean getSuccess() {
      return success;
    }
  
    public String getHint() {
      return "" + hint;
    }
  
    public int getNumGuesses() {
      return numGuesses;
    }
  
    public void reset() {
      answer = Math.abs(new Random().nextInt() % 100) + 1;
      success = false;
      numGuesses = 0;
    }
  }
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/webapps/sevak-test/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd">
  
  <web-app>
  </web-app>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/webapps/sevak-test/index.jsp
  
  Index: index.jsp
  ===================================================================
  <!--
    Copyright (c) 1999 The Apache Software Foundation.  All rights 
    reserved.
  
    Number Guess Game
    Written by Jason Hunter, CTO, K&A Software
    http://www.servlets.com
  -->
  
  <%@ page import = "num.NumberGuessBean" %>
  
  <jsp:useBean id="numguess" class="num.NumberGuessBean" scope="session"/>
  <jsp:setProperty name="numguess" property="*"/>
  
  <html>
  <head><title>Number Guess</title></head>
  <body bgcolor="white">
  <h1>Hello Mulithost Sevak</h1><hr/>
  <font size=4>
  
  <% if (numguess.getSuccess()) { %>
  
    Congratulations!  You got it.
    And after just <%= numguess.getNumGuesses() %> tries.<p>
  
    <% numguess.reset(); %>
  
    Care to <a href="numguess.jsp">try again</a>?
  
  <% } else if (numguess.getNumGuesses() == 0) { %>
  
    Welcome to the Number Guess game.<p>
  
    I'm thinking of a number between 1 and 100.<p>
  
    <form method=get>
    What's your guess? <input type=text name=guess>
    <input type=submit value="Submit">
    </form>
  
  <% } else { %>
  
    Good guess, but nope.  Try <b><%= numguess.getHint() %></b>.
  
    You have made <%= numguess.getNumGuesses() %> guesses.<p>
  
    I'm thinking of a number between 1 and 100.<p>
  
    <form method=get>
    What's your guess? <input type=text name=guess>
    <input type=submit value="Submit">
    </form>
  
  <% } %>
  
  </font>
  </body>
  </html>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message