donaldp     2002/06/03 23:03:46

  Added:       containerkit .cvsignore ant.properties.sample build.xml
                        BUILDING.txt default.properties README.txt
               containerkit/src/java/org/apache/excalibur/containerkit/metainfo
                        ComponentDescriptor.java ComponentInfo.java
                        DependencyDescriptor.java ServiceDescriptor.java
               containerkit/src/java/org/apache/excalibur/containerkit/lifecycle
                        LifecycleException.java LifecycleHelper.java
                        ResourceAccessor.java Resources.properties
               containerkit/src/conf MANIFEST.MF
               containerkit/src/java/org/apache/excalibur/containerkit/verifier
                        Resources.properties Verifier.java
                        VerifyException.java
  Log:
  Start to create a generic container infrastructure
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/containerkit/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  ant.properties
  build
  checkstyle.cache
  distributions
  dist
  excalibur-*
  *.el
  *.ipr
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/ant.properties.sample
  
  Index: ant.properties.sample
  ===================================================================
  # 
-----------------------------------------------------------------------------
  # Component ant.properties.sample
  #
  # This is an example "ant.properties" file, used to customize the building of
  # the component for your local environment.  It defines the location of all
  # external modules that this component depend on.  Copy this file to
  # "ant.properties" in the source directory, and customize it as needed.
  #
  # The ant.properties values in this directory apply only to this component.
  # It is overridden by ../ant.properties and ~/build.properties
  # It overrides all default.properties files and ~/.ant.properties
  #
  # $Id: ant.properties.sample,v 1.1 2002/06/04 06:03:45 donaldp Exp $
  # 
-----------------------------------------------------------------------------
  
  # ----- Compile Control Flags -----
  build.debug=on
  build.optimize=off
  build.deprecation=off
  #build.compiler=jikes
  
  # ----- Base Directory in which all the packages are stored -----
  base.path=${basedir}/../..
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  
  
  # --------------------------------------------------
  #                OPTIONAL LIBRARIES
  # --------------------------------------------------
  
  # ----- JUnit Unit Test Suite, version 3.7 or later. -----
  #  Not needed if junit.jar is in $ANT_HOME/lib 
  junit.home=${base.path}/junit3.7
  junit.lib=${junit.home}
  junit.jar=${junit.lib}/junit.jar
  
  
  # ----- Checkstyle, version 2.1 or later -----
  # Uncomment the 'do.checkstyle' flag property to enable checkstyle
  # do.checkstyle=
  checkstyle.home=${base.path}/checkstyle-2.1
  checkstyle.lib=${checkstyle.home}
  checkstyle.jar=${checkstyle.lib}/checkstyle-all-2.1.jar
  
  
  
  1.1                  jakarta-avalon-excalibur/containerkit/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <project name="Excalibur ContainerKit" default="main" basedir=".">
  
      <property file="${user.home}/build.properties"/>
      <property file="${basedir}/../ant.properties"/>
      <property file="${basedir}/ant.properties"/>
      <property file="${user.home}/.ant.properties"/>
      <property file="${basedir}/../default.properties"/>
      <property file="${basedir}/default.properties"/>
  
      <!-- Classpath for product -->
      <path id="project.class.path">
          <pathelement location="${build.classes}"/>
          <pathelement location="${avalon-framework.jar}"/>
          <pathelement location="${excalibur-i18n.jar}"/>
          <pathelement location="${checkstyle.jar}"/>
          <pathelement path="${java.class.path}"/>
      </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">
          <pathelement location="${build.testclasses}"/>
          <pathelement location="${junit.jar}"/>
          <path refid="project.class.path"/>
      </path>
      <property name="cp" refid="test.class.path"/>
  
      <target name="main" depends="jar" description="Build the project"/>
      <target name="rebuild" depends="clean,main" description="Rebuild the 
project"/>
  
      <target name="dependencies" description="Check dependencies" 
unless="skip.dependencies">
          <ant antfile="${depchecker.prefix}/depchecker.xml" 
target="checkCommon"/>
          <ant antfile="${depchecker.prefix}/depchecker.xml" 
target="checkFramework"/>
          <ant antfile="${depchecker.prefix}/depchecker.xml" 
target="checkI18N"/>
      </target>
  
      <target name="dependencies-test" depends="dist-jar, dependencies"
          description="Check unit test dependencies" unless="skip.dependencies">
          <!-- Need the jar to prevent recursive deps. -->
  
          <ant antfile="${depchecker.prefix}/depchecker.xml" 
target="checkJUnit"/>
      </target>
  
  
      <!-- Compiles the source code -->
      <target name="compile" depends="dependencies" description="Compiles the 
source code">
  
          <mkdir dir="${build.classes}"/>
  
          <!-- Compile all classes excluding the tests. -->
          <javac srcdir="${java.dir}"
              destdir="${build.classes}"
              debug="${build.debug}"
              optimize="${build.optimize}"
              deprecation="${build.deprecation}"
              target="1.2">
              <classpath refid="project.class.path" />
              <include name="**/*.java"/>
          </javac>
  
          <!-- copy resources to same location as .class files -->
          <copy todir="${build.classes}">
              <fileset dir="${java.dir}">
                  <exclude name="**/*.java"/>
                  <exclude name="**/package.html"/>
              </fileset>
          </copy>
  
      </target>
  
      <!-- Compiles the unit test source code -->
      <target name="compile-test" depends="compile, dependencies-test" 
description="Compiles the source code">
          <mkdir dir="${build.testsrc}"/>
  
          <!-- Copy over all of the tests applying test filters -->
          <copy todir="${build.testsrc}">
              <fileset dir="${test.dir}"/>
          </copy>
  
          <mkdir dir="${build.testclasses}"/>
  
          <!-- Compile all test classes. -->
          <javac srcdir="${build.testsrc}"
              destdir="${build.testclasses}"
              debug="${build.debug}"
              optimize="${build.optimize}"
              deprecation="${build.deprecation}"
              target="1.2">
              <classpath refid="test.class.path" />
              <include name="**/*.java"/>
          </javac>
  
          <copy todir="${build.testclasses}">
              <fileset dir="${test.dir}">
                  <exclude name="**/*.java"/>
                  <exclude name="**/package.html"/>
              </fileset>
          </copy>
  
      </target>
  
      <!-- Copies and filters the manifest and license. Used by jar and dist -->
      <target name="prepare-conf">
          <mkdir dir="${build.conf}"/>
          <copy todir="${build.conf}" flatten="true">
              <fileset dir="../" includes="LICENSE.txt"/>
              <fileset dir="${conf.dir}" includes="MANIFEST.MF"/> 
              <filterset>
                  <filtersfile file="default.properties"/>
              </filterset>
          </copy>
  
      </target>
  
      <!-- Creates all the .jar file -->
      <target name="jar" depends="compile, prepare-conf" description="Generates 
