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/java/org/apache/avalon/apps/sevak/blocks/catalina CatalinaSevak.java
Date Sun, 20 Oct 2002 22:02:34 GMT
hammant     2002/10/20 15:02:34

  Modified:    sevak    ant.properties.sample build.xml catalina.xml
               sevak/src/demo/conf catalina-assembly.xml
               sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina
                        CatalinaSevak.java
  Log:
  Update of Sevak from Daniel from 10 days ago.
  
  Revision  Changes    Path
  1.4       +1 -4      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ant.properties.sample	9 Oct 2002 06:07:17 -0000	1.3
  +++ ant.properties.sample	20 Oct 2002 22:02:34 -0000	1.4
  @@ -36,7 +36,4 @@
   #  (lightweight binary distribution of Tomcat 4, designed to be run on JDK 1.4.)
   # -----------------------------------------------------------------------------
   #catalina-zip-suffix=-LE-jdk14
  -
  -
  -phoenix.home=/local/phoenix
  -
  +#phoenix.home=/local/phoenix
  
  
  
  1.17      +10 -4     jakarta-avalon-apps/sevak/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/build.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- build.xml	2 Oct 2002 20:24:02 -0000	1.16
  +++ build.xml	20 Oct 2002 22:02:34 -0000	1.17
  @@ -227,13 +227,21 @@
       <jar jarfile="${build.lib}/sevak-catalina.jar"
            manifest="${build.xdoclet}/catalina/manifest.mf">
         <fileset dir="${build.classes}">
  -        <include name="org/apache/avalon/apps/sevak/blocks/catalina/**"/>
  +        <include name="org/apache/avalon/apps/sevak/blocks/catalina/startup/*"/>
         </fileset>
         <fileset dir="${build.xdoclet}/catalina">
  -        <include name="org/apache/avalon/apps/sevak/blocks/catalina/**/*.xinfo"/>
  +        <include name="org/apache/avalon/apps/sevak/blocks/catalina/startup/**/*.xinfo"/>
         </fileset>
       </jar>
   
  +      <jar jarfile="${build.lib}/sevak-catalina-impl.jar"
  +         manifest="${build.xdoclet}/catalina/manifest.mf">
  +          <fileset dir="${build.classes}">
  +              <include name="org/apache/avalon/apps/sevak/blocks/catalina/**"/>
  +              <exclude name="org/apache/avalon/apps/sevak/blocks/catalina/startup/**"/>
  +          </fileset>
  +      </jar>
  +
       <jar jarfile="${build.lib}/sevak-jo.jar"
            manifest="${build.xdoclet}/jo/manifest.mf">
         <fileset dir="${build.classes}">
  @@ -462,8 +470,6 @@
       <copy todir="${bin.dist.docs}">
         <fileset dir="${build.docs}"/>
       </copy>
  -
  -    <copy file="${build.lib}/avalon-${name}.sar" tofile="${bin.dist.dir}/avalon-${name}-${version}.sar"/>
   
       <chmod dir="${bin.dist.dir}" perm="go-rwx" />
     </target>
  
  
  
  1.8       +42 -32    jakarta-avalon-apps/sevak/catalina.xml
  
  Index: catalina.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/catalina.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- catalina.xml	9 Oct 2002 06:07:17 -0000	1.7
  +++ catalina.xml	20 Oct 2002 22:02:34 -0000	1.8
  @@ -24,16 +24,16 @@
     <property name="build.dir" value="build"/>
     <property name="build.lib" value="${build.dir}/lib"/>
     <property name="build.xdoclet" value="${build.dir}/xdoclet"/>
  -  <property name="build.src" value="${build.dir}/src"/>  
  +  <property name="build.src" value="${build.dir}/src"/>
     <property name="build.classes" value="${build.dir}/classes"/>
  -  <property name="build.javadocs" value="${build.dir}/javadocs"/>  
  +  <property name="build.javadocs" value="${build.dir}/javadocs"/>
     <property name="build.docs" value="${build.dir}/docs"/>
  -  <property name="build.context" value="${build.dir}/documentation"/>  
  +  <property name="build.context" value="${build.dir}/documentation"/>
     <property name="build.xdocs" value="${build.context}/content/xdocs"/>
  -  
  +
     <!-- Sevak specific properties for building -->
     <property name="build.reports" value="${build.dir}/reports"/>
  -  <property name="build.demoClasses" value="${build.dir}/demoClasses"/> 
  +  <property name="build.demoClasses" value="${build.dir}/demoClasses"/>
     <property name="build.demoXdoclet" value="${build.dir}/demoXdoclet"/>
   
   
  @@ -42,14 +42,13 @@
     <property name="java.dir" value="${src.dir}/java"/>
     <property name="manifest.dir" value="${src.dir}/manifest"/>
     <property name="conf.dir" value="${src.dir}/conf"/>
  -  <property name="context.dir" value="../../jakarta-avalon/src/documentation"/> 

  -  <property name="xdocs.dir" value="${src.dir}/xdocs"/>  
  +  <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="tools.jar" value="${java.home}/../lib/tools.jar"/>
     <property name="dist.base" value="dist"/>
     <property name="do.checkstyle" value="true"/>
   
  @@ -64,8 +63,6 @@
     <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">
  @@ -76,7 +73,7 @@
       </fileset>
       <fileset dir="${tomcat.jars.dir}">
         <include name="*.jar" />
  -    </fileset>       
  +    </fileset>
     </path>
   
     <path id="tools.class.path">
  @@ -92,7 +89,7 @@
       </fileset>
       <pathelement path="${build.lib}/sevak-api.jar"/>
     </path>
  -  
  +
     <taskdef name="sar" classname="org.apache.avalon.phoenix.tools.tasks.Sar">
       <classpath refid="project.class.path" />
     </taskdef>
  @@ -112,23 +109,23 @@
       <echo>****  to retrieve Tomcat4.0 ******</echo>
       <echo>****  jars or place the jars *****</echo>
       <echo>****  in ${tomcat.jars.dir} dir  *****</echo>
  -    <echo>**********************************</echo>   
  -    
  +    <echo>**********************************</echo>
  +
       <fail message="Catalina needed. See above."/>
   
     </target>
  -  
  +
     <!-- Get catalina jars from apache repository -->
     <target name="get-catalina">
       <mkdir  dir="catalina-download"/>
       <mkdir dir="${lib.dir}"/>
       <mkdir dir="${tomcat.jars.dir}"/>
   
  -    <get src="http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v${catalina-version}${catalina-dir-suffix}/bin/jakarta-tomcat-${catalina-version}${catalina-zip-suffix}.zip"

  -    dest="catalina-download/catalina-${catalina-version}${catalina-zip-suffix}.zip" 
  +    <get src="http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v${catalina-version}${catalina-dir-suffix}/bin/jakarta-tomcat-${catalina-version}${catalina-zip-suffix}.zip"
  +    dest="catalina-download/catalina-${catalina-version}${catalina-zip-suffix}.zip"
       verbose="true"
       usetimestamp="true"/>
  -    
  +
       <!-- Get the Jakarta-COMMONS jar files which do NOT come along with the tomcat distribution
