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 19:36:16 UTC

cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource AbstractLifestyleHandler.java DefaultManager.java DefaultResource.java LifecycleHelper.java SingletonLifestyleHandler.java

mcconnell    2002/08/12 10:36:16

  Modified:    assembly .cvsignore
               assembly/demo/src/java/org/apache/excalibur/playground
                        ComplexComponent.java ComplexComponent.xinfo
                        SimpleComponent.java
               assembly/src/etc kernel.xml
               assembly/src/java/org/apache/excalibur/merlin/assembly
                        ContainerManager.java DependencyGraph.java
                        ProfileRegistry.java
               assembly/src/java/org/apache/excalibur/merlin/container
                        ContainerService.java DefaultContainer.java
               assembly/src/java/org/apache/excalibur/merlin/resource
                        AbstractLifestyleHandler.java DefaultManager.java
                        DefaultResource.java LifecycleHelper.java
                        SingletonLifestyleHandler.java
  Log:
  Seperation of internal bootstrap assembly from application assembly.
  
  Revision  Changes    Path
  1.9       +1 -0      jakarta-avalon-excalibur/assembly/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/.cvsignore,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- .cvsignore	24 Jul 2002 17:03:06 -0000	1.8
  +++ .cvsignore	12 Aug 2002 17:36:15 -0000	1.9
  @@ -7,3 +7,4 @@
   extensions
   velocity.log
   sevak-conf.xml
  +pss
  
  
  
  1.7       +1 -1      jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ComplexComponent.java
  
  Index: ComplexComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ComplexComponent.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ComplexComponent.java	13 Jul 2002 15:35:25 -0000	1.6
  +++ ComplexComponent.java	12 Aug 2002 17:36:15 -0000	1.7
  @@ -22,7 +22,7 @@
    */
   
   public class ComplexComponent extends AbstractLogEnabled
  -implements Serviceable, Initializable, Startable, Disposable
  +implements Serviceable, Initializable, Startable, Disposable, EmptyService
   {
   
       private ServiceManager m_manager;
  
  
  
  1.9       +8 -2      jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ComplexComponent.xinfo
  
  Index: ComplexComponent.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ComplexComponent.xinfo,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ComplexComponent.xinfo	4 Aug 2002 11:49:35 -0000	1.8
  +++ ComplexComponent.xinfo	12 Aug 2002 17:36:15 -0000	1.9
  @@ -3,7 +3,7 @@
         PUBLIC "-//AVALON/Component Info DTD Version 1.0//EN"
                "http://jakarta.apache.org/avalon/componentinfo_1_0.dtd" >
   
  -<component-info>
  +<type>
   
     <component>
       <name>complex</name>
  @@ -13,6 +13,12 @@
        <logger name="init"/>
     </loggers>
   
  +  <services>
  +    <service> 
  +      <reference type="org.apache.excalibur.playground.EmptyService"/>
  +    </service> 
  +  </services>
  +
     <dependencies>
         <dependency>
             <role>basic</role>
  @@ -24,5 +30,5 @@
         </dependency>
     </dependencies>
   
  -</component-info>
  +</type>
   
  
  
  
  1.12      +1 -0      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SimpleComponent.java	12 Aug 2002 06:08:54 -0000	1.11
  +++ SimpleComponent.java	12 Aug 2002 17:36:15 -0000	1.12
  @@ -46,6 +46,7 @@
       {
           getLogger().debug( "service" );
           m_basic = (BasicService) manager.lookup( "basic" );
  +        manager.release( m_basic );
       }
   
       //=======================================================================
  
  
  
  1.31      +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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- kernel.xml	12 Aug 2002 06:08:54 -0000	1.30
  +++ kernel.xml	12 Aug 2002 17:36:15 -0000	1.31
  @@ -22,7 +22,7 @@
      the corresponds to the name of the logging file.
      -->
   
  -   <logging priority="INFO" target="default">
  +   <logging priority="DEBUG" target="default">
        <category priority="WARN"  name="logging" />
         <target name="kernel">
           <file location="kernel.log" />
  
  
  
  1.13      +45 -40    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ContainerManager.java	12 Aug 2002 08:11:08 -0000	1.12
  +++ ContainerManager.java	12 Aug 2002 17:36:16 -0000	1.13
  @@ -324,14 +324,28 @@
       * 
       * @exception Exception if a start related error occurs
       */
  +    public void start( ) throws Exception
  +    {
  +        start( m_map.getStartupGraph() );
  +    }
  +
  +   /**
  +    * Method invoked by the managers container to signal the activation of 
  +    * all components.  This method may be invoked multiple times during a 
  +    * the life of the manager.
  +    * 
  +    * @exception Exception if a start related error occurs
  +    */
       public void start( Profile[] profiles ) throws Exception
       {
  +
           if( profiles.length == 0 )
           {
  -            getLocalLogger().debug("nothing to start");
  +            getLogger().info("start");
               return;
           }
   
  +        logDependency( getLogger(), "start: ", profiles );
           for( int i=0; i<profiles.length; i++ )
           {
               Profile profile = profiles[i];
  @@ -348,11 +362,17 @@
           }
       }
   
  +    public void stop( )
  +    {
  +        m_map.getShutdownGraph();
  +    }
  +
       public void stop( Profile[] shutdown )
       {
  +
           if( shutdown.length == 0 )
           {
  -            getLogger().info( "shutdown" );
  +            getLogger().info( "stop" );
               return;
           }
   
  @@ -374,22 +394,7 @@
               return;
           }
   
  -        //
  -        // list the local components we are stopping
  -        //
  -
  -        if( getLogger().isInfoEnabled() )
  -        {        
  -            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() );
  -        }
  +        logDependency( getLogger(), "stop: ", profiles );
   
           //
           // stop the local components
  @@ -401,7 +406,7 @@
               try
               {
                   Resource resource = getResource( profile );
  -                getLocalLogger().info( "stopping: " + profile ); 
  +                getLogger().info( "stopping: " + profile ); 
                   resource.dispose();
               }
               catch ( Throwable e )
  @@ -762,7 +767,6 @@
           {
           }
   
  -
           SingletonLifestyleHandler handler = 
              new SingletonLifestyleHandler( this, m_provider, m_helper, profile, context );
           handler.enableLogging( getLocalLogger().getChildLogger("lifestyle") );
  @@ -775,18 +779,23 @@
       }
   
      /**
  -    * Assemble a profile into a consistent application.  This method 
  -    * attempts to establish associations between all dependencies in order to 
  -    * resolve an operational application context.
  +    * Assemble a profile dependecies independently of the application scope. This
  +    * method is typically applied to the establishment of associations between 
  +    * bootstrap components such as containers, their depedecies and extension
  +    * stage providers.
       *
       * @param profile the target profile to assemble
       * @param context the assembly context
       */
  -    public Resource assembleProfile( Profile profile, Context context ) throws AssemblyException
  +    public Resource assemble( Profile profile, Context context ) throws AssemblyException
       {
           DependencyGraph map = new DependencyGraph( m_map );
           Resource resource = m_registry.assembleProfile( map, profile, context );
  -        logStartup( getLocalLogger(), "assembly (" + profile.getName() + "): ",  map );
  +        logDependency( 
  +           getLocalLogger(), 
  +           "bootstrap-assembly: (" + profile.getName() + "): ",  
  +           map.getStartupGraph() 
  +        );
           return resource;
       }
   
  @@ -799,9 +808,9 @@
       * @param profile the target profile to assemble
       * @param context the assembly context
       */
  -    public DependencyGraph assemble( Profile profile, Context context ) throws Exception
  +    public DependencyGraph install( Profile profile, Context context ) throws Exception
       {
  -        return assemble( new Profile[]{ profile }, context );
  +        return install( new Profile[]{ profile }, context );
       }
   
      /**
  @@ -812,9 +821,9 @@
       * @param profiles the set of profiles constituting the core components
       *    from which the associations between components will be based
       */
  -    public DependencyGraph assemble( Profile[] profiles ) throws Exception
  +    public DependencyGraph install( Profile[] profiles ) throws Exception
       {
  -        return assemble( profiles, m_context );
  +        return install( profiles, m_context );
       }
   
      /**
  @@ -825,19 +834,16 @@
       * @param profiles the set of profiles constituting the core components
       *    from which the associations between components will be based
       */
  -    public DependencyGraph assemble( Profile[] profiles, Context context ) throws Exception
  +    public DependencyGraph install( Profile[] profiles, Context context ) throws Exception
       {
  -        DependencyGraph map = new DependencyGraph( m_map );
  -
           if( profiles.length == 0 )
  -          return map;
  +          return m_map;
   
  -        m_registry.assemble( map, profiles, context );
  -        logStartup( getLogger(), "assembly: ", map );
  -        return map;
  +        m_registry.assemble( m_map, profiles, context );
  +        logDependency( getLocalLogger(), "install: ", m_map.getStartupGraph() );
  +        return m_map;
       }
   
  -
      /**
       * Returns an order sequence of profiles under the management of this instance.
       * @param activate if TRUE, only return profiles with activation on startup
  @@ -1045,9 +1051,8 @@
           return getSelector( dependency.getService(), dependency.getAttribute("avalon:selector") );
       }
   
  -    private void logStartup( Logger logger, String lead, DependencyGraph map )
  +    private void logDependency( Logger logger, String lead, Profile[] result )
       {
  -        Profile[] result = map.getStartupGraph();
           if( logger.isInfoEnabled() )
           {
               if( result.length > 0 )
  
  
  
  1.3       +28 -17    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DependencyGraph.java	2 Aug 2002 06:36:09 -0000	1.2
  +++ DependencyGraph.java	12 Aug 2002 17:36:16 -0000	1.3
  @@ -44,19 +44,28 @@
        */
       private final ArrayList m_children = new ArrayList();
   
  -
  +   /**
  +    * Creation of a new empty dependecy graph.
  +    */
       public DependencyGraph()
       {
           this( null );
       }
   
  +   /**
  +    * Creation of a new dependecy graph holding a reference to a parent
  +    * graph.  Profiles in the parent graph are potential providers for services
  +    * if no profile in current assembly satisfies a dependency.
  +    *
  +    * @param parent the parent graph
  +    */
       public DependencyGraph( final DependencyGraph parent )
       {
           m_parent = parent;
       }
   
       /**
  -     * Add child dependency graph.
  +     * Addition of a consumer dependency graph.
        *
        * @param child the child map
        */
  @@ -66,7 +75,7 @@
       }
   
       /**
  -     * Remove child dependency graph.
  +     * Removal of a consumer dependency graph.
        *
        * @param child the child map
        */
  @@ -212,6 +221,7 @@
                                    final ArrayList done,
                                    final ArrayList order )
       {
  +
           //If already visited this profile then bug out early
           if( done.contains( profile ) )
           {
  @@ -310,6 +320,20 @@
   
               //
               // 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().getProfile().equals( profile ) )
  +                {
  +                    visitcomponent( other, false, done, order );
  +                }
  +            }
  +
  +            //
  +            // check if the 'other' profile is used by this 'profile'
               // as an extension provider
               //
   
  @@ -323,19 +347,6 @@
                    }
               }
   
  -            //
  -            // 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 ) )
  -                {
  -                    visitcomponent( other, false, done, order );
  -                }
  -            }
           }
   
           final int childCount = m_children.size();
  
  
  
  1.12      +5 -5      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ProfileRegistry.java	12 Aug 2002 08:11:08 -0000	1.11
  +++ ProfileRegistry.java	12 Aug 2002 17:36:16 -0000	1.12
  @@ -108,7 +108,7 @@
       {
           getLogger().debug("assembly target: " + profile );
           assembleProfile( map, profile, context, visited, "" );
  -        m_map.add( profile );
  +        //m_map.add( profile );
           map.add( profile );
           try
           {
  @@ -141,7 +141,7 @@
               ArrayList visited = new ArrayList();
               assembleProfile( map, profile, context, visited, "" );
   
  -            m_map.add( profile );
  +            //m_map.add( profile );
               map.add( profile );
   
               try
  @@ -265,7 +265,7 @@
                   }
   
                   profile.addProvider( role, resource );
  -                m_map.add( supplier );
  +                //m_map.add( supplier );
                   map.add( supplier );
               }
           }
  @@ -330,7 +330,7 @@
                       throw new AssemblyException( error, e );
                   }
                   profile.addExtension( phase, supplier, resource );
  -                m_map.add( supplier );
  +                //m_map.add( supplier );
                   map.add( supplier );
               }
           }
  
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerService.java
  
  Index: ContainerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContainerService.java	12 Aug 2002 01:55:44 -0000	1.1
  +++ ContainerService.java	12 Aug 2002 17:36:16 -0000	1.2
  @@ -155,7 +155,7 @@
               // resolved and return a reference to the container
               //
   
  -            return m_manager.assembleProfile( m_descriptor, context );
  +            return m_manager.assemble( m_descriptor, context );
           }
           catch( Throwable e )
           {
  
  
  
  1.31      +43 -25    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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- DefaultContainer.java	12 Aug 2002 06:08:54 -0000	1.30
  +++ DefaultContainer.java	12 Aug 2002 17:36:16 -0000	1.31
  @@ -266,22 +266,15 @@
   
           getLogger().debug("assembly");
           Profile[] profiles = m_descriptor.getComponents( Profile.EXPLICIT, true );
  -        if( profiles.length > 0 )
  +        try
           {
  -            try
  -            {
  -                getLogger().debug("profile assembly (" + profiles.length + ")");
  -                m_map = m_manager.assemble( profiles );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = "Assembly failure.";
  -                throw new AssemblyException( error, e );
  -            }
  +            getLogger().debug("profile assembly (" + profiles.length + ")");
  +            m_map = m_manager.install( profiles );
           }
  -        else
  +        catch( Throwable e )
           {
  -            m_map = new DependencyGraph();
  +            final String error = "Assembly failure.";
  +            throw new AssemblyException( error, e );
           }
       }
   
  @@ -523,13 +516,11 @@
             throw new IllegalStateException(
               "Container has already passed through start phase.");
   
  -        if( getLogger().isInfoEnabled() )
  -          getLogger().info( "startup " + m_map.getStartupGraph().length );
  -
           //
           // request startup of any unstarted components
           //
   
  +        //m_manager.start();
           m_manager.start( m_map.getStartupGraph() );
   
           //
  @@ -603,6 +594,7 @@
           // stop the local components
           //
   
  +        //m_manager.stop( );
           m_manager.stop( m_map.getShutdownGraph() );
   
           m_state = STOPPED;
  @@ -663,7 +655,8 @@
   
           try
           {
  -            m_manager.start( m_map.getStartupGraph() );
  +            m_manager.start( );
  +            //m_manager.start( m_map.getStartupGraph() );
           }
           catch( Throwable e )
           {
  @@ -869,13 +862,7 @@
               m_manager.addProfile( profile );
           }
   
  -        //
  -        // update the container's dependecy graph so that the startup 
  -        // procedure will include the installed components
  -        //
  -
  -        Profile[] startup = m_descriptor.getComponents(  true ); 
  -        m_map = m_manager.assemble( startup );
  +        m_manager.install( profiles );
       }
   
       //=======================================================================
  @@ -1121,4 +1108,35 @@
               return true;
           }
       }
  +
  +    private void logDependency( Logger logger, String lead, Profile[] result )
  +    {
  +        if( logger.isInfoEnabled() )
  +        {
  +            if( result.length > 0 )
  +            {
  +                StringBuffer buffer = new StringBuffer();
  +                for( int i=0; i<result.length; i++ )
  +                {
  +                    Profile profile = result[i];
  +                    if( m_manager.isLocal( profile ) )
  +                    {
  +                        buffer.append( result[i].getName() );
  +                    }
  +                    else
  +                    {
  +                        buffer.append( "[" + result[i].getName() + "]" );
  +                    }
  +                    if( i<(result.length-1) )
  +                      buffer.append(", ");
  +                }
  +                logger.info( lead + buffer.toString() );
  +            }
  +            else
  +            {
  +                logger.info( lead + "(empty)" );
  +            }
  +        }
  +    }
  +
   }
  
  
  
  1.2       +18 -2     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/AbstractLifestyleHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractLifestyleHandler.java	12 Aug 2002 08:11:09 -0000	1.1
  +++ AbstractLifestyleHandler.java	12 Aug 2002 17:36:16 -0000	1.2
  @@ -38,6 +38,8 @@
        private LifecycleHelper m_helper;
        private Context m_context;
   
  +     protected boolean m_disposed = false;
  +
       /**
        * Creation of a new singleton lifecycle manager.
        * @param manager the type manager 
  @@ -53,12 +55,22 @@
                              final Profile profile, 
                              final Context context )
        {
  -         if( profile == null )
  -           throw new NullPointerException("profile");
   
            if( manager == null )
              throw new NullPointerException("manager");
   
  +         if( provider == null )
  +           throw new NullPointerException("provider");
  +
  +         if( helper == null )
  +           throw new NullPointerException("helper");
  +
  +         if( profile == null )
  +           throw new NullPointerException("profile");
  +
  +         if( context == null )
  +           throw new NullPointerException("context");
  +
            m_profile = profile;
            m_manager = manager;
            m_provider = provider;
  @@ -200,9 +212,13 @@
        */
        public void dispose()
        {
  +         if( m_disposed ) 
  +           throw new IllegalStateException("disposed");
  +
            m_profile = null;
            m_manager = null;
            m_provider = null;
            m_helper = null;
  +         m_disposed = true;
        }
   }
  
  
  
  1.2       +11 -11    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultManager.java
  
  Index: DefaultManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultManager.java	12 Aug 2002 08:11:09 -0000	1.1
  +++ DefaultManager.java	12 Aug 2002 17:36:16 -0000	1.2
  @@ -89,17 +89,17 @@
        */
       public void put( Object object ) throws ResourceRuntimeException
       {
  -       final Resource resource = (Resource) m_mapping.get( 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 );
  -       }
  +        final Resource resource = (Resource) m_mapping.get( 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.2       +2 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultResource.java
  
  Index: DefaultResource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultResource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultResource.java	12 Aug 2002 08:11:09 -0000	1.1
  +++ DefaultResource.java	12 Aug 2002 17:36:16 -0000	1.2
  @@ -50,7 +50,7 @@
       /**
        * The lifestyle manager.
        */
  -    private LifestyleHandler m_handler;
  +    private final LifestyleHandler m_handler;
   
       /**
        * Create a new resoruce instance.
  @@ -134,7 +134,6 @@
           {
               ((Disposable)m_handler).dispose();
           }
  -        m_handler = null;
       }
   
      /**
  
  
  
  1.2       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/LifecycleHelper.java
  
  Index: LifecycleHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/LifecycleHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LifecycleHelper.java	12 Aug 2002 08:11:09 -0000	1.1
  +++ LifecycleHelper.java	12 Aug 2002 17:36:16 -0000	1.2
  @@ -364,7 +364,7 @@
                              name,
                              new Integer( stage ),
                              reason );
  -        getLogger().error( message );
  +        getLogger().error( message, t );
       }
   
       /**
  
  
  
  1.2       +27 -8     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/SingletonLifestyleHandler.java
  
  Index: SingletonLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/SingletonLifestyleHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SingletonLifestyleHandler.java	12 Aug 2002 08:11:09 -0000	1.1
  +++ SingletonLifestyleHandler.java	12 Aug 2002 17:36:16 -0000	1.2
  @@ -65,11 +65,14 @@
        */
        public Object get() throws Exception
        {
  -        getLogger().debug("get");
  -        if( m_object == null )
  -            m_object = super.createInstance();
  -        super.processAccessStage( m_object );
  -        return m_object;
  +         if( m_disposed ) 
  +           throw new IllegalStateException("disposed");
  +
  +         getLogger().debug("get");
  +         if( m_object == null )
  +             m_object = super.createInstance();
  +         super.processAccessStage( m_object );
  +         return m_object;
   
        }
   
  @@ -82,8 +85,23 @@
        */
        public void put( Object object ) throws Exception
        {
  -        getLogger().debug("put");
  -        super.processReleaseStage( m_object );
  +         if( m_disposed ) 
  +           throw new IllegalStateException("disposed");
  +
  +         getLogger().debug("put");
  +         if( object == null )
  +           return;
  +
  +         if( object.equals( m_object ))
  +         {
  +             super.processReleaseStage( m_object );
  +         }
  +         else
  +         {
  +             final String warning = 
  +               "Illegal attempt to release an object that was not provided by this handler.";
  +             getLogger().warn( warning );
  +         }  
        }
   
       /**
  @@ -94,6 +112,8 @@
        */
        public void dispose()
        {
  +         super.dispose();
  +
            if( m_object != null )
            {
                final String path = m_manager.getPath() + "/" + m_profile.getName();
  @@ -111,7 +131,6 @@
            m_manager = null;
            m_helper = null;
   
  -         super.dispose();
   
        }
   }
  
  
  

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