the jar files">
  
          <mkdir dir="${build.lib}"/>
  
          <jar jarfile="${build.lib}/${jar.name}"
              basedir="${build.classes}"
              compress="${build.compress}"
              manifest="${build.conf}/MANIFEST.MF">
              <exclude name="**/test/**"/>
              <zipfileset dir="${build.conf}" prefix="META-INF/">
                  <include name="LICENSE.txt"/>
              </zipfileset>
          </jar>
      </target>
  
      <!-- Creates all the Javadocs -->
      <target name="javadocs" depends="compile" description="Generates the 
javadocs" unless="skip.javadocs">
  
          <mkdir dir="${dist.javadocs}"/>
          <javadoc packagenames="org.apache.*"
              sourcepath="${java.dir}"
              destdir="${dist.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="test" depends="compile-test" description="Perform the unit 
tests" unless="skip.tests">
  
          <echo message="Performing Unit Tests" />
  
          <mkdir dir="${build.tests}"/>
  
          <junit fork="true"
              haltonfailure="${junit.failonerror}"
              printsummary="yes"
              dir="${build.tests}">
              <classpath refid="test.class.path"/>
  
              <formatter type="xml"/>    <!-- xml reports for junitreport -->
              <formatter type="plain" usefile="false"/>  <!-- text reports for 
humans     -->
  
              <batchtest todir="${build.tests}">
                  <fileset dir="${build.testclasses}">
                      <include name="**/test/*TestCase.class"/>
                      <exclude name="**/Abstract*"/>
                  </fileset>
              </batchtest>
          </junit>
  
      </target>
  
      <target name="test-reports" depends="test" description="Generate Reports 
for the unit tests">
  
          <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkBSF"/>
  
          <mkdir dir="${build.reports}/junit"/>
  
          <junitreport todir="${build.reports}/junit">
              <fileset dir="${build.tests}">
                  <include name="TEST-*.xml"/>
              </fileset>
              <report format="frames" todir="${build.reports}/junit"/>
          </junitreport>
  
          <!-- Clean up the xml reports used by the junitreport task -->
          <!--
          <delete>
              <fileset dir="${build.tests}" includes="TEST-*.xml"/>
              <fileset dir="${build.tests}" includes="TESTS-*.xml"/>
          </delete>
          -->
  
      </target>
  
      <target name="checkstyle" if="do.checkstyle" description="Checkstyle">
  
          <!-- this invocation of checkstyle requires that checkstyle be 
downloaded and setup -->
          <!-- thats why you are required to define do.checkstyle property to 
generate the report -->
          <taskdef name="checkstyle"
              classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
              <classpath refid="project.class.path"/>
          </taskdef>
          <checkstyle
              lcurlyType="nl"
              lcurlyMethod="nl"
              lcurlyOther="nl"
              rcurly="ignore"
              allowProtected="false"
              allowPackage="false"
              allowNoAuthor="false"
              maxLineLen="100"
              maxMethodLen="100"
              maxConstructorLen="100"
              memberPattern="^m_[a-z][a-zA-Z0-9]*$"
              staticPattern="^c_[a-z][a-zA-Z0-9]*$"
              constPattern="(^c_[a-z][a-zA-Z0-9]*$)|([A-Z_]*$)"
              ignoreImportLen="true"
              allowTabs="false"
              javadocScope="protected"
              ignoreWhitespace="true"
              cacheFile="checkstyle.cache"
              failOnViolation="false"
              ignoreCastWhitespace="true">
              <fileset dir="${java.dir}">
                  <include name="**/*.java"/>
              </fileset>
              <formatter type="plain"/>
              <formatter type="xml" 
toFile="${build.dir}/checkstyle-results.xml"/>
          </checkstyle>
      </target>
  
      <target name="checkstyle-report"
          depends="checkstyle"
          if="do.checkstyle"
          description="Generate Checkstyle Report">
  
          <mkdir dir="${build.reports}/checkstyle"/>
          <property name="checkstyle.pathhack" location="."/>
          <style style="${tools.dir}/etc/checkstyle-frames.xsl" 
in="${build.dir}/checkstyle-results.xml"
              out="${build.reports}/checkstyle/delete-me.html">
              <param name="pathhack" expression="${checkstyle.pathhack}"/>
          </style>
  
      </target>
  
      <!-- Creates the distribution -->
      <target name="dist"
          depends="dist-jar, test-reports, checkstyle-report, javadocs"
          description="Generates a distribution (jar + javadocs + unit tests + 
checkstyle reports)">
  
  
          <copy file="${build.conf}/LICENSE.txt" todir="${dist.dir}"/>
          <copy file="../KEYS" todir="${dist.dir}"/>
          <copy file="README.txt" todir="${dist.dir}"/>
  
          <mkdir dir="${dist.base}"/>
  
          <zip zipfile="${dist.base}/${dist.name}-bin.zip" compress="true">
              <zipfileset dir="${dist.dir}" prefix="${dist.name}"/>
          </zip>
  
          <!--
            Not supported by released ant but when it is we should enable this 
