akarasulu    2003/11/11 23:38:35

  Added:       kernel/bootstrap maven.xml project.xml snapshot.properties
               kernel/bootstrap/src/etc merlin.properties project.mf
               kernel/bootstrap/src/java BootstrapHelper.java
                        BootstrapRuntimeException.java Merlin.java
                        Resources.properties Resources_de.properties
                        Resources_fr.properties package.html
  Log:
  copy to work with in sandbox
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/kernel/bootstrap/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="jar:install" xmlns:maven="jelly:maven" xmlns:j="jelly:core" 
xmlns:util="jelly:util" xmlns:ant="jelly:ant">
  
    <property name="maven.jar.manifest" value="${basedir}/src/etc/project.mf"/>
    <property name="maven.jar.manifest.extensions.add" value="false"/>
    <property file="project.properties"/>
  
    <preGoal name="jar:jar">
      <maven:snapshot project="${pom}"/>
  <ant:echo file="${basedir}/snapshot.properties">
  build.signature = ${snapshotSignature}
  </ant:echo>
      <unzip src="${pom.getDependencyPath('avalon-repository:avalon-repository-spi')}" 
        dest="${maven.build.dir}/classes"/>
      <unzip 
src="${pom.getDependencyPath('avalon-repository:avalon-repository-impl')}" 
        dest="${maven.build.dir}/classes"/>
    </preGoal>
  
    <goal name="build" prereqs="jar:install">
      <ant:property environment="env"/>
      <ant:property name="merlinEnvironment" value="${env.MERLIN_HOME}"/>
      <j:if test="${merlinEnvironment != ''}">
         <ant:property name="merlin.home" value="${merlinEnvironment}"/>
      </j:if>
      <ant:property name="merlin.home" value="${user.home}/.merlin"/>
      <copy toDir="${merlin.home}/bin/lib" 
