You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2002/08/12 08:08:55 UTC

cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model Resource.java

mcconnell    2002/08/11 23:08:54

  Modified:    assembly build.xml
               assembly/demo/src/java/org/apache/excalibur/playground
                        SimpleComponent.java
               assembly/src/etc kernel.xml
               assembly/src/java/org/apache/excalibur/merlin/assembly
                        ContainerManager.java ProfileRegistry.java
               assembly/src/java/org/apache/excalibur/merlin/assembly/resource
                        LifecycleHelper.java ResourceProvider.java
               assembly/src/java/org/apache/excalibur/merlin/container
                        DefaultContainer.java
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java
               assembly/src/java/org/apache/excalibur/merlin/model
                        Resource.java
  Added:       assembly/src/java/org/apache/excalibur/merlin/assembly/resource
                        DefaultResource.java LifestyleHandler.java
                        SingletonLifestyleHandler.java
  Removed:     assembly/src/java/org/apache/excalibur/merlin/assembly/resource
                        ProfileDesignator.java
  Log:
  Lifestyle handler seperation.
  
  Revision  Changes    Path
  1.39      +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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- build.xml	9 Aug 2002 12:26:45 -0000	1.38
  +++ build.xml	12 Aug 2002 06:08:54 -0000	1.39
  @@ -296,8 +296,8 @@
   
     <target name="patch">
       <replace dir="${src.dir}/java" 
  -       token="org.apache.excalibur.merlin.builder"
  -       value="org.apache.excalibur.merlin.model.builder" >
  +       token="ProfileDesignator"
  +       value="DefaultResource" >
        <include name="org/apache/excalibur/merlin/**/*.*"/>
       </replace>
     </target>
  
  
  
  1.11      +3 -3      jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.java
  
  Index: SimpleComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SimpleComponent.java	2 Aug 2002 06:29:20 -0000	1.10
  +++ SimpleComponent.java	12 Aug 2002 06:08:54 -0000	1.11
  @@ -54,12 +54,12 @@
   
       public void incarnate() 
       {
  -        getLogger().info( "incarnation phase in exploitable" );
  +        getLogger().info( "incarnation stage" );
       }
   
       public void etherialize()
       {
  -        getLogger().info( "etherialize phase in exploitable" );
  +        getLogger().info( "etherialize stage" );
       }
   
   
  @@ -69,7 +69,7 @@
   
       public void demo( String stage )
       {
  -        getLogger().info( stage + " stage in demonstratable");
  +        getLogger().info( stage + " stage (demonstratable)");
       }
   
       //=======================================================================
  
  
  
  1.30      +1 -1      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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- kernel.xml	12 Aug 2002 02:00:08 -0000	1.29
  +++ kernel.xml	12 Aug 2002 06:08:54 -0000	1.30
  @@ -22,7 +22,7 @@
      the corresponds to the name of the logging file.
      -->
   
  -   <logging priority="DEBUG" target="default">
  +   <logging priority="INFO" target="default">
        <category priority="WARN"  name="logging" />
         <target name="kernel">
           <file location="kernel.log" />
  
  
  
  1.11      +36 -15    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java
  
  Index: ContainerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ContainerManager.java	12 Aug 2002 02:00:08 -0000	1.10
  +++ ContainerManager.java	12 Aug 2002 06:08:54 -0000	1.11
  @@ -37,7 +37,9 @@
   import org.apache.excalibur.merlin.assembly.resource.LifecycleHelper;
   import org.apache.excalibur.merlin.assembly.resource.ResourceProvider;
   import org.apache.excalibur.merlin.assembly.resource.ResourceException;
  -import org.apache.excalibur.merlin.assembly.resource.ProfileDesignator;
  +import org.apache.excalibur.merlin.assembly.resource.DefaultResource;
  +import org.apache.excalibur.merlin.assembly.resource.LifestyleHandler;
  +import org.apache.excalibur.merlin.assembly.resource.SingletonLifestyleHandler;
   import org.apache.excalibur.merlin.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.ClasspathDescriptor;
   import org.apache.excalibur.merlin.container.Container;
  @@ -277,7 +279,7 @@
           // setup the assembly sub-system
           //
   
  -        m_registry = new ProfileRegistry( this, m_map, m_helper, m_provider );
  +        m_registry = new ProfileRegistry( this, m_map );
           m_registry.enableLogging( getLocalLogger().getChildLogger( "assembly") );
   
           //
  @@ -335,11 +337,8 @@
               if( profile.getActivationPolicy() )
               {
                   Resource resource = getResource( profile );
  -                if( resource.getState() == Resource.NOT_STARTED )
  -                {
  -                    getLocalLogger().info( profile + " [activating]"); 
  -                    resource.access();
  -                }
  +                getLocalLogger().info( profile + " [activating]"); 
  +                resource.access();
               }
               else
               {
  @@ -401,11 +400,8 @@
               try
               {
                   Resource resource = getResource( profile );
  -                if( resource.getState() == Resource.STARTED )
  -                {
  -                    getLocalLogger().info( "stopping: " + profile ); 
  -                    resource.destroy();
  -                }
  +                getLocalLogger().info( "stopping: " + profile ); 
  +                resource.dispose();
               }
               catch ( Throwable e )
               {
  @@ -439,6 +435,12 @@
                                    ClasspathDescriptor classpath )
       {
   
  +        //
  +        // bootstrap the creation of logging categories here because
  +        // logging will occur before the actual container is created
  +        // and we need to manage type and profile related log messages
  +        //
  +
           String path;
           final String name = descriptor.getName();
           if( this instanceof KernelManager )
  @@ -453,6 +455,10 @@
           CategoriesDescriptor categories = descriptor.getCategories();
           getLoggingManager().addCategories( path, categories );
   
  +        //
  +        // create a new profile manager as a child of this manager
  +        //
  +
           try
           {
               ContainerManager loader = new ContainerManager( this, name );
  @@ -490,6 +496,10 @@
           return m_path;
       }
   
  +   /**
  +    * Return the singleton logging manager.
  +    * @return the logging manager
  +    */
       protected DefaultLoggerManager getLoggingManager()
       {
           ContainerManager parent = getParentManager();
  @@ -730,8 +740,19 @@
           if( resource != null )
             return resource;
   
  -        ProfileDesignator designator = 
  -          new ProfileDesignator( getPath(), profile, context, m_helper, m_provider );
  +        // ######################################################################
  +        // ##                                                                   #
  +        // ## This is where we need to lookup a lifestyle policy handler and    #
  +        // ## assemble it before supplying it to the default resource instance. #
  +        // ##                                                                   #
  +        // ######################################################################
  +
  +        SingletonLifestyleHandler handler = 
  +           new SingletonLifestyleHandler( this, m_provider, m_helper, profile, context );
  +        handler.enableLogging( getLocalLogger().getChildLogger("lifestyle") );
  +
  +        DefaultResource designator = 
  +          new DefaultResource( getPath(), profile, context, handler );
           designator.enableLogging( getLocalLogger().getChildLogger( "resource" ) );
           m_resources.put( profile, designator );
           return designator;
  
  
  
  1.10      +3 -7      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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ProfileRegistry.java	12 Aug 2002 02:00:09 -0000	1.9
  +++ ProfileRegistry.java	12 Aug 2002 06:08:54 -0000	1.10
  @@ -35,7 +35,7 @@
   import org.apache.excalibur.merlin.assembly.resource.LifecycleHelper;
   import org.apache.excalibur.merlin.assembly.resource.ResourceProvider;
   import org.apache.excalibur.merlin.assembly.resource.ResourceException;
  -import org.apache.excalibur.merlin.assembly.resource.ProfileDesignator;
  +import org.apache.excalibur.merlin.assembly.resource.DefaultResource;
   
   /**
    * Internal table that holds available component type keyed relative
  @@ -85,14 +85,10 @@
       */
       public ProfileRegistry( 
                         ContainerManager manager, 
  -                      DependencyGraph map, 
  -                      LifecycleHelper helper, 
  -                      ResourceProvider provider )
  +                      DependencyGraph map )
       {
           m_manager = manager;
           m_map = map;
  -        m_helper = helper;
  -        m_provider = provider;
       }
   
       //=======================================================================
  
  
  
  1.6       +9 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LifecycleHelper.java	12 Aug 2002 02:00:09 -0000	1.5
  +++ LifecycleHelper.java	12 Aug 2002 06:08:54 -0000	1.6
  @@ -79,13 +79,17 @@
       * @throws LifecycleException if an error occurs when the component passes
       *     through a specific lifecycle stage
       */
  -    public Object startup( final String path,
  +    public Object startup( final Object object,
  +                           final String path,
                              final Profile profile,
                              final ResourceProvider provider,
                              final Context phaseContext )
           throws LifecycleException
       {
   
  +        if( object == null )
  +          throw new NullPointerException("object");
  +
           if( path == null )
             throw new NullPointerException("path");
   
  @@ -104,9 +108,9 @@
           try
           {
               //Creation stage
  -            stage = STAGE_CREATE;
  -            notice( path, stage );
  -            final Object object = provider.createObject( profile );
  +            //stage = STAGE_CREATE;
  +            //notice( path, stage );
  +            //final Object object = provider.createObject( profile );
   
               //LogEnabled stage
               stage = STAGE_LOGGER;
  @@ -251,6 +255,7 @@
           Throwable failure = null;
   
           //Stoppable stage
  +
           if( object instanceof Startable )
           {
               notice( name, STAGE_STOP );
  
  
  
  1.6       +3 -81     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ResourceProvider.java	12 Aug 2002 02:00:09 -0000	1.5
  +++ ResourceProvider.java	12 Aug 2002 06:08:54 -0000	1.6
  @@ -87,14 +87,6 @@
   public class ResourceProvider extends AbstractLogEnabled
   {
   
  -    //#######################################################################
  -    //##                                                                   ##
  -    //##  This class will be changed to a interface and singleton policy   ##
  -    //##  implementation class and probably an underlying abstract         ##
  -    //##  provider class.                                                  ##
  -    //##                                                                   ##
  -    //#######################################################################
  -
       //=======================================================================
       // state
       //=======================================================================
  @@ -116,15 +108,9 @@
       private ContainerManager m_classloader;
   
      /**
  -    * A hashtable of service implemenentation object references keyed by profile.
  -    */
  -    private final Hashtable m_singletons = new Hashtable();
  -
  -   /**
  -    * A hashtable of profiles keyed by singleton object.
  +    * Context object containing system level values that is used 
  +    * as a sources for import directives.
       */
  -    private final Hashtable m_profiles = new Hashtable();
  -
       private DefaultContext m_dictionary;
   
       //=======================================================================
  @@ -152,59 +138,6 @@
       //=======================================================================
   
       /**
  -     * Create an object specified by profile.
  -     *
  -     * @param profile the profile
  -     * @return the new object
  -     * @throws Exception if unable to resolve resource
  -     */
  -    public Object createObject( Profile profile )
  -        throws Exception
  -    {
  -        Object object = getSingletonInstance( profile );
  -        if( object == null )
  -        {
  -            //
  -            // load the class
  -            //
  -
  -            Class clazz = null;
  -            String classname = null;
  -            try
  -            {
  -                classname = profile.getType().getInfo().getImplementationKey();
  -                clazz = m_classloader.loadClass( classname );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = 
  -                  "Unexpected exception while attempting to load class '" 
  -                  + classname + "' for the profile: " + profile;
  -                throw new ResourceException( error, e );
  -            }
  -
  -            //
  -            // create a new instance of the class
  -            //
  -
  -            try
  -            {
  -                object = clazz.newInstance();
  -                putSingletonInstance( profile, object );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = 
  -                  "Unexpected exception while attempting to instantiate an instance from profile: " 
  -                    + profile;
  -                throw new ResourceException( error, e );
  -            }
  -
  -        }
  -        return object;
  -    }
  -
  -    /**
        * Create a new Logger for component.
        *
        * @param profile the profile
  @@ -512,17 +445,6 @@
           }
           parameters.makeReadOnly();
           return parameters;
  -    }
  -
  -    private Object getSingletonInstance( Profile profile )
  -    {
  -        return m_singletons.get( profile );
  -    }
  -
  -    private void putSingletonInstance( Profile profile, Object object )
  -    {
  -        m_singletons.put( profile, object );
  -        m_profiles.put( object, profile );
       }
   
      /**
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultResource.java
  
  Index: DefaultResource.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 org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.excalibur.merlin.assembly.resource.LifecycleHelper;
  import org.apache.excalibur.merlin.model.Profile;
  import org.apache.excalibur.merlin.model.Resource;
  import org.apache.excalibur.meta.info.ServiceDescriptor;
  import org.apache.excalibur.meta.info.PhaseDescriptor;
  import org.apache.excalibur.meta.info.ExtensionDescriptor;
  import org.apache.excalibur.meta.info.Facility;
  
  /**
   * Opaque type that maps a path to a profile.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/08/12 06:08:54 $
   */
  public class DefaultResource extends AbstractLogEnabled implements Resource
  {
  
      public static final String HEADER = "service:";
  
      /**
       * The path of the profile designator.
       */
      private final String m_path;
  
      /**
       * The profile that disignator refers to.
       */
      private final Profile m_profile;
  
      /**
       * The deployment context.
       */
      private final Context m_context;
  
      /**
       * The lifestyle manager.
       */
      private LifestyleHandler m_handler;
  
      /**
       * Create a new resoruce instance.
       *
       * @param path the container path
       * @param profile the resource's profile
       * @param context the deployment context
       * @param factory the lifestyle manager
       */
      public DefaultResource( final String path,
                             final Profile profile,
                             final Context context,
                             final LifestyleHandler handler )
      {
          if( null == path )
              throw new NullPointerException( "path" );
  
          if( null == profile )
              throw new NullPointerException( "profile" );
  
          if( null == context )
              throw new NullPointerException( "context" );
  
          if( null == handler )
              throw new NullPointerException( "handler" );
  
          m_path = path;
          m_profile = profile;
          m_context = context;
          m_handler = handler;
      }
  
      /**
       * Returns the path of the resource.
       *
       * @return the symbolic path of the resource
       */
      public String getPath()
      {
          return HEADER + m_path;
      }
  
      /**
       * Returns the service descriptor.
       *
       * @return the service descriptor
       */
      public ServiceDescriptor[] getServices()
      {
          return m_profile.getType().getServices();
      }
  
      /**
       * Access an instance.
       *
       * @return the service instance.
       * @exception Exception if an error occurs while establishing the object
       */
      public Object access() throws Exception
      {
          getLogger().debug("access");
          return m_handler.get();
      }
  
      /**
       * Release a service instance.
       */
      public void release( Object object ) throws Exception
      {
          getLogger().debug("release");
          m_handler.put( object );
      }
  
      /**
       * Dispose of the reference and any consumed resources.
       */
      public void dispose()
      {
          getLogger().debug("dispose");
          if( m_handler instanceof Disposable )
          {
              ((Disposable)m_handler).dispose();
          }
          m_handler = null;
      }
  
     /**
      * Return the profile.
      *
      * @return the profile
      */
      public Profile getProfile()
      {
          return m_profile;
      }
  
      public String toString()
      {
          return "DefaultResource - profile:" + m_profile;
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/LifestyleHandler.java
  
  Index: LifestyleHandler.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.
   *
   * Original contribution by OSM SARL, http://www.osm.net
   */
  package org.apache.excalibur.merlin.assembly.resource;
  
  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;
  
  
  /**
   * Interface implemented by a component lifestyle handler. 
   *
   * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
   */
  public interface LifestyleHandler
  {
  
      /**
       * Returns the active state of the manager.
       * 
       * @return TRUE if the manager has supplied one or more instances
       */
       public boolean isActive();
  
  
      /**
       * Returns an instance of the object type supported by the 
       * manager to the client.
       * 
       * @return an instance
       */
       public Object get() throws Exception;
  
      /**
       * Invoked by a client to return an instance of the object type previously 
       * supported by the manager.
       * 
       * @param object the object to return
       */
       public void put( Object object ) throws Exception;
  
  }
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/SingletonLifestyleHandler.java
  
  Index: SingletonLifestyleHandler.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.
   *
   * Original contribution by OSM SARL, http://www.osm.net
   */
  package org.apache.excalibur.merlin.assembly.resource;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.context.Context;
  import org.apache.excalibur.merlin.assembly.ContainerManager;
  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.ExtensionDescriptor;
  import org.apache.excalibur.meta.info.Facility;
  
  
  /**
   * Lifestyle implementation that provides suppport for the singleton
   * policy.  Request for a single instance will allways return the 
   * same instance for each request.
   *
   * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
   */
  public class SingletonLifestyleHandler extends AbstractLogEnabled 
    implements LifestyleHandler, Disposable
  {
       private Profile m_profile;
  
       private ContainerManager m_manager;
       private ResourceProvider m_provider;
       private LifecycleHelper m_helper;
       private Context m_context;
  
       private Object m_object;
  
      /**
       * Creation of a new singleton lifecycle manager.
       * @param classloader the classloader to use to establish the object
       * @param profile the profile defining the object type
       */
       public SingletonLifestyleHandler( 
                             final ContainerManager manager, 
                             final ResourceProvider provider,
                             final LifecycleHelper helper,
                             final Profile profile,
                             final Context context )
       {
           m_profile = profile;
           m_manager = manager;
           m_provider = provider;
           m_helper = helper;
           m_context = context;
       }
  
      /**
       * Returns the active state of the manager.
       * 
       * @return TRUE if the manager has supplied one or more instances
       */
       public boolean isActive()
       {
           return (m_object != null);
       }
  
  
      /**
       * Returns an instance of the object type supported by the 
       * manager to the client.
       * 
       * @return an instance of the type defined by the profile
       */
       public Object get() throws Exception
       {
          getLogger().debug("get");
  
          if( m_object == null )
          {
              m_object = createSingletonInstance();
          }
  
          //
          // handle the access stage
          //
  
          DefaultContext context = new DefaultContext();
          PhaseDescriptor[] phases = m_profile.getType().getPhases();
          for( int i=0; i<phases.length; i++ )
          {
              processExtension( ExtensionDescriptor.ACCESS, phases[i], m_object, context );
          }
  
          return m_object;
  
       }
  
      /**
       * Invoked by a client to return an instance of the object type previously 
       * supported by the manager.  The singleton manager does nothing as the 
       * object may be used across an arbitary number of clients.
       * 
       * @param object the object to return
       */
       public void put( Object object ) throws Exception
       {
          getLogger().debug("put");
          DefaultContext context = new DefaultContext();
          PhaseDescriptor[] phases = m_profile.getType().getPhases();
          for( int i=0; i<phases.length; i++ )
          {
              processExtension( ExtensionDescriptor.RELEASE, phases[i], object, context );
          }
       }
  
  
      /**
       * Instantiate the singleton service.
       * 
       * @return an instance of the type defined by the profile
       */
       public Object createSingletonInstance() throws Exception
       {
          getLogger().debug("create");
  
          //
          // load the class
          //
  
          Class clazz = null;
          String classname = null;
          try
          {
              classname = m_profile.getType().getInfo().getImplementationKey();
              clazz = m_manager.loadClass( classname );
          }
          catch( Throwable e )
          {
              final String error = 
                "Unexpected exception while attempting to load class '" 
                + classname + "' for the profile: " + m_profile;
              throw new ResourceException( error, e );
          }
  
          //
          // create a new instance of the class
          //
  
          try
          {
              m_object = clazz.newInstance();
          }
          catch( Throwable e )
          {
              final String error = 
                "Unexpected exception while attempting to instantiate an instance from profile: " 
                   + m_profile;
               throw new ResourceException( error, e );
          }
  
          final String path = m_manager.getPath() + "/" + m_profile.getName();
          m_helper.startup( m_object, path, m_profile, m_provider, m_context );
  
          return m_object;
  
       }
  
      private void processExtension( int stage, PhaseDescriptor phase, Object object, Context context ) throws Exception
      {
          final Facility facility = m_profile.getFacility( phase );
          final ExtensionDescriptor ext = facility.getExtension( phase );
          if( ext.isApplicable( stage ) )
          {
              Resource resource = m_profile.getExtension( phase );
              Extension extension = (Extension) resource.access();
              try
              {
                  extension.extend( stage, object, context );
              }
              catch( Throwable e )
              {
                  final String error =
                    "Extension " + extension.getClass().getName() 
                    + " raised an exception " + e.getClass().getName()
                    + " while processing the " 
                    + ExtensionDescriptor.stageToString( stage ) 
                    + " phase for the component " 
                    + m_profile.getName();
  
                  throw new LifecycleException( error, e );
              }
          }
      }
  
      /**
       * Request for disposal of the manager.  This operation is normally invoked
       * by the client that initialy instantiated the manager.  The implementation
       * handles the disposal of the singleton resoruce and release of associated
       * references.
       */
       public void dispose()
       {
           if( m_object != null )
           {
               final String path = m_manager.getPath() + "/" + m_profile.getName();
               try
               {
                   m_helper.shutdown( path, m_profile, m_object );
               }
               catch( Throwable e )
               {
                   // ### should add loggging to the class so we can issue a warning
                   // ignore it for now
               }
           }
           m_object = null;
           m_profile = null;
           m_manager = null;
           m_provider = null;
           m_helper = null;
       }
  }
  
  
  1.30      +6 -9      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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- DefaultContainer.java	12 Aug 2002 02:00:09 -0000	1.29
  +++ DefaultContainer.java	12 Aug 2002 06:08:54 -0000	1.30
  @@ -406,7 +406,7 @@
                   throw new IllegalStateException( error );
               }
               Resource resource = service.getResource( this );
  -            resource.create();
  +            resource.access();
           }
   
           m_state = INITIALIZED;
  @@ -859,8 +859,7 @@
               throw new IllegalStateException( "Container not in suspended or initialized state." );
   
           //
  -        // Add the supplied profiles to this container and declare them to the 
  -        // container manager
  +        // Add the supplied profiles to this container
           //
   
           for( int i=0; i<profiles.length; i++ )
  @@ -875,10 +874,8 @@
           // procedure will include the installed components
           //
   
  -        Profile[] startup = m_descriptor.getComponents( Profile.EXPLICIT, true ); 
  -        getLogger().info("startup sequence length = " + startup.length );
  +        Profile[] startup = m_descriptor.getComponents(  true ); 
           m_map = m_manager.assemble( startup );
  -        getLogger().info("map startup sequence length = " + m_map.getStartupGraph().length );
       }
   
       //=======================================================================
  @@ -1067,7 +1064,7 @@
   
           ContainerService service = m_factory.build( config );
           Resource resource = service.getResource( this );
  -        return (Container) resource.create();
  +        return (Container) resource.access();
       }
   
      /**
  @@ -1087,7 +1084,7 @@
   
           ContainerService service = m_factory.build( descriptor, classpath );
           Resource resource = service.getResource( this );
  -        return (Container) resource.create();
  +        return (Container) resource.access();
       }
   
      /**
  
  
  
  1.35      +3 -3      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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- DefaultKernel.java	12 Aug 2002 02:00:10 -0000	1.34
  +++ DefaultKernel.java	12 Aug 2002 06:08:54 -0000	1.35
  @@ -290,7 +290,7 @@
               ContainerService service = factory.build( config );
               Resource resource = service.getResource();
   
  -            m_container = (Container) resource.create();
  +            m_container = (Container) resource.access();
               m_initialized = true;
               return;
           }
  @@ -352,7 +352,7 @@
               ContainerService service = factory.build( config );
               Resource resource = service.getResource();
   
  -            m_container = (Container) resource.create();
  +            m_container = (Container) resource.access();
               getLogger().info("kernel initialization complete");
               m_initialized = true;
           }
  
  
  
  1.5       +5 -36     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Resource.java
  
  Index: Resource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Resource.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Resource.java	12 Aug 2002 02:00:10 -0000	1.4
  +++ Resource.java	12 Aug 2002 06:08:54 -0000	1.5
  @@ -9,21 +9,17 @@
   
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.activity.Disposable;
   
   /**
  - * Interface implemented by object capable of supply a resources.
  + * Interface implemented by object capable of supply a resources indepedently
  + * of a particular lifestyle.
    *
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
  -public interface Resource
  +public interface Resource extends Disposable
   {
  -
  -     static final int NOT_STARTED = 0;
  -     static final int STARTED = 1;
  -     static final int STOPPED = 2;
  -
  -
       /**
        * Returns the designated resource path.
        *
  @@ -46,28 +42,6 @@
        Profile getProfile();
   
       /**
  -     * Returns the active state of the resoruce.
  -     * @return one of the values NOT_STARTED, STARTED, or STOPPED
  -     */
  -     int getState();
  -
  -    /**
  -     * Return the resource instance.
  -     *
  -     * @return an instance of the type constrained to the profile
  -     */
  -    Object create() throws Exception;
  -
  -    /**
  -     * Return the resource instance using a supplied context.
  -     *
  -     * @param context a supplimentary context for inport resolution
  -     * @return an instance of the type constrained to the profile
  -     */
  -    Object create( String name ) throws Exception;
  -
  -
  -    /**
        * Return the resource instance.
        *
        * @return an instance of the type defined by the profile
  @@ -78,11 +52,6 @@
        * Release the service instance.
        */
       public void release( Object instance ) throws Exception;
  -
  -    /**
  -     * Destroy the resource.
  -     */
  -    void destroy() throws Exception;
   
   
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>