mcconnell    2003/02/12 03:51:18

  Added:       merlin-bootstrap .cvsignore build.xml default.properties
               merlin-bootstrap/lib commons-cli-1.0.jar
                        excalibur-i18n-1.0.jar
               merlin-bootstrap/src/etc manifest.mf
               merlin-bootstrap/src/java BootstrapRuntimeException.java
                        Merlin.java Resources.properties
                        Resources_fr.properties package.html
  Log:
  Initial commit of the Merlin bootstrap resources (content seperated out from 
main Merlin project).
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/merlin-bootstrap/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  ant.properties
  build
  project.xml
  project.properties
  maven.xml
  maven.log
  velocity.log
  kernel.log
  target
  
  
  1.1                  avalon-sandbox/merlin-bootstrap/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!--  
  Copyright (C) The Apache Software Foundation. All rights reserved.
  This software is published under the terms of the Apache Software License
  version 1.1, a copy of which has been included with this distribution in
  the LICENSE.txt file.
  
  @author  Avalon Development Team
  @version 1.0 12/03/2001
  -->
  
  <project name="merlin-bootstrap" default="main" basedir=".">
  
    <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="${commons-cli.jar}"/>
      <pathelement location="${excalibur-i18n.jar}"/>
    </path>
  
    <target name="main" depends="jar" description="Build the bootstrap jar 
file."/>
    <target name="rebuild" depends="clean,main" description="Rebuild the 
project."/>
  
    <target name="context">
      <mkdir dir="${lib.dir}"/>
      <uptodate property="uptodate" targetfile="${build.lib}/${jar.name}">
        <srcfiles dir="${src.dir}">
          <include name="**/*.*"/>
        </srcfiles>
        <srcfiles dir="${lib.dir}">
          <include name="**/*.*"/>
        </srcfiles>
      </uptodate>
    </target>
  
    <!-- Compiles the bootstrap source code -->
    <target name="compile" depends="context" 
         description="Compiles the bootstrap source code" unless="uptodate">
      
      <echo message="compiling bootstrap"/>
  
      <mkdir dir="${build.classes}"/>
  
      <javac srcdir="${java.dir}"
         destdir="${build.classes}"
         debug="${build.debug}"
         optimize="${build.optimize}"
         deprecation="${build.deprecation}"
         target="1.2">
        <src path="${java.dir}" />
        <classpath refid="project.class.path" />
      </javac>
  
    </target>
  
    <!--
    Creation of the bootstrap jar file.  This contains the Excalibut i18n 
classes and the 
    commons CLI classes together with a Merlin bootstrap and related i18n 
resource class.
    -->
  
    <target name="jar" depends="compile" 
        description="Generates the jar files" unless="uptodate">
  
      <mkdir dir="${build.lib}"/>
  
      <unzip src="${excalibur-i18n.jar}" dest="${build.classes}"/>
      <unzip src="${commons-cli.jar}" dest="${build.classes}"/>
  
      <copy todir="${build.classes}">
        <fileset dir="${java.dir}">
          <include name="*.properties"/>
        </fileset>
      </copy>
  
      <jar jarfile="${build.lib}/${jar.name}"
         basedir="${build.classes}"
         compress="${build.compress}" >
  
        <exclude name="META-INF/**/*.*"/>
  
        <manifest>
          <attribute name="Main-Class" value="Merlin"/>
        </manifest>
  
      </jar>
  
    </target>
  
    <!-- Creates all the Javadocs -->
    <target name="javadocs" depends="compile" 
            description="Generates the javadocs" unless="skip.javadocs">
      <mkdir dir="${build.javadocs}"/>
      <javadoc sourcepath="${java.dir}" packagenames="*,*.*"
             destdir="${build.javadocs}" overview="${java.dir}/package.html">
        <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="-bottom"
             value="&quot;Copyright &#169; ${year} Apache Avalon Project. All 