-->
   
       <get src="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/coyote/release/v1.0-rc2/commons-logging.jar"
  @@ -157,31 +154,29 @@
   
   
       <unzip src="catalina-download/catalina-${catalina-version}${catalina-zip-suffix}.zip"
dest="catalina-download" />
  -    
  +
       <delete file="${tomcat.jars.dir}/*.jar"/>
  -    
  +
       <copy todir="${tomcat.jars.dir}" flatten="true">
         <fileset dir="catalina-download/jakarta-tomcat-${catalina-version}${catalina-zip-suffix}">
           <include  name="**/bin/*.jar"/>
           <include  name="**/lib/*.jar"/>
         </fileset>
  -    </copy>   
  -    
  +    </copy>
  +
     </target>
  - 
  +
     <!-- prepare -->
  -  <target name="prepare" depends="checkNeccesaryJars" >
  +  <target name="prepare" depends="checkNeccesaryJars" >   
     </target>
   
   
  - 
  +
    <!--- 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"/>
  - 
  +
       <sar sarfile="${build.lib}/sevak-catalina-demo.sar"
            config="${conf.demo.dir}/catalina-config.xml"
            environment="${conf.demo.dir}/catalina-environment.xml"
  @@ -193,7 +188,22 @@
           <include name="sevak-api.jar"/>
           <include name="sevak-demo.war"/>
         </lib>
  -      <zipfileset dir="catalina-download/jakarta-tomcat-${catalina-version}${catalina-zip-suffix}"
 />
  +      <zipfileset dir="${catalina.download}">
  +          <exclude name="**/bin/**"/>
  +      </zipfileset>
  +      <zipfileset dir="${catalina.download}/bin" prefix="common/lib">
  +          <include name="*.jar"/>
  +      </zipfileset>
  +      <zipfileset dir="${build.lib}" prefix="server/lib">
  +          <include name="sevak-catalina-impl.jar"/>
  +      </zipfileset>
  +      <zipfileset dir="${conf.demo.dir}" prefix="conf">
  +          <include name="tomcat-users.xml"/>
  +      </zipfileset>
  +      <zipfileset dir="${java.home}/../lib/" prefix="common/lib">
  +          <include name="tools.jar"/>
  +      </zipfileset>                
  +      
       </sar>
   
       <!-- Copy build/lib contents to dist/ folder -->
  @@ -202,11 +212,11 @@
         <fileset dir="${build.lib}">
           <include name="**"/>
         </fileset>
  -    </copy>    
  +    </copy>
   
    </target>
   
  - <target name="install" depends="sar" description="Installs Demo SAR into Phoenix" >

  + <target name="install" depends="sar" description="Installs Demo SAR into Phoenix" >
        <echo message="Installing to ${install.dir}" />
       <delete dir="${install.dir}/sevak-catalina-demo" />
       <copy file="${build.lib}/sevak-catalina-demo.sar" todir="${install.dir}" />
  
  
  
  1.4       +1 -1      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- catalina-assembly.xml	30 Sep 2002 22:03:11 -0000	1.3
  +++ catalina-assembly.xml	20 Oct 2002 22:02:34 -0000	1.4
  @@ -3,7 +3,7 @@
                     "http://jakarta.apache.org/phoenix/assembly_1_0.dtd">
   
   <assembly>
  -    <block class="org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevakBootstrap"