across
            all of the products
          <tar longfile="gnu" tarfile="${dist.base}/${dist.name}-bin.tar">
            <tarfileset dir="${dist.dir}"
                        prefix="${dist.name}"
                        username="avalon"
                        group="avalon"/>
          </tar>
  
          <gzip zipfile="${dist.base}/${dist.name}-bin.tar.gz"
                src="${dist.name}-bin.tar"/>
          <bzip2 zipfile="${dist.base}/${dist.name}-bin.tar.gz"
                 src="${dist.name}-bin.tar"/>
  
          <delete file="${dist.base}/${dist.name}-bin.tar"/>
  
          <checksum fileext=".md5">
            <fileset dir="${dist.base}" />
          </checksum>
          -->
          <delete dir="${dist.dir}" />
  
      </target>
  
      <!-- Creates a mini jar-only distribution -->
      <target name="dist-jar" depends="jar">
          <mkdir dir="${dist.dir}"/>
          <copy todir="${dist.dir}">
              <fileset dir="${build.lib}">
                  <include name="*.jar"/>
              </fileset>
          </copy> 
      </target>   
  
      <!-- Creates a minimal distribution -->
      <target name="dist.lite"
          depends="dist-jar, test, javadocs"
          description="Generates a minimal distribution (jar + javadocs)">
  
          <copy file="../LICENSE.txt" todir="${dist.dir}"/>
          <copy file="../KEYS" todir="${dist.dir}"/>
          <copy file="README.txt" todir="${dist.dir}"/>
  
      </target>
  
      <!-- Setup the filters -->
      <target name="setup-filters">
        <filter token="Name" value="Avalon ${Name}"/>
        <filter token="name" value="${dir-name}"/>
        <filter token="version" value="${version}"/>
        <filter token="year" value="${year}"/>
        <filter token="status" value="${status}"/>
        <filter token="release" value="${release}"/>
        <filter token="short-version" value="${short.version}"/>
  
        <property name="avalon.base" value="http://jakarta.apache.org/avalon"/>
        <property name="framework.base" 
value="http://jakarta.apache.org/avalon/framework"/>
        <property name="phoenix.base" 
value="http://jakarta.apache.org/avalon/phoenix"/>
        <property name="cornerstone.base" 
value="http://jakarta.apache.org/avalon/cornerstone"/>
        <property name="logkit.base" 
value="http://jakarta.apache.org/avalon/logkit"/>
        <property name="testlet.base" 
value="http://jakarta.apache.org/avalon/testlet"/>
  
        <filter token="year" value="${year}"/>
        <filter token="AVALON_BASE" value="${avalon.base}"/>
        <filter token="FRAMEWORK_BASE" value="${framework.base}"/>
        <filter token="PHOENIX_BASE" value="${phoenix.base}"/>
        <filter token="CORNERSTONE_BASE" value="${cornerstone.base}"/>
        <filter token="LOGKIT_BASE" value="${logkit.base}"/>
        <filter token="TESTLET_BASE" value="${testlet.base}"/>
      </target>
      
      
      <!-- Prepares the documentation directory -->
      <target name="docs" depends="setup-filters"> <!-- depends="javadocs" 
description="Generates the Docs" -->
        <mkdir dir="${docs.dir}"/>
  
        <mkdir dir="${build.context}"/>
        <mkdir dir="${build.xdocs}"/>
        <mkdir dir="${build.docs}"/>
        <mkdir dir="${build.dir}/work"/>
    
        <!-- Base pointers for non-xdocs documentation. Override these in 
.ant.properties to link to local docs -->
        <copy todir="${build.context}" filtering="on">
          <fileset dir="${context.dir}">
            <exclude name="diagrams/**"/>
            <exclude name="resources/**"/>
            <exclude name="xdocs"/>
          </fileset>
        </copy>
    
        <copy todir="${build.context}/xdocs" filtering="on" overwrite="yes">
          <fileset dir="${xdocs.dir}"/>
        </copy>
  
        <copy todir="${build.context}/resources" filtering="off" 
overwrite="yes">
          <fileset dir="${context.dir}/resources"/>
          <fileset dir="${xdocs.dir}">
            <include name="**/images/**"/>
          </fileset>
        </copy>
  
        <java classname="org.apache.cocoon.Main" fork="true">
          <arg value="-c${build.context}/"/>
          <arg value="-d${build.docs}"/>
          <arg value="-w${build.dir}/work"/>
          <arg value="-l${build.dir}/work/cocoon.log"/>
          <arg value="-uINFO"/>
          <arg value="-f${xdocs.dir}/${dir-name}.uris"/>
          <classpath>
            <path refid="tools.class.path"/>
            <fileset dir="${tools.dir}/ext"/>
          </classpath>
        </java>
  
        <copy todir="${docs.dir}">
          <fileset dir="${build.docs}">
            <include name="**"/>
          </fileset>
        </copy>    
  
        <!-- hack for stupid transport on api link -->
        <replace file="${docs.dir}/index.html" token="index.html.xml" 
value="index.html"/>
       
      </target>
      
      <target name="site" depends="javadocs, docs" description=" Places Docs 
ready for hosting on website">  
    
        <mkdir dir="../site/dist/docs/${dir-name}"/>     
        <copy todir="../site/dist/docs/${dir-name}">
          <fileset dir="${docs.dir}">
            <include name="**"/>
          </fileset>
        </copy>        
    
      </target>
  
      <!-- Cleans up build and distribution directories -->
      <target name="clean" description="Cleans up the project">
          <delete file="checkstyle.cache"/>
          <delete dir="${build.dir}" />
          <delete dir="${dist.dir}" />
          <delete dir="test" /> <!-- unit testing output directory -->
          <delete>
              <fileset dir="." includes="**/*~" defaultexcludes="no"/>
          </delete>
      </target>
  
      <target name="real-clean" depends="clean" description="Cleans up the 