Rights Reserved.&quot;"/>
        </doclet>
      </javadoc>
    </target>
  
    <!-- Cleans up build and distribution directories -->
    <target name="clean" description="Cleans up the project">
      <delete dir="${build.dir}" />
    </target>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/merlin-bootstrap/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
  
  codename=merlin-bootstrap
  name=avalon-${codename}
  Name=Merlin CLI Bootstrap
  dir-name=merlin-bootstrap
  version=1.0
  package-version=1.0
  year=2003
  
  # --------------------------------------------------
  #  directory structure
  # --------------------------------------------------
  
  src.dir = src
  java.dir = ${src.dir}/java
  etc.dir = ${src.dir}/etc
  lib.dir = lib
  dist.dir = dist
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  # ----- Library jars -----
  commons-cli.jar=${lib.dir}/commons-cli-1.0.jar
  
  # ----- Excalibur i18n -----
  excalibur-i18n.jar=${lib.dir}/excalibur-i18n-1.0.jar
  
  # --------------------------------------------------
  
  #  Settings used to configure compile environment
  build.debug = off
  build.optimize = on
  build.deprecation = on
  build.compress = true
  
  #  location of intermediate products
  build.dir = build
  build.lib = ${build.dir}/lib
  build.classes = ${build.dir}/classes
  build.docs = ${build.dir}/docs
  build.javadocs = ${build.docs}/api
  
  #  name of jar file
  jar.name = ${name}-${package-version}.jar
  
  
  
  1.1                  avalon-sandbox/merlin-bootstrap/lib/commons-cli-1.0.jar
  
        <<Binary file>>
  
  
  1.1                  
avalon-sandbox/merlin-bootstrap/lib/excalibur-i18n-1.0.jar
  
        <<Binary file>>
  
  
  1.1                  avalon-sandbox/merlin-bootstrap/src/etc/manifest.mf
  
  Index: manifest.mf
  ===================================================================
  Manifest-Version: 1.0
  Created-By: Apache Avalon
  Main-Class: Merlin
  
  
  1.1                  
