mcconnell    2002/08/08 02:58:41

  Added:       assembly/src/java/org/apache/excalibur/merlin/assembly
                        KernelManager.java
  Log:
  Seperation of Kernel and Container management.
  
  Revision  Changes    Path
  1.1                  
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/KernelManager.java
  
  Index: KernelManager.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;
  
  import java.io.File;
  import java.util.List;
  import java.util.Map;
  import java.util.ArrayList;
  import java.util.LinkedList;
  import java.util.Hashtable;
  import java.util.ArrayList;
  import java.util.Vector;
  import java.util.Iterator;
  import org.apache.avalon.framework.CascadingException;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.DefaultContext;
  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.Configurable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.excalibur.configuration.ConfigurationUtil;
  import org.apache.excalibur.merlin.assembly.resource.LifecycleHelper;
  import org.apache.excalibur.merlin.assembly.resource.ResourceProvider;
  import org.apache.excalibur.merlin.assembly.resource.ProfileDesignator;
  import org.apache.excalibur.merlin.model.ContainerDescriptor;
  import org.apache.excalibur.merlin.model.ClasspathDescriptor;
  import org.apache.excalibur.merlin.container.Container;
  import org.apache.excalibur.merlin.container.DefaultContainer;
  import org.apache.excalibur.merlin.model.LoggingDescriptor;
  import org.apache.excalibur.merlin.model.builder.XMLContainerUtil;
  import org.apache.excalibur.merlin.model.Category;
  import org.apache.excalibur.merlin.model.CategoriesDescriptor;
  import org.apache.excalibur.merlin.model.Profile;
  import org.apache.excalibur.merlin.model.Resource;
  import org.apache.excalibur.meta.info.PhaseDescriptor;
  import org.apache.excalibur.meta.info.ServiceDescriptor;
  import org.apache.excalibur.meta.info.ReferenceDescriptor;
  import org.apache.excalibur.meta.info.DependencyDescriptor;
  import org.apache.excalibur.meta.info.ExtensionDescriptor;
  import org.apache.excalibur.meta.info.Type;
  import org.apache.excalibur.meta.info.Facility;
  import org.apache.excalibur.meta.verifier.ComponentVerifier;
  
  /**
   * Classloader for an assembly of components that provides the complete
   * assembly engine, profile selection management, and resource creation
   * functionality.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/08/08 09:58:40 $
   */ 
  
  public class KernelManager extends ContainerManager
  {
  
      //===================================================================
      // static
      //===================================================================
  
      private static final Resources REZ =
          ResourceManager.getPackageResources( KernelManager.class );
  
     /**
      * Context key used by the kernel to access the kernel meta-data 
descriptor.
      */
      public static final String LOGGING_KEY = "logging";
  
      //===================================================================
      // state
      //===================================================================
  
     /**
      * The description of the logging system that contains the declaration of 
      * the logging targets to use.  This value is used as the constructor 
      * argument to the DefaultLoggerManager.
      */
      //private LoggingDescriptor m_loggingDescriptor;
  
     /**
      * The logging manager that we use to construct logging catagories 
      * and logging channels.
      */
      private DefaultLoggerManager m_logging;
  
      //===================================================================
      // constructor
      //===================================================================
  
     /**
      * Creation of a new KernelManager.
      */
      public KernelManager( )
      {
          this( "kernel" );
      }
  
     /**
      * Creation of a new <code>KernelManager</code>.
      * @param path the relative path to assign to this classloader
      */
      public KernelManager( String path )
      {
          this(  Thread.currentThread().getContextClassLoader(), path );
      }
  
     /**
      * Creation of a new <code>KernelManager</code>.
      * @param parent the parent classloader
      * @param name the relative path to assign to this classloader
      */
      public KernelManager( ClassLoader parent, String path )
      {
          super( parent, path );
      }
  
      //=======================================================================
      // Contextualizable
      //=======================================================================
  
     /**
      * Declaration of the logging manager.
      * @param context the context object containing the logging manager
      */
      public void contextualize( Context context ) throws ContextException
      {
          m_logging = (DefaultLoggerManager) context.get( LOGGING_KEY );
          super.contextualize( context );
      }
  
      //=======================================================================
      // Initializable
      //=======================================================================
  
      public void initialize() throws Exception
      {
          super.initialize();
      }
  
      protected DefaultLoggerManager getLoggingManager()
      {
          if( m_logging != null ) 
          {
              return m_logging;
          }
          else
          {
              ContainerManager parent = getParentManager();
              if( parent != null )
              {
                  return parent.getLoggingManager();
              }
              else
              {
                  throw new NullPointerException("logging");
              }
          }
      }
  
      //===================================================================
      // Disposable
      //===================================================================
  
      public void dispose()
      {
          super.dispose();
          m_logging = null;
      }
  
  }
  
  
  

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

Reply via email to