name="sevak"/>
  +    <block class="org.apache.avalon.apps.sevak.blocks.catalina.startup.Bootstrap" name="sevak"/>
       <block class="org.apache.avalon.apps.sevak.demo.MultihostSevakTest" name="multihost-sevak-test">
           <provide name="sevak" role="org.apache.avalon.apps.sevak.MultihostSevak"/>
       </block>
  
  
  
  1.5       +75 -34    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CatalinaSevak.java	9 Oct 2002 06:07:17 -0000	1.4
  +++ CatalinaSevak.java	20 Oct 2002 22:02:34 -0000	1.5
  @@ -14,17 +14,35 @@
   import org.apache.catalina.Server;
   import org.apache.catalina.Service;
   import org.apache.catalina.Deployer;
  +import org.apache.catalina.deploy.*;
   import org.apache.catalina.startup.ContextRuleSet;
   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.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.context.Contextualizable;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.activity.Startable;
  +import org.apache.avalon.apps.sevak.MultihostSevak;
  +import org.apache.avalon.apps.sevak.SevakException;
   import org.xml.sax.InputSource;
   
  +import javax.naming.InitialContext;
  +import javax.naming.NamingEnumeration;
  +import javax.naming.NameClassPair;
  +import javax.naming.NamingException;
   import java.io.File;
   import java.io.FileInputStream;
  +import java.io.IOException;
   
   /**
    * Tomcat Wrapper.  This is the true CatalinaSevak service.  It must be dynamically loaded
through a bootstrap
  @@ -37,29 +55,54 @@
    * @author  Daniel Krieg<dkrieg@kc.rr.com>
    * @version 1.0
    */
  -public class CatalinaSevak {
  +public class CatalinaSevak extends AbstractLogEnabled
  +        implements Contextualizable, Configurable, Serviceable, Initializable, Startable,
MultihostSevak
  + {
       private ClassLoader m_parentLoader = ClassLoader.getSystemClassLoader();
       private Server m_server = null;
       private String m_configFile;
       private boolean m_useNaming = true;
  +    private Configuration m_configuration;
  +    private ServiceManager m_serviceManager;
  +    private Context m_context;
  +
  +    public void contextualize(Context context) throws ContextException {
  +        getLogger().debug("CatalinaSevak.contextualize()");
  +        m_context = context;
  +    }
  +
  +    public void configure(Configuration configuration) throws ConfigurationException {
  +        getLogger().debug("CatalinaSevak.configure()");
  +        m_configuration = configuration;
  +    }
  +
  +    public void service(ServiceManager serviceManager) throws ServiceException {
  +        getLogger().debug("CatalinaSevak.service()");
  +        m_serviceManager = serviceManager;
  +    }
   
       public void setParentClassLoader( ClassLoader parentLoader ) {
  +        getLogger().debug("CatalinaSevak.setParentClassLoader()");
           m_parentLoader = parentLoader;
       }
   
       public void setConfigFile( String configFile ) {
  +        getLogger().debug("CatalinaSevak.setConfigFile()");
           m_configFile = configFile;
       }
   
       public void setUseNaming( boolean useNaming ) {
  +        getLogger().debug("CatalinaSevak.setUseNaming()");
           m_useNaming = useNaming;
       }
   
       public void setServer( Server server ) {
  +        getLogger().debug("CatalinaSevak.setServer()");
           this.m_server = server;
       }
   
       public void initialize() throws Exception {
  +        getLogger().debug("CatalinaSevak.initialize()");
           Digester digester = createStartDigester();
           File file = configFile();
           try {
  @@ -117,33 +160,20 @@
           if( m_server instanceof Lifecycle ) {
               m_server.initialize();
           }
  -//        Service[] services = m_server.findServices();
  -//        for( int i = 0; i < services.length; i++ ) {
  -//            Service service = services[ i ];
  -//            System.out.println( service.getName() + ": " + service.getInfo() );
  -//
  -//            Container container = service.getContainer();
  -//            System.out.println( container.getName() + ": " + container.getInfo() );
  -//            Container[] children = container.findChildren();
  -//            for( int j = 0; j < children.length; j++ ) {
  -//                Container child = children[ j ];
  -//                System.out.println( "    Child: " + child.getName() + ": " + child.getInfo()
);
  -//            }
  -//            System.out.println();
  -//        }
  -        System.out.println( "CatalinaSevak Server initialized" );
  +        getLogger().info( "CatalinaSevak Server initialized" );
       }
   
       public void start() throws Exception {
  +        getLogger().debug("CatalinaSevak.start()");
           if( m_server instanceof Lifecycle ) {
               try {
                   ( (Lifecycle) m_server ).start();
                   m_server.await();
               } catch( LifecycleException e ) {
  -                System.out.println( "Catalina.start: " + e );
  +                getLogger().debug( "Catalina.start: " + e );
                   e.printStackTrace( System.out );
                   if( e.getThrowable() != null ) {
  -                    System.out.println( "----- Root Cause -----" );
  +                    getLogger().debug( "----- Root Cause -----" );
                       e.getThrowable().printStackTrace( System.out );
                   }
               } catch( Throwable throwable ) {
  @@ -155,14 +185,15 @@
       }
   
       public void stop() throws Exception {
  +        getLogger().debug("CatalinaSevak.stop()");
           if( m_server instanceof Lifecycle ) {
               try {
                   ( (Lifecycle) m_server ).stop();
               } catch( LifecycleException e ) {
  -                System.out.println( "Catalina.stop: " + e );
  +                getLogger().debug( "Catalina.stop: " + e );
                   e.printStackTrace( System.out );
                   if( e.getThrowable() != null ) {
  -                    System.out.println( "----- Root Cause -----" );
  +                    getLogger().debug( "----- Root Cause -----" );
                       e.getThrowable().printStackTrace( System.out );
                   }
               }
  @@ -171,7 +202,8 @@
           }
       }
   
  -    public void deploy( String host, String context, File pathToWebAppFolder ) throws Exception
{
  +    public void deploy( String host, String context, File pathToWebAppFolder ) throws SevakException
{
  +        getLogger().debug("CatalinaSevak.deploy()");
           Service[] services = m_server.findServices();
           Container child = null;
           found_host: {
  @@ -190,18 +222,23 @@
               throw new IllegalArgumentException( host + ": no such host." );
           }
           if( !( child instanceof Deployer ) ) {
  -            throw new Exception( host + ": not able to deploy " + context );
  +            throw new SevakException( 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 );
  +            throw new SevakException( context + " already deployed to host " + host );
  +        }
  +
  +        try {
  +            deployer.install( context, pathToWebAppFolder.toURL() );
  +        } catch (IOException e) {
  +            throw new SevakException( context + " failed to deploy", e );
           }
  -        deployer.install( context, pathToWebAppFolder.toURL() );
  -//        deployer.start( context );
       }
   
  -    public void undeploy( String host, String context ) throws Exception {
  +    public void undeploy( String host, String context ) throws SevakException {
  +        getLogger().debug("CatalinaSevak.undeploy()");
           Service[] services = m_server.findServices();
           Container child = null;
           found_host: {
  @@ -220,17 +257,22 @@
               throw new IllegalArgumentException( host + ": no such host." );
           }
           if( !( child instanceof Deployer ) ) {
  -            throw new Exception( host + ": not able to undeploy " + context );
  +            throw new SevakException( 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 );
  +            throw new SevakException( context + " does not exist in host " + host );
  +        }
  +
  +        try {
  +            deployer.remove( context );
  +        } catch (IOException e) {
  +            throw new SevakException( context + " failed to undeploy", e );
           }
  -//        deployer.start( context );
  -        deployer.remove( context );
       }
   
       protected Digester createStartDigester() {
  +        getLogger().debug("CatalinaSevak.createStartDigester()");
           Digester digester = new Digester();
           digester.setValidating( false );
   
  @@ -313,12 +355,11 @@
       }
   
       protected File configFile() {
  -
  +        getLogger().debug("CatalinaSevak.configFile()");
           File file = new File( m_configFile );
           if( !file.isAbsolute() )
               file = new File( System.getProperty( "catalina.base" ), m_configFile );
           return ( file );
  -
       }
   }
   
  
  
  

--
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