avalon-sandbox/merlin-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:dev@avalon.apache.org";>Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/02/12 11:51:18 $
   */
  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 }, 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[] 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/merlin-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.FileInputStream;
  import java.io.IOException;
  import java.io.FileNotFoundException;
  import java.io.InputStream;
  import java.util.Properties;
  import java.util.Date;
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Locale;
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.lang.reflect.Constructor;
  
  import org.apache.commons.cli.Option;
  import org.apache.commons.cli.Options;
  import org.apache.commons.cli.OptionBuilder;
  import org.apache.commons.cli.CommandLineParser;
  import org.apache.commons.cli.BasicParser;
  import org.apache.commons.cli.ParseException;
  import org.apache.commons.cli.HelpFormatter;
  import org.apache.commons.cli.CommandLine;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * Merlin commandline bootstrap handler.
   */
  public class Merlin
  {
  
      
//--------------------------------------------------------------------------
      // static
      
//--------------------------------------------------------------------------
  
      private static final String PRODUCT = "Merlin";
  
      private static final String VERSION = "2.1";
  
      private static final File HOME = new File( System.getProperty( "user.dir" 
) );
  
      private static final String MERLIN_KERNEL_LOADER_CLASSNAME = 
        "org.apache.avalon.merlin.kernel.impl.KernelLoader";
  
      private static Resources I18N =
          ResourceManager.getPackageResources( Merlin.class );
  
      private static Options CL_OPTIONS = buildCommandLineOptions();
  
      private static URLClassLoader CLASSLOADER;
      private static URLClassLoader COMMON;
  
      private static File BASE;
      private static File PROFILE;
  
      private static Options buildCommandLineOptions()
      {
          // create Options object 
          Options options = new Options();
  
          Option help = new Option( 
             "help", 
             I18N.getString( "cli-help-description" ) );
  
          Option version = new Option( 
             "version", 
             I18N.getString( "cli-version-description" ) );
  
          Option debug = new Option( 
             "debug", 
             I18N.getString( "cli-debug-description" ) );
  
          Option locale = OptionBuilder
             .hasArg()
             .withArgName( "code" )
             .withDescription( I18N.getString( "cli-language-description" )  )
             .create( "lang" );
  
          Option home = OptionBuilder
             .hasArg()
             .withArgName( I18N.getString( "directory" ) )
             .withDescription( I18N.getString( "cli-home-description" ) )
             .create( "home" );
  
          Option system = OptionBuilder
             .hasArg()
             .withArgName( I18N.getString( "directory" ) )
             .withDescription( I18N.getString( "cli-system-description" ) )
             .create( "system" );
  
          Option profile = OptionBuilder
             .hasArg()
             .withArgName( I18N.getString( "file" ) )
             .withDescription( I18N.getString( "cli-profile-description" ) )
             .create( "profile" );
  
          options.addOption( help );
          options.addOption( version );
          options.addOption( debug );
          options.addOption( system );
          options.addOption( home );
          options.addOption( profile );
          options.addOption( locale );
  
          return options;
          
      }
  
      
//--------------------------------------------------------------------------
      // state
      
//--------------------------------------------------------------------------
  
     /**
      * Command line entry point to the Merlin system.
      * The main method handles the establishment of a bootstrap classloader, 
      * installation directory and base working directory from which a root 
      * [EMAIL PROTECTED] Kernel} is instantiated.
      *
      * @param args a set command line arguments
      * @see DefaultKernel
      */
      public static void main( String[] args )
      {
          CommandLineParser parser = new BasicParser();
          try
          {
              CommandLine line = parser.parse( CL_OPTIONS, args );
  
              if( line.hasOption( "lang" ) )
              {
                  ResourceManager.clearResourceCache();
                  String language = line.getOptionValue( "lang" );
                  Locale locale = new Locale( language );
                  Locale.setDefault( locale );
                  I18N = ResourceManager.getPackageResources( Merlin.class );
                  CL_OPTIONS = buildCommandLineOptions();
              }
  
              if( line.hasOption( "help" ) )
              {
                  doHelp();
                  return;
              }
  
              if( line.hasOption( "version" ) )
              {
                  System.out.println( getVersionString() );
                  return;
              }
  
              //
              // it's this is a genuine deployment scenario - we need to resolve
              // the home and system directories, and the filename of the kernel
              // profile we are using
              //
  
              File home = getHomePath( line );
              File system = getSystemPath( line );
              File profile = getProfile( home, line );
  
              if( !profile.exists() )
              {
                  File base = profile.getParentFile();
                  if( !base.exists() )
                  {
                      final String error = 
                        "Deployment path directory does not exist.\ndirectory: 
" + base;
                      throw new IllegalArgumentException( error );
                  }
                  else
                  {
                      final String error = 
                        "Deployment profile does not exist\nfile: " + profile;
                      throw new IllegalArgumentException( error );
                  }
              }
  
              if( !system.exists() )
              {
                  final String error = 
                    "System directory does not exist.\ndirectory: " + system;
                      throw new IllegalArgumentException( error );
              }
  
              if( !home.exists() )
              {
                  final String error = 
                    "Home directory does not exist.\ndirectory: " + home;
                      throw new IllegalArgumentException( error );
              }
  
              //
              // if we get this far we have a valid system, home and profile
              // so we can not go ahead with bootstrap classpath construction
              //
  
              BASE = home;
              PROFILE = profile;
              boolean debug = line.hasOption( "debug" );
              if( debug )
              {
                  System.out.println( "\n  " + getVersionString()  );
                  System.out.println( "  " + new Date()  );
                  System.out.println( "\n  urn:merlin:system.dir: " + system  );
                  System.out.println( "  urn:merlin:system.profile: " + profile 
);
                  System.out.println( "  urn:merlin:home.dir: " + home );
              }
  
              File common = new File( system, "common" );
              URL[] targets = getJarFiles( common );
              COMMON = new URLClassLoader( targets );
              if( debug )
              {
                  System.out.println( "\n  shared libraries:\n" );
                  for( int i=0; i<targets.length; i++ )
                  {
                      System.out.println("  " + targets[i] );
                  }
              }
              
              File lib = new File( system, "lib" );
              URL[] libs = getJarFiles( lib );
              CLASSLOADER = new URLClassLoader( libs, COMMON );
              if( debug )
              {
                  System.out.println( "\n  system libraries:\n" );
                  for( int i=0; i<libs.length; i++ )
                  {
                      System.out.println("  " + libs[i] );
                  }
              }
  
              if( debug )
              {
                  System.out.println( "\n" );
              }
  
              Thread.currentThread().setContextClassLoader( CLASSLOADER );
  
          }
          catch( ParseException e )
          {
              final String error = "\n" + e.getMessage();
              System.err.println( error );
              return;
          }
          catch( FileNotFoundException e )
          {
              final String error = "\n" + e.getMessage();
              System.err.println( error );
              return;
          }
          catch( IllegalArgumentException e )
          {
              final String error = "\n" + e.getMessage();
              System.err.println( error );
              return;
          }
          catch( IOException e )
          {
              final String error = "\n" + e.toString();
              System.err.println( error );
              return;
          }
  
          Object kernelLoader = null;
          Class clazz;
          try
          {
              clazz = CLASSLOADER.loadClass( MERLIN_KERNEL_LOADER_CLASSNAME );
          }
          catch( Throwable e )
          {
              final String error = 
                "Internal error during loader class creation.";
              throw new BootstrapRuntimeException( error, e );
          }
  
          try
          {
              Constructor constructor = clazz.getConstructor(
                  new Class[]{ClassLoader.class, ClassLoader.class, File.class, 
File.class } );
              kernelLoader = constructor.newInstance( new Object[]{ 
CLASSLOADER,  COMMON, BASE, PROFILE } );
          }
          catch( Throwable e )
          {
              final String error = 
                "Internal error during loader instantiation.";
              e.printStackTrace();
              throw new BootstrapRuntimeException( error, e );
          }
      }
  
      private static String getVersionString()
      {
           return PRODUCT + " " + VERSION;
      }
  
      private static void doHelp()
      {
          HelpFormatter formatter = new HelpFormatter();
          formatter.printHelp( "merlin", CL_OPTIONS );
      }
  
      private static File getProfile( File home, CommandLine command ) throws 
IOException
      {
          boolean flag = false;
          String filename = null;
          final String key = "profile"; 
          if( command.hasOption( key ) )
          {
              filename = command.getOptionValue( key );
          }
          else
          {
              flag = true;
              filename = "profile.xml";
          }
  
          try
          {
              File file = getFile( home, filename );
              if( !file.isFile() )
              {
                  final String error = 
                    "Supplied profile argument does not refer to a file: " + 
file;
              }
              return file;
          }
          catch( FileNotFoundException fnfe )
          {
              String error =
                "Could not locate profile: " + filename + " is the home 
directory: " + home;
              throw new FileNotFoundException( error );
          }
      }
  
      private static File getHomePath( CommandLine command ) throws IOException
      {
          String path = null;
          File file = null;
          final String key = "home"; 
          if( command.hasOption( key ) )
          {
              path = command.getOptionValue( key );
              file = getFile( HOME, path );
          }
          else
          {
              file = HOME;
          }
          return file;
      }
  
      private static File getSystemPath( CommandLine command ) throws 
IOException
      {
          File file = getSysPath( command );
          if( !file.exists() )
          {
              final String error = 
                "Supplied system path does not exist: " + file;
              throw new IllegalArgumentException( error );
          }
          if( !file.isDirectory() )
          {
              final String error = 
                "Supplied system path does not refer to a directory: " + file;
              throw new IllegalArgumentException( error );
          }
          File common = new File( file, "common" );
          if( !common.exists() )
          {
              final String error = 
                "Supplied system path does not contain a 'common' subdirectory: 
" + file;
              throw new IllegalArgumentException( error );
          }
          File lib = new File( file, "lib" );
          if( !lib.exists() )
          {
              final String error = 
                "Supplied system path does not contain a 'lib' subdirectory: " 
+ file;
              throw new IllegalArgumentException( error );
          }
          return file;
      }
  
      private static File getSysPath( CommandLine command ) throws IOException
      {
          String path = null;
          final String key = "system"; 
          if( command.hasOption( key ) )
          {
              path = command.getOptionValue( key );
              try
              {
                  return getFile( HOME, path );
              }
              catch( FileNotFoundException fnfe )
              {
                  final String error = 
                   "Supplied home path does not exist: " + path;
                  throw new FileNotFoundException( error );
              }
          }
          else
          {
              return HOME;
          }
      }
  
      private static File getFile( File base, String path ) throws IOException
      {
          if( path == null )
          {
              throw new NullPointerException( "path" );
          }
          if( base == null )
          {
              throw new NullPointerException( "base" );
          }
  
          File file = new File( path );
          if( file.isAbsolute() )
          {
              return file.getCanonicalFile();
          }
          else
          {
              return new File( base, path ).getCanonicalFile();
          }
      }
  
      private static URL[] getJarFiles( File base )
      {
          List list = new ArrayList();
          populateJars( list, base );
          return (URL[]) list.toArray( new URL[0] );
      }
  
      private static void populateJars( List list, File base )
      {
          try
          {
              File[] files = base.listFiles();
              for( int i=0; i<files.length; i++ )
              {
                  File file = files[i];
                  if( file.getName().endsWith( ".jar" ) )
                  {
                      list.add( file.toURL() );
                  }
              }
          }
          catch( Throwable e )
          {
              final String error =
                "Unexpected error while scanning files in common directory: " + 
base;
              throw new RuntimeException( error, e );
          }
      }
  
  }
  
  
  
  1.1                  
avalon-sandbox/merlin-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-version-description=Prints the Merlin system version number.
  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-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.
  cli-profile-description=An absolute or relative filename of a configuration 
containing the kernel and block deployment information. If the supplied 
filename is relative it will resolved relative to the home directory. If not 
supplied, the system will attempt to locate a file named "profile.xml" in the 
home directory.
  
  
  
  
  1.1                  
avalon-sandbox/merlin-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/merlin-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