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/util CatalinaLogger.java CustomWebappLoader.java
Date Sun, 22 Sep 2002 09:35:02 GMT
hammant     2002/09/22 02:35:01

  Modified:    sevak    build.xml
               sevak/src/conf sevak-assembly.xml
  Added:       sevak    catalina.xml jo.xml
               sevak/lib/jo-jars Readme
               sevak/src/demo/conf catalina-assembly.xml
                        catalina-config.xml catalina-environment.xml
                        jo-assembly.xml jo-config.xml jo-environment.xml
               sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina
                        CatalinaLogger.java CatalinaSevak.java
                        CustomWebappLoader.java
               sevak/src/java/org/apache/avalon/apps/sevak/blocks/jo
                        JoAvalonLogListener.java JoException.java
                        JoSevak.java
  Removed:     sevak/src/demo/conf sevak-demo-assembly.xml
                        sevak-demo-config.xml sevak-demo-environment.xml
               sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina
                        CatalinaSevakImpl.java
               sevak/src/java/org/apache/avalon/apps/sevak/util
                        CatalinaLogger.java CustomWebappLoader.java
  Log:
  Rework of Catalina. Addition of Jo.
  
  Revision  Changes    Path
  1.11      +155 -294  jakarta-avalon-apps/sevak/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/build.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- build.xml	3 Sep 2002 07:37:25 -0000	1.10
  +++ build.xml	22 Sep 2002 09:35:00 -0000	1.11
  @@ -3,17 +3,17 @@
   <project default="main" basedir=".">
   
   <!-- ==========================================================================================
  -	PROPERTY SETUP
  +  PROPERTY SETUP
        ========================================================================================== -->
   
  -	<!-- set up properties -->
  -	<property file="${user.home}/build.properties"/>
  -	<property file="${user.home}/.ant.properties"/>
  -	<property file="${basedir}/ant.properties"/>
  -	<property file="${basedir}/../ant.properties"/>
  -	<property file="${basedir}/default.properties"/>
  -	<property file="${basedir}/../default.properties"/>
  -	<property file="${basedir}/../cocoon.properties"/>
  +  <!-- set up properties -->
  +  <property file="${user.home}/build.properties"/>
  +  <property file="${user.home}/.ant.properties"/>
  +  <property file="${basedir}/ant.properties"/>
  +  <property file="${basedir}/../ant.properties"/>
  +  <property file="${basedir}/default.properties"/>
  +  <property file="${basedir}/../default.properties"/>
  +  <property file="${basedir}/../cocoon.properties"/>
   
   
     <!-- Set the installation variables for Cornerstone/Phoenix -->
  @@ -56,14 +56,9 @@
     <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"/>  
  -  
  -  <!-- Tomcat Jars -->
  -  <!-- <property name="catalina-version" value="4.0.7"/> -->
  -  <property name="catalina-version" value="4.1.7"/>
  -  <property name="catalina-dir-suffix" value="-beta"/>
  -  
  +   
     <property name="tomcat.jars.dir" value="${lib.dir}/tomcat-jars"/>
  -  
  +  <property name="jo.jars.dir" value="${lib.dir}/jo-jars"/>
   
   
     <path id="project.class.path">
  @@ -72,9 +67,15 @@
       <fileset dir="../common/lib">
         <include name="*.jar" />
       </fileset>
  +    <fileset dir="../common/lib/xdoclet">
  +      <include name="*.jar" />
  +    </fileset>    
       <fileset dir="${tomcat.jars.dir}">
         <include name="*.jar" />
       </fileset>    
  +    <fileset dir="${jo.jars.dir}">
  +      <include name="*.jar" />
  +    </fileset>        
     </path>
   
     <path id="tools.class.path">
  @@ -88,19 +89,9 @@
       <fileset dir="../common/lib">
         <include name="**/*.jar" />
       </fileset>
  -    <pathelement path="${build.lib}/sevak.jar"/>
  +    <pathelement path="${build.lib}/sevak-interfaces.jar"/>
     </path>
     
  -  <taskdef name="sar" classname="org.apache.avalon.phoenix.tools.tasks.Sar">
  -    <classpath refid="project.class.path" />
  -  </taskdef>
  -
  -  <!-- Help on usage -->
  -  <target name="help" depends="usage"/>
  -  <target name="usage">
  -    <echo message="Run ant -projecthelp to get a list of targets to run"/>
  -  </target>
  -
     <!-- Setup the filters -->
     <target name="setup-filters">
       <filter token="Name" value="Avalon Apps - ${Name}"/>
  @@ -128,14 +119,6 @@
       
     </target>
   
  -  <!-- Check Presense Of Tomcat 4.0 jars -->
  -  <target name="checkCatalinaJars">
  -    <condition property="catalina.present">
  -      <available file="catalina-download/catalina-${catalina-version}.zip"/>
  -    </condition>
  -
  -  </target>
  -
     <!-- checking for avalon-framework.jar too here -->
     <target name="checkFrameworkClass">
       <available classname="org.apache.avalon.framework.logger.Logger" classpathref="project.class.path" property="framework.present"/>    
  @@ -150,72 +133,15 @@
   
     </target>
   
  -  <target name="checkNeccesaryJars" depends="checkFramework,checkCatalinaJars" unless="catalina.present">
  -    <echo>**********************************</echo>
  -    <echo>***** Please execute target ******</echo>
  -    <echo>****     'get-catalina '    ******</echo>
  -    <echo>****  to retrieve Tomcat4.0 ******</echo>
  -    <echo>****  jars or place the jars *****</echo>
  -    <echo>****  in ${tomcat.jars.dir} dir  *****</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}.zip" 
  -    dest="catalina-download/catalina-${catalina-version}.zip" 
  -    verbose="true"
  -    usetimestamp="true"/>
  +  <!-- prepare -->
  +  <target name="prepare">
  +  
  +    <available classpathref="project.class.path" classname="org.apache.catalina.Engine" property="catalina.present"/>
  +    <available classpathref="project.class.path" classname="com.tagtraum.jo.JoServletService" property="jo.present"/>
       
  -    <!-- Get the Jakarta-COMMONS jar files which do NOT come along with the tomcat distribution -->
  +    <available classpathref="project.class.path" classname="xdoclet.DocletTask" property="xdoclet.present"/>
   
  -    <get src="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/coyote/release/v1.0-rc2/commons-logging.jar"
  -        dest="${tomcat.jars.dir}/commons-logging.jar"
  -        verbose="true"
  -        usetimestamp="true"
  -    />
  -
  -    <get src="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/coyote/release/v1.0-rc2/tomcat-coyote.jar"
  -        dest="${tomcat.jars.dir}/tomcat-coyote.jar"
  -        verbose="true"
  -        usetimestamp="true"
  -    />
  -
  -    <get src="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/coyote/release/v1.0-rc2/tomcat-http11.jar"
  -        dest="${tomcat.jars.dir}/tomcat-http11.jar"
  -        verbose="true"
  -        usetimestamp="true"
  -    />
  -
  -    <get src="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/coyote/release/v1.0-rc2/tomcat-util.jar"
  -        dest="${tomcat.jars.dir}/tomcat-util.jar"
  -        verbose="true"
  -        usetimestamp="true"
  -    />
  -
  -
  -    <unzip src="catalina-download/catalina-${catalina-version}.zip" dest="catalina-download" />
  -    
  -    <copy todir="${tomcat.jars.dir}" flatten="true">
  -      <fileset dir="catalina-download/jakarta-tomcat-${catalina-version}">
  -        <include  name="**/bin/*.jar"/>
  -        <include  name="**/lib/*.jar"/>
  -      </fileset>
  -    </copy>   
  -    
  -  </target>
  - 
  -  <!-- prepare -->
  -  <target name="prepare" depends="checkNeccesaryJars" >
  -    <mkdir dir="${lib.dir}"/>
     </target>
   
     <!-- Compiles project -->
  @@ -229,6 +155,8 @@
              optimize="${build.optimize}"
              deprecation="${build.deprecation}">
         <classpath refid="project.class.path" />
  +      <exclude name="org/apache/avalon/apps/sevak/blocks/jo/**" unless="jo.present"/>
  +      <exclude name="org/apache/avalon/apps/sevak/blocks/catalina/**" unless="catalina.present"/>
       </javac>
   
       <copy todir="${build.classes}">
  @@ -247,22 +175,34 @@
     <!-- Make .xinfo and manifest automatically for blocks -->
     <target name="phoenix-xdoclet" depends="compile" if="xdoclet.present">
     
  -    <mkdir dir="${build.xdoclet}"/>
  +    <mkdir dir="${build.xdoclet}/catalina"/>
  +    <mkdir dir="${build.xdoclet}/jo"/>
     
       <taskdef name="phoenix-blocks"
                classname="org.apache.avalon.phoenix.tools.xdoclet.PhoenixXDoclet"
                classpathref="project.class.path"/>
   
       <phoenix-blocks
  -        destdir="${build.xdoclet}"
  +        destdir="${build.xdoclet}/catalina"
           classpathref="project.class.path">
         <fileset dir="${java.dir}">
  -        <include name="**/*.java" />
  +        <include name="org/apache/avalon/apps/sevak/blocks/catalina/**/*.java" />
         </fileset>
         <blockinfo/>
         <manifest manifestFile="manifest.mf" />
       </phoenix-blocks>
   
  +    <phoenix-blocks
  +        destdir="${build.xdoclet}/jo"
  +        classpathref="project.class.path">
  +      <fileset dir="${java.dir}">
  +        <include name="org/apache/avalon/apps/sevak/blocks/jo/**/*.java" />
  +      </fileset>
  +      <blockinfo/>
  +      <manifest manifestFile="manifest.mf" />
  +    </phoenix-blocks>
  +
  +
     </target>
   
     <!-- Make .xinfo and manifest automatically for blocks -->
  @@ -280,16 +220,85 @@
   
       <mkdir dir="${build.lib}"/>
   
  -    <jar jarfile="${build.lib}/${name}.jar"
  -         manifest="${build.xdoclet}/manifest.mf">
  +    <jar jarfile="${build.lib}/sevak-interfaces.jar">
         <fileset dir="${build.classes}">
  -        <include name="org/apache/avalon/apps/sevak/**"/>
  +        <include name="org/apache/avalon/apps/sevak/*"/>
         </fileset>
  -      <fileset dir="${build.xdoclet}">
  -        <include name="**/*.xinfo"/>
  +    </jar>
  +
  +    <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/**"/>
  +      </fileset>
  +      <fileset dir="${build.xdoclet}/catalina">
  +        <include name="org/apache/avalon/apps/sevak/blocks/catalina/**/*.xinfo"/>
         </fileset>
       </jar>
   
  +    <jar jarfile="${build.lib}/sevak-jo.jar"
  +         manifest="${build.xdoclet}/jo/manifest.mf">
  +      <fileset dir="${build.classes}">
  +        <include name="org/apache/avalon/apps/sevak/blocks/jo/**"/>
  +      </fileset>
  +      <fileset dir="${build.xdoclet}/jo">
  +        <include name="org/apache/avalon/apps/sevak/blocks/jo/**/*.xinfo"/>
  +      </fileset>
  +    </jar>
  +
  +
  +  </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}"/>
  +    
  +    <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 -->
  @@ -306,48 +315,9 @@
     </target>
   
   
  -  <target name="main" depends="sars" description="Default target to generate build products minus docs"/> 
  +  <target name="main" depends="jars" description="Default target to generate build products minus docs"/> 
     <target name="all" depends="main,docs" description="Generate build products including docs" /> 
  - 
  -  <target name="sars" depends="jars">
  -
  -    <sar sarfile="${build.lib}/avalon-${name}.sar"
  -         config="${conf.dir}/${name}-config.xml"
  -         environment="${conf.dir}/${name}-environment.xml"
  -         assembly="${conf.dir}/${name}-assembly.xml" >
  -
  -      <lib dir="${build.lib}/">
  -        <include name="*.jar"/>
  -      </lib>
  -
  -      <lib dir="../common/lib">
  -        <include name="cornerstone.jar"/>
  -      </lib>
  -    
  -      <lib dir="${tomcat.jars.dir}">
  -        <include name="*.jar"/>
  -      </lib>
  -
  -      <!-- 
  -
  -      <lib dir="${java.home}/../lib/">
  -        <include name="tools.jar"/>
  -      </lib>
  -      
  -      -->
  -    </sar>
  -    
  -    <mkdir dir="dist"/>
  -
  -    <copy todir="dist">
  -      <fileset dir="${build.lib}">
  -        <include name="**"/>
  -      </fileset>
  -    </copy>    
  -
  -  </target>
  -
  -    
  +     
     <!-- CheckStyle tasks-->
     <target name="checkstyle" if="do.checkstyle" description="Checkstyle">
   
  @@ -402,12 +372,8 @@
       </target>
   
     
  -  <!-- Performs unit tests -->
  -  <target name="check" depends="compile" description="Perform any built in tests">
  -  </target>
  -
     <!-- Completely build all dists -->
  -  <target name="dist" depends="sars" description="Generates the distribution">
  +  <target name="dist" depends="jars" description="Generates the distribution">
   
       <property name="dist.name" value="${Name}-${version}"/>
   
  @@ -527,20 +493,6 @@
       <chmod dir="${src.dist.dir}" perm="go-rwx" />
     </target>
   
  -  <target name="install" depends="main" description="Installs into Phoenix" > 
  -    <!-- <fail message="install.dir not specified." unless="install.dir"/> -->
  -    <echo message="Installing to ${install.dir}" />
  -    <delete dir="${install.dir}/${name}" />
  -    <copy file="${build.lib}/avalon-${name}.sar" todir="${install.dir}" />
  -  </target>
  -
  -  <target name="uninstall" description="Uninstalls from Phoenix">
  -
  -    <!-- <fail message="install.dir not specified." unless="install.dir"/> -->
  -    <delete dir="${install.dir}/avalon-${name}/" />
  -    <delete file="avalon-${name}.sar" dir="${install.dir}"/>
  -  </target>
  -
     <target name="clean" description="Cleans up artifacts from build process">
       <delete dir="${build.dir}" />
       <delete>
  @@ -557,138 +509,47 @@
       </delete>
     </target>
   
  - <!-- Compile Demo Classes -->
  + 
  +<!-- ==========================================================================================
  +  DOCUMENTATION GENERATION
  +========================================================================================== -->
   
  - <target name="compileDemo" description="Compiles the Demo Block">
  -    <delete dir="${build.demoClasses}"/>
  -    <delete dir="${build.demoXdoclet}"/>
  +  <!-- Creates all docs -->
  +  <target name="docs" depends="html-docs, javadocs" description="generates all the documentation"/>
   
  -    <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" />
  +  <!-- copy docs to site dir -->
  +  <target name="site" depends="docs" description=" Places docs ready for hosting on website">
  +    <mkdir dir="../site/build/docs/apps/${dir-name}"/>
  +    <copy todir="../site/build/docs/apps/${dir-name}">
  +    <fileset dir="${build.docs}">
         <include name="**"/>
  -    </javac>
  - </target>
  -
  -  <target name="phoenix-demo-xdoclet" depends="compileDemo" >
  -  
  -    <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>
  -
  +    </fileset>
  +    </copy>
     </target>
   
  - 
  -
  - <target name="jarDemo" depends="phoenix-demo-xdoclet" description="Makes a jar file out of the Demo classes">
  -    <mkdir dir="${build.lib}"/>
  -
  -    <jar jarfile="${build.lib}/sevakDemo.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>
  - <!--- Build Test SAR Archive -->
  - <target name="demoSAR" depends="jars,jarDemo" description="Builds a Demo block which uses Sevak Service">
  -    <sar sarfile="${build.lib}/avalon-sevak-demo.sar"
  -         config="${conf.demo.dir}/sevak-demo-config.xml"
  -         environment="${conf.demo.dir}/sevak-demo-environment.xml"
  -         assembly="${conf.demo.dir}/sevak-demo-assembly.xml" >
  -
  -      <lib dir="${build.lib}/">
  -        <include name="*.jar"/>
  -      </lib>
  -
  -      <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}/webapps" prefix="webapps"/>
  -
  -    </sar>
  -
  -    <!-- Copy build/lib contents to dist/ folder -->
  -
  -    <copy todir="${dist.base}">
  -      <fileset dir="${build.lib}">
  -        <include name="**"/>
  -      </fileset>
  -    </copy>    
  -
  - </target>
  -
  - <target name="installDemo" depends="demoSAR" description="Installs Demo SAR into Phoenix" > 
  -     <echo message="Installing to ${install.dir}" />
  -    <delete dir="${install.dir}/avalon-sevak-demo" />
  -    <copy file="${build.lib}/avalon-sevak-demo.sar" todir="${install.dir}" />
  +  <!-- Creates javadocs -->
  +  <target name="javadocs" depends="compile" description="Generates the javadocs" unless="skip.javadocs">
  +    <mkdir dir="${build.javadocs}"/>
  +    <javadoc packagenames="org.apache.*"
  +    sourcepath="${java.dir}"
  +    destdir="${build.javadocs}">
  +    <classpath refid="project.class.path" />
  +    <doclet name="com.sun.tools.doclets.standard.Standard">
  +      <param name="-author"/>
  +      <param name="-version"/>
  +      <param name="-doctitle" value="${Name}"/>
  +      <param name="-windowtitle" value="${Name} API"/>
  +      <param name="-link" value="http://java.sun.com/j2se/1.4/docs/api/"/>
  +      <param name="-link" value="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
  +      <param name="-link" value="http://jakarta.apache.org/avalon/api/"/>
  +      <param name="-bottom"
  +      value="&quot;Copyright &#169; ${year} Apache Jakarta Project. All Rights Reserved.&quot;"/>
  +    </doclet>
  +    </javadoc>
  +  </target>
  +
  +  <target name="html-docs" description="generates the xdocs-based documentation">
  +    <!-- we call the build.xml target common to all of avalon-apps. This builds our html site -->
  +    <ant antfile="${basedir}/../cocoonbuild.xml"/>
     </target>
  -
  -<!-- ==========================================================================================
  -	DOCUMENTATION GENERATION
  -========================================================================================== -->
  -
  -	<!-- Creates all docs -->
  -	<target name="docs" depends="html-docs, javadocs" description="generates all the documentation"/>
  -
  -	<!-- copy docs to site dir -->
  -	<target name="site" depends="docs" description=" Places docs ready for hosting on website">
  -		<mkdir dir="../site/build/docs/apps/${dir-name}"/>
  -		<copy todir="../site/build/docs/apps/${dir-name}">
  -		<fileset dir="${build.docs}">
  -			<include name="**"/>
  -		</fileset>
  -		</copy>
  -	</target>
  -
  -	<!-- Creates javadocs -->
  -	<target name="javadocs" depends="compile" description="Generates the javadocs" unless="skip.javadocs">
  -		<mkdir dir="${build.javadocs}"/>
  -		<javadoc packagenames="org.apache.*"
  -		sourcepath="${java.dir}"
  -		destdir="${build.javadocs}">
  -		<classpath refid="project.class.path" />
  -		<doclet name="com.sun.tools.doclets.standard.Standard">
  -			<param name="-author"/>
  -			<param name="-version"/>
  -			<param name="-doctitle" value="${Name}"/>
  -			<param name="-windowtitle" value="${Name} API"/>
  -			<param name="-link" value="http://java.sun.com/j2se/1.4/docs/api/"/>
  -			<param name="-link" value="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
  -			<param name="-link" value="http://jakarta.apache.org/avalon/api/"/>
  -			<param name="-bottom"
  -			value="&quot;Copyright &#169; ${year} Apache Jakarta Project. All Rights Reserved.&quot;"/>
  -		</doclet>
  -		</javadoc>
  -	</target>
  -
  -	<target name="html-docs" description="generates the xdocs-based documentation">
  -		<!-- we call the build.xml target common to all of avalon-apps. This builds our html site -->
  -		<ant antfile="${basedir}/../cocoonbuild.xml"/>
  -	</target>
   </project>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/catalina.xml
  
  Index: catalina.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <project default="main" basedir=".">
  
  <!-- ==========================================================================================
       PROPERTY SETUP
       ========================================================================================== -->
  
    <!-- set up properties -->
    <property file="${user.home}/build.properties"/>
    <property file="${user.home}/.ant.properties"/>
    <property file="${basedir}/ant.properties"/>
    <property file="${basedir}/../ant.properties"/>
    <property file="${basedir}/default.properties"/>
    <property file="${basedir}/../default.properties"/>
    <property file="${basedir}/../cocoon.properties"/>
  
  
    <!-- Set the installation variables for Cornerstone/Phoenix -->
    <property name="phoenix.home" value="../../jakarta-avalon-phoenix/dist"/>
    <property name="install.dir" value="${phoenix.home}/apps"/>
  
    <!-- Set the properties for intermediate directory -->
    <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.classes" value="${build.dir}/classes"/>
    <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.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.demoXdoclet" value="${build.dir}/demoXdoclet"/>
  
  
    <!-- Set the properties for source directories -->
    <property name="src.dir" value="src"/>
    <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="tools.dir" location="../../jakarta-avalon/tools"/>
     
    <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"/>
    <property name="do.checkstyle" value="true"/>
  
    <property name="lib.dir" value="lib"/>
    <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"/>  
    
    <!-- Tomcat Stuff -->
    <property name="catalina-version" value="4.1.10"/>
    <property name="catalina-dir-suffix" value=""/>
    
    <property name="tomcat.jars.dir" value="${lib.dir}/tomcat-jars"/>
  
    <path id="project.class.path">
      <pathelement path="${java.class.path}" />
      <pathelement path="${build.classes}" />
      <fileset dir="../common/lib">
        <include name="*.jar" />
      </fileset>
      <fileset dir="../common/lib/xdoclet">
        <include name="*.jar" />
      </fileset>    
      <fileset dir="${tomcat.jars.dir}">
        <include name="*.jar" />
      </fileset>       
    </path>
  
    <path id="tools.class.path">
      <pathelement location="${junit.jar}"/>
      <pathelement location="${tools.jar}"/>
      <fileset dir="${tools.dir}/lib"/>
      <fileset dir="${tools.dir}/ext"/>
    </path>
  
    <path id="test.class.path">
      <fileset dir="../common/lib">
        <include name="**/*.jar" />
      </fileset>
      <pathelement path="${build.lib}/sevak-interfaces.jar"/>
    </path>
    
    <taskdef name="sar" classname="org.apache.avalon.phoenix.tools.tasks.Sar">
      <classpath refid="project.class.path" />
    </taskdef>
  
    <!-- Check Presense Of Tomcat 4.0 jars -->
    <target name="checkCatalinaJars">
      <condition property="catalina.present">
        <available file="catalina-download/catalina-${catalina-version}.zip"/>
      </condition>
  
    </target>
  
    <target name="checkNeccesaryJars" depends="checkCatalinaJars" unless="catalina.present">
      <echo>**********************************</echo>
      <echo>***** Please execute target ******</echo>
      <echo>****     'get-catalina '    ******</echo>
      <echo>****  to retrieve Tomcat4.0 ******</echo>
      <echo>****  jars or place the jars *****</echo>
      <echo>****  in ${tomcat.jars.dir} dir  *****</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}.zip" 
      dest="catalina-download/catalina-${catalina-version}.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"
          dest="${tomcat.jars.dir}/commons-logging.jar"
          verbose="true"
          usetimestamp="true"
      />
  
      <get src="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/coyote/release/v1.0-rc2/tomcat-coyote.jar"
          dest="${tomcat.jars.dir}/tomcat-coyote.jar"
          verbose="true"
          usetimestamp="true"
      />
  
      <get src="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/coyote/release/v1.0-rc2/tomcat-http11.jar"
          dest="${tomcat.jars.dir}/tomcat-http11.jar"
          verbose="true"
          usetimestamp="true"
      />
  
      <get src="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/coyote/release/v1.0-rc2/tomcat-util.jar"
          dest="${tomcat.jars.dir}/tomcat-util.jar"
          verbose="true"
          usetimestamp="true"
      />
  
  
      <unzip src="catalina-download/catalina-${catalina-version}.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}">
          <include  name="**/bin/*.jar"/>
          <include  name="**/lib/*.jar"/>
        </fileset>
      </copy>   
      
    </target>
   
    <!-- prepare -->
    <target name="prepare" depends="checkNeccesaryJars" >
    </target>
  
  
   
   <!--- Build Test SAR Archive -->
   <target name="sar" depends="prepare" description="Builds a Demo block which uses Sevak Service">
   
   
      <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"
           assembly="${conf.demo.dir}/catalina-assembly.xml" >
  
        <lib dir="${build.lib}/">
          <include name="sevak-catalina.jar"/>
          <include name="sevak-demo.jar"/>
          <include name="sevak-interfaces.jar"/>
        </lib>
  
        <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}/webapps" prefix="webapps"/>
        
        <zipfileset dir="catalina-download/jakarta-tomcat-${catalina-version}/conf" prefix="conf">
          <include name="tomcat-users.xml"/>
        </zipfileset>
  
      </sar>
  
      <!-- Copy build/lib contents to dist/ folder -->
  
      <copy todir="${dist.base}">
        <fileset dir="${build.lib}">
          <include name="**"/>
        </fileset>
      </copy>    
  
   </target>
  
   <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}" />
    </target>
  
  </project>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/jo.xml
  
  Index: jo.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <project default="main" basedir=".">
  
  <!-- ==========================================================================================
       PROPERTY SETUP
       ========================================================================================== -->
  
    <!-- set up properties -->
    <property file="${user.home}/build.properties"/>
    <property file="${user.home}/.ant.properties"/>
    <property file="${basedir}/ant.properties"/>
    <property file="${basedir}/../ant.properties"/>
    <property file="${basedir}/default.properties"/>
    <property file="${basedir}/../default.properties"/>
    <property file="${basedir}/../cocoon.properties"/>
  
  
    <!-- Set the installation variables for Cornerstone/Phoenix -->
    <property name="phoenix.home" value="../../jakarta-avalon-phoenix/dist"/>
    <property name="install.dir" value="${phoenix.home}/apps"/>
  
    <!-- Set the properties for intermediate directory -->
    <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.classes" value="${build.dir}/classes"/>
    <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.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.demoXdoclet" value="${build.dir}/demoXdoclet"/>
  
  
    <!-- Set the properties for source directories -->
    <property name="src.dir" value="src"/>
    <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="tools.dir" location="../../jakarta-avalon/tools"/>
     
    <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"/>
    <property name="do.checkstyle" value="true"/>
  
    <property name="lib.dir" value="lib"/>
    <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"/>  
    
    <!-- Jo stuff -->
    <property name ="jo.rel"    value="1.0"/>
    
    <property name="jo.jars.dir" value="${lib.dir}/jo-jars"/>
  
    <path id="project.class.path">
      <pathelement path="${java.class.path}" />
      <pathelement path="${build.classes}" />
      <fileset dir="../common/lib">
        <include name="*.jar" />
      </fileset>
      <fileset dir="../common/lib/xdoclet">
        <include name="*.jar" />
      </fileset>    
      <fileset dir="${jo.jars.dir}">
        <include name="*.jar" />
      </fileset>       
    </path>
  
    <path id="tools.class.path">
      <pathelement location="${junit.jar}"/>
      <pathelement location="${tools.jar}"/>
      <fileset dir="${tools.dir}/lib"/>
      <fileset dir="${tools.dir}/ext"/>
    </path>
  
    <path id="test.class.path">
      <fileset dir="../common/lib">
        <include name="**/*.jar" />
      </fileset>
      <pathelement path="${build.lib}/sevak-interfaces.jar"/>
    </path>
    
    <taskdef name="sar" classname="org.apache.avalon.phoenix.tools.tasks.Sar">
      <classpath refid="project.class.path" />
    </taskdef>
  
    <target name="checkJoJars">
      <condition property="jo.present">
        <available file="jo-download/jo${jo.rel}.zip"/>
      </condition>
  
    </target>
  
    <target name="checkNeccesaryJars" depends="checkJoJars" unless="jo.present">
        <echo>*************************</echo>
        <echo>* Please execute target *</echo>
        <echo>* 'get-jo' in the main  *</echo>
        <echo>* build.xml build file  *</echo>    
        <echo>* to download three and *</echo>
        <echo>* a half Mb of Jo! for  *</echo>
        <echo>* the servlet API and   *</echo>
        <echo>* to give EOB WAR file  *</echo>
        <echo>* capability.           *</echo>
        <echo>*************************</echo>   
        
        <fail message="Jo needed. See above."/>   
  
    </target>
  
      
    <target name="get-jo">
      
      <mkdir  dir="jo-download"/>
      
      <get src="http://unc.dl.sourceforge.net/sourceforge/tagtraum-jo/jo${jo.rel}.zip" 
    	dest="jo-download/jo${jo.rel}.zip" 
    	verbose="true"
    	usetimestamp="true"/>
    	
      <unzip src="jo-download/jo${jo.rel}.zip" dest="jo-download/jo-${jo.rel}" />
        
      <delete file="${jo.jars.dir}/*.jar"/>      
        
      <copy todir="${jo.jars.dir}" flatten="true">
        <fileset dir="jo-download/jo-${jo.rel}">
          <include  name="**/lib/*.jar"/>
        </fileset>
      </copy>
    	
   </target> 
   
   <!-- prepare -->
   <target name="prepare" depends="checkNeccesaryJars" >
   </target>
  
  
   
   <!--- Build Test SAR Archive -->
   <target name="sar" depends="prepare" description="Builds a Demo block which uses Sevak Service">
   
   
      <ant antfile="build.xml" target="jars"/>
      <ant antfile="build.xml" target="demo-jar"/>
   
      <sar sarfile="${build.lib}/sevak-jo-demo.sar"
           config="${conf.demo.dir}/jo-config.xml"
           environment="${conf.demo.dir}/jo-environment.xml"
           assembly="${conf.demo.dir}/jo-assembly.xml" >
  
        <lib dir="${build.lib}/">
          <include name="sevak-jo.jar"/>
          <include name="sevak-demo.jar"/>
          <include name="sevak-interfaces.jar"/>
        </lib>
  
        <lib dir="../../jakarta-avalon-apps/common/lib">
          <include name="cornerstone.jar"/>
        </lib>
      
        <lib dir="${jo.jars.dir}">
          <include name="*.jar"/>
        </lib>      
        
        <zipfileset dir="jo-download/jo-${jo.rel}/jo${jo.rel}/etc" prefix="etc">
            <include name="**/*"/>
        </zipfileset>
        <zipfileset dir="jo-download/jo-${jo.rel}/jo${jo.rel}/webapp" prefix="webapp">
            <include name="**/*"/>
        </zipfileset>
        <zipfileset dir="jo-download/jo-${jo.rel}/jo${jo.rel}/log" prefix="log">
            <include name="dummy.log"/>
        </zipfileset>      
  
      </sar>
  
      <!-- Copy build/lib contents to dist/ folder -->
  
      <copy todir="${dist.base}">
        <fileset dir="${build.lib}">
          <include name="**"/>
        </fileset>
      </copy>    
  
   </target>
  
   <target name="install" depends="sar" description="Installs Demo SAR into Phoenix" > 
       <echo message="Installing to ${install.dir}" />
      <delete dir="${install.dir}/sevak-jo-demo-demo" />
      <copy file="${build.lib}/sevak-jo-demo.sar" todir="${install.dir}" />
    </target>
  
  </project>
  
  
  
  1.3       +1 -1      jakarta-avalon-apps/sevak/src/conf/sevak-assembly.xml
  
  Index: sevak-assembly.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/sevak/src/conf/sevak-assembly.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sevak-assembly.xml	29 Jun 2002 17:46:23 -0000	1.2
  +++ sevak-assembly.xml	22 Sep 2002 09:35:01 -0000	1.3
  @@ -3,5 +3,5 @@
                     "http://jakarta.apache.org/phoenix/assembly_1_0.dtd">
   
   <assembly>
  -  <block class="org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevakImpl" name="sevak"/>
  +  <block class="org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevak" name="sevak"/>
   </assembly>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/lib/jo-jars/Readme
  
  Index: Readme
  ===================================================================
  This directory will contain the jo jars
  
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/conf/catalina-assembly.xml
  
  Index: catalina-assembly.xml
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE assembly PUBLIC "-//PHOENIX/Assembly DTD Version 1.0//EN" 
                    "http://jakarta.apache.org/phoenix/assembly_1_0.dtd">
  
  <assembly>
    <block class="org.apache.avalon.apps.sevak.blocks.catalina.CatalinaSevak" name="sevak"/>
    <block class="org.apache.avalon.apps.sevak.demo.SevakTest" name="sevakTest">
  	<provide name="sevak" role="org.apache.avalon.apps.sevak.Sevak"/>
    </block>
  </assembly>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/conf/catalina-config.xml
  
  Index: catalina-config.xml
  ===================================================================
  <?xml version="1.0"?>
  <!--
                                  README!
  
      MODIFY the catalina.home parameter to point to the webapps folder 
  
  -->
  <config>
  
    <sevak>
        <port>8080</port>
        <bind>127.0.0.1</bind>
    </sevak>
    <sevakTest>
  	  <!-- 
  	   * The Web Application's within the src/conf/webapps 
  	   * is added into the Sevak Demo Block SAR file under
  	   * webapps/ folder  within it.
  	   * -->
  	   
  	  <Context docBase="/" path="webapps/ROOT"/>	  
  	  
  	  <!-- 	  
  	    <Context docBase="/examples" path="webapps/examples"/>
  	    <Context docBase="/manager" path="webapps/manager"/>	  
  	  -->
  	  
  	  
  	  <Context docBase="/tomcat-docs" path="webapps/tomcat-docs"/>
  	  
  	  <!--
  	    <Context docBase="/webdav" path="webapps/webdav"/>	  
  	  -->
  	  
    </sevakTest>
  
  </config>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/conf/catalina-environment.xml
  
  Index: catalina-environment.xml
  ===================================================================
  <?xml version="1.0"?>
  <!--
                                  README!
  
      Basic config file that sets up context for server application.
  
  -->
  <environment>
  
      <logs>
  
        <category name="" target="default"
                  priority="DEBUG" />
        <category name="objectstorage" target="objectstorage-target"
                  priority="DEBUG" />
  
        <log-target name="default"
                    location="/logs/avalon-demo.log" />
        <log-target name="objectstorage-target"
                    location="/logs/objectstorage.log" />
      </logs>
  
      <policy>
        <grant code-base="sar:SAR-INF/lib/*">
          <permission class="java.security.AllPermission" />
        </grant>
      </policy>
  
  </environment>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/conf/jo-assembly.xml
  
  Index: jo-assembly.xml
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE assembly PUBLIC "-//PHOENIX/Assembly DTD Version 1.0//EN" 
                    "http://jakarta.apache.org/phoenix/assembly_1_0.dtd">
  
  <assembly>
    <block class="org.apache.avalon.apps.sevak.blocks.jo.JoSevak" name="sevak"/>
    <block class="org.apache.avalon.apps.sevak.demo.SevakTest" name="sevakTest">
  	<provide name="sevak" role="org.apache.avalon.apps.sevak.Sevak"/>
    </block>
  </assembly>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/conf/jo-config.xml
  
  Index: jo-config.xml
  ===================================================================
  <?xml version="1.0"?>
  <!--
                                  README!
  
      MODIFY the catalina.home parameter to point to the webapps folder 
  
  -->
  <config>
  
    <sevak>
        <hostname>localhost</hostname>
    </sevak>
    <sevakTest>  
    </sevakTest>
  
  </config>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/demo/conf/jo-environment.xml
  
  Index: jo-environment.xml
  ===================================================================
  <?xml version="1.0"?>
  <!--
                                  README!
  
      Basic config file that sets up context for server application.
  
  -->
  <environment>
  
      <logs>
  
        <category name="" target="default"
                  priority="DEBUG" />
        <category name="objectstorage" target="objectstorage-target"
                  priority="DEBUG" />
  
        <log-target name="default"
                    location="/logs/avalon-demo.log" />
        <log-target name="objectstorage-target"
                    location="/logs/objectstorage.log" />
      </logs>
  
      <policy>
        <grant code-base="sar:SAR-INF/lib/*">
          <permission class="java.security.AllPermission" />
        </grant>
      </policy>
  
  </environment>
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaLogger.java
  
  Index: CatalinaLogger.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/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.avalon.apps.sevak.blocks.catalina;
  
  //catalina imports
  import java.beans.PropertyChangeListener;
  import java.beans.PropertyChangeSupport;
  import java.io.CharArrayWriter;
  import java.io.PrintWriter;
  
  import javax.servlet.ServletException;
  
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.catalina.Container;
  import org.apache.catalina.LifecycleException;
  /**
   * Simple implementation of <b>Logger</b> that invokes Avalon Logger.
   *
   * @author Vinay Chandran<vinayc77@yahoo.com>
   * @author Craig R. McClanahan
   */
  
  public class CatalinaLogger implements LogEnabled, org.apache.catalina.Logger
  {
  
      /**
       * The descriptive information about this implementation.
       */
      private static final String m_info =
          "org.apache.avalon.sevak.util.CatalinaLogger/1.0";
  
      /** Avalon-Catalina Logger bridge*/
      private org.apache.avalon.framework.logger.Logger m_avalonLogger = null;
  
      /**
       * Provide component with a logger.
       *
       * @param logger the logger
       */
      public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
      {
          m_avalonLogger = logger;
      }
  
      /**
       * Writes the specified message to a servlet log file, usually an event
       * log.  The name and type of the servlet log is specific to the
       * servlet container.
       *
       * @param msg A <code>String</code> specifying the message to be written
       *  to the log file
       */
      public void log(String msg)
      {
  
          switch (getVerbosity())
          {
              case org.apache.catalina.Logger.FATAL :
                  m_avalonLogger.fatalError(msg);
                  break;
              case org.apache.catalina.Logger.ERROR :
                  m_avalonLogger.error(msg);
                  break;
              case org.apache.catalina.Logger.WARNING :
                  m_avalonLogger.warn(msg);
                  break;
              case org.apache.catalina.Logger.INFORMATION :
                  m_avalonLogger.info(msg);
                  break;
              case org.apache.catalina.Logger.DEBUG :
                  m_avalonLogger.debug(msg);
                  break;
  
          }
  
      }
  
      // ****** Liberally copied from org.apache.catalina.logger.LoggerBase
  
      // ----------------------------------------------------- Instance Variables
  
      /**
       * The Container with which this Logger has been associated.
       */
      protected Container container = null;
  
      /**
       * The debugging detail level for this component.
       */
      protected int debug = 0;
  
      /**
       * The property change support for this component.
       */
      protected PropertyChangeSupport support = new PropertyChangeSupport(this);
  
      /**
       * The verbosity level for above which log messages may be filtered.
       */
      protected int verbosity = ERROR;
  
      /**
       * @see org.apache.catalina.Logger#getContainer()
       */
  
      // ------------------------------------------------------------- Properties
  
      /**
       * Return the Container with which this Logger has been associated.
       * @return Container Return the container
       */
      public Container getContainer()
      {
  
          return (container);
  
      }
  
      /**
       * Set the Container with which this Logger has been associated.
       *
       * @param container The associated Container
       */
      public void setContainer(Container container)
      {
  
          Container oldContainer = this.container;
          this.container = container;
          support.firePropertyChange("container", oldContainer, this.container);
  
      }
  
      /**
       * Return the debugging detail level for this component.
       * @return int 
       */
      public int getDebug()
      {
  
          return (this.debug);
  
      }
  
      /**
       * Set the debugging detail level for this component.
       *
       * @param debug The new debugging detail level
       */
      public void setDebug(int debug)
      {
  
          this.debug = debug;
  
      }
  
      /**
       * Return descriptive information about this Logger implementation and
       * the corresponding version number, in the format
       * <code>&lt;description&gt;/&lt;version&gt;</code>.
       * @return String 
       */
      public String getInfo()
      {
  
          return (m_info);
  
      }
  
      /**
       * Return the verbosity level of this logger.  Messages logged with a
       * higher verbosity than this level will be silently ignored.
       * @return int
       */
      public int getVerbosity()
      {
  
          return (this.verbosity);
  
      }
  
      /**
       * Set the verbosity level of this logger.  Messages logged with a
       * higher verbosity than this level will be silently ignored.
       *
       * @param verbosity The new verbosity level
       */
      public void setVerbosity(int verbosity)
      {
  
          this.verbosity = verbosity;
  
      }
  
      /**
       * Set the verbosity level of this logger.  Messages logged with a
       * higher verbosity than this level will be silently ignored.
       *
       * @param verbosity The new verbosity level, as a string
       */
      public void setVerbosityLevel(String verbosity)
      {
  
          if ("FATAL".equalsIgnoreCase(verbosity))
          {
              this.verbosity = FATAL;
          }
          else if ("ERROR".equalsIgnoreCase(verbosity))
          {
              this.verbosity = ERROR;
          }
          else if ("WARNING".equalsIgnoreCase(verbosity))
          {
              this.verbosity = WARNING;
          }
          else if ("INFORMATION".equalsIgnoreCase(verbosity))
          {
              this.verbosity = INFORMATION;
          }
          else if ("DEBUG".equalsIgnoreCase(verbosity))
          {
              this.verbosity = DEBUG;
          }
  
      }
  
      // --------------------------------------------------------- Public Methods
  
      /**
       * Add a property change listener to this component.
       *
       * @param listener The listener to add
       */
      public void addPropertyChangeListener(PropertyChangeListener listener)
      {
  
          support.addPropertyChangeListener(listener);
  
      }
  
      /**
       * Writes the specified exception, and message, to a servlet log file.
       * The implementation of this method should call
       * <code>log(msg, exception)</code> instead.  This method is deprecated
       * in the ServletContext interface, but not deprecated here to avoid
       * many useless compiler warnings.  This message will be logged
       * unconditionally.
       *
       * @param exception An <code>Exception</code> to be reported
       * @param msg The associated message string
       */
      public void log(Exception exception, String msg)
      {
  
          log(msg, exception);
  
      }
  
      /**
       * Writes an explanatory message and a stack trace for a given
       * <code>Throwable</code> exception to the servlet log file.  The name
       * and type of the servlet log file is specific to the servlet container,
       * usually an event log.  This message will be logged unconditionally.
       *
       * @param msg A <code>String</code> that describes the error or
       *  exception
       * @param throwable The <code>Throwable</code> error or exception
       */
      public void log(String msg, Throwable throwable)
      {
  
          CharArrayWriter buf = new CharArrayWriter();
          PrintWriter writer = new PrintWriter(buf);
          writer.println(msg);
          throwable.printStackTrace(writer);
          Throwable rootCause = null;
          if (throwable instanceof LifecycleException)
          {
              rootCause = ((LifecycleException) throwable).getThrowable();
          }
          else if (throwable instanceof ServletException)
          {
              rootCause = ((ServletException) throwable).getRootCause();
          }
          if (rootCause != null)
          {
              writer.println("----- Root Cause -----");
              rootCause.printStackTrace(writer);
          }
          log(buf.toString());
  
      }
  
      /**
       * Writes the specified message to the servlet log file, usually an event
       * log, if the logger is set to a verbosity level equal to or higher than
       * the specified value for this message.
       *
       * @param message A <code>String</code> specifying the message to be
       *  written to the log file
       * @param verbosity Verbosity level of this message
       */
      public void log(String message, int verbosity)
      {
  
          if (this.verbosity >= verbosity)
  		{
              log(message);
  		}
  
      }
  
      /**
       * Writes the specified message and exception to the servlet log file,
       * usually an event log, if the logger is set to a verbosity level equal
       * to or higher than the specified value for this message.
       *
       * @param message A <code>String</code> that describes the error or
       *  exception
       * @param throwable The <code>Throwable</code> error or exception
       * @param verbosity Verbosity level of this message
       */
      public void log(String message, Throwable throwable, int verbosity)
      {
  
          if (this.verbosity >= verbosity)
  		{
              log(message, throwable);
  		}
  
      }
  
      /**
       * Remove a property change listener from this component.
       *
       * @param listener The listener to remove
       */
      public void removePropertyChangeListener(PropertyChangeListener listener)
      {
  
          support.removePropertyChangeListener(listener);
  
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CatalinaSevak.java
  
  Index: CatalinaSevak.java
  ===================================================================
  /*
   * 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 java.io.File;
  import java.io.FileOutputStream;
  import java.io.InputStream;
  
  import org.apache.avalon.apps.sevak.Sevak;
  import org.apache.avalon.apps.sevak.SevakException;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.activity.Initializable;
  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.context.Context;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.catalina.Engine;
  import org.apache.catalina.Host;
  import org.apache.catalina.Lifecycle;
  import org.apache.catalina.LifecycleException;
  import org.apache.catalina.Loader;
  import org.apache.catalina.DefaultContext;
  import org.apache.catalina.core.StandardContext;
  import org.apache.catalina.startup.ContextConfig;
  import org.apache.catalina.startup.Embedded;
  import org.apache.coyote.tomcat4.CoyoteConnector;
  
  /**
   * @phoenix:block
   * @phoenix:service name="org.apache.avalon.apps.sevak.Sevak"
   *
   * Tomcat Wrapper.
   *
   *
   * @see <a href="http://jakarta.apache.org/tomcat">Tomcat Project Page</a>
   *
   * @author  Vinay Chandran<vinayc77@yahoo.com>
   * @version 1.0
   */
  public class CatalinaSevak
      extends AbstractLogEnabled
      implements Contextualizable, Configurable, Initializable, Startable, Sevak
  {
      //private BlockContext m_context;
      private Context m_context;
      private Configuration m_configuration;
      private Engine m_engine = null;
      private Embedded m_embedded = null;
      private Host m_tomcatHost = null;
      private Loader m_catalinaCustomClassLoader = null;
      private int m_port;
      private String m_host = null;
  
     /**
      * The thread that monitors stop requests from the container.
      */
      private Thread m_thread;
  
     /**
      * A flag used to trigger stop.
      */
      private boolean CONTINUE = false;
  
     /**
      * The period to sleep before checking for a stop request.
      */
      private int SLEEP_INTERVAL = 1000;
  
  
      /**
       * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
       */
  
      public void contextualize(final Context context)
      {
          getLogger().info("Sevak.contextualize()");
          //m_context = (BlockContext) context;
          m_context = (Context) context;
      }
  
      /**
       * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
       */
  
      public void configure(final Configuration configuration)
          throws ConfigurationException
      {
  
          m_configuration = configuration;
  
      }
  
      /**
       * @see org.apache.avalon.framework.activity.Initializable#initialize()
       */
  
      public void initialize() throws Exception
      {
          getLogger().info("Sevak.initialize()");
  
          //create the Logger
          CatalinaLogger catalinaLogger = new CatalinaLogger();
          catalinaLogger.enableLogging( getLogger().getChildLogger("catalina") );
  
          //create the Custom ClassLoader
          m_catalinaCustomClassLoader =
              new CustomWebappLoader(this.getClass().getClassLoader());
  
          //read the configuration properties
          String catalinaHome =
              m_configuration.getChild("catalina.home").getValue(null);
          if (catalinaHome == null)
          {
              catalinaHome = ((File)m_context.get("app.home")).getAbsolutePath();
  
              File confDir=new File( (File) m_context.get("app.home"),"conf");
              confDir.mkdir();
              getLogger().info("Created conf/ folder");
              InputStream in= CatalinaSevak.class.getResourceAsStream("default-web.xml");
              FileOutputStream fos =
                          new FileOutputStream(new File(confDir,"web.xml").getAbsolutePath());
              byte[] bytes= new byte[512];
              int read=0;
              while((read=in.read(bytes))!=-1)
              {
                  fos.write(bytes,0,read);
              }
              fos.close();
              in.close();
          }
          /*
           * TODO : Hack Tomcat to be able to run without the catalina.home property set
          {
              System.out.println(
                  "catalina.home property Not Found. Using : "
                      + m_context.get("app.home"));
              catalinaHome = ((File)m_context.get("app.home")).getAbsolutePath();
          }
          */
          m_port = m_configuration.getChild("port").getValueAsInteger(8080);
          m_host = m_configuration.getChild("bind").getValue("localhost");
  
          //set the catalina home directory
          System.setProperty("catalina.home", new File(catalinaHome).getAbsolutePath());
          // Create an Embedded Tomcat server
          m_embedded = new Embedded();
          m_embedded.setDebug(0);
          m_embedded.setLogger(catalinaLogger);
  
          //Create Tomcat Engine
          m_engine = m_embedded.createEngine();
          m_engine.setDefaultHost("localhost");
  
          // Create Tomcat Host
          m_tomcatHost = m_embedded.createHost("localhost", "webapps");
          m_engine.addChild(m_tomcatHost);
  
          // Create HTTP Coyote Connector
          CoyoteConnector coyoteConnector = new CoyoteConnector();
          coyoteConnector.setPort(8080);
          coyoteConnector.setMinProcessors(5);
          coyoteConnector.setMaxProcessors(75);
          coyoteConnector.setEnableLookups(true);
          coyoteConnector.setAcceptCount(10);
          coyoteConnector.setDebug(0);
          coyoteConnector.setConnectionTimeout(20000);
          coyoteConnector.setUseURIValidationHack(false);
  
          m_embedded.addEngine(m_engine);
          m_embedded.addConnector(coyoteConnector);
          getLogger().debug( "initialization complete" );
      }
  
      //=======================================================================
      // Startable
      //=======================================================================
  
     /**
      */
      public void start() throws Exception
      {
          getLogger().debug( "starting" );
          m_thread = new Thread(
            new Runnable() {
              public void run()
              {
                  while( CONTINUE )
                  {
                      try
                      {
                          Thread.currentThread().sleep( SLEEP_INTERVAL );
                      }
                      catch( Throwable e )
                      {
                      }
                  }
              }
            }
          );
  
          //START  Tomcat Instance
          try
          {
              getLogger().debug("starting Tomcat on home: " + System.getProperty("catalina.home"));
              m_embedded.start();
              getLogger().debug("Tomcat started");
          }
          catch (LifecycleException le)
          {
              le.printStackTrace();
              throw new ConfigurationException("[FATAL] Could Not START Tomcat  ");
          }
  
          CONTINUE = true;
          m_thread.start();
          getLogger().debug( "started" );
      }
  
     /**
      * Request to stop the service from the container.
      */
      public void stop()
      {
          getLogger().debug( "stopping" );
          CONTINUE = false;
          try
          {
              m_thread.join();
              m_embedded.stop();
          }
          catch( Throwable e )
          {
              getLogger().warn("Unexpected error while reqesting stop.", e );
          }
      }
  
  
      /**
       * Deploy the given Web Application
       * @param context Context for the the webapp
       * @param dirToWebAppFolder path can be a war-archive or exploded directory
       * @throws org.apache.avalon.apps.sevak.SevakException Thrown when the context already exists
       */
      public void deploy(String context, File dirToWebAppFolder)
          throws SevakException
      {
          if (!dirToWebAppFolder.exists())
          {
              throw new SevakException(
                  "Path not Found[" + dirToWebAppFolder + "]");
          }
          try
          {
              if (context == null)
              {
                  throw new SevakException("Invalid Context[" + context + "]");
              }
              if (context.equals("/"))
              {
                  context = "";
              }
              if (dirToWebAppFolder == null)
              {
                  throw new SevakException(
                      "Invalid WAR [" + dirToWebAppFolder + "]");
              }
              //now deploy ....
              org.apache.catalina.Context catalinaContext =
                  (org.apache.catalina.Context) m_tomcatHost.findChild(context);
              if (catalinaContext != null)
              {
                  throw new Exception("Context " + context + " Already Exists!");
              }
              catalinaContext =
                  createContext(context, dirToWebAppFolder.getAbsolutePath());
              m_tomcatHost.addChild(catalinaContext);
              // TODO - get this whole beast working!!!!
              //m_tomcatHost.setRealm(new org.apache.catalina.realm.MemoryRealm());
              System.out.println("Deployed [" + context + "] Context");
          }
          catch (Exception catalinaException)
          {
  
              throw new SevakException(
                  "Catalina Internal Error",
                  catalinaException);
          }
  
      }
  
      /**
       * Undeploy the given WebApp 
       * @param context Webapp context
       * @throws org.apache.avalon.apps.sevak.SevakException Thrown when context does NOT exist
       */
      public void undeploy(String context) throws SevakException
      {
          if (context == null)
          {
              throw new SevakException("Invalid Context[" + context + "]");
          }
          if (context.equals("/"))
          {
              context = "";
          }
          org.apache.catalina.Context catalinaContext =
              (org.apache.catalina.Context) m_tomcatHost.findChild(context);
          if (catalinaContext == null)
          {
              throw new SevakException("Context " + context + " does NOT Exist");
          }
          m_tomcatHost.removeChild(catalinaContext);
      }
      /**
       * Create a StandardContext 
       * @param path
       * @param docBase
       * @return Context
       */
  
      private org.apache.catalina.Context createContext(
          String path,
          String docBase)
      {
  
          StandardContext context = new StandardContext();
  
          context.setDebug(0);
          context.setDocBase(docBase);
          context.setPath(path);
          context.setLoader(m_catalinaCustomClassLoader);
  
          ContextConfig config = new ContextConfig();
          config.setDebug(0);
          ((Lifecycle) context).addLifecycleListener(config);
  
          return (context);
  
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/catalina/CustomWebappLoader.java
  
  Index: CustomWebappLoader.java
  ===================================================================
  /*
   * 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.loader.WebappLoader;
  import org.apache.catalina.LifecycleException;
  
  /**
   * Tomcat ClassLoader Hack to make Catalina run over Avalon/Phoenix .
   *
   * @author  Vinay Chandran<vinayc77@yahoo.com>
   * @version 1.0
   */
  
  public class CustomWebappLoader extends WebappLoader
  {
  
      private boolean m_started = false;
  
      /**
        * Start this component, initializing our associated class loader.
        *
        * @exception org.apache.catalina.LifecycleException if a lifecycle error occurs
        */
      public void start() throws LifecycleException
      {
          //Prevent the LifecycleException by preventing any further calls made 
          // to the base implementation to ' start' again
          if (m_started)
          {
              return;
          }
          m_started = true;
          super.start();
  
      }
  
      /**
       *  Constructor 
       * @param classLoader ClassLoader
       */
      public CustomWebappLoader(ClassLoader classLoader)
      {
          super(classLoader);
      }
  }
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jo/JoAvalonLogListener.java
  
  Index: JoAvalonLogListener.java
  ===================================================================
  /*
  License $Id: JoAvalonLogListener.java,v 1.1 2002/09/22 09:35:01 hammant Exp $
  
  Copyright (c) 2001-2002 tagtraum industries.
  
  LGPL
  ====
  
  jo! is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  
  jo! is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  
  For LGPL see <http://www.fsf.org/copyleft/lesser.txt>
  
  
  Sun license
  ===========
  
  This release contains software by Sun Microsystems. Therefore
  the following conditions have to be met, too. They apply to the
  files
  
   - lib/mail.jar
   - lib/activation.jar
   - lib/jsse.jar
   - lib/jcert.jar
   - lib/jaxp.jar
   - lib/crimson.jar
   - lib/servlet.jar
   - lib/jnet.jar
   - lib/jaas.jar
   - lib/jaasmod.jar
  
  contained in this release.
  
  a. Licensee may not modify the Java Platform
     Interface (JPI, identified as classes contained within the javax
     package or any subpackages of the javax package), by creating additional
     classes within the JPI or otherwise causing the addition to or modification
     of the classes in the JPI.  In the event that Licensee creates any
     Java-related API and distribute such API to others for applet or
     application development, you must promptly publish broadly, an accurate
     specification for such API for free use by all developers of Java-based
     software.
  
  b. Software is confidential copyrighted information of Sun and
     title to all copies is retained by Sun and/or its licensors.  Licensee
     shall not modify, decompile, disassemble, decrypt, extract, or otherwise
     reverse engineer Software.  Software may not be leased, assigned, or
     sublicensed, in whole or in part.  Software is not designed or intended
     for use in on-line control of aircraft, air traffic, aircraft navigation
     or aircraft communications; or in the design, construction, operation or
     maintenance of any nuclear facility.  Licensee warrants that it will not
     use or redistribute the Software for such purposes.
  
  c. Software is provided "AS IS," without a warranty
     of any kind. ALL EXPRESS OR IMPLIED REPRESENTATIONS AND WARRANTIES,
     INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
     PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
  
  d. This License is effective until terminated.  Licensee may
     terminate this License at any time by destroying all copies of Software.
     This License will terminate immediately without notice from Sun if Licensee
     fails to comply with any provision of this License.  Upon such termination,
     Licensee must destroy all copies of Software.
  
  e. Software, including technical data, is subject to U.S.
     export control laws, including the U.S.  Export Administration Act and its
     associated regulations, and may be subject to export or import regulations
     in other countries.  Licensee agrees to comply strictly with all such
     regulations and acknowledges that it has the responsibility to obtain
     licenses to export, re-export, or import Software.  Software may not be
     downloaded, or otherwise exported or re-exported (i) into, or to a national
     or resident of, Cuba, Iraq, Iran, North Korea, Libya, Sudan, Syria or any
     country to which the U.S. has embargoed goods; or (ii) to anyone on the
     U.S. Treasury Department's list of Specially Designated Nations or the U.S.
     Commerce Department's Table of Denial Orders.
  
  
  Feedback
  ========
  
  We encourage your feedback and suggestions and want to use your feedback to
  improve the Software. Send all such feedback to:
  <feedback@tagtraum.com>
  /*
   * 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.jo;
  
  import com.tagtraum.framework.log.C_Log;
  import com.tagtraum.framework.log.I_LogEventListener;
  import com.tagtraum.framework.log.Log;
  import com.tagtraum.framework.log.LogEvent;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * A connector between the tagtraum log packages and avalon logging.
   *
   * @author <a href="mailto:hs@tagtraum.com">Hendrik Schreiber</a>
   * @version $Revision: 1.1 $
   */
  public class JoAvalonLogListener implements I_LogEventListener {
  
      private String name;
      private Logger logger;
  
      public JoAvalonLogListener(String name, Logger logger) {
          this.name = name;        // source
          this.logger = logger;
          Log.getLog(name).addI_LogEventListener(this);
      }
  
      public void handleLogEvent(LogEvent le) {
          switch (le.getLevel()) {
              case C_Log.NOLOG:
                  break;
              case C_Log.ERROR:
                  if (le.getMessage() != null && le.getThrowable() != null) logger.error(le.getMessage(), le.getThrowable());
                  else if (le.getMessage() != null) logger.error(le.getMessage());
                  else if (le.getThrowable() != null) logger.error(le.getThrowable().toString(), le.getThrowable());
                  break;
              case C_Log.MODULE:
                  if (le.getMessage() != null && le.getThrowable() != null) logger.info(le.getMessage(), le.getThrowable());
                  else if (le.getMessage() != null) logger.info(le.getMessage());
                  else if (le.getThrowable() != null) logger.info(le.getThrowable().toString(), le.getThrowable());
                  break;
              default:
                  if (le.getMessage() != null && le.getThrowable() != null) logger.debug(le.getMessage(), le.getThrowable());
                  else if (le.getMessage() != null) logger.debug(le.getMessage());
                  else if (le.getThrowable() != null) logger.debug(le.getThrowable().toString(), le.getThrowable());
          }
      }
  
      public String getName() {
          return name;
      }
  
      public Logger getLogger() {
          return logger;
      }
  
      public int hashCode() {
          return name.hashCode() ^ logger.hashCode();
      }
  
      public boolean equals(Object obj) {
          if (obj == null) return false;
          if (obj == this) return true;
          if (obj.getClass() == getClass()) {
              return logger.equals(((JoAvalonLogListener)obj).getLogger()) && name.equals(((JoAvalonLogListener)obj).getName());
          }
          return false;
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jo/JoException.java
  
  Index: JoException.java
  ===================================================================
  /*
   * 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.jo;
  
  import java.io.PrintStream;
  import java.io.PrintWriter;
  
  /**
   *
   * Date: Jan 15, 2002
   * Time: 7:04:54 PM
   * @author <a href="mailto:hs@tagtraum.com">Hendrik Schreiber</a>
   * @version $Id: JoException.java,v 1.1 2002/09/22 09:35:01 hammant Exp $
   */
  public class JoException extends Exception {
     private Exception nestedException;
     public JoException(String s) {
        super(s);
     }
     public JoException(Exception nestedException) {
        super(nestedException.toString());
        setNestedException(nestedException);
     }
  
     public Exception getNestedException() {
        return nestedException;
     }
  
     private void setNestedException(Exception nestedException) {
        this.nestedException = nestedException;
     }
  
     public void printStackTrace() {
        if (nestedException != null) nestedException.printStackTrace();
        super.printStackTrace();
     }
  
     public void printStackTrace(PrintStream s) {
        if (nestedException != null) nestedException.printStackTrace(s);
        super.printStackTrace(s);
     }
  
     public void printStackTrace(PrintWriter s) {
        if (nestedException != null) nestedException.printStackTrace(s);
        super.printStackTrace(s);
     }
  }
  
  
  
  1.1                  jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jo/JoSevak.java
  
  Index: JoSevak.java
  ===================================================================
  /*
   * 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.jo;
  
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Startable;
  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.context.Context;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.phoenix.BlockContext;
  import org.apache.avalon.apps.sevak.Sevak;
  import org.apache.avalon.apps.sevak.SevakException;
  
  
  import java.net.URL;
  import java.net.MalformedURLException;
  import java.io.File;
  
  import com.tagtraum.framework.util.URLHelper;
  import com.tagtraum.framework.util.I_Builder;
  import com.tagtraum.framework.util.BuildException;
  import com.tagtraum.framework.log.C_Log;
  import com.tagtraum.framework.log.Log;
  import com.tagtraum.framework.server.ServerException;
  
  
  import com.tagtraum.jo.builder.JoPropertyServiceBuilder;
  import com.tagtraum.jo.builder.I_JoHostBuilder;
  import com.tagtraum.jo.I_JoServletService;
  import com.tagtraum.jo.JoServletService;
  import com.tagtraum.jo.I_JoHost;
  import com.tagtraum.jo.I_JoServletContextPeer;
  
  
  /**
   * @phoenix:block
   * @phoenix:service name="org.apache.avalon.apps.sevak.Sevak"
   *
   * Tomcat Wrapper.
   *
   *
   * @see <a href="http://jakarta.apache.org/tomcat">Tomcat Project Page</a>
   *
   * @author  Hendrik Schreiber & Paul Hammant
   * @version 1.0
   */
  public class JoSevak extends AbstractLogEnabled implements Sevak, Startable, Contextualizable,
          Configurable, Initializable
  {
  
      private Log m_log;
      private I_JoServletService m_joServletService;
      private I_Builder m_builder;
      private URL m_buildURL;
      private BlockContext m_context;
      private String m_hostName;
  
      public JoSevak()
      {
          m_log = com.tagtraum.framework.log.Log.getLog("Jo");
      }
  
      public void contextualize(final Context context)
      {
          this.m_context = (BlockContext) context;
      }
  
      public void configure(final Configuration configuration) throws ConfigurationException
      {
          m_hostName = configuration.getChild("hostname").getValue("localhost");
      }
  
  
      public void initialize() throws Exception
      {
  
          m_buildURL = URLHelper.make(((BlockContext) m_context).getBaseDirectory().toString() + "/etc/");
  
          JoServletService._setJoHome(((BlockContext) m_context).getBaseDirectory());
          // ugly hack...
          getLogger().info("JO_HOME = " + JoServletService._getJoHome());
  
          new JoAvalonLogListener("Jo", getLogger());
          m_builder = (I_Builder) new JoPropertyServiceBuilder();
          m_builder.setName("Jo");
          m_builder.setURL(m_buildURL);
          m_joServletService = (I_JoServletService) m_builder.build();
      }
  
      public final void start() throws Exception
      {
          m_joServletService.start();
      }
  
      public void stop() throws Exception
      {
          try
          {
              if (m_joServletService != null)
              {
                  m_joServletService.stop();
              }
              m_joServletService = null;
              m_builder = null;
          }
          catch (ServerException e)
          {
              m_log.log(e, C_Log.ERROR);
              getLogger().error("Error uring stopping of Jo!",e);
          }
      }
  
      //----------------------------------------------------------------------------
      // 'deploy' interface
      //----------------------------------------------------------------------------
      /**
       * @param context context path
       * @param pathToWebAppFolder
       */
      public void deploy(String context, File pathToWebAppFolder) throws SevakException
      {
  
          String warUrl = "TODO";
          try
          {
              warUrl = pathToWebAppFolder.toURL().toString();
              // now build the servletcontext
              I_JoHost host = m_joServletService.getHost(m_hostName);
              if (host == null) throw new JoException("Host '" + m_hostName + "' does not exist.");
              I_JoHostBuilder builder = (I_JoHostBuilder) host.getBuilder();
  
              /*
               * @param host Host to add the webapps to
               * @param url url the docbase is relative to.
               * @param name name of the webapp
               * @param docbase relative or absolute docbase
               * @param mappping URI this webapp will be mapped to
               */
  
  
  
              m_log.log("ContextPath: " + context);
              m_log.log("WARUrl: " + warUrl);
              if (host.getNamedServletContextPeer(context) != null)
              {
                  throw new JoException("Webapp " + context + " is already deployed. You need to undeploy it in order to deploy a different WAR with the same name.");
              }
              I_JoServletContextPeer peer = builder.buildWebApp(host, null, context, warUrl, context);
              // now start the webapp
              if (peer == null) throw new JoException("Failed to built webapp. Please check logs.");
              peer.start();
              m_log.log("Successfully deployed " + warUrl + " to " + context);
          }
          catch (JoException je)
          {
              m_log.log("Problem deploying " + warUrl + " to " + context, C_Log.ERROR);
              m_log.log(je, C_Log.ERROR);
              throw new SevakException("Jo could not deploy " + warUrl + " to " + context + ": " + je.getMessage());
          }
          catch (BuildException be)
          {
              m_log.log("Problem deploying " + warUrl + " to " + context, C_Log.ERROR);
              m_log.log(be, C_Log.ERROR);
              throw new SevakException("Jo could not build deployment : " + be.getMessage());
          }
          catch (MalformedURLException mufe)
          {
              m_log.log("Problem deploying " + warUrl + " to " + context + " as URL cannot be made from path", C_Log.ERROR);
              m_log.log(mufe, C_Log.ERROR);
              throw new SevakException("Jo could not build deployment : " + mufe.getMessage());
          }
      }
  
      public void undeploy(String context) throws SevakException
      {
          I_JoHost host = m_joServletService.getHost(m_hostName);
          if (host == null) throw new SevakException("Host '" + m_hostName + "' does not exist.");
          try
          {
              host.removeServletContextPeer(context);
          }
          catch (Exception e)
          {
              m_log.log("Problem undeploying webapp " + context, C_Log.ERROR);
              m_log.log(e, C_Log.ERROR);
              throw new SevakException("Jo could not undeploy " + context);
          }
      }
  
  
  }
  
  
  

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