project, including distributions">
          <delete dir="${dist.base}" />
      </target>
  
  </project>
  
  
  
  1.1                  jakarta-avalon-excalibur/containerkit/BUILDING.txt
  
  Index: BUILDING.txt
  ===================================================================
  
                 Building The Component
                 ======================
  
  Building from CVS
  -----------------
  
  Assuming:
   - You have a JDK installed, $JAVA_HOME set and 'java -version' works
   - Your directory structure follows standard CVS layout:
  
  jakarta-avalon/                   # jakarta-avalon CVS module, containing Ant
  jakarta-avalon-excalibur/              # contains build.sh, build.bat
  jakarta-avalon-excalibur/<component>   # you are here
  
  Then to build, you need only customize ant.properties (see step 6 below) and
  type './build.sh' (Unix) or 'build' (DOS). The '-projecthelp' option will
  list the available targets.
  
  
  Building from source distribution
  ---------------------------------
  
  In order to build a binary distribution version of the component from a 
  source  distribution,  you must have  a Java Development Kit (JDK)  for 
  version  1.1 (or  later)  downloaded  and  installed  (version  1.3.1 
  recommended), and do the following:
  
  (0) Download and Install a Java Development Kit
  
  * Download a Java Development Kit (JDK) release (version 1.1 or later) 
    from:
  
      http://java.sun.com/j2se/
  
  * Install the JDK according to the instructions included with the release.
  
  * Set an environment variable JAVA_HOME to the pathname of the directory
    into which you installed the JDK release.
  
  
  (1) Download and Install the Ant Binary Distribution
  
  * Download a binary distribution of Ant 1.4.1 from:
  
      http://jakarta.apache.org/builds/jakarta-ant/release/v1.4.1/bin/
  
    On a Windows platform, you will need:
      jakarta-ant-1.4.1-bin.zip
      jakarta-ant-1.4.1-optional.jar
  
    On a Unix platform, you will need:
      jakarta-ant-1.4.1-bin.tar.gz
      jakarta-ant-1.4.1-optional.jar
  
  * Unpack the binary distribution into a convenient location so that the
    Ant release resides in its own directory (conventionally named
    "jakarta-ant-1.4.1").  For the purposes of the remainder of this document,
    the symbolic name "${ant.home}" is used to refer to the full pathname of
    the release directory.
  
  * Copy the file "jakarta-ant-1.4.1-optional.jar", downloaded above, into
    the directory "${ant.home}/lib".  This makes available several Ant
    extension commands that are commonly required when building Jakarta
    based projects.
  
  * Modify the PATH environment variable to include directory
    "${ant.home}/bin" in its list.  This makes the "ant" command line script
    available, which will be used to actually perform the build.
  
  (2) Download and Install the JUnit Testing Package (OPTIONAL)
  
  NOTE: This is only required if you wish to run the unit tests for 
  this component
  
  * Download the JUnit unit test package (version 3.7 or later) from:
  
      http://www.junit.org/
  
  * Unpack the package into a convenient location so that it resides in its
    own subdirectory.
  
  * Copy the file "junit.jar", downloaded above, into the directory 
    "${ant.home}/lib".  This makes available the unit testing tasks that are 
    commonly required when building Jakarta based projects.
  
  (3) Download and Install Checkstyle, 2.1 or later (OPTIONAL)
  
  NOTE: This is only required if you wish to generate reports regarding code 
style.
  
  * Download the Checkstyle package (version 2.1 or later) from:
  
      http://checkstyle.sourceforge.net/
  
  * Unpack the package into a convenient location so that it resides in its
    own subdirectory.
  
  (4) Download and Install the Xalan, XSLT engine (OPTIONAL)
  
  NOTE: This is only required if you wish to generate reports for the 