file="${maven.build.dir}/${maven.final.name}.jar"/>
    </goal>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <project>
  
    <extend>${basedir}/../../project.xml</extend>
    <groupId>merlin</groupId>
    <id>merlin-bootstrap</id>
    <name>Merlin Kernel CLI</name>
    <currentVersion>1.0</currentVersion>
    <package>*</package>
  
    <inceptionYear>2003</inceptionYear>
    <shortDescription>Merlin Command-Line Interface.</shortDescription>
  
    <description>
      Command line interface for the Merlin system.
    </description>
    
    <dependencies>
  
      <dependency>
        <groupId>avalon-repository</groupId>
        <artifactId>avalon-repository-spi</artifactId>
        <version>1.1-dev</version>
      </dependency>
      <dependency>
        <groupId>avalon-repository</groupId>
        <artifactId>avalon-repository-impl</artifactId>
        <version>1.1-dev</version>
      </dependency>
  
    </dependencies>
    
    <build>
  
      <sourceDirectory>src/java</sourceDirectory>
      <unitTestSourceDirectory></unitTestSourceDirectory>
      <unitTest></unitTest>
      <testResources></testResources>
      <integrationUnitTestPatterns></integrationUnitTestPatterns>
      <resources>
        <resource>
          <directory>${basedir}/src/etc</directory>
          <includes> 
            <include>merlin.properties</include>
          </includes>
        </resource>
        <resource>
          <directory>${basedir}</directory>
          <includes> 
            <include>snapshot.properties</include>
          </includes>
        </resource>
      </resources>
  
      <jars></jars>
  
    </build>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/snapshot.properties
  
  Index: snapshot.properties
  ===================================================================
  
  build.signature = merlin-bootstrap-20031105.083922
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/src/etc/merlin.properties
  
  Index: merlin.properties
  ===================================================================
  
  #
  # the bootstrap kernel loader class
  #
  merlin.bootstrap.class=org.apache.avalon.merlin.kernel.impl.CLIKernelLoader
  
  #
  # the api classpath
  #
  merlin.api.classpath.0=avalon-framework:avalon-framework-api;4.1.5
  merlin.api.classpath.1=avalon-meta:avalon-meta-api;1.2.1-dev
  merlin.api.classpath.2=avalon-composition:avalon-composition-api;1.2-dev
  merlin.api.classpath.3=avalon-activation:avalon-activation-api;1.2-dev
  merlin.api.classpath.4=excalibur-lifecycle:excalibur-lifecycle-api;1.0
  merlin.api.classpath.5=avalon-extension:avalon-extension-spi;1.0
  merlin.api.classpath.6=merlin:merlin-kernel-spi;3.2-dev
  
  #
  # the spi classpath
  #
  merlin.spi.classpath.0=avalon-meta:avalon-meta-spi;1.2.1-dev
  merlin.spi.classpath.1=avalon-composition:avalon-composition-spi;1.2-dev
  merlin.spi.classpath.2=avalon-activation:avalon-activation-spi;1.2.1-dev
  merlin.spi.classpath.3=avalon-repository:avalon-repository-spi;1.1-dev
  
  #
  # the bootstrap classpath
  #
  merlin.impl.classpath.0=avalon-framework:avalon-framework-impl;4.1.5
  merlin.impl.classpath.1=avalon-meta:avalon-meta-impl;1.2.1-dev
  merlin.impl.classpath.2=avalon-extension:avalon-extension-impl;1.0
  merlin.impl.classpath.3=avalon-composition:avalon-composition-impl;1.2-dev
  merlin.impl.classpath.4=avalon-activation:avalon-activation-impl;1.2.2-dev
  merlin.impl.classpath.5=excalibur-i18n:excalibur-i18n;1.1
  merlin.impl.classpath.6=avalon-repository:avalon-repository-impl;1.1-dev
  merlin.impl.classpath.7=commons-cli:commons-cli;1.0
  merlin.impl.classpath.8=merlin:merlin-kernel-impl;3.2-dev
  merlin.impl.classpath.9=logkit:logkit;1.2
  merlin.impl.classpath.10=excalibur-event:excalibur-event;1.0.3
  merlin.impl.classpath.11=excalibur-configuration:excalibur-configuration;1.1
  merlin.impl.classpath.12=mx4j:mx4j-jmx;1.1.1
  merlin.impl.classpath.13=mx4j:mx4j-tools;1.1.1
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/src/etc/project.mf
  
  Index: project.mf
  ===================================================================
  Manifest-Version: 1.0
  Created-By: Apache Avalon
  Main-Class: Merlin
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/src/java/BootstrapHelper.java
  
  Index: BootstrapHelper.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 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", "Apache Avalon", "Avalon Framework" 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 [EMAIL PROTECTED]
  
   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/>.
  
  */
  
  import java.io.PrintWriter;
  import java.io.StringWriter;
  import java.lang.reflect.Method;
  import java.util.StringTokenizer;
  
  /**
   * General utilities supporting the packaging of exception messages.
   * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
   */
  public class BootstrapHelper
  {
      private static final String LINE_SEPARATOR = System.getProperty( 
"line.separator" );
  
      /**
       * Returns the exception and causal exceptions as a formatted string.
       * @param message the header message
       * @param e the exception
       * @return String the formatting string
       */
      public static String packException( final String message, final Throwable e )
      {
          return packException( message, e, true );
      }
  
      /**
       * Returns the exception and causal exceptions as a formatted string.
       * @param message the header message
       * @param e the exception
       * @return String the formatting string
       */
      public static String packException( 
         final String message, final Throwable e, boolean stack )
      {
          StringBuffer buffer = new StringBuffer();
          buffer.append( message );
          if( e == null )
          {
              return buffer.toString();
          } else
          {
              buffer.append( "\n" );
              buffer.append( 
  "-------------------------------------------------------------------" );
              buffer.append( "\nException: " + e.getClass().getName() );
              buffer.append( "\nMessage: " + e.getMessage() );
              packCause( buffer, getCause( e ) ).toString();
          }
          Throwable root = getLastThrowable( e );
          if( (root != null) && stack )
          {
              buffer.append( 
  "\n\n---- stack trace --------------------------------------------------" );
              String[] trace = captureStackTrace( root );
              for( int i = 0; i < trace.length; i++ )
              {
                  buffer.append( "\n" + trace[i] );
              }
          }
          buffer.append( 
  "\n-------------------------------------------------------------------" );
          return buffer.toString();
      }
  
      private static StringBuffer packCause( StringBuffer buffer, Throwable cause )
      {
          if( cause == null )
          {
              return buffer;
          }
          buffer.append( "\n\nCause: " + cause.getClass().getName() );
          buffer.append( "\nMessage: " + cause.getMessage() );
          return packCause( buffer, getCause( cause ) );
      }
  
      private static Throwable getLastThrowable( Throwable exception )
      {
          Throwable cause = getCause( exception );
          if( cause != null )
          {
              return getLastThrowable( cause );
          }
          return exception;
      }
  
      private static Throwable getCause( Throwable exception )
      {
          if( exception == null )
          {
              throw new NullPointerException( "exception" );
          }
  
          try
          {
              Method method = exception.getClass().getMethod( "getCause", new Class[0] 
);
              return (Throwable) method.invoke( exception, new Object[0] );
          } catch( Throwable e )
          {
              return null;
          }
      }
  
      /**
       * Captures the stack trace associated with this exception.
       *
       * @param throwable a <code>Throwable</code>
       * @return an array of Strings describing stack frames.
       */
      private static String[] captureStackTrace( final Throwable throwable )
      {
          final StringWriter sw = new StringWriter();
          throwable.printStackTrace( new PrintWriter( sw, true ) );
          return splitString( sw.toString(), LINE_SEPARATOR );
      }
  
      /**
       * Splits the string on every token into an array of stack frames.
       *
       * @param string the string to split
       * @param onToken the token to split on
       * @return the resultant array
       */
      private static String[] splitString( final String string, final String onToken )
      {
          final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
          final String[] result = new String[tokenizer.countTokens()];
  
          for( int i = 0; i < result.length; i++ )
          {
              result[i] = tokenizer.nextToken();
          }
  
          return result;
      }
  
      private static void printCause( java.io.PrintStream out, Throwable e )
      {
          Throwable cause = getCause( e );
          out.println( "Cause: " + cause.toString() );
          if( getCause( cause ) != null )
          {
              printCause( out, cause );
          }
      }
  }
  
  
  
  1.1                  
