avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craft...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/xfc/src/xdocs converter.txt
Date Wed, 02 Oct 2002 17:32:28 GMT
crafterm    2002/10/02 10:32:28

  Added:       xfc      .cvsignore ant.properties.sample build.xml
                        default.properties
               xfc/bin  runconverter.sh
               xfc/data ecm.roles fortress.roles
               xfc/src/etc project.mf
               xfc/src/java/org/apache/excalibur/xfc Converter.java
                        Main.java Module.java package.html
               xfc/src/java/org/apache/excalibur/xfc/model Definition.java
                        Model.java RoleRef.java package.html
               xfc/src/java/org/apache/excalibur/xfc/modules
                        AbstractModule.java ECM.java Fortress.java
                        package.html
               xfc/src/xdocs converter.txt
  Log:
  Initial Import of XFC, the (X)Conf (F)ile (C)onverter which is a tool for
  converting between supported container configuration file formats.
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/xfc/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  ant.properties
  build
  checkstyle.cache
  distributions
  dist
  excalibur-*
  *.el
  *.ipr
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/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/10/02 17:32:27 crafterm 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/xfc/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <project name="Excalibur XFC" 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="${avalon-framework.jar}"/>
          <pathelement location="${build.classes}"/>
          <pathelement location="${checkstyle.jar}"/>
  <!--        <pathelement location="${excalibur-meta.jar}"/> -->
          <pathelement location="${excalibur-cli.jar}"/>
          <pathelement path="${java.class.path}"/>
      </path>
  
      <path id="tools.class.path">
          <pathelement location="${junit.jar}"/>
          <fileset dir="${jakarta-site.dir}/lib"/>
      </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">
  <!--        <copy todir="${build.lib}" file="${excalibur-meta.jar}"/> -->
          <copy todir="${build.lib}" file="${excalibur-cli.jar}"/>
          <copy todir="${build.lib}" file="${avalon-framework.jar}"/>
          <copy todir="${build.lib}" file="${xerces.jar}"/>
          <copy todir="${build.lib}" file="${xml-apis.jar}"/>
          <copy todir="${build.lib}" file="${xalan.jar}"/>
      </target>
      <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="checkMeta"/>
          <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkCli"/>	
      </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 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"/>
              <filterset>
                  <filter token="year" value="${year}"/>
              </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="${src.dir}/etc/project.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="${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="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}"/>
  
          <zip zipfile="${dist.dir}/src.zip" compress="false">
              <zipfileset dir="src/java"/>
          </zip>
  
          <mkdir dir="${dist.base}"/>
  
          <zip zipfile="${dist.base}/${dist.name}.zip" compress="true">
              <zipfileset dir="${dist.dir}" prefix="${dist.name}"/>
          </zip>
  
          <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}"/>
      </target>
  
      <target name="docs" depends="javadocs, xdocs" description="generates all the Avalon documentation"/>
  
      <target name="xdocs" description="generates the xdocs-based documentation">
        <ant antfile="${basedir}/../cocoonbuild.xml"/>
      </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="velocity.*"/>
              <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>
  
     <!--
    Misc. utilities.
    -->
  
    <target name="patch">
      <replace dir="src/java" 
         token="getTypes("
         value="getTypeEntries(" >
       <include name="**/classloader/*.java"/>
      </replace>
      <replace dir="src/java" 
         token="getBlocks("
         value="getBlockEntries(" >
       <include name="**/classloader/*.java"/>
      </replace>
      <replace dir="src" 
         token="getServices("
         value="getServiceEntries(" >
       <include name="**/classloader/*.java"/>
      </replace>
    </target>
  
  </project>
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/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-xfc
  Name=Excalibur Xconf Converter
  dir-name=xfc
  version=0.1
  package-version=0.99
  year=2000-2002
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  # ----- Avalon Framework, version 4.1 or later -----
  avalon-framework.home=${basedir}/../../jakarta-avalon
  avalon-framework.lib=${avalon-framework.home}/build/lib
  avalon-framework.jar=${avalon-framework.lib}/avalon-framework.jar
  
  # ----- Excalibur Meta -----
  excalibur-meta.home=${basedir}/../meta
  excalibur-meta.lib=${excalibur-meta.home}/build/lib
  excalibur-meta.jar=${excalibur-meta.lib}/excalibur-meta-1.0.jar
  
  # ----- Excalibur Cli -----
  excalibur-cli.home=${basedir}/../cli
  excalibur-cli.lib=${excalibur-cli.home}/build/lib
  excalibur-cli.jar=${excalibur-cli.lib}/excalibur-cli-1.0.jar
  
  # ----- Misc tools -----
  tools.dir=${basedir}/../../jakarta-avalon/tools
  xml-apis.jar = ${tools.dir}/lib/xml-apis.jar
  xerces.jar = ${tools.dir}/lib/xerces-2.0.1.jar
  xalan.jar = ${tools.dir}/lib/xalan-2.3.1.jar
  
  # --------------------------------------------------
  
  #  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
  build.docs = ${build.dir}/docs
  build.javadocs = ${build.docs}/api
  
  #  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
  
  xdocs.dir = ${src.dir}/xdocs
  docs.dir = ${dist.dir}/docs
  jakarta-site.dir = ../../jakarta-site
  
  #  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/xfc/bin/runconverter.sh
  
  Index: runconverter.sh
  ===================================================================
  #!/bin/bash
  #
  # Startup script.
  #
  
  #
  # Determine if JAVA_HOME is set and if so then use it
  #
  if [ -z "$JAVA_HOME" ] ;  then
    JAVA=`which java`
    if [ -z "$JAVA" ] ; then
      echo "Cannot find JAVA. Please set your PATH."
      exit 1
    fi
    JAVA_BINDIR=`dirname $JAVA`
    JAVA_HOME=$JAVA_BINDIR/..
  fi
  
  if [ "$JAVACMD" = "" ] ; then
     # it may be defined in env - including flags!!
     JAVACMD=$JAVA_HOME/bin/java
  fi
  
  # Main.java has hard coded config values so this script must be run from
  # altprofile/bin (any better ideas ?)
  EXAMPLE_HOME=.
  
  #
  # Build the runtime classpath
  #
  for i in ${EXAMPLE_HOME}/build/lib/*.jar ; do
      CP=${CP}:$i
  done
  
  CP=${CP}:${EXAMPLE_HOME}/build/classes
  
  echo $CP
  
  # Run the example application
  $JAVACMD -classpath $CP org.apache.excalibur.xfc.Main $@
  
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/data/ecm.roles
  
  Index: ecm.roles
  ===================================================================
  <?xml version="1.0"?>
  
  <!DOCTYPE role-list [
  <!ELEMENT role-list (role+)> 
  <!ELEMENT role (hint*)>
  <!ELEMENT hint EMPTY>
  <!ATTLIST role name CDATA #REQUIRED
                 shorthand CDATA #REQUIRED
                 default-class CDATA #IMPLIED
  >
  <!ATTLIST hint shorthand CDATA #REQUIRED
                 class CDATA #REQUIRED
  >
  ]>
  
  <role-list>
    <role name="org.apache.avalon.excalibur.xml.Parser"
          shorthand="xml-parser"
          default-class="org.apache.avalon.excalibur.xml.JaxpParser"/>
  
    <role name="org.apache.avalon.excalibur.xml.EntityResolver"
          shorthand="entity-resolver"
          default-class="org.apache.cocoon.components.resolver.ResolverImpl"/>
  
    <role name="org.apache.avalon.excalibur.xml.xslt.XSLTProcessor"
          shorthand="xslt-processor"
          default-class="org.apache.avalon.excalibur.xml.xslt.XSLTProcessorImpl"/>
  
    <role name="org.apache.avalon.excalibur.xml.xpath.XPathProcessor"
          shorthand="xpath-processor"
          default-class="org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"/>
  
  </role-list>
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/data/fortress.roles
  
  Index: fortress.roles
  ===================================================================
  <fortress-roles logger="system.roles">
  
    <role name="org.apache.excalibur.fortress.examples.components.Translator">
      <component shorthand="translator"
                 class="org.apache.excalibur.fortress.examples.components.TranslatorImpl"
                 handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler"/>
    </role>
  
  </fortress-roles>
  
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/etc/project.mf
  
  Index: project.mf
  ===================================================================
  Manifest-Version: 1.0
  Created-By: Apache Software Foundation
  Extension-Name: excalibur-xfc
  Specification-Vendor: Apache Software Foundation
  Specification-Version: 1.0
  Implementation-Vendor: Apache Software Foundation
  Implementation-Version: 0.9
  Extension-List: framework
  framework-Extension-Name: avalon-framework
  framework-Specification-Version: 1.0
  framework-Implementation-Version: 4.1.2
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/Converter.java
  
  Index: Converter.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.NullLogger;
  
  /**
   * Class for performing conversions between input and output
   * {@link Module} implementations.
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Id: Converter.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public class Converter extends AbstractLogEnabled
  {
      // internals
      private String m_inputCtx;
      private String m_outputCtx;
  
      private Module m_input;
      private Module m_output;
  
      /**
       * Creates a new <code>Converter</code> instance.
       *
       * @param logger a <code>Logger</code> instance
       */
      public Converter( final Logger logger )
      {
          enableLogging( logger == null ? new NullLogger() : logger );
      }
  
      /**
       * Sets the input {@link Module}.
       *
       * @param module a <code>Class</code> instance
       * @exception Exception if an error occurs
       */
      public void setInputModule( final Class module )
          throws Exception
      {
          m_input = ( Module ) module.newInstance();
          m_input.enableLogging( getLogger().getChildLogger( module.getName() ) );
      }
  
      /**
       * Sets the output {@link Module}.
       *
       * @param module a <code>Class</code> instance
       * @exception Exception if an error occurs
       */
      public void setOutputModule( final Class module )
          throws Exception
      {
          m_output = ( Module ) module.newInstance();
          m_output.enableLogging( getLogger().getChildLogger( module.getName() ) );
      }
  
      /**
       * Sets the input {@link Module} Context.
       *
       * @param context a <code>String</code> value
       */
      public void setInputModuleContext( final String context )
      {
          m_inputCtx = context;
      }
  
      /**
       * Sets the output {@link Module} Context.
       *
       * @param context a <code>String</code> value
       */
      public void setOutputModuleContext( final String context )
      {
          m_outputCtx = context;
      }
  
      /**
       * Performs conversion.
       *
       * @exception Exception if an error occurs
       */
      public void convert()
          throws Exception
      {
          m_output.serialize( m_input.generate( m_inputCtx ), m_outputCtx );
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/Main.java
  
  Index: Main.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc;
  
  import java.util.List;
  
  import org.apache.avalon.framework.logger.ConsoleLogger;
  import org.apache.avalon.framework.logger.Logger;
  
  import org.apache.avalon.excalibur.cli.CLArgsParser;
  import org.apache.avalon.excalibur.cli.CLOption;
  import org.apache.avalon.excalibur.cli.CLOptionDescriptor;
  import org.apache.avalon.excalibur.cli.CLUtil;
  
  /**
   * Command line based XFC entry point.
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * (parts also taken from the Excalibur CLI example)
   * @version CVS $Id: Main.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public final class Main
  {
      // Define our short one-letter option identifiers.
      private static final int HELP_OPT = 'h';
      private static final int VERSION_OPT = 'v';
      private static final int INPUT_OPT = 'i';
      private static final int OUTPUT_OPT = 'o';
  
      // Array of understood options, for setting the input and output
      // conversion modules
      private static final CLOptionDescriptor[] OPTIONS = new CLOptionDescriptor[]
      {
          new CLOptionDescriptor( "help",
                                  CLOptionDescriptor.ARGUMENT_DISALLOWED,
                                  HELP_OPT,
                                  "print this message and exit" ),
          new CLOptionDescriptor( "version",
                                  CLOptionDescriptor.ARGUMENT_DISALLOWED,
                                  VERSION_OPT,
                                  "print this version and exit" ),
          new CLOptionDescriptor( "input",
                                  CLOptionDescriptor.ARGUMENT_REQUIRED,
                                  INPUT_OPT,
                                  "set the input module name and context" ),
          new CLOptionDescriptor( "output",
                                  CLOptionDescriptor.ARGUMENT_REQUIRED,
                                  OUTPUT_OPT,
                                  "set the output module name and context" ),
      };
  
      // Logger for output. REVISIT(MC): add debug option for debug logging
      private static final Logger m_logger = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
  
      // Input module name
      private static String m_inputModule;
  
      // Input module context
      private static String m_inputCtx;
  
      // Output module name
      private static String m_outputModule;
  
      // Output module context
      private static String m_outputCtx;
  
      /**
       * Main method, entry point to program
       *
       * @param args a <code>String[]</code> array of command line arguments
       * @exception Exception if an error occurs
       */
      public static void main( final String[] args )
          throws Exception
      {
          // parse command line args
          parseArgs( args );
  
          if ( getLogger().isInfoEnabled() )
          {
              getLogger().info( "Input Module = " + m_inputModule );
              getLogger().info( "Input Module Context = " + m_inputCtx );
              getLogger().info( "Output Module = " + m_outputModule );
              getLogger().info( "Output Module Context = " + m_outputCtx );
          }
          
          // create converter
          final Converter cv = new Converter( getLogger() );
  
          // set up input and output modules
          cv.setInputModule( getClass( m_inputModule ) );
          cv.setInputModuleContext( m_inputCtx );
  
          cv.setOutputModule( getClass( m_outputModule ) );
          cv.setOutputModuleContext( m_outputCtx );
  
          // convert
          cv.convert();
  
          // all done, good show
      }
  
      /**
       * Helper method for parsing the command line arguments
       *
       * @param args a <code>String[]</code> value
       */
      private static void parseArgs( final String[] args )
      {
          // Parse the arguments
          final CLArgsParser parser = new CLArgsParser( args, OPTIONS );
  
          // Make sure that there was no errors parsing arguments
          if( null != parser.getErrorString() )
          {
              System.err.println( "Error: " + parser.getErrorString() );
              System.exit(1);
          }
  
          // Get a list of parsed options
          final List options = parser.getArguments();
          final int size = options.size();
  
          // Check that there are enough arguments (should be no more than 2)
          if ( size > 2 )
          {
              printUsage();
          }
  
          for( int i = 0; i < size; i++ )
          {
              final CLOption option = (CLOption)options.get( i );
  
              switch( option.getId() )
              {
                  case CLOption.TEXT_ARGUMENT:
                      // This occurs when a user supplies an unknown argument
                      System.err.println( "Unknown argument: " + option.getArgument() );
                      break;
  
                  case HELP_OPT:
                      // Print some help information
                      printUsage();
                      break;
  
                  case VERSION_OPT:
                      // Print some version information
                      printVersion();
  
                  case INPUT_OPT:
                      // Set the input module and context
                      m_inputModule = getModule( option.getArgument() );
                      m_inputCtx = getContext( option.getArgument() );
                      break;
  
                  case OUTPUT_OPT:
                      // Set the output module and context
                      m_outputModule = getModule( option.getArgument() );
                      m_outputCtx = getContext( option.getArgument() );
                      break;
              }
          }
  
          // check that modules/contexts are set
          if ( m_inputModule == null ||
               m_inputCtx == null ||
               m_outputModule == null ||
               m_outputCtx == null )
          {
              printUsage();
          }
      }
  
      /**
       * Helper method for obtaining the {@link Module} name 
       * from the given {@link String} parameter
       *
       * @param str a <code>String</code> value
       * @return a <code>String</code> value
       */
      private static String getModule( final String str )
      {
          final int i = str.indexOf(':');
          return str.substring( 0, i );
      }
  
      /**
       * Helper method for obtaining the {@link Module} Context
       * value from the given {@link String} parameter
       *
       * @param str a <code>String</code> value
       * @return a <code>String</code> value
       */
      private static String getContext( final String str )
      {
          final int i = str.indexOf(':');
          return str.substring( i + 1 );
      }
  
      /**
       * Obtain the {@link Class} object for the plugin module
       * specified. This method makes a simple check with some pre-defined
       * plugin's and returns their {@link Class} objects if specified.
       *
       * <p>
       *  If the specified plugin is not known, it's assumed to be a
       *  fully qualified class name of a custom plugin, and is loaded manually.
       * </p>
       *
       * @param clazz class name as a <code>String</code> object
       * @return a <code>Class</code> instance
       * @exception ClassNotFoundException if an error occurs
       */
      private static Class getClass( final String clazz )
          throws ClassNotFoundException
      {
          if ( "ecm".equalsIgnoreCase( clazz ) )
          {
              return Class.forName( "org.apache.excalibur.xfc.modules.ECM" );
          }
  
          if ( "fortress".equalsIgnoreCase( clazz ) )
          {
              return Class.forName( "org.apache.excalibur.xfc.modules.Fortress" );
          }
  
          if ( "merlin".equalsIgnoreCase( clazz ) )
          {
              return Class.forName( "org.apache.excalibur.xfc.modules.Merlin" );
          }
  
          // assume custom module
          return Class.forName( clazz );
      }
  
      /**
       * Print out a usage statement
       */
      private static void printUsage()
      {
          final String lineSeparator = System.getProperty( "line.separator" );
  
          final StringBuffer msg = new StringBuffer();
  
          msg.append( lineSeparator );
          msg.append( "XFC - The Avalon Excalibur (X)Conf (F)ile (C)onverter" );
          msg.append( lineSeparator );
          msg.append( "Usage: java " + Main.class.getName() + " [options]" );
          msg.append( lineSeparator );
          msg.append( lineSeparator );
          msg.append( "Options: " );
          msg.append( lineSeparator );
  
          //
          // Uses CLUtil.describeOptions to generate the
          // list of descriptions for each option
          //
          msg.append( CLUtil.describeOptions( OPTIONS ).toString() );
  
          // Usage examples
          msg.append( "\nExample: \n" );
          msg.append( "\tjava " + Main.class.getName() + "\\\n" );
          msg.append( "\t\t--input ecm:conf/ecm.roles:conf/ecm.xconf \\\n" );
          msg.append( "\t\t--output fortress:conf/fortress.roles:conf/fortress.xconf" );
  
          System.out.println( msg.toString() );
  
          System.exit( 0 );
      }
  
      /**
       * Simple method to print a version number
       */
      private static void printVersion()
      {
          System.out.println( "XFC Version 0.1" );
          System.exit( 0 );
      }
  
      /**
       * Helper method to return the <code>Logger</code> object
       *
       * @return a <code>Logger</code> value
       */
      private static Logger getLogger()
      {
          return m_logger;
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/Module.java
  
  Index: Module.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc;
  
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.excalibur.xfc.model.Model;
  
  /**
   * Interface defining the operations for creation and serialization of
   * {@link Model} objects.
   *
   * <p>
   *  Implementations of this interface provide creation/serialization
   *  support for specific containers, allowing us to convert to and from
   *  different file formats now and in the future.
   * </p>
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Id: Module.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public interface Module extends LogEnabled
  {
      /**
       * Generate a {@link Model} object from a given input
       * <code>Context</code>.
       *
       * @param context a <code>String</code> Context value
       * @return a {@link Model} instance
       * @exception Exception if an error occurs
       */
      Model generate( String context )
          throws Exception;
  
      /**
       * Serialize the contents of a {@link Model} into a particular
       * output <code>Context</code>.
       *
       * @param model a {@link Model} instance
       * @param context a <code>String</code> Context value
       * @exception Exception if an error occurs
       */
      void serialize( Model model, String context )
          throws Exception;
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/package.html
  
  Index: package.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  <html>
  <body>
  
  <p>
  <b>XFC</b> - The Excalibur <b>X</b>Conf <b>F</b>ile <b>C</b>onverter
  <i>(currently in development)</i>
  </p>
  
  <p>
  XFC is a general tool to allow conversions between arbitrary container
  configuration & component definition files.
  </p>
  
  <p>
  When fully functional, it should be possible to convert the
  configuration & component definitions between any of the supported
  container formats.
  </p>
  
  <!--
  <h2>Package Specification</h2>
  
  ##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
  <ul>
    <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
  </ul>
  
  <h2>Related Documentation</h2>
  
  For overviews, tutorials, examples, guides, and tool documentation, please see:
  <ul>
    <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
  </ul>
  -->
  
  <!-- Put @see and @since tags down here. -->
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/Definition.java
  
  Index: Definition.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc.model;
  
  /**
   * Class containing information about a particular Component's definition.
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Id: Definition.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public final class Definition
  {
      // internals
      private final String m_role;
      private final String m_clazz;
      private final String m_shorthand;
      private final String m_handler;
  
      /**
       * Creates a new <code>Definition</code> instance.
       *
       * @param role a <code>String</code> value
       * @param clazz a <code>String</code> value
       * @param shorthand a <code>String</code> value
       * @param handler a <code>String</code> value
       */
      public Definition(
          final String role, 
          final String clazz,
          final String shorthand,
          final String handler
      )
      {
          m_role = role;
          m_clazz = clazz;
          m_shorthand = shorthand;
          m_handler = handler;
      }
  
      /**
       * Obtain this Component role name.
       *
       * @return a <code>String</code> value
       */
      public String getRole() 
      {
          return m_role;
      }
      
      /**
       * Obtain this Component's default implementing class.
       *
       * @return a <code>String</code> value
       */
      public String getDefaultClass()
      {
          return m_clazz;
      }
  
      /**
       * Obtain this Component's shorthand name
       *
       * @return a <code>String</code> value
       */
      public String getShorthand()
      {
          return m_shorthand;
      }
  
      /**
       * Obtain this Component's normalized component handler name.
       *
       * @return a <code>String</code> value
       */
      public String getHandler()
      {
          return m_handler;
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/Model.java
  
  Index: Model.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc.model;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  /**
   * Class for maintaining the Roles and their providing Components
   * a particular Container configuration.
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Id: Model.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public final class Model
  {
      private final List m_definitions = new ArrayList();
  
      /**
       * Adds a <code>Definition</code> object to the system.
       * A <code>Definition</code> contains information particular to
       * Component definition.
       *
       * @param definition a <code>Definition</code> instance
       */
      public void addDefinition( final Definition definition )
      {
          // add a definition to the system
          String role = definition.getRole();
  
          for ( Iterator i = m_definitions.iterator(); i.hasNext(); )
          {
              RoleRef r = (RoleRef) i.next();
  
              if ( role.equals( r.getRole() ) )
              {
                  r.addDefinition( definition );
                  return;
              }
          }
  
          m_definitions.add( new RoleRef( role, definition ) );
      }
  
      /**
       * Obtain all definitions this Model contains, as an
       * array of RoleRef objects.
       *
       * @return a <code>RoleRef[]</code> array
       */
      public RoleRef[] getDefinitions()
      {
          return (RoleRef[]) m_definitions.toArray(
              new RoleRef[ m_definitions.size() ]
          );
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/RoleRef.java
  
  Index: RoleRef.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc.model;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * Class for maintaining a 1-N list of references between Roles & Components.
   *
   * <p>
   *  Normally there is a 1 Component per role definition, but in the of a
   *  ComponentSelector there can be more.
   * </p>
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Id: RoleRef.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public final class RoleRef
  {
      // internals
      private final List m_definitions = new ArrayList();
      private final String m_role;
  
      /**
       * Creates a new <code>RoleRef</code> instance.
       *
       * @param role role name
       * @param definition a <code>Definition</code> instance
       */
      public RoleRef( final String role, final Definition definition )
      {
          m_role = role;
          m_definitions.add( definition );
      }
  
      /**
       * Obtain the role this ref object manages
       *
       * @return a <code>String</code> value
       */
      public String getRole()
      {
          return m_role;
      }
  
      /**
       * Add a Definition object to this ref
       *
       * @param definition a <code>Definition</code> instance
       */
      public void addDefinition( final Definition definition )
      {
          m_definitions.add( definition );
      }
  
      /**
       * Obtain a list of all Definition objects that provide the role
       * this roleref manages.
       *
       * @return a <code>Definition[]</code> array
       */
      public Definition[] getProviders()
      {
          return (Definition[]) m_definitions.toArray(
              new Definition[ m_definitions.size() ]
          );
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/package.html
  
  Index: package.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  <html>
  <body>
  
  <p>
  <b>XFC Model</b> - Simple set of classes used for storing the structure of
  a particular container's configuration.
  </p>
  
  <p>
  This package provides the base level functionality for managing definitions
  of different roles and the classes that provide these roles. In the future
  this package could perhaps be replaced by excalibur/meta.
  </p>
  
  <!--
  <h2>Package Specification</h2>
  
  ##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
  <ul>
    <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
  </ul>
  
  <h2>Related Documentation</h2>
  
  For overviews, tutorials, examples, guides, and tool documentation, please see:
  <ul>
    <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
  </ul>
  -->
  
  <!-- Put @see and @since tags down here. -->
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/AbstractModule.java
  
  Index: AbstractModule.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc.modules;
  
  import java.util.Properties;
  
  import org.apache.avalon.framework.Version;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  
  import org.apache.excalibur.xfc.Module;
  import org.apache.excalibur.xfc.model.Model;
  
  /**
   * Abstract {@link Module} class which provides common operations/constants
   * to prospective subclasses.
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Id: AbstractModule.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public abstract class AbstractModule
      extends AbstractLogEnabled
      implements Module
  {
      // normalized component handler names
      protected static final String     TRANSIENT = "transient";
      protected static final String     THREAD    = "thread";
      protected static final String     POOLED    = "pooled";
      protected static final String     SINGLETON = "singleton";
  
      protected static final char       CONTEXT_SEPARATOR = ':';
  
      protected final DefaultConfigurationSerializer m_serializer;
      protected final DefaultConfigurationBuilder m_builder;
  
      /**
       * Creates a new <code>AbstractModule</code> instance.
       */
      public AbstractModule()
      {
          m_builder = new DefaultConfigurationBuilder();
          m_serializer = new DefaultConfigurationSerializer();
  
          // enable pretty printing of output
          m_serializer.setIndent( true );
      }
  
      /**
       * Abstract method for generating a {@link Model} from an
       * input context
       *
       * @param context a <code>String</code> value
       * @return a <code>Model</code> value
       * @exception Exception if an error occurs
       */
      public abstract Model generate( final String context )
          throws Exception;
  
      /**
       * Abstract method for serializing a given {@link Model} to
       * an output context.
       *
       * @param model a <code>Model</code> value
       * @param context a <code>String</code> value
       * @exception Exception if an error occurs
       */
      public abstract void serialize( final Model model, final String context )
          throws Exception;
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/ECM.java
  
  Index: ECM.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc.modules;
  
  import java.io.File;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  
  import org.apache.excalibur.xfc.model.Model;
  import org.apache.excalibur.xfc.model.Definition;
  import org.apache.excalibur.xfc.model.RoleRef;
  
  /**
   * <code>ECM</code> module implementation.
   *
   * <p>
   *  This implementation supports ECM style role files. ie:
   *
   *  <pre>
   *   &lt;role-list&gt;
   *     &lt;role name="..." shorthand="..." default-class="..."/&gt;
   *   &lt;/role-list&gt;
   *  </pre>
   * </p>
   *
   * <p>
   *  The input context should be the name of the roles file, followed
   *  by the name of the configuration file, separated by a colon.
   *  eg: definitions.roles:config.xconf
   * </p>
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Id: ECM.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public class ECM extends AbstractModule
  {
      // Avalon Framework and Excalibur Pool markers
      private static final String SINGLETHREADED =
          "org.apache.avalon.framework.thread.SingleThreaded";
      private static final String THREADSAFE =
          "org.apache.avalon.framework.thread.ThreadSafe";
      private static final String POOLABLE =
          "org.apache.avalon.excalibur.mpool.Poolable";
      private static final String RECYCLABLE =
          "org.apache.avalon.excalibur.mpool.Recyclable";
  
      private static Map m_handlers = new HashMap();
  
      /**
       * Generates a {@link Model} based on an a given ECM style
       * Context.
       *
       * <p>
       *  The specified Context string names the ECM role and
       *  xconf files, separated by a ':' character. ie:
       *  <code>ecm.roles:ecm.xconf</code>
       * </p>
       *
       * @param context a <code>String</code> context value
       * @return a <code>Model</code> instance
       * @exception Exception if an error occurs
       */
      public Model generate( final String context )
          throws Exception
      {
          Configuration[] roles = getRoles( getRoleFile( context ) );
          Model model = new Model();
  
          if ( getLogger().isDebugEnabled() )
          {
              getLogger().debug( "Identified total of " + roles.length + " roles" );
          }
  
          // for each role create a type object
          for ( int i = 0; i < roles.length; ++i )
          {
              model.addDefinition( buildDefinition( roles[i] ) );
          }
  
          if ( getLogger().isDebugEnabled() )
          {
              getLogger().debug( "Model built" );
          }
  
          return model;
      }
  
      /**
       * Helper method for obtaining the Role file.
       *
       * @param context a <code>String</code> value
       * @return a <code>File</code> value
       */
      private File getRoleFile( final String context )
      {
          int i = context.indexOf( CONTEXT_SEPARATOR );
          return new File( context.substring( 0, i ) );
      }
  
      /**
       * Helper method for obtaining the Configuration file.
       *
       * @param context a <code>String</code> value
       * @return a <code>File</code> value
       */
      private File getConfigurationFile( final String context )
      {
          int i = context.indexOf( CONTEXT_SEPARATOR );
          return new File( context.substring( i + 1 ) );
      }
  
      /**
       * Helper method for obtaining the roles defined in
       * a particular input file.
       *
       * @param input a <code>File</code> value
       * @return a <code>Configuration[]</code> value
       * @exception Exception if an error occurs
       */
      private Configuration[] getRoles( final File input )
          throws Exception
      {
          Configuration config = m_builder.buildFromFile( input );
          return config.getChildren( "role" );
      }
  
      /**
       * Method to construct a {@link Definition} object from
       * a Role definition.
       *
       * @param role role information
       * @return a <code>Definition</code> instance
       * @exception Exception if an error occurs
       */
      protected Definition buildDefinition( final Configuration role )
          throws Exception
      {
          return new Definition(
              getRole( role ),
              getDefaultClass( role ),
              getShorthand( role ),
              getHandler( role )
          );
      }
  
      /**
       * Method to extract the role name ECM style.
       *
       * @param role role <code>Configuration</code> information
       * @return the role name
       * @exception Exception if an error occurs
       */
      protected String getRole( final Configuration role )
          throws Exception
      {
          return role.getAttribute( "name" );
      }
  
      /**
       * Method to extract a role's implementing class, ECM
       * style
       *
       * @param role role <code>Configuration</code> information
       * @return the implementing class name
       * @exception Exception if an error occurs
       */
      protected String getDefaultClass( final Configuration role )
          throws Exception
      {
          return role.getAttribute( "default-class" );
      }
  
      /**
       * Method for extracting a role's shorthand name, ECM
       * style
       *
       * @param role role <code>Configuration</code> information
       * @return the shorthand name
       * @exception Exception if an error occurs
       */
      protected String getShorthand( final Configuration role )
          throws Exception
      {
          return role.getAttribute( "shorthand" );
      }
  
      /**
       * Method for extracting a role's ComponentHandler name,
       * ECM style. ECM roles don't define ComponentHandlers explicitly,
       * so some simple class analysis is made in this method to
       * try to ascertain which handler has been chosed by the 
       * implementor.
       *
       * @param role role <code>Configuration</code> information
       * @return normalized handler name
       * @exception Exception if an error occurs
       */
      protected String getHandler( final Configuration role )
          throws Exception
      {
          try
          {
              Class clazz = Class.forName( getDefaultClass( role ) );
              Class[] interfaces = clazz.getInterfaces();
  
              for ( int i = 0; i < interfaces.length; ++i )
              {
                  if ( m_handlers.containsKey( interfaces[ i ] ) )
                  {
                      return (String) m_handlers.get( interfaces[ i ] );
                  }
              }
  
              if ( getLogger().isWarnEnabled() )
              {
                  getLogger().warn(
                      "Defaulting to 'transient' lifestyle for component " +
                      clazz.getName()
                  );
              }
  
              return TRANSIENT;
          }
          catch ( ClassNotFoundException e )
          {
              if ( getLogger().isWarnEnabled() )
              {
                  getLogger().warn(
                      "Could not load Class " + role.getAttribute( "default-class" ) +
                      " for Component Handler analysis, defaulting to 'transient'"
                  );
              }
  
              /* leave out for the moment
              if ( getLogger().isDebugEnabled() )
              {
                  getLogger().debug( "Exception: ", e );
              }
              */
  
              return TRANSIENT;
          }
      }
  
      /**
       * Serializes a {@link Model} definition, ECM style, to an
       * output context.
       *
       * @param model a <code>Model</code> instance
       * @param context ECM output Context
       * @exception Exception if an error occurs
       */
      public void serialize( final Model model, final String context )
          throws Exception
      {
          RoleRef[] rolerefs = model.getDefinitions();
          DefaultConfiguration roles = new DefaultConfiguration("role-list", "");
  
          // for each type object generate a roles file entry
          for ( int i = 0; i < rolerefs.length; ++i )
          {
              roles.addChild( buildRole( rolerefs[i] ) );
          }
  
          m_serializer.serializeToFile( getRoleFile( context ), roles );
      }
  
      /**
       * Method to build a Role definition from a {@link RoleRef}
       * object.
       *
       * @param roleref a <code>RoleRef</code> instance
       * @return role definition as a <code>Configuration</code> instance
       * @exception Exception if an error occurs
       */
      protected Configuration buildRole( final RoleRef roleref )
          throws Exception
      {
          DefaultConfiguration role = new DefaultConfiguration("role", "");
  
          Definition[] defs = roleref.getProviders();
  
          if ( defs.length > 1 )
          {
              // REVISIT: generate component selector
          }
          else
          {
              role.setAttribute( "name", roleref.getRole() );
              role.setAttribute( "shorthand", defs[0].getShorthand() );
              role.setAttribute( "default-class", defs[0].getDefaultClass() );
          }
  
          if ( getLogger().isDebugEnabled() )
          {
              getLogger().debug( "Building role for model: " + roleref.getRole() );
          }
  
          return role;
      }
  
      // Default mappings for ECM and Type lifestyles
      static
      {
          // ECM -> Type
          m_handlers.put( SINGLETHREADED, TRANSIENT );
          m_handlers.put( POOLABLE, POOLED );
          m_handlers.put( RECYCLABLE, POOLED );
          m_handlers.put( THREADSAFE, SINGLETON );
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/Fortress.java
  
  Index: Fortress.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.excalibur.xfc.modules;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  
  import org.apache.excalibur.xfc.model.Definition;
  import org.apache.excalibur.xfc.model.RoleRef;
  
  /**
   * <code>Fortress</code> module implementation.
   *
   * <p>
   *  Fortress style role files are an extension to the ECM model.
   *  This implementation supports Fortress style role files. ie:
   *
   *  <pre>
   *   &lt;role-list&gt;
   *     &lt;role name=""&gt;
   *       &lt;component shorthand="..." class="..." handler="..."/&gt;
   *     &lt;/role&gt;
   *   &lt;/role-list&gt;
   *  </pre>
   * </p>
   *
   * <p>
   *  The input context should be the name of the roles file, followed
   *  by the name of the configuration file, separated by a colon.
   *  eg: definitions.roles:config.xconf
   * </p>
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Id: Fortress.java,v 1.1 2002/10/02 17:32:28 crafterm Exp $
   */
  public class Fortress extends ECM
  {
      // ComponentHandler constants
      private static final String FACTORY =
          "org.apache.excalibur.fortress.handler.FactoryComponentHandler";
      private static final String PERTHREAD =
          "org.apache.excalibur.fortress.handler.PerThreadComponentHandler";
      private static final String POOLABLE =
          "org.apache.excalibur.fortress.handler.PoolableComponentHandler";
      private static final String THREADSAFE =
          "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler";
  
      // Map of fortress/type handlers
      private static final Map m_handlers = new HashMap();
  
      // <role-list>
      //  <role name="">
      //   <component shorthand="" class="" handler="">
      //  </role>
      // </role-list>
  
      /**
       * Method for extracting a role's default implementing class, 
       * Fortress style.
       *
       * @param role role <code>Configuration</code> information
       * @return the role's default implementing class name
       * @exception Exception if an error occurs
       */
      protected String getDefaultClass( final Configuration role )
          throws Exception
      {
          return role.getChild( "component" ).getAttribute( "class" );
      }
  
      /**
       * Method for extracting a role's shorthand name, Fortress
       * style.
       *
       * @param role role <code>Configuration</code> information
       * @return the role's shorthand name
       * @exception Exception if an error occurs
       */
      protected String getShorthand( final Configuration role )
          throws Exception
      {
          return super.getShorthand( role.getChild( "component" ) );
      }
  
      /**
       * Method for extracting a role's ComponentHandler name.
       *
       * @param role role <code>Configuration</code> information
       * @return the role's normalized handler name
       * @exception Exception if an error occurs
       */
      protected String getHandler( final Configuration role )
          throws Exception
      {
          return getLifestyleType(
              role.getChild( "component" ).getAttribute( "handler" ), TRANSIENT
          );
      }
  
      /**
       * Helper method to convert known Fortress ComponentHandler types to meta
       * REVISIT: meta should define transient/thread/pooled/etc as constants.
       *
       * @param handler a <code>String</code> value
       * @param defaultValue a <code>String</code> default value if handler
       *                     type cannot be found
       * @return a <code>String</code> value
       */
      private String getLifestyleType( String handler, String defaultValue )
      {
          if ( handler != null )
          {
              String type = (String) m_handlers.get( handler );
  
              if ( type != null )
                  return type;
          }
  
          if ( getLogger().isWarnEnabled() )
          {
              getLogger().warn(
                  "Custom or unknown handler " + handler +
                  " defined, defaulting to " + defaultValue
              );
          }
  
          return defaultValue;
      }
  
      /**
       * Method for building a Fortress style Role definition
       * based on a {@link RoleRef} object.
       *
       * @param roleref a <code>RoleRef</code> instance
       * @return role definition as a <code>Configuration</code> value
       * @exception Exception if an error occurs
       */
      protected Configuration buildRole( final RoleRef roleref )
          throws Exception
      {
          DefaultConfiguration role = new DefaultConfiguration( "role", "" );
          Definition[] defs = roleref.getProviders();
  
          if ( defs.length > 1 )
          {
              // REVISIT(MC): generate component selector
          }
          else
          {
              role.setAttribute( "name", roleref.getRole() );
  
              DefaultConfiguration component = new DefaultConfiguration( "component", "");
              component.setAttribute( "shorthand", defs[0].getShorthand() );
              component.setAttribute( "class", defs[0].getDefaultClass() );
              component.setAttribute(
                  "handler", getLifestyleType( defs[0].getHandler(), FACTORY )
              );
              role.addChild( component );
          }
  
          return role;
      }
  
      // Default mappings for Fortress and Type component handlers
      static
      {
          // Fortress -> Type
          m_handlers.put( FACTORY, TRANSIENT );
          m_handlers.put( PERTHREAD, THREAD );
          m_handlers.put( POOLABLE, POOLED );
          m_handlers.put( THREADSAFE, SINGLETON );
  
          // Type -> Fortress
          m_handlers.put( TRANSIENT, FACTORY );
          m_handlers.put( THREAD, PERTHREAD );
          m_handlers.put( POOLED, POOLABLE );
          m_handlers.put( SINGLETON, THREADSAFE );
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/package.html
  
  Index: package.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  <html>
  <body>
  
  <p>
  <b>XFC Modules</b>, Module implementations for concrete container types.
  </p>
  
  <p>
  This package contains concrete implementations of the Module interface
  for particular containers.
  </p>
  
  <!--
  <h2>Package Specification</h2>
  
  ##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
  <ul>
    <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
  </ul>
  
  <h2>Related Documentation</h2>
  
  For overviews, tutorials, examples, guides, and tool documentation, please see:
  <ul>
    <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
  </ul>
  -->
  
  <!-- Put @see and @since tags down here. -->
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-avalon-excalibur/xfc/src/xdocs/converter.txt
  
  Index: converter.txt
  ===================================================================
  
  Aim:
  
  Write a utility to convert one container configuration file into another.
  eg:
  
          ECM roles/xconf -> Fortress roles/xconf
          ECM roles/xconf -> Merlin xinfo/xconfig
          Fortress roles/xconf -> Merlin xinfo/xconfig
          etc.
  
  Design:
  
  Create a middle format and define an interface for converting to and from it, 
  add implementations for each container type and use one of these 'modules' as
  input, one as output.
  
  Create a utility for calling this structure, and an ant task. In the future
  perhaps build the support into the meta package to allow all 'meta' based
  containers to use any other containers config files.
  
  Container particulars:
  
      ECM roles/xconf:
  
          role format specifies:
          o role name
          o implementation class
          o shorthand name (for configuration purposes)
  
          configuration file specifies:
          o configuration details
          o logger
          o implementation class (optional, overrides role specified class)
  
          configuration file is either indexed via shorthand or 'component' tag.
  
      Fortress roles/xconf:
  
          role format specifies:
          o same as ECM plus component handler name (different attribute names though)
  
          configuration file specifies
          o same as ECM
  
      Merlin xinfo/xconfig:
  
          xinfo specifies component meta information
          xconfig specifies default configuration
  
  
  Prospective Solution:
  
  Use meta Type class as middle format. Write conversion modules to convert from concrete
  container role/config formats to and from Type.
  
      ECM:                                                Type placeholder
  
        roles
          role name                                       service-ref
          default or overridden class name                implementation key (base filename)
          shorthand name                                  component name
        xconf
          logger                                          logger definition
          configuration                                   ??
  
      Fortress
  
        roles
          role name                                       service-ref
          default or overriden class name                 implementation key (base filename)
          shorthand name                                  component name
          handler                                         component handler attribute
        xconf
          logger                                          logger definition
          configuration                                   ??
  
      Merlin
  
        xinfo
          full Type meta info                             meta info as normal
                                                          (need filename as implementation key?)
        xprofile
          configuration                                   ??
  
  
  Conversion process to and from Type:
  
  ECM                  : each role definition equates to a Type
  Fortress             : each role definition equates to a Type
  Merlin               : each .xinfo equates to a Type
  
  Each Type object can potentially be converted to 1-N role definitions due to each Type
  having 1-N service-refs.
  
  Usage:
  
          java converter --input <module>:<module-context> --output <module>:<module-context>
  
          where <module> == ecm|fortress|merlin|class-name
                <module-context> == : separated values applicable to the specified <module>
  
  Examples:
  
          java converter --input ecm:file.roles:file.xconf --output merlin:directory
          java converter --input ecm:file.roles:file.xconf --output fortress:file.roles:file.xconf
          java converter --input merlin:jarfile --output fortress:file.roles:file.xconf
          java converter --input fortress:file.roles:file.xconf --output merlin:directory
  
  (ant task will also be written).
  
  Interfaces:
  
  /**
   * module interface for creating an array of Type[] objects from an input
   * context, and similarly serializing an array of Type[] objects to a
   * context.
   */
  public interface Module
  {
      Type[] generate(String context) throws Exception;
      void serialize(Type[] model, String context) throws Exception;
  }
  
  (REVISIT: may need to change generate/serialize to work with a custom
  object that holds Type's along with the particular objects default
  configuration?).
  
  

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