avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/kernel/test/src/test/org/apache/avalon/merlin MerlinEmbeddedTest.java
Date Sun, 30 Nov 2003 05:55:30 GMT
mcconnell    2003/11/29 21:55:30

  Modified:    kernel   maven.xml
               kernel/impl project.xml
               kernel/test project.xml
               kernel/test/src/test/org/apache/avalon/merlin
                        MerlinEmbeddedTest.java
  Added:       kernel/api .cvsignore maven.xml project.xml
               kernel/api/src/java/org/apache/avalon/merlin Kernel.java
                        KernelController.java KernelException.java
                        KernelRuntimeException.java
               kernel/impl project.properties
               kernel/impl/src/java/org/apache/avalon/merlin/impl
                        DefaultCriteria.java DefaultFactory.java
                        Resources.properties package.html
               kernel/spi .cvsignore maven.xml project.xml
               kernel/spi/src/java/org/apache/avalon/merlin/criteria
                        KernelCriteria.java
  Log:
  Synchronization of Merlin with the repository API/SPI.
  
  Revision  Changes    Path
  1.6       +1 -1      avalon-sandbox/kernel/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/kernel/maven.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- maven.xml	24 Nov 2003 21:26:36 -0000	1.5
  +++ maven.xml	30 Nov 2003 05:55:29 -0000	1.6
  @@ -1,4 +1,4 @@
  -<project default="merlin:build" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util" xmlns:ant="jelly:ant">
  +<project default="avalon:build" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util" xmlns:ant="jelly:ant">
   
     <maven:snapshot project="${pom}"/>
   
  
  
  
  1.1                  avalon-sandbox/kernel/api/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  *.log
  build.properties
  repository
  .classpath
  .project
  target
  
  
  1.1                  avalon-sandbox/kernel/api/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">
  
  </project>
  
  
  
  1.1                  avalon-sandbox/kernel/api/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <project>
  
    <extend>${basedir}/../project.xml</extend>
  
    <groupId>merlin</groupId>
    <id>merlin-api</id>
    <name>Merlin API</name>
    <package>org.apache.avalon.merlin</package>
  
    <currentVersion>3.2.2-dev</currentVersion>
    <inceptionYear>2002</inceptionYear>
    <shortDescription>Merlin API</shortDescription>
  
    <description>
  Merlin service management platform.
    </description>
  
    <dependencies>
      <dependency>
        <groupId>avalon-framework</groupId>
        <artifactId>avalon-framework-api</artifactId>
        <version>4.1.5</version>
      </dependency>
      <dependency>
        <groupId>avalon-repository</groupId>
        <artifactId>avalon-repository-api</artifactId>
        <version>1.2-dev</version>
      </dependency>
      <dependency>
        <groupId>avalon-composition</groupId>
        <artifactId>avalon-composition-api</artifactId>
        <version>1.2-dev</version>
      </dependency>
      <dependency>
        <groupId>avalon-activation</groupId>
        <artifactId>avalon-activation-api</artifactId>
        <version>1.2-dev</version>
      </dependency>
    </dependencies>
    
  </project>
  
  
  
  1.1                  avalon-sandbox/kernel/api/src/java/org/apache/avalon/merlin/Kernel.java
  
  Index: Kernel.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 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.avalon.merlin;
  
  import org.apache.avalon.activation.appliance.Block;
  import org.apache.avalon.composition.model.ContainmentModel;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * A Kernel is the root of a containment solution. This interfaces 
   * defines the contract for any kernel implementation covering 
   * management aspects and service resolution aspects.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/11/30 05:55:30 $
   */
  public interface Kernel extends KernelController
  {
     /**
      * Return the root containment model.
      * @return the containment model
      */
      ContainmentModel getContainmentModel();
  
     /**
      * Return the block matching the supplied model.
      * @return the containment block
      */
      Block getBlock( ContainmentModel model ) throws KernelException;
  
     /**
      * Return the root block.
      * @return the containment block
      */
      Block getRootBlock();
  
     /**
      * Return the Logger for the specified category.
      * @param category the category path
      * @return the logging channel
      */
      Logger getLoggerForCategory( final String category );
  }
  
  
  
  1.1                  avalon-sandbox/kernel/api/src/java/org/apache/avalon/merlin/KernelController.java
  
  Index: KernelController.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 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.avalon.merlin;
  
  /**
   * The Controller interface defines a subset of management operations exposed by
   * a kernel implementation.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/11/30 05:55:30 $
   */
  public interface KernelController
  {
     /**
      * Initiate the establishment of the root container.
      */
      void startup() throws Exception;
  
     /**
      * Initiate an orderly shutdown of the kernel.
      */
      void shutdown();
  
  }
  
  
  
  1.1                  avalon-sandbox/kernel/api/src/java/org/apache/avalon/merlin/KernelException.java
  
  Index: KernelException.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 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.avalon.merlin;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate that there was an error relating to kernel execution.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/11/30 05:55:30 $
   */
  public class KernelException
      extends CascadingException
  {
  
      /**
       * Construct a new <code>KernelException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public KernelException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>KernelException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public KernelException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/kernel/api/src/java/org/apache/avalon/merlin/KernelRuntimeException.java
  
  Index: KernelRuntimeException.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 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.avalon.merlin;
  
  import org.apache.avalon.framework.CascadingRuntimeException;
  
  /**
   * Exception to indicate that there was a runtime error related to the kernel.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/11/30 05:55:30 $
   */
  public final class KernelRuntimeException
      extends CascadingRuntimeException
  {
  
      /**
       * Construct a new <code>KernelRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public KernelRuntimeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>KernelRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public KernelRuntimeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.11      +13 -10    avalon-sandbox/kernel/impl/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/kernel/impl/project.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- project.xml	27 Nov 2003 00:00:13 -0000	1.10
  +++ project.xml	30 Nov 2003 05:55:30 -0000	1.11
  @@ -5,13 +5,13 @@
     <extend>${basedir}/../project.xml</extend>
   
     <groupId>merlin</groupId>
  -  <id>merlin-kernel-impl</id>
  -  <name>Merlin Kernel Implementation</name>
  +  <id>merlin-impl</id>
  +  <name>Merlin Implementation</name>
     <package>org.apache.avalon.merlin</package>
   
     <currentVersion>3.2.2-dev</currentVersion>
     <inceptionYear>2002</inceptionYear>
  -  <shortDescription>Merlin Kernel Implementation</shortDescription>
  +  <shortDescription>Merlin Implementation</shortDescription>
   
     <description>
   Merlin service management platform.
  @@ -36,12 +36,20 @@
   
       <dependency>
         <groupId>merlin</groupId>
  -      <artifactId>merlin-kernel-spi</artifactId>
  -      <version>3.2-dev</version>
  +      <artifactId>merlin-api</artifactId>
  +      <version>3.2.2-dev</version>
         <properties>
           <avalon.classloader>api</avalon.classloader>
         </properties>
       </dependency>
  +    <dependency>
  +      <groupId>merlin</groupId>
  +      <artifactId>merlin-spi</artifactId>
  +      <version>3.2.2-dev</version>
  +      <properties>
  +        <avalon.classloader>spi</avalon.classloader>
  +      </properties>
  +    </dependency>
   
       <!-- avalon dependecies -->
   
  @@ -82,11 +90,6 @@
         <properties>
           <avalon.classloader>spi</avalon.classloader>
         </properties>
  -    </dependency>
  -    <dependency>
  -      <groupId>avalon-repository</groupId>
  -      <artifactId>avalon-repository-impl</artifactId>
  -      <version>1.2-dev</version>
       </dependency>
   
       <dependency>
  
  
  
  1.1                  avalon-sandbox/kernel/impl/project.properties
  
  Index: project.properties
  ===================================================================
  #
  # factory class
  #
  avalon.artifact.factory = org.apache.avalon.merlin.impl.DefaultFactory
  
  
  
  
  
  1.1                  avalon-sandbox/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultCriteria.java
  
  Index: DefaultCriteria.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 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.avalon.merlin.impl;
  
  import java.io.File;
  import java.io.InputStream;
  import java.io.IOException;
  import java.net.URL;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Properties;
  import java.util.ArrayList;
  import java.util.Map;
  
  import org.apache.avalon.merlin.criteria.KernelCriteria;
  import org.apache.avalon.merlin.KernelRuntimeException;
  
  import org.apache.avalon.repository.RepositoryException;
  import org.apache.avalon.repository.criteria.Criteria;
  import org.apache.avalon.repository.criteria.ValidationException;
  import org.apache.avalon.repository.criteria.Parameter;
  
  import org.apache.avalon.util.defaults.Defaults;
  import org.apache.avalon.util.defaults.DefaultsFinder;
  import org.apache.avalon.util.defaults.SimpleDefaultsFinder;
  import org.apache.avalon.util.defaults.SystemDefaultsFinder;
  import org.apache.avalon.util.env.Env;
  import org.apache.avalon.util.env.EnvAccessException;
  import org.apache.avalon.util.exception.ExceptionHelper;
  
  /**
   * A Criteria is a class holding the values supplied by a user 
   * for application to a factory.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $
   */
  public class DefaultCriteria extends Criteria implements KernelCriteria
  {
      //--------------------------------------------------------------
      // static
      //--------------------------------------------------------------
  
      private static final String AVALON = "/avalon.properties";
      private static final String MERLIN = "/merlin.properties";
  
      private static final String [] SINGLE_KEYS = {
             MERLIN_REPOSITORY.getKey(),
             MERLIN_HOME.getKey(),
             MERLIN_SYSTEM.getKey(),
             MERLIN_CONFIG.getKey(),
             MERLIN_KERNEL.getKey(),
             MERLIN_DIR.getKey(),
             MERLIN_CONTEXT.getKey(),
             MERLIN_EXT.getKey(),
             MERLIN_INFO.getKey(),
             MERLIN_DEBUG.getKey(),
             MERLIN_SERVER.getKey() };
  
      private static final String[] MULTI_VALUE_KEYS = new String[0];
  
      //--------------------------------------------------------------
      // state
      //--------------------------------------------------------------
  
       private final Hashtable m_bindings = new Hashtable();
  
      //--------------------------------------------------------------
      // constructor
      //--------------------------------------------------------------
  
     /**
      * Creation of a new default kernel criteria.
      */
      public DefaultCriteria()
      {
          super( PARAMS );
  
          Properties avalon = getStaticProperties( AVALON );
          Properties merlin = getStaticProperties( MERLIN );
          Properties env = getEnvinronment();
          Properties system = System.getProperties();
  
          printProperties( avalon, "avalon" );
          printProperties( merlin, "merlin" );
          printProperties( env, "environment" );
  
          //
          // Create the finder (discovery policy), construct the defaults, and
          // macro expand the values.
          //
  
          final DefaultsFinder[] finders = 
            new DefaultsFinder[]{
              new SimpleDefaultsFinder( 
                new Properties[] { merlin, avalon, env }, 
                false ), 
              new SystemDefaultsFinder() 
            };
          
          Defaults defaults = new Defaults( SINGLE_KEYS, MULTI_VALUE_KEYS, finders );
          printProperties( defaults, "defaults (unresolved)" );
          Defaults.macroExpand( defaults, new Properties[]{ system, avalon, env } );
          Defaults.macroExpand( defaults, new Properties[]{ system, avalon, env } );
          printProperties( defaults, "defaults (resolved)" );
          System.out.print( "" );
  
          //
          // following aquistion of the default parameters we need to assign
          // them as criteria values before we expose the criteria instance to the
          // client
          //
  
          ArrayList errors = new ArrayList();
          for( int i=0; i<PARAMS.length; i++ )
          {
              Parameter param = PARAMS[i];
              final String key = param.getKey();
              try
              {
                  put( key, defaults.getProperty( key ));
              }
              catch( Exception re )
              {
                  errors.add( re );
              }
          }
  
          //
          // check for any errors created in the process and dump a 
          // notice to System.err
          //
  
          if( errors.size() > 0 )
          {
              Throwable[] throwables = 
                (Throwable[]) errors.toArray( new Throwable[0] );
              final String report = 
                "One or more errors occured while attempting to resolve defaults.";
              String message = 
                ExceptionHelper.packException( report, throwables, false );
              System.err.println( message );
          }
      }
  
      //--------------------------------------------------------------
      // Criteria
      //--------------------------------------------------------------
  
     /**
      * Return a string representation of the kernel criteria.
      * @return the criteria as a string
      */
      public String toString()
      {
          return "[merlin: " + super.toString() + "]";
      }
  
      //--------------------------------------------------------------
      // KernelCriteria
      //--------------------------------------------------------------
  
     /**
      * Return the root directory to the shared repository.
      * @return the avalon home root repository directory
      */
      public File getRepositoryDirectory()
      {
          return (File) get( MERLIN_REPOSITORY );
      }
  
     /**
      * Return the root directory to the merlin installation
      * @return the merlin home directory
      */
      public File getHomeDirectory()
      {
          return (File) get( MERLIN_HOME );
      }
  
     /**
      * Return the root directory to the merlin system repository
      * @return the merlin system repository directory
      */
      public File getSystemDirectory()
      {
          return (File) get( MERLIN_SYSTEM );
      }
  
     /**
      * Return the root directory to the merlin configurations
      * @return the merlin configuration directory
      */
      public File getConfigDirectory()
      {
          return (File) get( MERLIN_CONFIG );
      }
  
     /**
      * Return the url to the kernel confiuration
      * @return the kernel configuration url
      */
      public URL getKernelURL()
      {
          return (URL) get( MERLIN_KERNEL );
      }
  
     /**
      * Return the working client directory.
      * @return the working directory
      */
      public File getWorkingDirectory()
      {
          return (File) get( MERLIN_DIR );
      }
  
     /**
      * Return the temporary directory.
      * @return the temp directory
      */
      public File getTempDirectory()
      {
          return (File) get( MERLIN_TEMP );
      }
  
     /**
      * Return the context directory from which relative 
      * runtrime home directories will be established for 
      * components referencing urn:avalon:home
      *
      * @return the working directory
      */
      public File getContextDirectory()
      {
          return (File) get( MERLIN_CONTEXT );
      }
  
     /**
      * Return the anchor directory to be used when resolving 
      * library declarations in classload specifciations.
      *
      * @return the jar extension anchor directory
      */
      public File getExtensionDirectory()
      {
          return (File) get( MERLIN_EXT );
      }
  
     /**
      * Return info generation policy.  If TRUE the parameters 
      * related to deployment will be listed on startup. 
      *
      * @return the info policy
      */
      public boolean isInfoEnabled()
      {
          Boolean value = (Boolean) get( MERLIN_INFO );
          if( null != value ) return value.booleanValue();
          return false;
      }
  
     /**
      * Return debug policy.  If TRUE all logging channels will be 
      * set to debug level (useful for debugging).
      *
      * @return the debug policy
      */
      public boolean isDebugEnabled()
      {
          Boolean value = (Boolean) get( MERLIN_DEBUG );
          if( null != value ) return value.booleanValue();
          return false;
      }
  
     /**
      * Return server execution policy.  If TRUE the kernel will 
      * continue until explicitly terminated.  If FALSE the kernel
      * will initiate decommissioning on completion of deployment.
      *
      * @return the server execution mode
      */
      public boolean isServerEnabled()
      {
          Boolean value = (Boolean) get( MERLIN_SERVER );
          if( null != value ) return value.booleanValue();
          return false;
      }
  
      //--------------------------------------------------------------
      // internal
      //--------------------------------------------------------------
  
      private void printProperties( Properties properties, String label )
      {
          System.out.print( "\n------------ " + label.toUpperCase()
            + "--------------------------------".substring( label.length() ) + "\n\n" );
          if( null == properties ) return;
          Enumeration names = properties.propertyNames();
          while( names.hasMoreElements() )
          {
              String name = (String) names.nextElement();
              System.out.println( "   ${" + name + "} == " + properties.getProperty( name ) );
          }
      }
  
      private Properties getEnvinronment()
      {
          try
          {
              Properties properties = new Properties();
              setProperty( properties, "avalon.home", Env.getEnvVariable( "AVALON_HOME" ) );
              setProperty( properties, "maven.home", Env.getEnvVariable( "MAVEN_HOME" ) );
              setProperty( properties, "maven.home.local", Env.getEnvVariable( "MAVEN_HOME_LOCAL" ) );
              setProperty( properties, "merlin.home", Env.getEnvVariable( "MERLIN_HOME" ) );
              return properties;
          }
          catch( Throwable e )
          {
              final String error =
                "Internal error occured while attempting to access system environment.";
              throw new KernelRuntimeException( error, e );
          }
      }
  
      private void setProperty( Properties properties, String key, String value )
      {
          if( null != value ) properties.setProperty( key, value );
      }
  
     /**
      * Read in the static defined properties that contribute to 
      * the default context value establishment.
      *
      * @return the static default properties
      * @exception RepositoryException if a error occurs while attempt to 
      *    load the property resource
      */
      private Properties getStaticProperties( String path ) throws KernelRuntimeException
      {
          try
          {
              return Defaults.getStaticProperties( DefaultCriteria.class, path );
          }
          catch ( IOException e )
          {
              throw new KernelRuntimeException( 
               "Failed to load implementation defaults resource: "
               + path, e );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java
  
  Index: DefaultFactory.java
  ===================================================================
  
  
  package org.apache.avalon.merlin.impl;
  
  import java.io.File;
  import java.io.InputStream;
  import java.net.URL;
  import java.util.Map;
  import java.util.ArrayList;
  
  import org.apache.avalon.activation.appliance.Block;
  import org.apache.avalon.activation.appliance.Composite;
  import org.apache.avalon.activation.appliance.impl.AbstractBlock;
  import org.apache.avalon.activation.appliance.impl.DefaultServiceContext;
  
  import org.apache.avalon.composition.data.ContainmentProfile;
  import org.apache.avalon.composition.data.CategoriesDirective;
  import org.apache.avalon.composition.data.ContainmentProfile;
  import org.apache.avalon.composition.data.TargetDirective;
  import org.apache.avalon.composition.data.builder.XMLDeploymentProfileCreator;
  import org.apache.avalon.composition.data.builder.XMLContainmentProfileCreator;
  import org.apache.avalon.composition.logging.LoggingManager;
  import org.apache.avalon.composition.logging.LoggingDescriptor;
  import org.apache.avalon.composition.logging.TargetDescriptor;
  import org.apache.avalon.composition.logging.TargetProvider;
  import org.apache.avalon.composition.logging.impl.DefaultLoggingManager;
  import org.apache.avalon.composition.logging.impl.FileTargetProvider;
  import org.apache.avalon.composition.model.ContainmentContext;
  import org.apache.avalon.composition.model.ContainmentModel;
  import org.apache.avalon.composition.model.ModelFactory;
  import org.apache.avalon.composition.model.impl.DefaultSystemContext;
  import org.apache.avalon.composition.model.impl.DefaultModelFactory;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  
  import org.apache.avalon.merlin.KernelException;
  import org.apache.avalon.merlin.criteria.KernelCriteria;
  
  import org.apache.avalon.repository.Repository;
  import org.apache.avalon.repository.InitialContext;
  import org.apache.avalon.repository.criteria.Parameter;
  import org.apache.avalon.repository.criteria.Criteria;
  import org.apache.avalon.repository.criteria.ValidationException;
  import org.apache.avalon.repository.criteria.Factory;
  
  import org.apache.excalibur.configuration.ConfigurationUtil;
  import org.apache.excalibur.mpool.PoolManager;
  
  import org.xml.sax.InputSource;
  
  
  /**
   * The DefaultFactory provides support for the establishment of a 
   * new merlin kernel.
   */
  public class DefaultFactory implements Factory
  {
      //--------------------------------------------------------------------------
      // static
      //--------------------------------------------------------------------------
  
      private static Resources REZ =
          ResourceManager.getPackageResources( DefaultFactory.class );
  
      private static final String CATEGORY_NAME = "context";
  
      private static final XMLDeploymentProfileCreator CREATOR = 
        new XMLDeploymentProfileCreator();
  
      private static final XMLContainmentProfileCreator CONTAINER_CREATOR = 
        new XMLContainmentProfileCreator();
  
      //--------------------------------------------------------------------------
      // state
      //--------------------------------------------------------------------------
  
      private Logger m_logger;
  
      private Logger m_kernelLogger;
  
      private LoggingManager m_logging;
  
      private Repository m_repository;
  
      private InitialContext m_context;
  
      private PoolManager m_pool;
  
      private ContainmentContext m_root;
  
      private ModelFactory m_modelFactory;
  
      private ContainmentModel m_model;
  
      private Block m_block;
  
      //--------------------------------------------------------------------------
      // constructor
      //--------------------------------------------------------------------------
  
     /**
      * Creation of a new default factory.
      * @param factory the repository inital factory
      */
      public DefaultFactory( InitialContext context )
      {
          m_context = context;
      }
  
      //--------------------------------------------------------------------------
      // Factory
      //--------------------------------------------------------------------------
  
     /**
      * Return of map containing the default parameters.
      *
      * @return the default parameters 
      */
      public Map createDefaultCriteria()
      {
          return new DefaultCriteria();
      }
  
     /**
      * Creation of the root block within the container heirachy using 
      * the default parameters.
      *
      * @param map the parameters 
      * @return the root block instance
      * @exception Exception if an error occurs during root block establishment
      */
      public Object create() throws Exception
      {
          return create( createDefaultCriteria() );
      }
  
     /**
      * Creation of the root block within the container heirachy using 
      * the supplied parameters.
      *
      * @param map the parameters 
      * @return the root block instance
      * @exception Exception if an error occurs during root block establishment
      */
      public Object create( Map map ) throws Exception
      {
          if( null == map ) 
            throw new NullPointerException( "map" );
  
          KernelCriteria criteria = null;
          if( map instanceof KernelCriteria) 
          {
              criteria = (KernelCriteria) map;
          }
          else
          {
              final String error = 
               "Suppied map was not created by this factory. ";
              throw new IllegalArgumentException( error );
          }
  
          //
          // create the kernel configuration
          //
  
          URL kernelURL = (URL) criteria.getKernelURL();
          Configuration kernelConfig = getKernelConfiguration( kernelURL );
          String listing = ConfigurationUtil.list( kernelConfig );
          System.out.println( listing );
  
          //
          // create the logging subsystem
          //
  
          Configuration loggingConfig = kernelConfig.getChild( "logging" );
          LoggingDescriptor loggingDescriptor = createLoggingDescriptor( loggingConfig );
  
          m_logging = 
            new DefaultLoggingManager( 
              criteria.getWorkingDirectory(), 
              loggingDescriptor, 
              criteria.isDebugEnabled() );
  
          m_kernelLogger = m_logging.getLoggerForCategory( loggingDescriptor.getName() );
          m_logger = m_kernelLogger.getChildLogger( CATEGORY_NAME );
          getLogger().info( "logging system established" );
  
          //
          // create the common repository
          //
  
          Configuration repositoryConfig = kernelConfig.getChild( "repository" );
          File cache = criteria.getRepositoryDirectory();
          m_repository = createRepository( m_context, cache, repositoryConfig );
          getLogger().debug( "repository established: " + m_repository );
  
          //
          // setup the pool manager
          // TODO: an implementation following more thinking (pools should
          // probably be declared at the component directive level)
          //
  
          PoolManager m_pool = null;
  
  
          //
          // setup the model factory
          //
  
          try
          {
              m_modelFactory = new DefaultModelFactory( 
                new DefaultSystemContext( 
                  m_logging,
                  criteria.getExtensionDirectory(),
                  criteria.getContextDirectory(),
                  criteria.getTempDirectory(),
                  m_repository,
                  loggingDescriptor.getName(),
                  criteria.isDebugEnabled() ) );
              getLogger().info( "model factory established" );
          }
          catch( Throwable e )
          {
              final String error = 
                "Unexpected exception while creating internal model factory.";
              throw new KernelException( error, e );
          }
  
          //
          // create the root containment context
          //
  
          try
          {
              final ContainmentProfile profile = 
                CONTAINER_CREATOR.createContainmentProfile( 
                  kernelConfig.getChild( "container" ) );
              m_root = m_modelFactory.createContainmentContext( profile );
              Thread.currentThread().setContextClassLoader( m_root.getClassLoader() );
          }
          catch( Throwable e )
          {
              final String error = 
                "Internal error while build default containment context.";
              throw new KernelException( error, e );
          }
  
          //
          // create the root containment model
          //
  
          try
          {
              getLogger().debug( "construction phase" );
              m_model = m_modelFactory.createContainmentModel( m_root );
          }
          catch( Throwable e )
          {
              final String error = 
                "Internal error while build default containment model.";
              throw new KernelException( error, e );
          }
  
          //
          // we now have everything established such that we can add urls
          // to the root model
  
          try
          {
              DefaultServiceContext services = new DefaultServiceContext();
              services.put( PoolManager.ROLE, m_pool );
              services.put( LoggingManager.KEY, m_logging );
              m_block = AbstractBlock.createRootBlock( services, m_model );
              if( m_block instanceof Composite )
              {
                  try
                  {
                      getLogger().debug( "assembly phase" );
                      ((Composite)m_block).assemble();
                  }
                  catch( Throwable e )
                  {
                      final String error = 
                        "Assembly failure.";
                      throw new KernelException( error, e );
                  }
              }
          }
          catch( Throwable e )
          {
              final String error = 
                "Composition failure.";
              throw new KernelException( error, e );
          }
  
          return m_block;
      }
  
      private Repository createRepository( 
        InitialContext context, File root, Configuration config ) 
        throws KernelException
      {
  
          //
          // the supplied root argument is the root cache resolved relative
          // to system properties and environment variables.  This value is 
          // overriden if a cache is declared in the kernel repository 
          // configuration
          //
  
          File cache = getCacheDirectory( root, config.getChild( "cache" ) );
          String[] hosts = getHosts( config.getChild( "hosts" ) );
  
          try
          {
              Factory factory = context.getInitialFactory();
              Map criteria = factory.createDefaultCriteria();
              criteria.put( "avalon.repository.remote.url", hosts );
  
              Configuration proxyConfig = config.getChild( "proxy", false );
              if( null != proxyConfig )
              {
                  final String host = 
                    proxyConfig.getChild( "host" ).getValue( null );
                  criteria.put( "avalon.repository.proxy.host", hosts );
  
                  final int port = 
                    proxyConfig.getChild( "port" ).getValueAsInteger( 0 );
                  criteria.put( "avalon.repository.proxy.port", new Integer( port ) );
  
                  Configuration credentials = 
                    proxyConfig.getChild( "credentials", false );
                  if( credentials != null )
                  {
                      final String username = 
                        credentials.getChild( "username" ).getValue( null );
                      if( username == null )
                      {
                          final String error =
                            "Credentials configuration does not contain the required 'username' element."
                            + ConfigurationUtil.list( credentials );
                          throw new KernelException( error );                
                      }
                      else
                      {
                          criteria.put( "avalon.repository.proxy.username", username );
                      }
  
                      final String password = 
                          credentials.getChild( "password" ).getValue( null );
                      if( password == null )
                      {
                          final String error =
                            "Credentials configuration does not contain the required 'password' element."
                            + ConfigurationUtil.list( credentials );
                          throw new KernelException( error );                
                      }
                      else
                      {
                          criteria.put( "avalon.repository.proxy.password", password );
                      }
                  }
              }
  
              return (Repository) factory.create( criteria );
          }
          catch ( Throwable e )
          {
              final String error = 
                "Internal error while attempting to create the common repository "
                + " using the supplied cache: [" + cache + "].";
              throw new KernelException( error, e );
          }
      }
  
      private File getCacheDirectory( File cache, Configuration config )
      {
          String directive = config.getValue( null );
          if( null == directive ) return cache;
          return new File( directive );  
      }
  
      private String[] getHosts( Configuration config ) throws KernelException
      {
          ArrayList list = new ArrayList();
          Configuration[] hosts = config.getChildren( "host" );
          for( int i=0; i<hosts.length; i++ )
          {
              Configuration host = hosts[i];
              String path = host.getAttribute( "path", null );
              if( path == null )
              {      
                  final String error = 
                    "Missing host element value: " 
                  + ConfigurationUtil.list( host );
                  throw new KernelException( error );
              }
              else
              {
                  list.add( path );
              }
          }
          return (String[]) list.toArray( new String[0] );
      }
  
      /**
       * Utility method to create a new logging descriptor from a
       * configuration instance.
       * @param config a configuration defining the logging descriptor
       * @return the logging descriptor
       * @exception ConfigurationException if the configuration is
       *   incomplete
       */
      private LoggingDescriptor createLoggingDescriptor(
          Configuration config )
          throws KernelException
      {
          final String name = config.getAttribute( "name", "kernel" );
          CategoriesDirective categories = null;
          try
          {
              categories = CREATOR.getCategoriesDirective( config, name );
          }
          catch( Throwable e )
          {
              final String error =
                "Invalid logging directive.";
              throw new KernelException( error, e );
          }
  
          //
          // create any custom targets declared in the kernel directive
          //
  
          ArrayList list = new ArrayList();
          Configuration[] configs = config.getChildren( "target" );
          for( int i = 0; i < configs.length; i++ )
          {
              Configuration c = configs[ i ];
              try
              {
                  list.add( createTargetDescriptor( c ) );
              }
              catch( Throwable e )
              {
                  final String error = 
                    "Invalid target descriptor.";
                  throw new KernelException( error, e );
              }
          }
  
          TargetDescriptor[] targets =
              (TargetDescriptor[])list.toArray(
                  new TargetDescriptor[ 0 ] );
  
          //
          // return the logging descriptor
          //
  
          return new LoggingDescriptor(
            categories.getName(), 
            categories.getPriority(), 
            categories.getTarget(), 
            categories.getCategories(), 
            targets );
      }
  
  
     /**
      * Create the kernel configuration using a supplied url.  If the supplied
      * url is null the implementation will attempt to resolve a "/kernel.xml" 
      * resource within the deployment unit.
      *
      * @param url the location of the kernel confiuration
      * @return the kernel configuration
      * @exception if the configuration could not be resolved
      */
      private Configuration getKernelConfiguration( URL url ) throws Exception
      {
          if( null == url )
          {
              try
              {
                  return new DefaultConfiguration( 
                    "kernel", 
                    DefaultFactory.class.getName() );
              }
              catch( Throwable e )
              {
                  final String error = 
                    "Unable to build kernel configuration from the supplied url: " + url;
                  throw new KernelException( error, e );
              }
          }
  
          try
          {
              final InputStream stream =
              DefaultFactory.class.getClassLoader().getResourceAsStream( 
                "kernel.xml" );
              final InputSource source = new InputSource( stream );
              DefaultConfigurationBuilder builder = 
                new DefaultConfigurationBuilder();
              return builder.build( source );
          }
          catch( Throwable ee )
          {
              final String error = 
                "Internal error while attempting to build default kernel "
                + "configuration from the kernel spec: " + url;
              throw new KernelException( error, ee );
          }
      }
  
      private Logger getLogger()
      {
          return m_logger;
      }
  
      /**
       * Utility method to create a new target descriptor from a
       * configuration instance.
       * @param config a configuration defining the target descriptor
       * @return the logging target descriptor
       * @exception ConfigurationException if the configuration is
       *   incomplete
       */
      private TargetDescriptor createTargetDescriptor( Configuration config )
          throws ConfigurationException
      {
          final String name = config.getAttribute( "name" );
          if( config.getChildren().length == 0 )
          {
              throw new ConfigurationException(
                  "missing target provider element in '"
                  + config.getName() + "'." );
          }
  
          final Configuration c = config.getChildren()[ 0 ];
          TargetProvider provider = null;
          if( c.getName().equals( "file" ) )
          {
              provider = createFileTargetProvider( c );
          }
          else
          {
              throw new ConfigurationException(
                  "Unrecognized provider: " + c.getName() + " in " + config.getName() );
          }
          return new TargetDescriptor( name, provider );
      }
  
      /**
       * Utility method to create a new file target descriptor from a
       * configuration instance.
       * @param config a configuration defining the file target descriptor
       * @return the file target descriptor
       * @exception ConfigurationException if the configuration is
       *   incomplete
       */
      private FileTargetProvider createFileTargetProvider( Configuration config )
          throws ConfigurationException
      {
          String file = config.getAttribute( "location" );
          return new FileTargetProvider( file );
      }
  
  }
  
  
  
  1.1                  avalon-sandbox/kernel/impl/src/java/org/apache/avalon/merlin/impl/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  
  template-description=Merlin Service Manangement Platform.
  
  template-repository-dir=The root directory for the local application repository. This directory will used for the caching of artifacts such as jar files referenced by block include directives and classloader resource references.  If not supplied the default value resolves to ${merlin.home}/repository.
  
  template-library-dir=The directory used as the base anchor for resolution of relative path references for jar extension library directory statements in classloader directives. If not supplied the value defaults to the current working directory.
  
  template-home-dir=The directory used as the current directory. Logging files will be directed to the home directory by default (unless an alternative target is declared within the kernel). The default value is the current working directory ${user.dir}.
  
  template-base-dir=The directory used as the working base directory. Working and temporary directories are created relative to this directory in combination with the component partition name. The default value is the current working directory ${user.dir}.
  
  template-kernel-url=A optional url to a kernel configuration.
  
  template-info-policy=The info generation policy option. If TRUE a summary listing of the Merlin environment will be generated on system establishment.  This information is generally useful when validating current version information and configuration paths.
  
  template-debug-policy=The debug generation policy. If TRUE debug level logging is automatically enabled on all channels (typically only used when debugging an application).
  
  template-server-policy=The server mode execution policy. If TRUE the kernel will execute in server mode otherwise components will be decommissioned following deployment.
  
  
  
  url=url
  
  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=Print version information and return.
  
  cli-info-description=Lists info about the deployment context.
  
  cli-jmx-description=Bootstrap Merlin under a JMX server.
  
  cli-install-description=Install a block archive into the local repository.
  
  cli-debug-description=Enables debug mode.
  
  cli-home-description=A relative or absolute path to a working home directory. If not suppled, the system will default to the current directory.
  
  cli-kernel-description=The filename of a custom kernel profile.
  
  cli-block-description=An absolute or relative filename of a block descriptor or block jar file.
  
  cli-config-description=The filename of the configuration target override.
  
  cli-repository-description=An absolute or relative path to a alternative runtime repository.
  
  cli-library-description=A directory that serves as the anchor for relative library references.
  
  cli-description=\nDescription: The merlin command executes the deployment of one or more component blocks.  The [block] argument may be either an block descriptor file or a jar file containing a block descriptor.  If no value if declared, Merlin will attempt to execute a file named 'block.xml' in the current directory.
  
  
  
  1.1                  avalon-sandbox/kernel/impl/src/java/org/apache/avalon/merlin/impl/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The kernel package defines a top level Kernel implementation that serves as a host to a set 
  of blocks. The default kernel implementation handles the setup of supporting 
  infrastructure and deployment of declared blocks.
  </p>
  <p>
    <table border="1" cellpadding="3" cellspacing="0" width="100%">
      <tr bgcolor="#ccccff">
        <td colspan="2"><font size="+2"><b>Component Summary</b></font></td>
      <tr>
        <td width="20%" valign="top"><strong>
        {@link org.apache.avalon.merlin.kernel.impl.DefaultKernel}</strong></td>
        <td>A <code>{@link org.apache.avalon.merlin.kernel.Kernel}</code> implementation 
        that provides support the establishment, deployment and decommissioning of a set 
        of {@link org.apache.avalon.activation.appliance.Block } instances.</td></tr>
      </tr>
    </table>
  </p>
  </body>
  
  
  
  
  1.3       +3 -3      avalon-sandbox/kernel/spi/.cvsignore
  
  
  
  
  1.1                  avalon-sandbox/kernel/spi/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">
  
  </project>
  
  
  
  1.6       +11 -20    avalon-sandbox/kernel/spi/project.xml
  
  
  
  
  1.1                  avalon-sandbox/kernel/spi/src/java/org/apache/avalon/merlin/criteria/KernelCriteria.java
  
  Index: KernelCriteria.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 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.avalon.merlin.criteria;
  
  import java.net.URL;
  import java.io.File;
  import java.util.Map;
  
  import org.apache.avalon.repository.criteria.Parameter;
  
  
  /**
   * A service that provides access to versioned resources.
   * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2003/11/30 05:55:30 $
   */
  public interface KernelCriteria extends Map
  {
      File USER_DIR = new File( System.getProperty( "user.dir" ) );
      File TEMP_DIR = new File( System.getProperty( "java.io.tmpdir" ) );
      File AVALON_HOME_DIR = new File( USER_DIR, ".avalon" );
      File MERLIN_HOME_DIR = new File( USER_DIR, ".merlin" );
  
     /**
      * Shared application repository root directory.
      */
      public static final Parameter MERLIN_REPOSITORY = 
        new Parameter( 
          "merlin.repository",
          File.class.getName(),
          AVALON_HOME_DIR );
  
     /**
      * Repository parameter descriptor.
      */
      public static final Parameter MERLIN_HOME = 
        new Parameter( 
          "merlin.home",
          File.class.getName(),
          MERLIN_HOME_DIR );
  
     /**
      * Repository parameter descriptor.
      */
      public static final Parameter MERLIN_SYSTEM = 
        new Parameter( 
          "merlin.system",
          File.class.getName(),
          new File( MERLIN_HOME_DIR, "system" ) );
  
     /**
      * Repository parameter descriptor.
      */
      public static final Parameter MERLIN_CONFIG = 
        new Parameter( 
          "merlin.config",
          File.class.getName(),
          new File( MERLIN_HOME_DIR, "config" ) );
  
     /**
      * Library path parameter descriptor.
      */
      public static final Parameter MERLIN_KERNEL = 
        new Parameter( 
          "merlin.kernel",
          URL.class.getName(),
          null );
  
     /**
      * Home directory parameter descriptor.
      */
      public static final Parameter MERLIN_DIR = 
        new Parameter( 
          "merlin.dir",
          File.class.getName(),
          USER_DIR );
  
     /**
      * The temp directory parameter descriptor.
      */
      public static final Parameter MERLIN_TEMP = 
        new Parameter( 
          "merlin.temp",
          File.class.getName(),
          TEMP_DIR );
  
     /**
      * Base directory parameter descriptor.
      */
      public static final Parameter MERLIN_CONTEXT = 
        new Parameter( 
          "merlin.context",
          File.class.getName(),
          new File( USER_DIR, "home" ) );
  
     /**
      * Kernel url parameter descriptor.
      */
      public static final Parameter MERLIN_EXT = 
        new Parameter( 
          "merlin.ext",
          File.class.getName(),
          USER_DIR );
  
     /**
      * Info policy parameter descriptor.
      */
      public static final Parameter MERLIN_INFO = 
        new Parameter( 
          "merlin.info",
          Boolean.class.getName(),
          new Boolean( false ) );
  
     /**
      * Debug policy parameter descriptor.
      */
      public static final Parameter MERLIN_DEBUG = 
        new Parameter( 
          "merlin.debug",
          Boolean.class.getName(),
          new Boolean( false ) );
  
     /**
      * Server model parameter descriptor.
      */
      public static final Parameter MERLIN_SERVER = 
        new Parameter( 
          "merlin.server",
          Boolean.class.getName(),
          new Boolean( false ) );
  
     /**
      * The factory parameters template.
      */
      public static final Parameter[] PARAMS = 
        new Parameter[]{
             MERLIN_REPOSITORY,
             MERLIN_HOME,
             MERLIN_SYSTEM,
             MERLIN_CONFIG,
             MERLIN_KERNEL,
             MERLIN_DIR,
             MERLIN_TEMP,
             MERLIN_CONTEXT,
             MERLIN_EXT,
             MERLIN_INFO,
             MERLIN_DEBUG,
             MERLIN_SERVER };
  
     /**
      * Return the root directory to the shared repository.
      * @return the root common repository directory
      */
      File getRepositoryDirectory();
  
     /**
      * Return the root directory to the merlin installation
      * @return the merlin home directory
      */
      File getHomeDirectory();
  
     /**
      * Return the root directory to the merlin system repository
      * @return the merlin system repository directory
      */
      File getSystemDirectory();
  
     /**
      * Return the root directory to the merlin configurations
      * @return the merlin configuration directory
      */
      File getConfigDirectory();
  
     /**
      * Return the url to the kernel confiuration
      * @return the kernel configuration url
      */
      URL getKernelURL();
  
     /**
      * Return the working client directory.
      * @return the working directory
      */
      File getWorkingDirectory();
  
     /**
      * Return the temporary client directory.
      * @return the temp directory
      */
      File getTempDirectory();
  
     /**
      * Return the context directory from which relative 
      * runtrime home directories will be established for 
      * components referencing urn:avalon:home
      *
      * @return the working directory
      */
      File getContextDirectory();
  
     /**
      * Return the anchor directory to be used when resolving 
      * library declarations in classload specifciations.
      *
      * @return the jar extension anchor directory
      */
      File getExtensionDirectory();
  
     /**
      * Return info generation policy.  If TRUE the parameters 
      * related to deployment will be listed on startup. 
      *
      * @return the info policy
      */
      boolean isInfoEnabled();
  
     /**
      * Return debug policy.  If TRUE all logging channels will be 
      * set to debug level (useful for debugging).
      *
      * @return the debug policy
      */
      boolean isDebugEnabled();
  
     /**
      * Return server execution policy.  If TRUE the kernel will 
      * continue until explicitly terminated.  If FALSE the kernel
      * will initiate decommissioning on completion of deployment.
      *
      * @return the server execution mode
      */
      boolean isServerEnabled();
  
  }
  
  
  
  1.2       +4 -4      avalon-sandbox/kernel/test/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/kernel/test/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	24 Nov 2003 14:57:27 -0000	1.1
  +++ project.xml	30 Nov 2003 05:55:30 -0000	1.2
  @@ -5,14 +5,14 @@
     <extend>${basedir}/../project.xml</extend>
   
     <groupId>avalon-repository</groupId>
  -  <id>avalon-repository-test</id>
  -  <name>Avalon Repository Test</name>
  +  <id>merlin-test</id>
  +  <name>Merlin Test</name>
     <currentVersion>1.2-dev</currentVersion>
   
  -  <package>org.apache.avalon.repository</package>
  +  <package>org.apache.avalon.merlin</package>
   
     <inceptionYear>2002</inceptionYear>
  -  <shortDescription>Avalon Repository Test</shortDescription>
  +  <shortDescription>Merlin Test</shortDescription>
     
     <dependencies>
       <dependency>
  
  
  
  1.7       +69 -73    avalon-sandbox/kernel/test/src/test/org/apache/avalon/merlin/MerlinEmbeddedTest.java
  
  Index: MerlinEmbeddedTest.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/kernel/test/src/test/org/apache/avalon/merlin/MerlinEmbeddedTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MerlinEmbeddedTest.java	27 Nov 2003 00:00:14 -0000	1.6
  +++ MerlinEmbeddedTest.java	30 Nov 2003 05:55:30 -0000	1.7
  @@ -48,7 +48,7 @@
   
   */
   
  -package org.apache.avalon.merlin ;
  +package org.apache.avalon.merlin;
   
   import java.io.File;
   import java.net.URL;
  @@ -57,17 +57,20 @@
   import javax.naming.directory.Attributes;
   import javax.naming.directory.Attribute;
   
  -import junit.framework.TestCase ;
  +import junit.framework.TestCase;
   
  -import org.apache.avalon.repository.Artifact ;
  -import org.apache.avalon.repository.ClassicArtifact ;
  -import org.apache.avalon.repository.Repository ;
  -import org.apache.avalon.repository.RepositoryException ;
  -import org.apache.avalon.repository.criteria.Criteria ;
  -import org.apache.avalon.repository.criteria.Factory ;
  -import org.apache.avalon.repository.meta.ApplicationDescriptor ;
  -import org.apache.avalon.repository.main.InitialRepositoryFactory ;
  +import org.apache.avalon.repository.Artifact;
  +import org.apache.avalon.repository.Builder;
  +import org.apache.avalon.repository.InitialContext;
  +import org.apache.avalon.repository.Repository;
  +import org.apache.avalon.repository.RepositoryException;
  +import org.apache.avalon.repository.criteria.Criteria;
  +import org.apache.avalon.repository.criteria.Factory;
  +import org.apache.avalon.repository.meta.RelationalDescriptor;
  +import org.apache.avalon.repository.main.DefaultInitialContext;
  +import org.apache.avalon.repository.main.DefaultBuilder;
   
  +import org.apache.avalon.util.env.Env;
   import org.apache.avalon.util.exception.ExceptionHelper;
   
   /**
  @@ -79,11 +82,11 @@
    */
   public class MerlinEmbeddedTest extends TestCase
   {
  -    private Factory m_factory;
  +    private InitialContext m_context;
       private Repository m_repository;
   
       /**
  -     * Constructor for InitialRepositoryFactoryTest.
  +     * Constructor for MerlinEmbeddedTest.
        * @param name the name of the testcase
        */
       public MerlinEmbeddedTest( String name )
  @@ -91,63 +94,32 @@
           super( name );
       }
   
  -    protected void setUp() throws Exception
  -    {
  -        String[] bootstrap = getBootstrapRepositorySet();
  -        m_factory = new InitialRepositoryFactory( bootstrap );
  -        Map criteria = m_factory.createDefaultCriteria();
  -        String[] repositories = getWorkingRepositorySet();
  -        criteria.put( "avalon.repository.remote.url", repositories );
  -        m_repository = (Repository) m_factory.create( criteria ) ;
  -    }
  -
       //----------------------------------------------------------------------
       // tests
       //----------------------------------------------------------------------
   
  -    public void testEmbeddingScenario() throws Exception
  +    public void testEmbeddedScenario() throws Exception
       {
           try
           {
  -            Artifact spec = ClassicArtifact.createClassicArtifact( "merlin", "merlin-kernel-impl" );
  -            Attributes attributes = m_repository.getArtifactAttributes( spec );
  -            ApplicationDescriptor target = new ApplicationDescriptor( attributes );
  -            Artifact implementation = target.getImplementation();
  -            String classname = target.getFactoryClassname();
  -
  -            //
  -            // create a classloader using the artifact referenced by the target
  -            // using the context classloader as the parent
  -            //
  -
  -            ClassLoader parent = Thread.currentThread().getContextClassLoader();
  -            ClassLoader loader = m_repository.getClassLoader( parent, implementation );
  -            Class c = loader.loadClass( target.getFactoryClassname() );
  -            Constructor constructor = c.getConstructor( new Class[]{ Factory.class } );
  -
  -            Factory factory = (Factory) constructor.newInstance( new Object[]{ m_factory } );
  -            Map criteria = (Map) factory.createDefaultCriteria();
  -            assertNotNull( "criteria", criteria );
  -
  -            //
  -            // list the supplied default criteria
  -            //
  -
  -            String[] keys = (String[]) criteria.keySet().toArray( new String[0] ) ;
  -
  -            System.out.println( "\n----------- LISTING (in unit test) ------------\n" );
  -            for( int i=0; i<keys.length; i++ )
  -            {
  -                final String key = keys[i];
  -                Object arg = criteria.get( key );
  -                System.out.println( "   ${" + key + "} == " + arg );
  -            }
  -
  -            //
  -            // instantiate the application
  -            //
  +            Artifact artifact = 
  +              Artifact.createArtifact( 
  +                "merlin", "merlin-impl", "3.2.2-dev" );
  +
  +            InitialContext context = 
  +               new DefaultInitialContext( 
  +                 getDefaultHosts(),
  +                 getMavenRepositoryDirectory() );
  +
  +            Builder builder = new DefaultBuilder( context, artifact );
  +            Factory factory = builder.getFactory();
  +            Map criteria = factory.createDefaultCriteria();
  +            criteria.put( "merlin.debug", new Boolean( true ) );
  +
  +            System.out.println( "\n----------- INSTANTIATION ------------\n" );
   
               Object app = factory.create( criteria );
  +            assertNotNull( "app", app );
           }
           catch( Throwable e )
           {
  @@ -161,26 +133,50 @@
       // utilities
       //----------------------------------------------------------------------
   
  -    private static String[] getBootstrapRepositorySet()
  +    private static File getMavenRepositoryDirectory()
       {
  -        return new String[]{ 
  -          "file:///" + System.getProperty( "basedir" ) + "/target/repository/",
  -        };
  +        return new File( getMavenHomeDirectory(), "repository" );
       }
   
  -    private static String[] getWorkingRepositorySet()
  +    private static File getMavenHomeDirectory()
  +    {
  +        return new File( getMavenHome() );
  +    }
  +
  +    private static String getMavenHome()
  +    {
  +        try
  +        {
  +            String local = 
  +              System.getProperty( 
  +                "maven.home.local", 
  +                Env.getEnvVariable( "MAVEN_HOME_LOCAL" ) );
  +            if( null != local ) return local;
  +
  +            String maven = 
  +              System.getProperty( 
  +                "maven.home", 
  +                Env.getEnvVariable( "MAVEN_HOME" ) );
  +            if( null != maven ) return maven;
  +
  +            return System.getProperty( "user.home" ) + File.separator + ".maven";
  +
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Internal error while attempting to access environment.";
  +            final String message = 
  +              ExceptionHelper.packException( error, e, true );
  +            throw new RuntimeException( message );
  +        }
  +    }
  +
  +    private static String[] getDefaultHosts()
       {
           return new String[]{ 
  -          "file:///" + System.getProperty( "basedir" ) + "/target/repository/",
             "http://dpml.net/",
             "http://www.ibiblio.org/maven/"
           };
  -    }
  -
  -    private File getBaseDirectory()
  -    {
  -        String work = System.getProperty( "user.dir" );
  -        String base = System.getProperty( "basedir", work );
  -        return new File( base );
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message