avalon-sandbox/kernel/bootstrap/src/java/BootstrapRuntimeException.java
  
  Index: BootstrapRuntimeException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 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", "Apache Avalon", "Avalon Framework" 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 [EMAIL PROTECTED]
  
   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/>.
  
  */
  
  /**
   * Exception to indicate that there was a bootstrap related runtime error.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/11/12 07:38:35 $
   */
  public final class BootstrapRuntimeException
      extends RuntimeException
  {
      private Throwable m_cause;
      private String[] m_actions = new String[0];
  
      /**
       * Construct a new <code>BootstrapRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public BootstrapRuntimeException( final String message )
      {
          this( message, (String) null, (Throwable) null );
      }
  
      /**
       * Construct a new <code>BootstrapRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public BootstrapRuntimeException( final String message, final Throwable 
throwable )
      {
          this( message, (String) null, throwable );
      }
  
      /**
       * Construct a new <code>BootstrapRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param action recommended action
       */
      public BootstrapRuntimeException( final String message, String action )
      {
          this( message, action, null );
      }
  
      /**
       * Construct a new <code>BootstrapRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param action recommended action
       * @param throwable the root cause of the exception
       */
      public BootstrapRuntimeException( final String message, String action, final 
Throwable throwable )
      {
          this( message, new String[]{ action }, throwable );
      }
  
      /**
       * Construct a new <code>BootstrapRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param action recommended action
       * @param throwable the root cause of the exception
       */
      public BootstrapRuntimeException( final String message, String[] actions, final 
Throwable throwable )
      {
          super( message );
          m_cause = throwable;
          m_actions = actions;
      }
  
  
     /**
      * Returns the cause of the error.
      * @return the causal exception
      */
      public Throwable getCause()
      {
          return m_cause;
      }
  
     /**
      * Returns the recommended corrective action pertaining to the error condition.
      * @return the recommended corrective action.
      */
      public String[] getActions()
      {
          return m_actions;
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/src/java/Merlin.java
  
  Index: Merlin.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 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", "Apache Avalon", "Avalon Framework" 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 [EMAIL PROTECTED]
  
   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/>.
  
  */
  
  import java.io.File;
  import java.io.InputStream;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.util.ArrayList;
  import java.util.Properties;
  import java.util.StringTokenizer;
  
  import org.apache.avalon.repository.Repository;
  import org.apache.avalon.repository.impl.DefaultFileRepository;
  
  /**
   * Merlin commandline bootstrap handler.
   */
  public class Merlin
  {
      //--------------------------------------------------------------------------
      // static
      //--------------------------------------------------------------------------
  
      private static final String REPOSITORY_PATH = 
        "http://dpml.net/,http://www.ibiblio.org/maven/";;
  
      private static final String MERLIN_HOME_KEY = 
        "merlin.home";
  
      private static final String MERLIN_SYSTEM_REPOSITORY_KEY = 
        "merlin.system.repository";
  
      private static final String MERLIN_SYSTEM_REMOTE_REPOSITORY_PATH_KEY = 
        "merlin.system.remote-repository.path";
  
      private static final String MERLIN_BOOTSTRAP_CLASSNAME_KEY = 
        "merlin.bootstrap.class";
      private static final String MERLIN_API_CLASSPATH_KEY = 
        "merlin.api.classpath";
      private static final String MERLIN_SPI_CLASSPATH_KEY = 
        "merlin.spi.classpath";
      private static final String MERLIN_IMPL_CLASSPATH_KEY = 
        "merlin.impl.classpath";
      private static final String MERLIN_PROPERTIES_NAME = 
        "merlin.properties";
  
      private static final File HOME = 
        new File( System.getProperty( "user.dir" ) );
  
     /**
      * Command line entry point to the Merlin system.
      * The main method handles the establishment of a bootstrap repository
      * from which a classload is built that contains the classes necessary
      * to bootstrap a kernel into existance.  The implementation passes
      * all command line parameters to the CLIKernelLoader class for 
      * processing and kernel establishment.
      *
      * @param args the command-line arguments
      * @exception Exception is an error occurs
      */
      public static void main( String[] args ) throws Exception
      {
          boolean debug = isDebugEnabled( args );
  
          //
          // the base directory is the directory containing the 
          // the merlin jar repository
          //
  
          String fallback =  System.getProperty( "user.home" ) + "/.merlin";
          String home =  System.getProperty( MERLIN_HOME_KEY, fallback );
          File merlinHome = new File( home );
          File merlinDefaultSystemRepository = new File( merlinHome, "system" );
          String merlinSystemRepositoryPath = 
            System.getProperty( 
              MERLIN_SYSTEM_REPOSITORY_KEY, 
              merlinDefaultSystemRepository.toString() );
  
          File base = new File( merlinSystemRepositoryPath );
  
          if( !base.exists() )
          {
              final String info = 
                "INFO-NEW-REPOSITORY, creating a new repository at: " + base;
              System.out.println( info );
              base.mkdirs();
          }
  
          if( debug )
          {
              System.out.println( "System Repository: " + base );
          }
  
          //
          // Establish the repository.  If a system property corresponding to 
          // MERLIN_REPOSITORY_REMOTE_KEY is not null then setup the repository
          // so that it dynamcally downloads content.  If the value is null then
          // default values.
          //
  
          Repository repository = null;
          String remotePath = 
            System.getProperty( MERLIN_SYSTEM_REMOTE_REPOSITORY_PATH_KEY, 
REPOSITORY_PATH );
          if( debug )
          {
              System.out.println( "system remote repositories: " + remotePath );
          }
  
          URL[] remote = getRemoteURLs( remotePath );
          repository = new DefaultFileRepository( base, null, remote );
  
          //
          // get the set of URLs for the bootstrap classloader from the 
          // merlin.properties file bundled with the bootstrap jar file
          //
  
          ClassLoader classloader = Merlin.class.getClassLoader();
          InputStream input = 
            classloader.getResourceAsStream( MERLIN_PROPERTIES_NAME  );
          Properties properties = new Properties();
          properties.load( input );
  
          URL[] api = null;
          try
          {
              api = getURLs( repository, properties, MERLIN_API_CLASSPATH_KEY );
          }
          catch( Throwable e )
          {
              final String error =
                "\nInternal error while attempting to build api classloader.";
              String msg = 
                BootstrapHelper.packException( error, e, true );
              System.err.println( msg );
              return;
          }
  
          URL[] spi = null;
          try
          {
              spi = getURLs( repository, properties, MERLIN_SPI_CLASSPATH_KEY );
          }
          catch( Throwable e )
          {
              final String error =
                "\nInternal error while attempting to build api classloader.";
              String msg = 
                BootstrapHelper.packException( error, e, true );
              System.err.println( msg );
              return;
          }
  
          URL[] impl = null;
          try
          {
              impl = getURLs( repository, properties, MERLIN_IMPL_CLASSPATH_KEY );
          }
          catch( Throwable e )
          {
              final String error =
                "\nInternal error while attempting to build implementation 
classloader.";
              String msg = 
                BootstrapHelper.packException( error, e, true );
              System.err.println( msg );
              return;
          }
  
          //
          // create the container bootstrap classloader using these
          // URLs
          //
  
          ClassLoader apiLoader = new URLClassLoader( api );
          ClassLoader spiLoader = new URLClassLoader( spi, apiLoader );
          URLClassLoader loader = new URLClassLoader( impl, spiLoader );
          Thread.currentThread().setContextClassLoader( loader );
  
          if( debug )
          {
              System.out.println( "Classloader dump:\n" );
              printClassLoader( loader );
              System.out.println( "\n" );
          }
  
          //
          // get the bootstrap kernel loader class
          //
  
          Class clazz;
          String classname = 
            properties.getProperty( MERLIN_BOOTSTRAP_CLASSNAME_KEY );
  
          try
          {
              clazz = loader.loadClass( classname );
          }
          catch( Throwable e )
          {
              final String error =
                "\nInternal error during loader class creation.";
              String msg = 
                BootstrapHelper.packException( error, e, true );
              System.err.println( msg );
              return;
          }
  
          //
          // instantiate the kernel loader
          //
  
          try
          {
              Constructor constructor = 
                clazz.getConstructor( 
                  new Class[]{ Repository.class, args.getClass() } );
              Object kernelLoader = 
                constructor.newInstance( 
                  new Object[]{ repository, args } );
          }
          catch( InvocationTargetException e )
          {
              Throwable target = e.getTargetException();
              boolean cliError = 
                target.getClass().getName().startsWith( "org.apache.commons.cli" );
              if( cliError )
              {
                  System.err.println( "Commandline error: " + target.getMessage() );
              }
              else
              {
                  final String error =
                    "\nInternal error during kernel instantiation.";
                  String msg = 
                    BootstrapHelper.packException( 
                      error, target, true );
                  System.err.println( msg );
              }
              return;
          }
          catch( Throwable e )
          {
              final String error =
                "\nInternal error during kernel instantiation.";
              String msg = 
                BootstrapHelper.packException( error, e, true );
              System.err.println( msg );
              return;
          }
      }
  
      private static URL[] getRemoteURLs( String path ) throws Exception
      {
          ArrayList list = new ArrayList();
          StringTokenizer tokenizer = new StringTokenizer( path, "," );
          while( tokenizer.hasMoreElements() )
          {
              String token = tokenizer.nextToken();
              list.add( new URL( token ) );
          }
          return (URL[]) list.toArray( new URL[0] );
      }
  
     /**
      * Consruct an array of URLs based on the declarations provided
      * in the supplied properties object.  Each URL is specified 
      * as a property value is mapped to a numbered property key in 
      * the form [key].n.  Each value is expressed as a repository
      * entry in the form [group]:[artifact];[version]. 
      * 
      * @param repository the repository from which artifacts shall be
      *   cached
      * @param properties the properties holding the keyed artifact ids
      * @param key the property name key
      * @return the array of urls
      */ 
      private static URL[] getURLs( 
         Repository repository, Properties properties, String key )
      {
          int i = 0;
          ArrayList list = new ArrayList();
          String label = getProperty( properties, key, i );
          while( label != null )
          {
              i++;
              list.add( getURL( repository, label ) );
              label = getProperty( properties, key, i );
          }
          return (URL[]) list.toArray( new URL[0] );
      }
  
     /**
      * Return a property key by concatonation of the supplied
      * key, the period character and an integer.
      * @param prioperties the properties set containing the keyed entry
      * @param key the partial key
      * @param i the key index
      * @return the value of the property [key].[i]
      */
      private static String getProperty( Properties properties, String key, int i )
      {
           final String label = key + "." + i;
           return properties.getProperty( label );
      }
  
     /**
      * Return a URL a a local repository cached resource replative to 
      * a suplied property value in the form [group]:[artifact];[version].
      * @param repository the repository under whcih resources are cached
      * @param item the encoded artifact identifier
      * @return the URL to the locally cached artifact
      */ 
      private static URL getURL( Repository repository, String item )
      {
           try
           {
               int n = item.indexOf( ":" );
               final String group = item.substring( 0, n );
              
               String artifact = null;
               String version = null;
               int m = item.indexOf( ";" );
               if( m > -1 )
               {
                   artifact = item.substring( n+1, m );
                   version = item.substring( m+1, item.length() );
               }
               else
               {
                   artifact = item.substring( n+1, item.length() );
               }
              
               return repository.getArtifact( group, artifact, version, "jar" );
           }
           catch( Throwable e )
           {
               final String error = 
                "Internal bootstrap error.  Unable to load item: " + item;
               throw new BootstrapRuntimeException( error, e );
           }
      }
  
     /**
      * Utilitiy method to test if the -debug flag is present.
      * @param args the command line arguments
      * @return TRUE if the -debug flag is present
      */
      private static boolean isDebugEnabled( final String[] args )
      {
          for( int i=0; i<args.length; i++ )
          {
              final String arg = args[i];
              if( arg.equals( "-debug" ) ) return true;
          }
          return false;
      }
  
     /**
      * Debug utility to dump a classloader url set to system.out.
      * The implementation will print url from the supplied loader 
      * following which it will print the parent recursively if the 
      * parent is a URLClassLoader.
      * 
      * @param loader the classloader to dump
      */
      private static void printClassLoader( URLClassLoader loader )
      {
          URL[] urls = loader.getURLs();
          for( int i=0; i<urls.length; i++ )
          {
              System.out.println( urls[i] );
          }
          if( loader.getParent() instanceof URLClassLoader )
          {
              printClassLoader( (URLClassLoader) loader.getParent() );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/src/java/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  
  directory=directory
  
  file=file
  
  cli-help-description=Prints this message.
  
  cli-language-description=A two-letter language code.
  
  cli-execute-description=If present the kernel will initiate shutdown immediately 
following deployment.
  
  cli-version-description=Prints Merlin version information.
  
  cli-debug-description=Enable debug messages during the bootstrap phase.
  
  cli-home-description=A relative or absolute path to a working home directory. If not 
suppled, the system will default to the current directory. If the resolved home path 
does not exist it will be created.
  
  cli-kernel-description=The filename of the kernel configuration.  The value defaults 
to the system kernel.xml file.
  
  cli-block-description=An absolute or relative filename of a block descriptor or 
block jar file (required).
  
  cli-config-description=The filename of the block configuration.  If not specified 
the value defaults to a file name config.xml in the same directory as the block.
  
  cli-system-description=An absolute or relative path to the directory containining 
the /common and /lib system directories. If not supplied the default value shall 
correspond to the value System "user.work". A relative path name will be resolved 
relative the System "user.work" directory.
  
  
  
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/src/java/Resources_de.properties
  
  Index: Resources_de.properties
  ===================================================================
  
  directory=Verzeichnis
  file=Datei
  
  cli-help-description=Gibt diese Meldung aus.
  cli-language-description=Ein Sprachcode aus zwei Buchstaben (ISO-639).
  cli-version-description=Gibt die Systemversionsnummer von Merlin aus.
  cli-debug-description=Aktiviere Debug-Meldungen w\u00e4hrend der Bootstrap-Phase.
  cli-home-description=Ein relativer oder absoluter Pfad zu einem 
Arbeitswurzelverzeichnis. Wenn der Pfad nicht existiert, wird er angelegt.
  cli-system-description=Ein relativer oder absoluter Pfad zu dem Verzeichnis, das die 
Systemverzeichnisse /commonn und /lib enth\u00e4lt. Wenn der Wert nicht angegeben 
wird, wird als Standardwert der Wert der Systemvariablen "user.work" verwendet. Ein 
relativer Pfad wird relativ zum Systemverzeichnis "user.work" aufgel\u00f6st.
  cli-profile-description=Ein relativer oder absoluter Dateiname einer Konfiguration, 
die die Kernel- und Block-Deployment-Information ent\u00e4lt. Wenn der angegebene 
Dateiname relativ ist, wird er relativ zum Wurzelverzeichnis aufgel\u00f6st. Wenn 
keine Datei angegeben ist, versucht das Sytsem eine Datei "profile.xml" im 
Wurzelverzeichnis zu finden.
  
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/src/java/Resources_fr.properties
  
  Index: Resources_fr.properties
  ===================================================================
  directory=annuaire
  file=dossier
  
  cli-help-description=Imprime ce message.
  
  cli-language-description=Un code de pays de deux lettres.
  
  cli-version-description=Imprime le version de systeme de Merlin.
  
  cli-debug-description=Presentation des messages debug pendant la phase 
d'initialisation.
  
  cli-home-description=Un chemin relatif ou absolu a un repertoire local de 
fonctionnement. Si non fourni la valeur par defaut correspondra au repertoire local. 
Un nom releative de chemin sera parent resolu par le repertoire local.
  
  cli-system-description=Un chemin absolu ou relatif a l'annuaire contenant les 
annuaires de systeme de /common et de /lib. Si non fourni la valeur par defaut 
correspondra a la valeur propriete du repertoire local. Un chemin relatif sera parent 
resolu annuaire du repertoire local.
  
  cli-profile-description=Un nom de fichier absolu ou relatif d'une configuration 
contenant l'information d'deploiement. Si le nom de fichier fourni est relatif il 
resolu relativement au repertoire local. Si non fourni, le systeme essayera de 
localiser un dossier appele "profile.xml" dans le repertoire local.
  
  
  
  1.1                  avalon-sandbox/kernel/bootstrap/src/java/package.html
  
  Index: package.html
  ===================================================================
  <body>
  <a name="description"><h3>Description</h3></a>
  <p>The Merlin system is established through a bootstrap loader.  To startup Merlin 
from the command line you use either of the commands listed below.  These command 
handle the establishment of the system directory, the working home directory, and the 
filename of the deployment profile.</p>
  
  <pre>
     java -classpath %MERLIN_HOME%\lib\merlin-bootstrap-1.0.jar Merlin -profile 
&lt;profile&gt;
  
     java -jar %MERLIN_HOME%\lib\merlin-bootstrap-1.0.jar -profile &lt;profile&gt;
  </pre>
  
  <p>
  To validate your instalation try running the demo deployment profile using the 
following command line:
  </p>
  <pre>
     java -jar %MERLIN_HOME%\lib\merlin-bootstrap-1.0.jar -profile config/demo.xml
  </pre>
  <p>
  Information concerning command line options are available using the -help option.
  </p>
  <pre>
     java -jar %MERLIN_HOME%\lib\merlin-bootstrap-1.0.jar -help 
  </pre>
  </body>
  
  
  

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

Reply via email to