dependency 
  analysis, checkstyle and unit testing results.
  
  * Download the Xalan package (version 2.3.1 or later) from:
  
      http://xml.apache.org/xalan-j/
  
  * Unpack the package into a convenient location so that it resides in its
    own subdirectory.
  
  * Copy the files "xalan.jar", and "xml-apis.jar", downloaded above, into 
    the directory "${ant.home}/lib".  This makes available the XSLT reporting
    capabilities.
  
  (5) Customize Build Properties For This Subproject
  
  Most Jakarta subprojects allow you to customize Ant properties (with default
  values defined in the "build.xml" file.  This is done by creating a text file
  named "ant.properties" in the source distribution directory (for property
  definitions local to this subproject) and/or your user home directory (for
  property definitions shared across subprojects).  You can use the included
  "ant.properties.sample" file as a starting point for this.
  
  External dependencies are satisfied by configuring appropriate values in your 
  ant.properties file.  The easiest way to satisfy these dependencies is to 
copy 
  the "ant.properties.sample" file (in the top-level directory) to 
"ant.properties", 
  and then edit it to suit your environment.  On Unix, this would be done as:
  
    cd @dist.name@
    cp ant.properties.sample ant.properties
    emacs ant.properties
  
  NOTE:  Be *sure* that you do not check "ant.properties" in to the CVS
  repository.  This file is local to your own development environment, and
  each developer will have their own version.
  
  (6) Build A Binary Distribution
  
  Open a command line shell, and issue the following commands:
  
    cd @dist.name@
    ant -projecthelp
  
  If everything is installed correctly, you should see a list of the Ant
  "targets" that represent different commands you might wish to build.  By
  convention, the "jar" target creates the jar of the component. To execute 
  it, type the following commands:
  
    cd @dist.name@
    ant jar
  
  This will create a jar in the @dist.name@/build/lib directory that contains 
  the component.
  
  
  
  1.1                  jakarta-avalon-excalibur/containerkit/default.properties
  
  Index: default.properties
  ===================================================================
  # -------------------------------------------------------------------
  # B U I L D  P R O P E R T I E S
  # -------------------------------------------------------------------
  # Specifies default property values
  # Overridden by ../default.properties and all ant.properties
  # Not user-editable; use ant.properties files instead
  
  name=excalibur-containerkit
  Name=Excalibur ContainerKit
  dir-name=containerkit
  version=1.0
  package-version=0.99
  year=2000-2002
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  
  # --------------------------------------------------
  
  #  Settings used to configure compile environment
  build.debug = on
  build.optimize = off
  build.deprecation = off
  build.compress = false
  junit.failonerror = false
  
  #  location of intermediate products
  build.dir = build
  build.testsrc = ${build.dir}/testsrc
  build.testclasses = ${build.dir}/testclasses
  build.lib = ${build.dir}/lib
  build.conf = ${build.dir}/conf
  build.classes = ${build.dir}/classes
  build.tests = ${build.dir}/tests
  build.reports = ${build.dir}/reports
  
  #  Set the properties for source directories
  src.dir = src
  java.dir = ${src.dir}/java
  conf.dir = ${src.dir}/conf
  test.dir = ${src.dir}/test
  
  #  Set the properties for distribution directories
  dist.dir = dist
  dist.javadocs = ${dist.dir}/docs/api
  
  #  name of .zip/.tar.gz/.bz2 files and their top-level directory
  dist.name = ${name}-${version}
  
  #  name of jar file
  jar.name = ${name}-${version}.jar
  
  #  property indicating directory where all distribution archives are placed
  dist.base = distributions
  
  depchecker.prefix=.
  
  
  
  
  1.1                  jakarta-avalon-excalibur/containerkit/README.txt
  
  Index: README.txt
  ===================================================================
                    Avalons Excalibur ContainerKit
                    ------------------------------
  
  The ContainerKit is a set of utilities aimed at helping developers
  create containers of various types.
  
  Getting Started:
  ----------------
  
  If you downloaded a source release of the component then you
  will need to build the component. Directions for building the
  component are located in BUILDING.txt
  
  If you downloaded a binary release, or a release with both binary
  and source then it is recomended you look over the documentation
  in docs/index.html - and then look into the examples/ directory
  for examples of the component in action.
  
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ComponentDescriptor.java
  
  Index: ComponentDescriptor.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  import org.apache.avalon.framework.Version;
  
  /**
   * This class is used to provide explicit information to assembler
   * and administrator about the Component. It includes information
   * such as;
   *
   * <ul>
   *   <li>a symbolic name</li>
   *   <li>a display name</li>
   *   <li>classname</li>
   *   <li>version</li>
   * </ul>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 06:03:45 $
   */
  public class ComponentDescriptor
  {
      /**
       * The short name of the Component Type. Useful for displaying
       * human readable strings describing the type in
       * assembly tools or generators.
       */
      private final String m_name;
      private final String m_displayName;
      private final String m_classname;
      private final Version m_version;
  
      public ComponentDescriptor( final String name,
                                  final String displayName,
                                  final String classname,
                                  final Version version )
      {
          m_name = name;
          m_displayName = displayName;
          m_classname = classname;
          m_version = version;
      }
  
      /**
       * Return the symbolic name of component.
       *
       * @return the symbolic name of component.
       */
      public String getName()
      {
          return m_name;
      }
  
      /**
       * Return the display name of component.
       *
       * @return the display name of component.
       */
      public String getDisplayName()
      {
          return m_displayName;
      }
  
      /**
       * Return the classname of component.
       *
       * @return the classname of component.
       */
      public String getClassname()
      {
          return m_classname;
      }
  
      /**
       * Return the version of component.
       *
       * @return the version of component.
       */
      public Version getVersion()
      {
          return m_version;
      }
  }
  
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ComponentInfo.java
  
  Index: ComponentInfo.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  /**
   * This class contains the meta information about a particular
   * component type. It describes;
   *
   * <ul>
   *   <li>Human presentable meta data such as name, version, description etc
   *   useful when assembling the system.</li>
   *   <li>the services that this component type is capable of providing</li>
   *   <li>the services that this component type requires to operate (and the
   *   names via which services are accessed)</li>
   * </ul>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 06:03:45 $
   */
  public class ComponentInfo
  {
      private final ComponentDescriptor m_descriptor;
      private final ServiceDescriptor[] m_services;
      private final DependencyDescriptor[] m_dependencies;
  
      /**
       * Basic constructor that takes as parameters all parts.
       */
      public ComponentInfo( final ComponentDescriptor descriptor,
                            final ServiceDescriptor[] services,
                            final DependencyDescriptor[] dependencies )
      {
          m_descriptor = descriptor;
          m_services = services;
          m_dependencies = dependencies;
      }
  
      /**
       * Return meta information that is generallly only required by 
administration tools.
       *
       * It should be loaded on demand and not always present in memory.
       *
       * @return the ComponentDescriptor
       */
      public ComponentDescriptor getComponentDescriptor()
      {
          return m_descriptor;
      }
  
      /**
       * Return the set of Services that this Component is capable of providing.
       *
       * @return the set of Services that this Component is capable of 
providing.
       */
      public ServiceDescriptor[] getServices()
      {
          return m_services;
      }
  
      /**
       * Return the set of Dependencies that this Component requires to operate.
       *
       * @return the set of Dependencies that this Component requires to 
operate.
       */
      public DependencyDescriptor[] getDependencies()
      {
          return m_dependencies;
      }
  
      /**
       * Retrieve a dependency with a particular role.
       *
       * @param role the role
       * @return the dependency or null if it does not exist
       */
      public DependencyDescriptor getDependency( final String role )
      {
          for( int i = 0; i < m_dependencies.length; i++ )
          {
              if( m_dependencies[ i ].getRole().equals( role ) )
              {
                  return m_dependencies[ i ];
              }
          }
  
          return null;
      }
  }
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/DependencyDescriptor.java
  
  Index: DependencyDescriptor.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  /**
   * A descriptor that describes dependency information for
   * a particular Component. This class contains information
   * about;
   * <ul>
   *   <li>role: the name component uses to look up dependency</li>
   *   <li>service: the class/interface that the dependency must provide</li>
   * </ul>
   *
   * <p>Note that in the future we may also add information relating to
   * constraints on dependency. ie The dependency must be configured in
   * particular fashion or must be able to provide certain facilities etc</p>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 06:03:45 $
   */
  public final class DependencyDescriptor
  {
      /**
       * The name the component uses to lookup dependency.
       */
      private final String m_role;
  
      /**
       * The service class/interface that the dependency must provide.
       */
      private final ServiceDescriptor m_service;
  
      /**
       * Constructor that has all parts as parameters.
       */
      public DependencyDescriptor( final String role, final ServiceDescriptor 
service )
      {
          m_role = role;
          m_service = service;
      }
  
      /**
       * Return the name the component uses to lookup dependency.
       *
       * @return the name the component uses to lookup dependency.
       */
      public String getRole()
      {
          return m_role;
      }
  
      /**
       * Return the service class/interface that the dependency must provide.
       *
       * @return the service class/interface that the dependency must provide.
       */
      public ServiceDescriptor getService()
      {
          return m_service;
      }
  }
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ServiceDescriptor.java
  
  Index: ServiceDescriptor.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  import org.apache.avalon.framework.Version;
  
  /**
   * This descriptor defines the type of service offerend or required
   * by a component. The type corresponds to the class name of the
   * class/interface implemented by component. Associated with each
   * classname is a version object so that different versions of same
   * interface can be represented.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 06:03:45 $
   */
  public final class ServiceDescriptor
  {
      /**
       * The name of service class.
       */
      private final String m_name;
  
      /**
       * The version of service class.
       */
      private final Version m_version;
  
      /**
       * Construct a service with specified name and version.
       *
       * @param name the name of the service
       * @param version the version of service
       */
      public ServiceDescriptor( final String name, final Version version )
      {
          m_name = name;
          m_version = version;
      }
  
      /**
       * Return name of Service (which coresponds to the interface
       * name eg org.apache.block.WebServer)
       *
       * @return the name of the Service
       */
      public String getName()
      {
          return m_name;
      }
  
      /**
       * Return the version of interface
       *
       * @return the version of interface
       */
      public Version getVersion()
      {
          return m_version;
      }
  
      /**
       * Determine if specified service will match this service.
       * To match a service has to have same name and must comply with version.
       *
       * @param other the other ServiceInfo
       * @return true if matches, false otherwise
       */
      public boolean matches( final ServiceDescriptor other )
      {
          return
              other.getName().equals( m_name ) &&
              other.getVersion().complies( m_version );
      }
  
      /**
       * Convert to a string of format name/version
       *
       * @return string describing service
       */
      public String toString()
      {
          return m_name + "/" + m_version;
      }
  }
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/LifecycleException.java
  
  Index: LifecycleException.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate error processing block through its lifecycle.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 06:03:46 $
   */
  public final class LifecycleException
      extends CascadingException
  {
      /**
       * Construct a new <code>VerifyException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public LifecycleException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>VerifyException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public LifecycleException( final String message, final Throwable 
throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/LifecycleHelper.java
  
  Index: LifecycleHelper.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.container.ContainerUtil;
  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.logger.LogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.Serviceable;
  
  /**
   * This is a class to help an Application manage lifecycle of
   * <code>Blocks</code> and <code>BlockListeners</code>. The
   * class will run each individual Entry through each lifecycle stage,
   * and manage erros in a consistent way.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public class LifecycleHelper
      extends AbstractLogEnabled
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( LifecycleHelper.class );
  
      //Constants to designate stages
      private static final int STAGE_CREATE = 0;
      private static final int STAGE_LOGGER = 1;
      private static final int STAGE_CONTEXT = 2;
      private static final int STAGE_COMPOSE = 3;
      private static final int STAGE_CONFIG = 4;
      private static final int STAGE_PARAMETER = 5;
      private static final int STAGE_INIT = 6;
      private static final int STAGE_START = 7;
      private static final int STAGE_STOP = 8;
      private static final int STAGE_DISPOSE = 9;
      private static final int STAGE_DESTROY = 10;
  
      /**
       * Method to run a <code>Block</code> through it's startup phase.
       * This will involve notification of <code>BlockListener</code>
       * objects, creation of the Block/Block Proxy object, calling the startup
       * Avalon Lifecycle methods and updating State property of BlockEntry.
       * Errors that occur during shutdown will be logged appropriately and
       * cause exceptions with useful messages to be raised.
       *
       * @param name the name o f the component
       * @param entry the entry representing object
       * @throws LifecycleException if an error occurs when block passes
       *            through a specific lifecycle stage
       */
      public Object startup( final String name,
                             final Object entry,
                             final ResourceAccessor accessor )
          throws LifecycleException
      {
          int stage = 0;
          try
          {
              //Creation stage
              stage = STAGE_CREATE;
              notice( name, stage );
              final Object object = accessor.createObject( entry );
  
              //LogEnabled stage
              stage = STAGE_LOGGER;
              if( object instanceof LogEnabled )
              {
                  notice( name, stage );
                  final Logger logger = accessor.createLogger( entry );
                  ContainerUtil.enableLogging( object, logger );
              }
  
              //Contextualize stage
              stage = STAGE_CONTEXT;
              if( object instanceof Contextualizable )
              {
                  notice( name, stage );
                  final Context context = accessor.createContext( entry );
                  ContainerUtil.contextualize( object, context );
              }
  
              //Composition stage
              stage = STAGE_COMPOSE;
              if( object instanceof Composable )
              {
                  notice( name, stage );
                  final ComponentManager componentManager =
                      accessor.createComponentManager( entry );
                  ContainerUtil.compose( object, componentManager );
              }
              else if( object instanceof Serviceable )
              {
                  notice( name, stage );
                  final ServiceManager manager =
                      accessor.createServiceManager( entry );
                  ContainerUtil.service( object, manager );
              }
  
              //Configuring stage
              stage = STAGE_CONFIG;
              if( object instanceof Configurable )
              {
                  notice( name, stage );
                  final Configuration configuration =
                      accessor.createConfiguration( entry );
                  ContainerUtil.configure( object, configuration );
              }
  
              //Parameterizing stage
              stage = STAGE_PARAMETER;
              if( object instanceof Parameterizable )
              {
                  notice( name, stage );
                  final Parameters parameters =
                      accessor.createParameters( entry );
                  ContainerUtil.parameterize( object, parameters );
              }
  
              //Initialize stage
              stage = STAGE_INIT;
              if( object instanceof Initializable )
              {
                  notice( name, stage );
                  ContainerUtil.initialize( object );
              }
  
              //Start stage
              stage = STAGE_START;
              if( object instanceof Startable )
              {
                  notice( name, stage );
                  ContainerUtil.start( object );
              }
  
              return object;
          }
          catch( final Throwable t )
          {
              fail( name, stage, t );
  
              //fail() throws an exception so next
              //line will never be executed
              return null;
          }
      }
  
      /**
       * Method to run a <code>Block</code> through it's shutdown phase.
       * This will involve notification of <code>BlockListener</code>
       * objects, invalidating the proxy object, calling the shutdown
       * Avalon Lifecycle methods and updating State property of BlockEntry.
       * Errors that occur during shutdown will be logged appropraitely.
       *
       * @param object the component to shutdown
       */
      public void shutdown( final String name,
                            final Object object )
          throws LifecycleException
      {
          //Stage at which failure occured
          int stage = 0;
  
          //Failure exception
          Throwable failure = null;
  
          //Stoppable stage
          if( object instanceof Startable )
          {
              notice( name, STAGE_STOP );
              try
              {
                  ContainerUtil.stop( object );
              }
              catch( final Throwable t )
              {
                  safeFail( name, STAGE_STOP, t );
                  failure = t;
                  stage = STAGE_STOP;
              }
          }
  
          //Disposable stage
          if( object instanceof Disposable )
          {
              notice( name, STAGE_DISPOSE );
              try
              {
                  ContainerUtil.dispose( object );
              }
              catch( final Throwable t )
              {
                  safeFail( name, STAGE_DISPOSE, t );
                  failure = t;
                  stage = STAGE_DISPOSE;
              }
          }
  
          notice( name, STAGE_DESTROY );
  
          if( null != failure )
          {
              fail( name, stage, failure );
          }
      }
  
      /**
       * Utility method to report that a lifecycle stage is about to be 
processed.
       *
       * @param name the name of block that caused failure
       * @param stage the stage
       */
      private void notice( final String name, final int stage )
      {
          if( getLogger().isDebugEnabled() )
          {
              final String message =
                  REZ.getString( "lifecycle.stage.notice",
                                 name,
                                 new Integer( stage ) );
              getLogger().debug( message );
          }
      }
  
      /**
       * Utility method to report that there was an error processing
       * specified lifecycle stage.
       *
       * @param name the name of block that caused failure
       * @param stage the stage
       * @param t the exception thrown
       */
      private void safeFail( final String name, final int stage, final 
Throwable t )
      {
          //final String reason = t.getMessage();
          final String reason = t.toString();
          final String message =
              REZ.getString( "lifecycle.fail.error", name, new Integer( stage 
), reason );
          getLogger().error( message );
      }
  
      /**
       * Utility method to report that there was an error processing
       * specified lifecycle stage. It will also rethrow an exception
       * with a better error message.
       *
       * @param name the name of block that caused failure
       * @param stage the stage
       * @param t the exception thrown
       * @throws LifecycleException containing error
       */
      private void fail( final String name, final int stage, final Throwable t )
          throws LifecycleException
      {
          //final String reason = t.getMessage();
          final String reason = t.toString();
          final String message =
              REZ.getString( "lifecycle.fail.error",
                             name,
                             new Integer( stage ), reason );
          getLogger().error( message );
          throw new LifecycleException( message, t );
      }
  }
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/ResourceAccessor.java
  
  Index: ResourceAccessor.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.service.ServiceManager;
  
  /**
   * The interface via which resources required for a component
   * are aquired.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 06:03:46 $
   */
  public interface ResourceAccessor
  {
      Object createObject( Object entry )
          throws Exception;
  
      Logger createLogger( Object entry )
          throws Exception;
  
      Context createContext( Object entry )
          throws Exception;
  
      ComponentManager createComponentManager( Object entry )
          throws Exception;
  
      ServiceManager createServiceManager( Object entry )
          throws Exception;
  
      Configuration createConfiguration( Object entry )
          throws Exception;
  
      Parameters createParameters( Object entry )
          throws Exception;
  }
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  lifecycle.stage.notice=Component named "{0}" is passing through the 
{1,choice,0#Creation|1#Logger 
initialization|2#Contextualization|3#Composing|4#Configuration|5#Parameterizing|6#Initialization|7#Starting|8#Stopping|9#Disposing|10#Destruction}
 stage.
  lifecycle.fail.error=Component named "{0}" failed to pass through the 
{1,choice,0#Creation|1#Logger 
initialization|2#Contextualization|3#Composing|4#Configuration|5#Parameterizing|6#Initialization|7#Starting|8#Stopping|9#Disposing|10#Destruction}
 stage. (Reason: {2}).
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/conf/MANIFEST.MF
  
  Index: MANIFEST.MF
  ===================================================================
  Extension-Name: @name@
  Specification-Vendor: Apache Software Foundation
  Specification-Version: 1.0
  Implementation-Vendor: Apache Software Foundation
  Implementation-Version: @package-version@
  
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  #From Verifier class
  verifier.non-public-ctor.error=The implementation class {1} for component 
named "{0}" does not have a public no-arg constructor.
  verifier.missing-noargs-ctor.error=The implementation class {1} for component 
named "{0}" does not have a no-arg constructor.
  verifier.abstract-class.error=The implementation class {1} for component 
named "{0}" is abstract.
  verifier.nonpublic-class.error=The implementation class {1} for component 
named "{0}" is not public.
  verifier.primitive-class.error=The implementation class {1} for component 
named "{0}" is primitive.
  verifier.interface-class.error=The implementation class {1} for component 
named "{0}" is an interface.
  verifier.array-class.error=The implementation class {1} for component named 
"{0}" is an array class.
  verifier.non-interface-service.error=The service class {1} for component 
named "{0}" is not an interface.
  verifier.non-public-service.error=The service class {1} for component named 
"{0}" is not public.
  verifier.incompat-serviceable.error=The implementation class {1} for 
component named "{0}" is both Serviceable and Composable (incompatible 
lifecycle interfaces).
  verifier.incompat-config.error=The implementation class {1} for component 
named "{0}" is both Configurable and Parameterizable (incompatible lifecycle 
interfaces).
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/Verifier.java
  
  Index: Verifier.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Modifier;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.activity.Suspendable;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.component.Recomposable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Reconfigurable;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.Recontextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Reparameterizable;
  import org.apache.avalon.framework.service.Serviceable;
  
  /**
   * Utility class to help verify that component respects the
   * rules of an Avalon component.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 06:03:46 $
   */
  public class Verifier
      extends AbstractLogEnabled
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( Verifier.class );
  
      private static final Class[] EMPTY_TYPES = new Class[ 0 ];
  
      /**
       * The interfaces representing lifecycle stages.
       */
      private static final Class[] FRAMEWORK_CLASSES = new Class[]
      {
          LogEnabled.class,
          Contextualizable.class,
          Recontextualizable.class,
          Composable.class,
          Recomposable.class,
          Serviceable.class,
          Configurable.class,
          Reconfigurable.class,
          Parameterizable.class,
          Reparameterizable.class,
          Initializable.class,
          Startable.class,
          Suspendable.class,
          Disposable.class
      };
  
      /**
       * Verify that the supplied implementation class
       * and service classes are valid for a component.
       *
       * @param name the name of component
       * @param implementation the implementation class of component
       * @param services the classes representing services
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyComponent( final String name,
                                   final Class implementation,
                                   final Class[] services )
          throws VerifyException
      {
          verifyClass( name, implementation );
          verifyLifecycles( name, implementation );
          verifyServices( name, services );
      }
  
      /**
       * Verify that the supplied class is a valid class for
       * a Component.
       *
       * @param name the name of component
       * @param clazz the class representign component
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyClass( final String name,
                               final Class clazz )
          throws VerifyException
      {
          verifyNoArgConstructor( name, clazz );
          verifyNonAbstract( name, clazz );
          verifyNonArray( name, clazz );
          verifyNonInterface( name, clazz );
          verifyNonPrimitive( name, clazz );
          verifyPublic( name, clazz );
      }
  
      /**
       * Verify that the supplied classes are valid classes for
       * a service.
       *
       * @param name the name of component
       * @param classes the classes representign services
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyServices( final String name,
                                  final Class[] classes )
          throws VerifyException
      {
          for( int i = 0; i < classes.length; i++ )
          {
              verifyService( name, classes[ i ] );
          }
      }
  
      /**
       * Verify that the supplied class is a valid class for
       * a service.
       *
       * @param name the name of component
       * @param clazz the class representign service
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyService( final String name,
                                 final Class clazz )
          throws VerifyException
      {
          verifyServiceIsaInterface( name, clazz );
          verifyServiceIsPublic( name, clazz );
          verifyServiceNotALifecycle( name, clazz );
      }
  
      /**
       * Verify that the implementation class does not
       * implement incompatible lifecycle interfaces.
       *
       * @param name the name of component
       * @param implementation the implementation class
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyLifecycles( final String name,
                                    final Class implementation )
          throws VerifyException
      {
          final boolean composable =
              Composable.class.isAssignableFrom( implementation ) ||
              Recomposable.class.isAssignableFrom( implementation );
          final boolean serviceable = Serviceable.class.isAssignableFrom( 
implementation );
          if( serviceable && composable )
          {
              final String message =
                  REZ.getString( "verifier.incompat-serviceable.error",
                                 name,
                                 implementation.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
  
          final boolean configurable =
              Configurable.class.isAssignableFrom( implementation ) ||
              Reconfigurable.class.isAssignableFrom( implementation );
          final boolean parameterizable =
              Parameterizable.class.isAssignableFrom( implementation ) ||
              Reparameterizable.class.isAssignableFrom( implementation );
          if( parameterizable && configurable )
          {
              final String message =
                  REZ.getString( "verifier.incompat-config.error",
                                 name,
                                 implementation.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  
      /**
       * Verify that the service implemented by
       * specified component is an interface.
       *
       * @param name the name of component
       * @param clazz the class representign service
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyServiceIsaInterface( final String name,
                                             final Class clazz )
          throws VerifyException
      {
          if( !clazz.isInterface() )
          {
              final String message =
                  REZ.getString( "verifier.non-interface-service.error",
                                 name,
                                 clazz.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  
      /**
       * Verify that the service implemented by
       * specified component is public.
       *
       * @param name the name of component
       * @param clazz the class representign service
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyServiceIsPublic( final String name,
                                         final Class clazz )
          throws VerifyException
      {
          final boolean isPublic =
              Modifier.isPublic( clazz.getModifiers() );
          if( !isPublic )
          {
              final String message =
                  REZ.getString( "verifier.non-public-service.error",
                                 name,
                                 clazz.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  
      /**
       * Verify that the service implemented by
       * specified component does not extend any lifecycle interfaces.
       *
       * @param name the name of component
       * @param clazz the class representign service
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyServiceNotALifecycle( final String name,
                                              final Class clazz )
          throws VerifyException
      {
          for( int i = 0; i < FRAMEWORK_CLASSES.length; i++ )
          {
              final Class lifecycle = FRAMEWORK_CLASSES[ i ];
              if( lifecycle.isAssignableFrom( clazz ) )
              {
                  final String message =
                      REZ.getString( "verifier.service-isa-lifecycle.error",
                                     name,
                                     clazz.getName(),
                                     lifecycle.getName() );
                  getLogger().error( message );
                  throw new VerifyException( message );
              }
          }
      }
  
      /**
       * Verify that the component has a no-arg aka default
       * constructor.
       *
       * @param name the name of component
       * @param clazz the class representign component
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyNoArgConstructor( final String name,
                                          final Class clazz )
          throws VerifyException
      {
          try
          {
              final Constructor ctor = clazz.getConstructor( EMPTY_TYPES );
              if( !Modifier.isPublic( ctor.getModifiers() ) )
              {
                  final String message =
                      REZ.getString( "verifier.non-public-ctor.error",
                                     name,
                                     clazz.getName() );
                  getLogger().error( message );
                  throw new VerifyException( message );
              }
          }
          catch( final NoSuchMethodException nsme )
          {
              final String message =
                  REZ.getString( "verifier.missing-noargs-ctor.error",
                                 name,
                                 clazz.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  
      /**
       * Verify that the component is not represented by
       * abstract class.
       *
       * @param name the name of component
       * @param clazz the class representign component
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyNonAbstract( final String name,
                                     final Class clazz )
          throws VerifyException
      {
          final boolean isAbstract =
              Modifier.isAbstract( clazz.getModifiers() );
          if( isAbstract )
          {
              final String message =
                  REZ.getString( "verifier.abstract-class.error",
                                 name,
                                 clazz.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  
      /**
       * Verify that the component is not represented by
       * abstract class.
       *
       * @param name the name of component
       * @param clazz the class representign component
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyPublic( final String name,
                                final Class clazz )
          throws VerifyException
      {
          final boolean isPublic =
              Modifier.isPublic( clazz.getModifiers() );
          if( !isPublic )
          {
              final String message =
                  REZ.getString( "verifier.nonpublic-class.error",
                                 name,
                                 clazz.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  
      /**
       * Verify that the component is not represented by
       * primitive class.
       *
       * @param name the name of component
       * @param clazz the class representign component
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyNonPrimitive( final String name,
                                      final Class clazz )
          throws VerifyException
      {
          if( clazz.isPrimitive() )
          {
              final String message =
                  REZ.getString( "verifier.primitive-class.error",
                                 name,
                                 clazz.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  
      /**
       * Verify that the component is not represented by
       * interface class.
       *
       * @param name the name of component
       * @param clazz the class representign component
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyNonInterface( final String name,
                                      final Class clazz )
          throws VerifyException
      {
          if( clazz.isInterface() )
          {
              final String message =
                  REZ.getString( "verifier.interface-class.error",
                                 name,
                                 clazz.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  
      /**
       * Verify that the component is not represented by
       * an array class.
       *
       * @param name the name of component
       * @param clazz the class representign component
       * @throws VerifyException if error thrown on failure and
       *         component fails check
       */
      public void verifyNonArray( final String name,
                                  final Class clazz )
          throws VerifyException
      {
          if( clazz.isArray() )
          {
              final String message =
                  REZ.getString( "verifier.array-class.error",
                                 name,
                                 clazz.getName() );
              getLogger().error( message );
              throw new VerifyException( message );
          }
      }
  }
  
  
  
  1.1                  
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/VerifyException.java
  
  Index: VerifyException.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.txt file.
   */
  package org.apache.excalibur.containerkit;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate error verifying a Block or application.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 06:03:46 $
   */
  public final class VerifyException
      extends CascadingException
  {
      /**
       * Construct a new <code>VerifyException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public VerifyException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>VerifyException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public VerifyException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to