avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/doc-files DefaultKernel.gif
Date Fri, 02 Aug 2002 06:36:10 GMT
mcconnell    2002/08/01 23:36:10

  Modified:    assembly build.xml
               assembly/demo/src/etc demo.mf
               assembly/src/etc kernel.xml merlin.html sevak.xml
               assembly/src/java/org/apache/excalibur/merlin
                        DefaultController.java DefaultController.xinfo
                        Main.java
               assembly/src/java/org/apache/excalibur/merlin/assembly
                        DefaultLoggerManager.java DependencyGraph.java
                        ProfileRegistry.java TypeManager.java
                        TypeRegistry.java
               assembly/src/java/org/apache/excalibur/merlin/assembly/resource
                        AbstractExtension.java DefaultManager.java
                        LifecycleHelper.java ProfileDesignator.java
                        ResourceProvider.java
               assembly/src/java/org/apache/excalibur/merlin/container
                        DefaultContainer.java DefaultContainer.xinfo
               assembly/src/java/org/apache/excalibur/merlin/doc-files
                        DefaultController.gif
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java DefaultKernel.xinfo
               assembly/src/java/org/apache/excalibur/merlin/kernel/doc-files
                        DefaultKernel.gif
  Added:       assembly/src/java/org/apache/excalibur/merlin/assembly/resource
                        ResourceRuntimeException.java
  Log:
  general enhancements to support simplified coding when embedding a kernel
  
  Revision  Changes    Path
  1.35      +2 -2      jakarta-avalon-excalibur/assembly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/build.xml,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- build.xml	30 Jul 2002 13:49:06 -0000	1.34
  +++ build.xml	2 Aug 2002 06:36:09 -0000	1.35
  @@ -299,8 +299,8 @@
   
     <target name="patch">
       <replace dir="${src.dir}/java" 
  -       token="ResourceDesignator" 
  -       value="Resource" >
  +       token="org.apache.excalibur.merlin.builder"
  +       value="org.apache.excalibur.merlin.model.builder" >
        <include name="org/apache/excalibur/merlin/**/*.*"/>
       </replace>
     </target>
  
  
  
  1.8       +3 -0      jakarta-avalon-excalibur/assembly/demo/src/etc/demo.mf
  
  Index: demo.mf
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/etc/demo.mf,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- demo.mf	30 Jul 2002 13:49:07 -0000	1.7
  +++ demo.mf	2 Aug 2002 06:36:09 -0000	1.8
  @@ -24,3 +24,6 @@
   
   Name: org/apache/excalibur/playground/DemoManager.class
   Avalon-Facility: true
  +
  +Name: org/apache/excalibur/playground/EmbeddedDemo.class
  +Avalon-Block: true
  
  
  
  1.20      +18 -7     jakarta-avalon-excalibur/assembly/src/etc/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/kernel.xml,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- kernel.xml	30 Jul 2002 07:05:54 -0000	1.19
  +++ kernel.xml	2 Aug 2002 06:36:09 -0000	1.20
  @@ -21,19 +21,19 @@
      the corresponds to the name of the logging file.
      -->
   
  -   <logging priority="INFO" target="default">
  +   <logging priority="WARN" target="default">
         <target name="kernel">
           <file location="kernel.log" />
         </target>
      </logging>
   
  +   <!--
      <categories priority="INFO">
  -     <category priority="WARN" name="logging" />
  +     <category priority="WARN"  name="logging" />
        <category priority="WARN"  name="loader" />
  -     <category priority="WARN"  name="loader.assembly" />
  -     <category priority="WARN"  name="loader.lifecycle" />
        <category priority="INFO"  name="export" />
      </categories>
  +   -->
   
      <!--
      Declaration of installed extension directories.
  @@ -58,11 +58,14 @@
        for completness. 
        -->
   
  -     <categories priority="DEBUG">
  +       <!--
  +     <categories>
          <category priority="WARN"  name="loader" />
  -       <category priority="WARN"  name="loader.assembly" />
  -       <category priority="WARN"  name="loader.lifecycle" />
  +       <category priority="DEBUG"  name="loader.assembly" />
  +       <category priority="WARN"  name="demo-ext" />
  +       <category priority="WARN"  name="exploit-ext" />
        </categories>
  +       -->
   
        <!--
        Declaration of the classpath for this container.
  @@ -74,6 +77,12 @@
          </fileset>
        </classpath>
   
  +     <component name="embedded-kernel" class="org.apache.excalibur.playground.EmbeddedDemo" activation="true">
  +        <context>
  +          <import key="avalon:home" name="avalon:home"/>
  +        </context>
  +     </component>
  +
        <!--
        Declaration of the services hosted by this container.  Service container here 
        will be managed relative to other provider components at the same level and 
  @@ -128,9 +137,11 @@
   
          <container name="demo">
   
  +         <!--
            <categories priority="INFO">
              <category priority="WARN"  name="loader" />
            </categories>
  +         -->
   
            <!--
            Including the next entry demonstrates the resolution of a dependency via a profile
  
  
  
  1.9       +0 -1      jakarta-avalon-excalibur/assembly/src/etc/merlin.html
  
  Index: merlin.html
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/merlin.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- merlin.html	29 Jul 2002 06:14:29 -0000	1.8
  +++ merlin.html	2 Aug 2002 06:36:09 -0000	1.9
  @@ -16,7 +16,6 @@
   <h3>Kernel Model</h3>
   <p>Merlin seperates the notion of a kernel from a container.  A kernal manages resources (Objects) whereas a container manages services (Objects that serve as service providers and consumers).  The Merlin implementation provides a default kernal that manages a container hierachy.  The kernel provides the framework for overall management including startup, shutting down, extensions management, and other system wide facilities.  The Melin implementation provides a utility class {@link org.apache.excalibur.merlin.Main} that handles establish of a kernel based on a single command line argument.</p>
   
  -<p>A merlin kernel is created using a kernel model ({@link org.apache.excalibur.merlin.kernel.model.KernelDescriptor}).  The model may be defined programatically or through an XML file.  A kernel XML file contains the defintion of kernal execution parameters and a root container.</P>
   <p><i>Minimilist kernel defintion.</i></p>
   <pre>
     &lt;kernel&gt;
  
  
  
  1.8       +1 -1      jakarta-avalon-excalibur/assembly/src/etc/sevak.xml
  
  Index: sevak.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/sevak.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- sevak.xml	30 Jul 2002 07:05:54 -0000	1.7
  +++ sevak.xml	2 Aug 2002 06:36:09 -0000	1.8
  @@ -86,7 +86,7 @@
           activation="true">
   
           <context>
  -          <import key="app.home" name="avalon:work"/>
  +          <import key="app.home" name="avalon:home"/>
           </context>
   
           <!-- you need to provide your own sevak-conf.xml file if you want to override defaults -->
  
  
  
  1.10      +86 -45    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.java
  
  Index: DefaultController.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultController.java	30 Jul 2002 13:49:07 -0000	1.9
  +++ DefaultController.java	2 Aug 2002 06:36:09 -0000	1.10
  @@ -24,16 +24,19 @@
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.excalibur.merlin.assembly.ProfileManager;
  -import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.assembly.TypeManager;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
  +import org.apache.excalibur.merlin.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.kernel.Kernel;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
   import org.apache.excalibur.merlin.kernel.DefaultKernel;
   import org.apache.excalibur.merlin.kernel.KernelException;
  -import org.apache.excalibur.merlin.kernel.model.KernelDescriptor;
  -import org.apache.excalibur.merlin.kernel.builder.XMLKernelCreator;
  +import org.apache.excalibur.merlin.model.builder.XMLContainerUtil;
   import org.apache.excalibur.merlin.model.Resource;
  -import org.apache.excalibur.merlin.container.model.ClasspathDescriptor;
  -import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor;
  -import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor;
  +import org.apache.excalibur.merlin.model.CategoriesDescriptor;
  +import org.apache.excalibur.merlin.model.ClasspathDescriptor;
  +import org.apache.excalibur.merlin.model.ExtensionsDescriptor;
  +import org.apache.excalibur.merlin.model.LoggingDescriptor;
   
   
   /**
  @@ -54,13 +57,15 @@
    *     // create the execution context
    *     //</font>
    *
  - *     File <strong>file</strong> = new File( <font color="darkred"/>&quot;src/etc/kernel.xml&quot;</font> );
  + *     File <strong>base</strong> = new File( <font color="darkred"/>&quot;.&quot;</font> );
  + *     String <strong>filename</strong> = <font color="darkred"/>&quot;src/etc/kernel.xml&quot;</font> );
    *     DefaultContext <strong>context</strong> = new DefaultContext();
  - *     <strong>context</strong>.put( DefaultController.CONTROLLER_PATH_KEY, <strong>file</strong> );
  + *     <strong>context</strong>.put( DefaultController.APPLICATION_DIR_KEY, <strong>base</strong> );
  + *     <strong>context</strong>.put( DefaultController.CONTROLLER_PATH_KEY, <strong>filename</strong> );
    *     <strong>context</strong>.makeReadOnly();
    *     
    *     <font color="gray">//
  - *     // deploy the kernel
  + *     // deploy the controller
    *     //</font>
    *
    *     DefaultController <strong>controller</strong> = new DefaultController();
  @@ -89,15 +94,18 @@
       private static final int STOPPED = 3;
       private static final int DISPOSED = 4;
   
  -    public static final String CONTROLLER_PATH_KEY = "path";
  +    public static final String CONTROLLER_PATH_KEY = "merlin:path";
  +    public static final String APPLICATION_DIR_KEY = "avalon:home";
   
       //=======================================================================
       // state
       //=======================================================================
   
  -    private File m_path;
  +    private File m_home;
   
  -    private final DefaultKernel m_kernel = new DefaultKernel();
  +    private String m_path;
  +
  +    private DefaultKernel m_kernel;
   
       private int m_status = NOT_READY;
   
  @@ -107,12 +115,29 @@
   
      /**
       * Invoked by the bootstrap process to supply the path to the kernel configuration.
  -    * @param context the context object containing the inital path
  +    * @param context the context object containing the working directory under the 
  +    *    context key {@link #APPLICATION_DIR_KEY} as a {@link File}, and the path to 
  +    *    the kernel configuration as a string, supplied under the key {@link #CONTROLLER_PATH_KEY} 
       * @exception ContextException if the supplied does not contain a CONTROLLER_PATH_KEY value 
       */
       public void contextualize( Context context ) throws ContextException
       {
  -        m_path = (File) context.get( CONTROLLER_PATH_KEY );
  +        try
  +        {
  +            m_path = (String) context.get( CONTROLLER_PATH_KEY );
  +        }
  +        catch( ContextException e )
  +        {
  +            m_path = "kernel.xml";
  +        }
  +        try
  +        {
  +            m_home = (File) context.get( APPLICATION_DIR_KEY );
  +        }
  +        catch( ContextException e )
  +        {
  +            m_home = new File( System.getProperty("user.dir") );
  +        }
           m_status = CONTEXTUALIZED;
       }
   
  @@ -120,55 +145,72 @@
       // Initializable
       //=======================================================================
   
  +   /**
  +    * Initialization of the controller resulting in the establishment of a new Kernel.
  +    * The initialization action undertakes the following:
  +    * <ul>
  +    *  <li>validation of the application home directory
  +    *  <li>validation that the configuration path is resolvable relative to the home directory
  +    *  <li>marchalls the XML kernel description into a kernel meta-data model
  +    *  <li>establishes a kernel instance
  +    *  <li>establishes and applies the application context to the kernel
  +    *  <li>initilializes the kernel
  +    * </ul>
  +    *
  +    * @exception Exception if a validation or establishment error occurs
  +    */
       public void initialize() throws Exception
       {
           if( m_status < CONTEXTUALIZED )
             throw new ControllerException( "Controller has not been contextualized." );
   
  -        Configuration config = null;
  -        XMLKernelCreator creator = new XMLKernelCreator();
  -        KernelDescriptor descriptor = null;
  -        try
  +        final File file = new File( m_home, m_path );
  +        if( !file.exists() )
           {
  -
  -            //
  -            // build the kernel descriptor
  -            //
  -
  -            config = getProfile( m_path );
  -            descriptor = creator.createKernelDescriptor( 
  -              config, Thread.currentThread().getContextClassLoader() );
  -            descriptor.getLogger().info("kernel descriptor created");
  -
  +            final String error = "Supplied filename does not exist. (" + file + ")";
  +            throw new ControllerException( error );
           }
  -        catch( Throwable e )
  +        if( file.isDirectory() )
           {
  -            final String error = "Controller bootstrap failure.";
  -            throw new ControllerException( error, e );
  +            final String error = "Supplied filename is not a file. (" + file + ")";
  +            throw new ControllerException( error );
  +        }
  +        if( !file.canRead() )
  +        {
  +            final String error = "Cannot read the file. (" + file + ")";
  +            throw new ControllerException( error );
           }
   
  -        // run it up
  +        //
  +        // create the application context
  +        // (in the future this should include a more general framework where 
  +        // application context can be defined in the kernel configuration)
  +        //
   
           DefaultContext context = new DefaultContext();
  -        context.put( DefaultKernel.KERNEL_DESCRIPTOR_KEY, descriptor );
  +        context.put( DefaultKernel.APPLICATION_DIR_KEY, m_home );
           context.makeReadOnly();
  +
  +        Configuration config = null;
  +        config = getProfile( file );
  +
           try
           {
  -            m_kernel.enableLogging( descriptor.getLogger() );
  +            //
  +            // create the kernel
  +            //
  +
  +            m_kernel = new DefaultKernel();
               m_kernel.contextualize( context );
  -            m_kernel.initialize( );
  -        }
  -        catch( KernelException e )
  -        {
  -            final String error = "Kernel initialization failure.";
  -            throw new ControllerException( error, e );
  +            m_kernel.configure( config );
  +            m_kernel.initialize();
           }
           catch( Throwable e )
           {
  -            final String error = "Unexpected initialization failure.";
  +            final String error = "Kernel establishment failure.";
               throw new ControllerException( error, e );
           }
  -
  +            
           m_status = INITIALIZED;
       }
   
  @@ -219,7 +261,6 @@
                   // ignore
               }
           }
  -        m_kernel.dispose();
           m_status = DISPOSED;
       }
   
  
  
  
  1.3       +2 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.xinfo
  
  Index: DefaultController.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.xinfo,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultController.xinfo	29 Jul 2002 06:14:29 -0000	1.2
  +++ DefaultController.xinfo	2 Aug 2002 06:36:09 -0000	1.3
  @@ -18,7 +18,8 @@
     </component>
   
     <context>
  -    <entry key="path" type="java.io.File" optional="false"/>
  +    <entry key="avalon:home" type="java.io.File" optional="true"/>
  +    <entry key="merlin:path" optional="true"/>
     </context>
   
     <services>
  
  
  
  1.11      +13 -31    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Main.java	30 Jul 2002 07:05:55 -0000	1.10
  +++ Main.java	2 Aug 2002 06:36:09 -0000	1.11
  @@ -56,13 +56,11 @@
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.excalibur.meta.info.DependencyDescriptor;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
  -import org.apache.excalibur.merlin.assembly.ProfileManager;
  -import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
  -import org.apache.excalibur.merlin.kernel.builder.XMLKernelCreator;
  -import org.apache.excalibur.merlin.kernel.model.KernelDescriptor;
  -import org.apache.excalibur.merlin.container.model.ClasspathDescriptor;
  -import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor;
  -import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
  +import org.apache.excalibur.merlin.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.model.ClasspathDescriptor;
  +import org.apache.excalibur.merlin.model.ExtensionsDescriptor;
  +import org.apache.excalibur.merlin.model.LoggingDescriptor;
   import org.apache.excalibur.merlin.kernel.DefaultKernel;
   import org.apache.excalibur.merlin.kernel.KernelException;
   
  @@ -136,33 +134,16 @@
       */
       public static void main( String[] args )
       {
  +
           //
  -        // get the filename from the command line arguments and check it 
  -        // for existance and general integrity
  +        // get the filename from the command line argument
           //
   
  -        File path = null;
  +        String filename = null;
  +        final File base = new File( System.getProperty("user.dir") ); 
           if( args.length > 0 )
           {
  -            String filename = args[0];
  -            path = new File( filename );
  -            if( !path.exists() )
  -            {
  -                final String error = "Supplied filename does not exist. (" + filename + ")";
  -                throw new ControllerRuntimeException( error );
  -            }
  -
  -            if( path.isDirectory() )
  -            {
  -                final String error = "Supplied filename is not a file. (" + filename + ")";
  -                throw new ControllerRuntimeException( error );
  -            }
  -
  -            if( !path.canRead() )
  -            {
  -                final String error = "Cannot read the file. (" + filename + ")";
  -                throw new ControllerRuntimeException( error );
  -            }
  +            filename = args[0];
           }
           else
           {
  @@ -176,7 +157,8 @@
   
           final DefaultController controller = new DefaultController();
           DefaultContext context = new DefaultContext();
  -        context.put( DefaultController.CONTROLLER_PATH_KEY, path );
  +        context.put( DefaultController.APPLICATION_DIR_KEY, base );
  +        context.put( DefaultController.CONTROLLER_PATH_KEY, filename );
           context.makeReadOnly();
           Runtime.getRuntime().addShutdownHook(
               new Thread()
  
  
  
  1.2       +20 -33    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java
  
  Index: DefaultLoggerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLoggerManager.java	29 Jul 2002 06:14:29 -0000	1.1
  +++ DefaultLoggerManager.java	2 Aug 2002 06:36:09 -0000	1.2
  @@ -28,11 +28,11 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.AvalonFormatter;
   import org.apache.avalon.framework.logger.LogKitLogger;
  -import org.apache.excalibur.merlin.container.model.Parent;
  -import org.apache.excalibur.merlin.kernel.model.TargetDescriptor;
  -import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor;
  -import org.apache.excalibur.merlin.kernel.model.TargetProvider;
  -import org.apache.excalibur.merlin.kernel.model.FileTargetProvider;
  +//import org.apache.excalibur.merlin.model.Parent;
  +import org.apache.excalibur.merlin.model.TargetDescriptor;
  +import org.apache.excalibur.merlin.model.LoggingDescriptor;
  +import org.apache.excalibur.merlin.model.TargetProvider;
  +import org.apache.excalibur.merlin.model.FileTargetProvider;
   import org.apache.excalibur.merlin.model.Category;
   import org.apache.excalibur.merlin.model.CategoriesDescriptor;
   
  @@ -90,6 +90,15 @@
   
      /**
       * Creation of a new LoggerManager.
  +    * @exception Exception is an error occurs
  +    */
  +    public DefaultLoggerManager() throws Exception
  +    {
  +        this( new LoggingDescriptor( "", null, null, new TargetDescriptor[0] ) );
  +    }
  +
  +   /**
  +    * Creation of a new LoggerManager.
       * @param descriptor the logging system description
       * @exception Exception is an error occurs
       */
  @@ -107,14 +116,12 @@
           m_targets.put( DEFAULT_TARGET, m_stream );
           if( descriptor.getPriority() != null )
           {
  -            getLogger().debug("supplied system priority: " + descriptor.getPriority() );
               getHierarchy().setDefaultPriority( 
                 Priority.getPriorityForName( descriptor.getPriority( ) ) 
               );
           }
           else
           {
  -            getLogger().debug("internal system priority: " + DEFAULT_PRIORITY );
               getHierarchy().setDefaultPriority( 
                 Priority.getPriorityForName( DEFAULT_PRIORITY ) 
               );
  @@ -165,29 +172,9 @@
       * @param path the category header
       * @param descriptor a set of category descriptors to be added under the path
       */
  -    public void addCategories( Parent parent, CategoriesDescriptor descriptor )
  -    {
  -        String path = null;
  -        final String name = descriptor.getName();
  -        if( parent != null )
  -        {
  -            path = parent.getPath().replace('/','.').substring(1) + "." + name;
  -        }
  -        else
  -        {
  -            path = name;
  -        }
  -        addCategories( path, descriptor );
  -    }
  -
  -   /**
  -    * Add a set of category entries using the system wide defaults.
  -    * @param path the category header
  -    * @param descriptor a set of category descriptors to be added under the path
  -    */
       public void addCategories( String path, CategoriesDescriptor descriptor )
       {
  -        addSingleCategory( path, descriptor.getPriority(), descriptor.getTarget( ) );
  +        addCategory( path, descriptor.getPriority(), descriptor.getTarget( ) );
           Category[] categories = descriptor.getCategories();
           for( int i=0; i<categories.length; i++ )
           {
  @@ -196,16 +183,16 @@
               final String target = category.getTarget();
               if( path.equals("") )
               {
  -                addSingleCategory( category.getName(), priority, target );
  +                addCategory( category.getName(), priority, target );
               }
               else
               {
  -                addSingleCategory( path + "." + category.getName(), priority, target );
  +                addCategory( path + "." + category.getName(), priority, target );
               }
           }
       }
   
  -    private Logger addSingleCategory( String path, String priority, String target )
  +    private Logger addCategory( String path, String priority, String target )
       {
           final Logger logger = getHierarchy().getLoggerFor( path );
           if( priority != null )
  @@ -281,7 +268,7 @@
         final String name, String target, String priority )
           throws Exception
       {
  -        return new LogKitLogger( addSingleCategory( name, target, priority ) );
  +        return new LogKitLogger( addCategory( name, target, priority ) );
       }
   
       /**
  @@ -295,7 +282,7 @@
           throws Exception
       {
           return new LogKitLogger( 
  -          addSingleCategory( 
  +          addCategory( 
               category.getName(), 
               category.getPriority(), 
               category.getTarget() 
  
  
  
  1.2       +44 -2     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DependencyGraph.java
  
  Index: DependencyGraph.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DependencyGraph.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DependencyGraph.java	29 Jul 2002 06:14:29 -0000	1.1
  +++ DependencyGraph.java	2 Aug 2002 06:36:09 -0000	1.2
  @@ -11,6 +11,7 @@
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Association;
   import org.apache.excalibur.meta.info.DependencyDescriptor;
  +import org.apache.excalibur.meta.info.PhaseDescriptor;
   
   /**
    * <p>Utility class to help aquire a ordered graph of
  @@ -240,6 +241,27 @@
                                    final ArrayList done,
                                    final ArrayList order )
       {
  +        //
  +        // get all of the extensions the provide extension
  +        // support to the subject profile
  +        //
  +
  +        final PhaseDescriptor[] phases = profile.getType().getPhases();
  +        for( int i=(phases.length-1); i>-1; i-- )
  +        {
  +            PhaseDescriptor phase = phases[i];
  +            Profile extension = profile.getExtensionProfile( phase );
  +            if( extension != null )
  +            {
  +                visitcomponent( extension, true, done, order );
  +            }
  +        }
  +
  +        //
  +        // get all of the profiles that are service providers
  +        // towards the target profile
  +        //
  +
           final DependencyDescriptor[] descriptors =
               profile.getType().getDependencies();
   
  @@ -285,8 +307,28 @@
           {
               final Profile other =
                   (Profile)m_components.get( i );
  -            final Association[] providers = other.getAssociations();
   
  +            //
  +            // check if the 'other' profile is used by this 'profile'
  +            // as an extension provider
  +            //
  +
  +            final PhaseDescriptor[] phases = other.getType().getPhases();
  +            for( int j = 0; j < phases.length; j++ )
  +            {
  +                 Profile extension = other.getExtensionProfile( phases[j] );
  +                 if( extension.equals( profile ) )
  +                 {
  +                     visitcomponent( other, false, done, order );
  +                 }
  +            }
  +
  +            //
  +            // check if the 'other' profile is used by this 'profile'
  +            // as a service provider
  +            //
  +
  +            final Association[] providers = other.getAssociations();
               for( int j = 0; j < providers.length; j++ )
               {
                   if( providers[ j ].getProvider().equals( profile ) )
  
  
  
  1.4       +4 -4      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileRegistry.java
  
  Index: ProfileRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileRegistry.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProfileRegistry.java	30 Jul 2002 13:49:07 -0000	1.3
  +++ ProfileRegistry.java	2 Aug 2002 06:36:09 -0000	1.4
  @@ -54,7 +54,7 @@
      /**
       * Classloader used to load a service profile selector.
       */
  -    private ProfileManager m_classloader;
  +    private ContainerManager m_classloader;
   
      /**
       * The dependency map that is populated during the assembly process.
  @@ -70,7 +70,7 @@
       * @param loader the registry class loader
       * @param map the dependency map
       */
  -    public ProfileRegistry( ProfileManager loader, DependencyGraph map )
  +    public ProfileRegistry( ContainerManager loader, DependencyGraph map )
       {
           m_classloader = loader;
           m_map = map;
  @@ -98,7 +98,7 @@
               assembleProfile( profile, visited, "" );
   
               final String name = 
  -              m_classloader.getPath() + ProfileManager.DELIMITER + profile.getName();
  +              m_classloader.getPath() + ContainerManager.DELIMITER + profile.getName();
               final Resource resource = m_classloader.getResource( profile, true );
               getLogger().debug( "created explicit resource for: " + name );
               m_map.add( profile );
  
  
  
  1.3       +38 -27    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java
  
  Index: TypeManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeManager.java	30 Jul 2002 07:05:55 -0000	1.2
  +++ TypeManager.java	2 Aug 2002 06:36:09 -0000	1.3
  @@ -45,14 +45,14 @@
   import org.apache.excalibur.meta.info.Facility;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
   import org.apache.excalibur.meta.info.PhaseDescriptor;
  -import org.apache.excalibur.merlin.container.model.IncludeDescriptor;
  -import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor;
  -import org.apache.excalibur.merlin.container.model.DirsetDescriptor;
  -import org.apache.excalibur.merlin.container.model.ClasspathDescriptor;
  -import org.apache.excalibur.merlin.container.model.FilesetDescriptor;
  -import org.apache.excalibur.merlin.container.model.IncludeDescriptor;
  -import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor;
  -import org.apache.excalibur.merlin.container.model.DirsetDescriptor;
  +import org.apache.excalibur.merlin.model.IncludeDescriptor;
  +import org.apache.excalibur.merlin.model.ExtensionsDescriptor;
  +import org.apache.excalibur.merlin.model.DirsetDescriptor;
  +import org.apache.excalibur.merlin.model.ClasspathDescriptor;
  +import org.apache.excalibur.merlin.model.FilesetDescriptor;
  +import org.apache.excalibur.merlin.model.IncludeDescriptor;
  +import org.apache.excalibur.merlin.model.ExtensionsDescriptor;
  +import org.apache.excalibur.merlin.model.DirsetDescriptor;
   
   /**
    * Abstract type manager.
  @@ -93,6 +93,11 @@
       private Logger m_logger;
   
      /**
  +    * Logging channel for the type manager.
  +    */
  +    private Logger m_localLogger;
  +
  +   /**
       * Description of the extension directories.
       */
       private ExtensionsDescriptor m_extensions;
  @@ -140,6 +145,7 @@
       public void enableLogging( Logger logger )
       {
           m_logger = logger;
  +        m_localLogger = logger.getChildLogger("loader");
       }
   
       protected Logger getLogger()
  @@ -147,6 +153,12 @@
           return m_logger;
       }
   
  +    protected Logger getLocalLogger()
  +    {
  +        return m_localLogger;
  +    }
  +
  +
       //=======================================================================
       // Contextualizable
       //=======================================================================
  @@ -158,7 +170,6 @@
       */
       public void contextualize( Context context ) throws ContextException
       {
  -        getLogger().debug( "contextualize" );
           try
           {
               m_extensions = (ExtensionsDescriptor) context.get( EXTENSIONS_DESCRIPTOR_KEY );
  @@ -188,8 +199,8 @@
           // initialize the type registries and install the classpath
           //
   
  -        getLogger().debug("initialize");
  -        m_types = new TypeRegistry( this, getLogger().getChildLogger( "types" ) );
  +        getLocalLogger().debug("initialize");
  +        m_types = new TypeRegistry( this, getLocalLogger().getChildLogger( "types" ) );
   
           //
           // setup the extension directories
  @@ -197,7 +208,7 @@
   
           if( m_extensions != null )
           {
  -            getLogger().debug( "initializing extensions libraries" );
  +            getLocalLogger().debug( "initializing extensions libraries" );
               ArrayList list = new ArrayList();
               File dir = new File( System.getProperty("user.dir") );
               DirsetDescriptor[] dirs = m_extensions.getDirsetDescriptors();
  @@ -232,7 +243,7 @@
   
           if( m_classpath != null )
           {
  -            getLogger().debug("installing classpath");
  +            getLocalLogger().debug("installing classpath");
               addClasspath( m_classpath );
           }
       }
  @@ -279,7 +290,7 @@
                               catch( Throwable e )
                               {
                                   final String warning = "Bypassing type: " + path ;
  -                                getLogger().warn( warning, e );
  +                                getLocalLogger().warn( warning, e );
                               }
                           }
                       }
  @@ -295,7 +306,7 @@
                               catch( Throwable e )
                               {
                                   final String warning = "Bypassing extension: " + path ;
  -                                getLogger().warn( warning, e );
  +                                getLocalLogger().warn( warning, e );
                               }
                           }
                       }
  @@ -325,7 +336,7 @@
       */
       void addClasspath( ClasspathDescriptor classpath ) throws Exception
       {
  -        getLogger().debug( "adding classpath" );
  +        getLocalLogger().debug( "adding classpath" );
           List list = new ArrayList();
           Vector stack = new Vector();
           File dir = new File( System.getProperty("user.dir") );
  @@ -349,16 +360,16 @@
           for( int i = 0; i < extensions.length; i++ )
           {
               URL url = extensions[ i ].toURL();
  -            getLogger().info("extension: " + url ); 
  +            getLocalLogger().info("extension: " + url ); 
               super.addURL( url );
           }
           load( stack );
           for( int i = 0; i < urls.length; i++ )
           {
  -            getLogger().info("adding: " + urls[i] );    
  +            getLocalLogger().info("adding: " + urls[i] );    
               scan( urls[i] );
           }
  -        getLogger().debug( "classpath addition complete" );
  +        getLocalLogger().debug( "classpath addition complete" );
       }
   
       
  @@ -377,13 +388,13 @@
       private void load( Vector stack )
       {
           int size = stack.size();
  -        getLogger().debug( "Stack size: " + stack.size() );
  +        getLocalLogger().debug( "Stack size: " + stack.size() );
           Hashtable errors = new Hashtable();
           Enumeration enum = stack.elements();
           while( enum.hasMoreElements() )
           {
               File file = (File)enum.nextElement();
  -            getLogger().debug( "Loading resource: " + file );
  +            getLocalLogger().debug( "Loading resource: " + file );
               try
               {
                   super.addURL( file.toURL() );
  @@ -391,7 +402,7 @@
               }
               catch( Throwable error )
               {
  -                getLogger().warn(
  +                getLocalLogger().warn(
                           "Encountered error while loading resource: " + file, error );
                   errors.put( file, error );
               }
  @@ -407,11 +418,11 @@
           else
           {
               Enumeration keys = errors.keys();
  -            getLogger().error( "Load error count = " + errors.size() );
  +            getLocalLogger().error( "Load error count = " + errors.size() );
               while( keys.hasMoreElements() )
               {
                   File key = (File)keys.nextElement();
  -                getLogger().error(
  +                getLocalLogger().error(
                       "Error while loading file."
                       + "\n\tfile: " + key.toString(), (Throwable)errors.get( key ) );
               }
  @@ -437,7 +448,7 @@
       */
       public Type loadType( String classname ) throws Exception
       {
  -        getLogger().debug("LOOKUP: " + classname );
  +        getLocalLogger().debug("LOOKUP: " + classname );
           Type type = m_types.loadType( classname );
           if( type != null )
           {
  @@ -564,7 +575,7 @@
                       extension.getImplementationURL()
                   };
                   final String message = REZ.format( "missing.extension", params );
  -                getLogger().warn( message );
  +                getLocalLogger().warn( message );
               }
   
               final String message =
  
  
  
  1.3       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java
  
  Index: TypeRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeRegistry.java	30 Jul 2002 07:05:55 -0000	1.2
  +++ TypeRegistry.java	2 Aug 2002 06:36:09 -0000	1.3
  @@ -82,7 +82,7 @@
           super.enableLogging( logger );
           m_typeBuilder.enableLogging( logger.getChildLogger("component") );
           m_facilityBuilder.enableLogging( logger.getChildLogger("facility") );
  -        getLogger().info("type registry established");
  +        getLogger().debug("type registry established");
       }
   
       //=======================================================================
  
  
  
  1.2       +37 -25    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/AbstractExtension.java
  
  Index: AbstractExtension.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/AbstractExtension.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractExtension.java	30 Jul 2002 13:52:57 -0000	1.1
  +++ AbstractExtension.java	2 Aug 2002 06:36:09 -0000	1.2
  @@ -30,30 +30,42 @@
        */
       public void extend( int stage, Object object, Context context )
           throws Exception
  -     {
  -        if( stage == CREATE )
  -        {
  -            if( getLogger().isDebugEnabled() )
  -              getLogger().debug("extend CREATE" );
  -        }
  -        else if( stage == ACCESS )
  -        {
  -            if( getLogger().isDebugEnabled() )
  -              getLogger().debug("extend ACCESS" );
  -        }
  -        else if( stage == RELEASE )
  -        {
  -            if( getLogger().isDebugEnabled() )
  -              getLogger().debug("extend RELEASE" );
  -        }
  -        else if( stage == DESTROY )
  -        {
  -            if( getLogger().isDebugEnabled() )
  -              getLogger().debug("extend DESTROY" );
  -        }
  -        else
  -        {
  -            throw new IllegalArgumentException("stage");
  -        }
  +    {
  +        if( getLogger().isDebugEnabled() )
  +          getLogger().debug(
  +             "extending " + object.getClass().getName() 
  +             + "#" + System.identityHashCode( object ) 
  +             + " for stage " + stageToString( stage ) );
       }
  +
  +   /**
  +    * Utility method to return a string representation of the lifecycle stage.
  +    * @param stage the lifecycle stage
  +    * @return the string representation of the stage
  +    */
  +    public static String stageToString( int stage )
  +    {
  +       if( stage == CREATE )
  +       {
  +           return "CREATE";
  +       }
  +       else if( stage == ACCESS )
  +       {
  +           return "ACCESS";
  +       }
  +       else if( stage == RELEASE )
  +       {
  +           return "RELEASE";
  +       }
  +       else if( stage == DESTROY )
  +       {
  +           return "DESTROY";
  +       }
  +       else
  +       {
  +           throw new IllegalArgumentException( "stage: " + stage );
  +       }
  +    }
  +
  +
   }
  
  
  
  1.4       +13 -3     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultManager.java
  
  Index: DefaultManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultManager.java	30 Jul 2002 14:34:04 -0000	1.3
  +++ DefaultManager.java	2 Aug 2002 06:36:09 -0000	1.4
  @@ -12,6 +12,7 @@
   import java.util.Map;
   import java.util.Hashtable;
   import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.excalibur.merlin.model.Resource;
   
   
  @@ -84,12 +85,21 @@
       /**
        * Release a pooled object.
        * @param object a pooled object
  +     * @exception ResourceRuntimeException is an error occurs during release
        */
  -    public void put( Object object ) 
  +    public void put( Object object ) throws ResourceRuntimeException
       {
          final Resource resource = (Resource) m_mapping.get( object );
  -       resource.release( object );
  -       m_mapping.remove( object );
  +       try
  +       {
  +           resource.release( object );
  +           m_mapping.remove( object );
  +       }
  +       catch( Throwable e )
  +       {
  +           final String error = "Unexpected error while attempting to release resource: " + resource;
  +           throw new ResourceRuntimeException( error, e );
  +       }
       }
   
   }
  
  
  
  1.4       +2 -4      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/LifecycleHelper.java
  
  Index: LifecycleHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/LifecycleHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LifecycleHelper.java	30 Jul 2002 13:49:07 -0000	1.3
  +++ LifecycleHelper.java	2 Aug 2002 06:36:09 -0000	1.4
  @@ -245,9 +245,7 @@
   
           //
           // apply disposal extensions
  -        // ### what about context ? ###
  -        // ## what about extension exceptions - it should containue
  -        // to subsequent extensions - needs testing ##
  +        // ### TO-DO context ###
           //
   
           stage = STAGE_EXTENSION_POST;
  @@ -332,7 +330,6 @@
                              final int stage,
                              final Throwable t )
       {
  -        //final String reason = t.getMessage();
           final String reason = t.toString();
           final String message =
               REZ.getString( "lifecycle.fail.error",
  @@ -366,4 +363,5 @@
           getLogger().error( message );
           throw new LifecycleException( message, t );
       }
  +
   }
  
  
  
  1.5       +24 -11    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ProfileDesignator.java
  
  Index: ProfileDesignator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ProfileDesignator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProfileDesignator.java	30 Jul 2002 14:34:04 -0000	1.4
  +++ ProfileDesignator.java	2 Aug 2002 06:36:09 -0000	1.5
  @@ -150,25 +150,38 @@
           {
               create();
           }
  -        handleExtensions( ExtensionDescriptor.ACCESS, m_service );
  +
  +        //
  +        // handle the extension phases
  +        //
  +
  +        DefaultContext context = new DefaultContext();
  +        PhaseDescriptor[] phases = m_profile.getType().getPhases();
  +        for( int i=0; i<phases.length; i++ )
  +        {
  +            processExtension( ExtensionDescriptor.ACCESS, phases[i], m_service, context );
  +        }
  +
           return m_service;
       }
   
       /**
        * Release an established service instance.
        */
  -    public void release( Object object )
  +    public void release( Object object ) throws Exception
       {
  +        //
  +        // implementation assumes singleton services for now so nothing to on
  +        // relase apart form application of extensions
  +        //
  +
           if( !m_released )
           {
  -            try
  -            {
  -                handleExtensions( ExtensionDescriptor.RELEASE, object );
  -            }
  -            catch( Throwable e )
  +            DefaultContext context = new DefaultContext();
  +            PhaseDescriptor[] phases = m_profile.getType().getPhases();
  +            for( int i=0; i<phases.length; i++ )
               {
  -                final String error = "Release inconsitency - extension handler throw and exception.";
  -                getLogger().error( error, e );
  +                 processExtension( ExtensionDescriptor.RELEASE, phases[i], m_service, context );
               }
           }
       }
  @@ -264,11 +277,11 @@
                     + ExtensionDescriptor.stageToString( stage ) 
                     + " phase for the component " 
                     + m_profile.getName();
  +
                   throw new LifecycleException( error, e );
               }
           }
       }
  -
   
       public String toString()
       {
  
  
  
  1.4       +6 -14     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ResourceProvider.java
  
  Index: ResourceProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ResourceProvider.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResourceProvider.java	30 Jul 2002 13:49:07 -0000	1.3
  +++ ResourceProvider.java	2 Aug 2002 06:36:09 -0000	1.4
  @@ -61,9 +61,9 @@
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.excalibur.meta.info.DependencyDescriptor;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
  -import org.apache.excalibur.merlin.assembly.ProfileManager;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
   import org.apache.excalibur.merlin.assembly.DefaultLoggerManager;
  -import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Association;
   import org.apache.excalibur.merlin.model.Resource;
  @@ -97,7 +97,7 @@
      /**
       * The classloader to use when servicing object creation requests.
       */
  -    private ProfileManager m_classloader;
  +    private ContainerManager m_classloader;
   
      /**
       * A hashtable of service implemenentation object references keyed by profile.
  @@ -122,20 +122,12 @@
       * @param loader the class loader
       * @param dictionary the parent dictionary
       */
  -    public ResourceProvider( ProfileManager loader, Context dictionary, DefaultLoggerManager logging )
  +    public ResourceProvider( ContainerManager loader, Context dictionary, DefaultLoggerManager logging )
       {
           m_classloader = loader;
           m_logging = logging;
  -
  -        // ## WARNING ###################################################################//
  -        // The following is a hack to add the avalon:work context key - this needs to    //
  -        // constructed using context creation directives at the level of the kernel      //
  -        // defintion (which requires the commons factory interface).                     //
  -        //###############################################################################//
  -
           m_dictionary = new DefaultContext( dictionary );
           m_dictionary.put( "classloader", loader );
  -        m_dictionary.put( "avalon:work", new File( System.getProperty("user.dir") ) );
           m_dictionary.makeReadOnly();
       }
   
  @@ -295,7 +287,7 @@
       public Configuration createConfiguration( Profile profile )
           throws Exception
       {
  -        Configuration config = profile.getConfiguration();
  +        Configuration config = profile.getConfiguration( m_classloader );
           if( config == null ) 
             config = new DefaultConfiguration("configuration", null );
           return config;
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ResourceRuntimeException.java
  
  Index: ResourceRuntimeException.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.merlin.assembly.resource;
  
  import java.util.Enumeration;
  import java.util.Dictionary;
  import java.util.Hashtable;
  
  import org.apache.avalon.framework.CascadingRuntimeException;
  
  /**
   * Exception to indicate that there was an error relating to resource management.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/08/02 06:36:09 $
   */
  public final class ResourceRuntimeException
      extends CascadingRuntimeException
  {
  
      /**
       * Construct a new <code>ResourceRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public ResourceRuntimeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ResourceRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public ResourceRuntimeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.19      +145 -60   jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java
  
  Index: DefaultContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DefaultContainer.java	30 Jul 2002 13:49:07 -0000	1.18
  +++ DefaultContainer.java	2 Aug 2002 06:36:10 -0000	1.19
  @@ -65,13 +65,16 @@
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
   import org.apache.excalibur.meta.verifier.VerifyException;
   import org.apache.excalibur.merlin.assembly.TypeManager;
  -import org.apache.excalibur.merlin.assembly.ProfileManager;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
   import org.apache.excalibur.merlin.assembly.DefaultLoggerManager;
  -import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.model.ClasspathDescriptor;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Resource;
  +import org.apache.excalibur.merlin.model.CategoriesDescriptor;
   import org.apache.excalibur.merlin.model.verifier.AssemblyVerifier;
   import org.apache.excalibur.merlin.model.verifier.MetaDataVerifier;
  +import org.apache.excalibur.merlin.model.builder.XMLContainerUtil;
   import org.apache.excalibur.merlin.Verifiable;
   import org.apache.excalibur.merlin.Controller;
   
  @@ -84,16 +87,16 @@
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
  -public class DefaultContainer extends AbstractLogEnabled implements Container, Contextualizable, Initializable, Disposable, Startable
  +public class DefaultContainer extends AbstractLogEnabled implements Container, Contextualizable, Configurable, Initializable, Disposable, Startable
   {
       //=======================================================================
       // static
       //=======================================================================
   
      /**
  -    * Context key used to locate the container meta data model.
  +    * Context key used to locate the container manager.
       */
  -    public static final String CONTAINER_DESCRIPTOR_KEY = "descriptor";
  +    public static final String MANAGER_KEY = "manager";
   
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultContainer.class );
  @@ -110,7 +113,7 @@
      /**
       * The classloader resolved from the meta model.
       */
  -    private ProfileManager m_classloader;
  +    private ContainerManager m_manager;
   
      /**
       * The meta data model of this container.
  @@ -122,6 +125,10 @@
       */
       private boolean m_initialized = false;
   
  +    private Configuration m_configuration;
  +
  +    private XMLContainerUtil m_creator = new XMLContainerUtil();
  +
       //=======================================================================
       // Contextualizable
       //=======================================================================
  @@ -129,15 +136,24 @@
      /**
       * <p>Service context from which the container meta data model is provided.</p>
       * <ul>
  -    *  <li>{@link #CONTAINER_DESCRIPTOR_KEY} the container meta model as 
  -    *         a {@link ContainerDescriptor} (REQUIRED}</li>
  +    *  <li>{@link #MANAGER_KEY} the container manager 
  +    *         a {@link ContainerManager} (REQUIRED}</li>
       * </ul>
       * @param context the service context value 
       */
       public void contextualize( Context context ) throws ContextException
       {
  -        m_descriptor = (ContainerDescriptor) context.get( CONTAINER_DESCRIPTOR_KEY );
  -        m_classloader = m_descriptor.getProfileManager();
  +        m_manager = (ContainerManager) context.get( MANAGER_KEY );
  +        m_descriptor = m_manager.getContainerDescriptor();
  +    }
  +
  +    //=======================================================================
  +    // Configurable
  +    //=======================================================================
  +
  +    public void configure( Configuration config )
  +    {
  +        m_configuration = config;
       }
   
       //=======================================================================
  @@ -154,26 +170,28 @@
       */
       public void initialize() throws Exception
       {
  -        getLogger().debug("initialization");
  -        getLogger().debug( "container creation using classloader: " + m_classloader );
  +        getLogger().debug( "initialization" );
  +
  +        Configuration[] components = m_configuration.getChildren("component");
  +        for( int i=0; i<components.length; i++ )
  +        {
  +            Configuration config = components[i];
  +            Type type = m_manager.loadType( config.getAttribute("class") );
  +            Profile profile = m_creator.createProfile( type, config );
  +            m_descriptor.addComponent( profile );
  +            m_manager.addProfile( profile );
  +        }
   
           // 
  -        // explicit component profile registration
  +        // initiate component assembly
           //
   
           getLogger().debug("explicit profile registration");
  -        Profile[] children = m_descriptor.getComponents( Profile.EXPLICIT, true );
  -        for( int i=0; i<children.length; i++ )
  -        {
  -            Profile profile = children[i];
  -            m_classloader.addProfile( profile );
  -        }
  -
  +        Profile[] profiles = m_descriptor.getComponents( Profile.EXPLICIT, true );
           try
           {
  -            getLogger().debug("profile assembly");
  -            //m_profiles.assemble( children );
  -            m_classloader.assemble( children );
  +            getLogger().debug("profile assembly (" + profiles.length + ")");
  +            m_manager.assemble( profiles );
           }
           catch( Throwable e )
           {
  @@ -182,17 +200,16 @@
           }
   
           //
  -        // Place the profiles into resource designators so that we can publish 
  -        // the service to service/component managers and finsh up initialization
  -        // with the creation of the subsidiary containers.
  +        // creation of the subsidiary containers
           //
   
           getLogger().debug("subsidiary container creation");
  -        ContainerDescriptor[] containers = m_descriptor.getContainers();
  -        for( int i=0; i<containers.length; i++ )
  +
  +        final Configuration[] configs = m_configuration.getChildren("container");
  +        for( int i=0; i<configs.length; i++ )
           {
  -            getLogger().debug("container: " + containers[i].getName() );
  -            m_containers.add( createContainer( containers[i] ) );
  +            final Configuration conf = configs[i];
  +            m_containers.add( createContainer( conf ) );
           }
   
           //
  @@ -235,8 +252,27 @@
       */
       public void start() throws Exception
       {
  -        getLogger().debug("start");
  -        m_classloader.start();
  +        if( getLogger().isInfoEnabled() )
  +        {
  +            Profile[] profiles = m_manager.getStartupGraph( false );
  +            if( profiles.length > 0 )
  +            {
  +                StringBuffer buffer = new StringBuffer();
  +                for( int i=0; i<profiles.length; i++ )
  +                {
  +                    Profile profile = profiles[i];
  +                    buffer.append( profiles[i].getName() );
  +                    if( i<(profiles.length-1) )
  +                          buffer.append(", ");
  +                }  
  +                getLogger().info("startup: " + buffer.toString() );
  +            }
  +            else
  +            {
  +                getLogger().info( "startup" );
  +            }
  +        }
  +        m_manager.start();
       }
   
      /**
  @@ -247,8 +283,28 @@
       */
       public void stop()
       {
  -        getLogger().debug("stop");
  -        m_classloader.stop();
  +        if( getLogger().isInfoEnabled() )
  +        {
  +            Profile[] profiles = m_manager.getShutdownGraph();
  +        
  +            if( profiles.length > 0 )
  +            {
  +                StringBuffer buffer = new StringBuffer();
  +                for( int i=0; i<profiles.length; i++ )
  +                {
  +                    Profile profile = profiles[i];
  +                    buffer.append( profiles[i].getName() );
  +                    if( i<(profiles.length-1) )
  +                          buffer.append(", ");
  +                }  
  +                getLogger().info("shutdown: " + buffer.toString() );
  +            }
  +            else
  +            {
  +                getLogger().info( "shutdown" );
  +            }
  +        }
  +        m_manager.stop();
       }
   
       //======================================================================
  @@ -261,22 +317,23 @@
       public void startup() throws Exception
       {
   
  +        if( getLogger().isDebugEnabled() )
  +          getLogger().debug("container startup");
  +
           //
           // startup all of the components in this container 
           // before starting up any of the nested containers
           //
   
  -        if( getLogger().isDebugEnabled() )
  -          getLogger().debug("startup");
  -
           start();
  +
           Iterator iterator = m_containers.iterator();
           while( iterator.hasNext() )
           {
               ((Controller)iterator.next()).startup();
           }
   
  -        getLogger().info("container startup complete");
  +        getLogger().debug("container startup complete");
       }
   
      /**
  @@ -285,20 +342,23 @@
       public void shutdown()
       {
   
  +        if( getLogger().isDebugEnabled() )
  +          getLogger().debug("container shutdown");
  +
           //
           // shutdown all of the nested containers before stopping 
           // the components in this container 
           //
   
  -        if( getLogger().isDebugEnabled() )
  -          getLogger().debug("shutdown");
           Iterator iterator = m_containers.iterator();
           while( iterator.hasNext() )
           {
               ((Controller)iterator.next()).shutdown();
           }
  +
           stop();
  -        getLogger().info("container shutdown complete");
  +
  +        getLogger().debug("container shutdown complete");
       }
   
       //=======================================================================
  @@ -316,7 +376,7 @@
             throw new IllegalStateException("not-initialized");
   
           ArrayList list = new ArrayList();
  -        Resource[] local = m_classloader.getExport();
  +        Resource[] local = m_manager.getExport();
           for( int i=0; i<local.length; i++ )
           {
               list.add( local[i] );
  @@ -360,17 +420,14 @@
       private void verifyContainer() throws VerifyException
       {
           getLogger().debug("verify");
  -        
           /*
  -        ### Need to move this to the profile manager ####
  -
  -        Profile[] profiles = m_map.getStartupGraph();
  +        Profile[] profiles = m_manager.getStartupGraph( false );
           MetaDataVerifier mdv = new MetaDataVerifier();
           for( int i=0; i<profiles.length; i++ )
           {
               try
               {
  -                mdv.verifyType( profiles[i], m_classloader );
  +                mdv.verifyType( profiles[i], m_manager );
               }
               catch( Throwable e )
               {
  @@ -425,19 +482,47 @@
       * @param descriptor the subsidiary container descriptor
       * @exception Exception is an error occurs
       */
  -    private DefaultContainer createContainer( ContainerDescriptor descriptor ) throws Exception
  +    private DefaultContainer createContainer( Configuration config ) throws Exception
       {
  -        String name = descriptor.getName();
  -        getLogger().info("creating child container: " + name );
  -        DefaultContext context = new DefaultContext();
  -        context.put( CONTAINER_DESCRIPTOR_KEY, descriptor );
  -        context.makeReadOnly();
  +        ContainerManager manager = null;
  +        String name = null;
  +        try
  +        {
  +            name = config.getAttribute("name");
  +            ClasspathDescriptor classpath = 
  +              m_creator.createClasspathDescriptor( config.getChild("classpath") );
  +            CategoriesDescriptor categories = 
  +              m_creator.createCategoriesDescriptor( name, config.getChild("categories") );
  +            ContainerDescriptor descriptor = 
  +              new ContainerDescriptor( name, classpath, categories );
  +            manager = m_manager.createContainerManager( descriptor, false );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Error establishing subsidiary container manager.";
  +            throw new ContainerException( error, e );
  +        }
  +
  +        try
  +        {
  +
  +            getLogger().info("creating subsidiary container: " + name );
  +            DefaultContext context = new DefaultContext();
  +            context.put( MANAGER_KEY, manager );
  +            context.makeReadOnly();
     
  -        DefaultContainer container = new DefaultContainer();
  -        final Logger logger = getLogger().getChildLogger( name );
  -        container.enableLogging( logger );
  -        container.contextualize( context );
  -        container.initialize( );
  -        return container;
  +            DefaultContainer container = new DefaultContainer();
  +            final Logger logger = getLogger().getChildLogger( name );
  +            container.enableLogging( logger );
  +            container.contextualize( context );
  +            container.configure( config );
  +            container.initialize( );
  +            return container;
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Error establishing subsidiary container.";
  +            throw new ContainerException( error, e );
  +        }
       }
   }
  
  
  
  1.6       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.xinfo
  
  Index: DefaultContainer.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.xinfo,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultContainer.xinfo	29 Jul 2002 06:14:30 -0000	1.5
  +++ DefaultContainer.xinfo	2 Aug 2002 06:36:10 -0000	1.6
  @@ -18,9 +18,9 @@
     </component>
   
     <context>
  -    <entry key="classloader" type="org.apache.excalibur.merlin.assembly.ProfileManager" optional="false"/>
  +    <entry key="classloader" type="org.apache.excalibur.merlin.assembly.ContainerManager" optional="false"/>
       <entry key="logging" type="org.apache.excalibur.merlin.assembly.DefaultLoggerManager" optional="false"/>
  -    <entry key="descriptor" type="org.apache.excalibur.merlin.container.model.ContainerDescriptor" optional="false"/>
  +    <entry key="descriptor" type="org.apache.excalibur.merlin.model.ContainerDescriptor" optional="false"/>
       <entry key="map" type="org.apache.excalibur.merlin.assembly.DependencyGraph" optional="false"/>
       <entry key="container" type="org.apache.excalibur.merlin.container.Container" optional="true"/>
     </context>
  
  
  
  1.3       +16 -19    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/doc-files/DefaultController.gif
  
  	<<Binary file>>
  
  
  1.25      +138 -62   jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- DefaultKernel.java	30 Jul 2002 13:49:08 -0000	1.24
  +++ DefaultKernel.java	2 Aug 2002 06:36:10 -0000	1.25
  @@ -64,14 +64,19 @@
   import org.apache.excalibur.meta.info.DependencyDescriptor;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
   import org.apache.excalibur.meta.info.EntryDescriptor;
  -import org.apache.excalibur.merlin.kernel.model.KernelDescriptor;
  -import org.apache.excalibur.merlin.container.model.DirsetDescriptor;
  +import org.apache.excalibur.merlin.model.builder.XMLContainerUtil;
  +import org.apache.excalibur.merlin.model.DirsetDescriptor;
  +import org.apache.excalibur.merlin.model.ExtensionsDescriptor;
  +import org.apache.excalibur.merlin.model.ClasspathDescriptor;
   import org.apache.excalibur.merlin.model.Profile;
  -import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.model.CategoriesDescriptor;
  +import org.apache.excalibur.merlin.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.merlin.assembly.TypeManager;
  -import org.apache.excalibur.merlin.assembly.ProfileManager;
  -import org.apache.excalibur.merlin.kernel.builder.XMLKernelCreator;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
  +import org.apache.excalibur.merlin.model.builder.XMLContainerUtil;
  +import org.apache.excalibur.merlin.model.LoggingDescriptor;
  +import org.apache.excalibur.merlin.container.Container;
   import org.apache.excalibur.merlin.container.DefaultContainer;
   
   /**
  @@ -84,34 +89,32 @@
    * <pre>
      
           <font color="gray">//
  +        // create the execution context
  +        //</font>
  +  
  +        File <strong>base</strong> = new File( <font color="darkred"/>&quot;.&quot;</font> );
  +        DefaultContext <strong>context</strong> = new DefaultContext();
  +        <strong>context</strong>.put( DefaultKernel.APPLICATION_DIR_KEY, <strong>base</strong> );
  +        <strong>context</strong>.makeReadOnly();
  +       
  +        <font color="gray">//
           // Read in the configuration.
           //</font>
   
  -        File <strong>file</strong> = new File("<font color="darkred"/>kernel.xml</font>");
  +        File <strong>file</strong> = new File("<font color="darkred"/>base</font>, "<font color="darkred"/>kernel.xml</font>");
           {@link DefaultConfigurationBuilder} <strong>builder</strong> = new DefaultConfigurationBuilder();
           InputStream <strong>input</strong> = new FileInputStream( <strong>file</strong> );
           {@link Configuration} <strong>configuration</strong> = <strong>builder</strong>.build( <strong>input</strong> );
   
           <font color="gray">//
  -        // Create the kernel meta model using the configuration and a root classloder.
  -        //</font>
  -
  -        ClassLoader <strong>classloader</strong> = Thread.currentThread().getContextClassLoader();
  -        {@link XMLKernelCreator} <strong>creator</strong> = new XMLKernelCreator();
  -        {@link KernelDescriptor} <strong>descriptor</strong> = <strong>creator</strong>.createKernelDescriptor(
  -           <strong>configuration</strong>, <strong>classloader</strong> );
  -
  -        <font color="gray">//
  -        // Create a kernel implementation.
  +        // Create the kernel.
           //</font>
   
  -        {@link DefaultContext} <strong>context</strong> = new DefaultContext();
  -        <strong>context</strong>.put( DefaultKernel.{@link #KERNEL_DESCRIPTOR_KEY}, <strong>descriptor</strong> );
  -        <strong>context</strong>.makeReadOnly();
           DefaultKernel <strong>kernel</strong> = new DefaultKernel();
           Logger <strong>logger</strong> = <strong>descriptor</strong>.getLogger();
           <strong>kernel</strong>.enableLogging( <strong>logger</strong> );
           <strong>kernel</strong>.contextualize( <strong>context</strong> );
  +        <strong>kernel</strong>.configure( <strong>configuration</strong> );
           <strong>kernel</strong>.initialize();
   
           <font color="gray">//
  @@ -126,24 +129,19 @@
   
    * </pre>
    *
  - * @see XMLKernelCreator
  - * @see KernelDescriptor
    * @see Kernel
    *
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
  -public class DefaultKernel extends AbstractLogEnabled 
  -  implements Kernel, Contextualizable, Initializable, Startable, Disposable
  +public class DefaultKernel extends AbstractLogEnabled
  +  implements Kernel, Contextualizable, Configurable, Initializable, Startable, Disposable
   {
       //=======================================================================
       // static
       //=======================================================================
   
  -   /**
  -    * Context key used by the kernel to access the kernel meta-data descriptor.
  -    */
  -    public static final String KERNEL_DESCRIPTOR_KEY = "descriptor";
  +    public static final String APPLICATION_DIR_KEY = "avalon:home";
   
       //=======================================================================
       // state
  @@ -153,8 +151,6 @@
   
       private boolean m_verified = false;
   
  -    private KernelDescriptor m_descriptor;
  -
       private boolean m_initialized = false;
   
      /**
  @@ -167,69 +163,145 @@
       */
       private ArrayList m_services = new ArrayList();
   
  +    private ContainerManager m_manager;
  +
  +    private Logger m_logger;
  +
  +    private Configuration m_config;
  +
  +    private Context m_context;
  +
  +    private XMLContainerUtil m_creator = new XMLContainerUtil();
  +
       //=======================================================================
       // Contextualizable
       //=======================================================================
   
      /**
  -    * Invoked by the bootstrap process to supply to kernel defintion.
  +    * Invoked by the bootstrap process to supply the root directory.
       * @param context the context object containing the inital parameters
       * @exception ContextException if the supplied does not contain a 
  -    *   KERNEL_CONTAINER_DESCRIPTOR_KEY value.
  +    *   APPLICATION_DIR_KEY value.
       */
       public void contextualize( Context context ) throws ContextException
       {
  -        m_descriptor = (KernelDescriptor) context.get( KERNEL_DESCRIPTOR_KEY );
  +        m_context = context;
  +        context.get( APPLICATION_DIR_KEY );
       }
   
       //=======================================================================
  -    // Initializable
  +    // Configurable
       //=======================================================================
   
  -    public void initialize() throws Exception
  +    public void configure( Configuration config )
       {
  -        getLogger().debug( "creating root container descriptor" );
  -        ContainerDescriptor descriptor = m_descriptor.getContainer();
  +        m_config = config;
  +    }
   
  -        //
  -        // root container context creation
  -        //
  -
  -        getLogger().debug( "root container context creation" );
  -        DefaultContext context = new DefaultContext();
  -        context.put( DefaultContainer.CONTAINER_DESCRIPTOR_KEY, descriptor );
  -        context.makeReadOnly();
  -
  -        //
  -        // container instantiation
  -        //
  +    //=======================================================================
  +    // Initializable
  +    //=======================================================================
   
  -        getLogger().debug( "root container instantiation" );
  +    public void initialize() throws Exception
  +    {
           try
           {
  -            m_container = new DefaultContainer();
  -            m_container.enableLogging( descriptor.getLogger() );
  -            m_container.contextualize( context );
  -            m_container.initialize( );
  -            m_container.verify();
  +            DefaultContext ctx = new DefaultContext( m_context );
  +
  +            String name = m_config.getName();
  +
  +            ExtensionsDescriptor extensions = 
  +              m_creator.createExtensionsDescriptor( m_config.getChild("extensions") );
  +            ClasspathDescriptor classpath = 
  +              m_creator.createClasspathDescriptor( m_config.getChild("classpath") );
  +            LoggingDescriptor loggingDescriptor = 
  +              m_creator.createLoggingDescriptor( m_config.getChild("logging"), name );
  +            CategoriesDescriptor categories = 
  +              m_creator.createCategoriesDescriptor( name, m_config.getChild("categories") );
  +
  +            m_manager = new ContainerManager( name );
  +            ctx.put( ContainerManager.LOGGING_DESCRIPTOR_KEY, loggingDescriptor );
  +            ctx.put( ContainerManager.CATEGORIES_DESCRIPTOR_KEY, categories );
  +            ctx.put( ContainerManager.EXTENSIONS_DESCRIPTOR_KEY, extensions );
  +            ctx.put( ContainerManager.CLASSPATH_DESCRIPTOR_KEY, classpath );
  +            m_manager.contextualize( ctx );
  +            m_manager.initialize();
  +
  +            if( getLogger() == null )
  +            {
  +                enableLogging( m_manager.getLoggingManager().getLoggerForCategory( name ) );
  +            }
  +            getLogger().debug("kernel manager established");
  +
           }
           catch( Throwable e )
           {
  -            final String error = "Kernel initialization failure.";
  -            if( getLogger() != null )
  -              getLogger().error( error, e );
  -            throw new KernelException( error, e );
  +            final String error = "manager establishment failure";
  +            throw new KernelException( error );
           }
   
  +        final Configuration config = m_config.getChild("container");
  +        m_container = createContainer( config );
  +        
  +        /*
  +        getLogger().info( "listing exportable resources" );
           Resource[] resources = getResources();
           Logger export = getLogger().getChildLogger( "export" );
           for( int i=0; i<resources.length; i++ )
           {
               export.info( resources[i].getPath() );
           }
  -
  +        */
           m_initialized = true;
  +    }
  +
  +   /**
  +    * Internal utility to create the root container.
  +    *
  +    * @param descriptor the subsidiary container descriptor
  +    * @exception Exception is an error occurs
  +    */
  +    private DefaultContainer createContainer( Configuration config ) throws Exception
  +    {
  +        ContainerManager manager = null;
  +        String name = null;
  +        try
  +        {
  +            name = config.getAttribute( "name", "root");
  +            ClasspathDescriptor classpath = 
  +              m_creator.createClasspathDescriptor( config.getChild("classpath") );
  +            CategoriesDescriptor categories = 
  +              m_creator.createCategoriesDescriptor( name, config.getChild("categories") );
  +            ContainerDescriptor descriptor = 
  +              new ContainerDescriptor( name, classpath, categories );
  +            manager = m_manager.createContainerManager( descriptor, true );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Error establishing subsidiary container manager.";
  +            throw new KernelException( error, e );
  +        }
   
  +        try
  +        {
  +            getLogger().info("creating root container: " + name );
  +            DefaultContext context = new DefaultContext();
  +            context.put( DefaultContainer.MANAGER_KEY, manager );
  +            context.makeReadOnly();
  +  
  +            DefaultContainer container = new DefaultContainer();
  +            Logger logger = manager.getLoggingManager().getLoggerForCategory( name );
  +            container.enableLogging( logger );
  +            container.contextualize( context );
  +            container.configure( config );
  +            container.initialize( );
  +            return container;
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Error establishing root container.";
  +            throw new KernelException( error, e );
  +        }
       }
   
       //=======================================================================
  @@ -260,6 +332,7 @@
       {
           if( !m_initialized ) return;
           //listProfiles();
  +
           if( getLogger().isInfoEnabled() )
             getLogger().info("startup");
   
  @@ -277,7 +350,6 @@
           getLogger().info("startup complete");
       }
   
  -
       public void stop()
       {
           if( !m_initialized ) return;
  @@ -305,9 +377,13 @@
       // Kernel
       //=======================================================================
   
  +    public Container getRootContainer()
  +    {
  +        return m_container;
  +    }
  +
       public Resource[] getResources()
       {
           return m_container.getResources();
       }
  -
   }
  
  
  
  1.8       +1 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.xinfo
  
  Index: DefaultKernel.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.xinfo,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultKernel.xinfo	29 Jul 2002 06:14:32 -0000	1.7
  +++ DefaultKernel.xinfo	2 Aug 2002 06:36:10 -0000	1.8
  @@ -18,9 +18,7 @@
     </component>
   
     <context>
  -    <entry key="classloader" type="org.apache.excalibur.merlin.assembly.ProfileManager" optional="false"/>
  -    <entry key="logging" type="org.apache.excalibur.merlin.assembly.DefaultLoggerManager" optional="false"/>
  -    <entry key="descriptor" type="org.apache.excalibur.merlin.kernel.model.KernelDescriptor" optional="false"/>
  +    <entry key="avalon:home" type="java.io.File" optional="false"/>
     </context>
   
     <services>
  
  
  
  1.3       +21 -22    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/doc-files/DefaultKernel.gif
  
  	<<Binary file>>
  
  

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


Mime
View raw message