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/meta/info ExtensionDescriptor.java
Date Tue, 30 Jul 2002 13:49:08 GMT
mcconnell    2002/07/30 06:49:08

  Modified:    assembly build.xml
               assembly/demo/src/etc demo.mf
               assembly/demo/src/java/org/apache/excalibur/playground
                        ExploitationManager.java ExploitationManager.xinfo
                        SimpleComponent.java SimpleComponent.xconfig
                        SimpleComponent.xinfo
               assembly/src/java/org/apache/excalibur/merlin
                        DefaultController.java
               assembly/src/java/org/apache/excalibur/merlin/assembly
                        ProfileManager.java ProfileRegistry.java
               assembly/src/java/org/apache/excalibur/merlin/assembly/doc-files
                        DependencyGraph.gif
               assembly/src/java/org/apache/excalibur/merlin/assembly/resource
                        DefaultComponentManager.java DefaultManager.java
                        DefaultServiceManager.java LifecycleHelper.java
                        ProfileDesignator.java ResourceProvider.java
               assembly/src/java/org/apache/excalibur/merlin/container
                        Container.java DefaultContainer.java
               assembly/src/java/org/apache/excalibur/merlin/container/doc-files
                        Container.gif DefaultContainer.gif
               assembly/src/java/org/apache/excalibur/merlin/doc-files
                        merlin.gif
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java Kernel.java
               assembly/src/java/org/apache/excalibur/merlin/kernel/doc-files
                        DefaultKernel.gif
               assembly/src/java/org/apache/excalibur/merlin/model
                        Association.java Profile.java
               assembly/src/java/org/apache/excalibur/merlin/model/doc-files
                        uml.gif
               assembly/src/java/org/apache/excalibur/meta/info
                        ExtensionDescriptor.java
  Log:
  Copletion of pluggable phase management (addition of inner phases ACCESS and RELEASE).
  
  Revision  Changes    Path
  1.34      +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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- build.xml	30 Jul 2002 07:05:54 -0000	1.33
  +++ build.xml	30 Jul 2002 13:49:06 -0000	1.34
  @@ -299,8 +299,8 @@
   
     <target name="patch">
       <replace dir="${src.dir}/java" 
  -       token="org.apache.excalibur.merlin.model.TargetProvider" 
  -       value="org.apache.excalibur.merlin.kernel.model.TargetProvider" >
  +       token="ResourceDesignator" 
  +       value="Resource" >
        <include name="org/apache/excalibur/merlin/**/*.*"/>
       </replace>
     </target>
  
  
  
  1.7       +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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- demo.mf	30 Jul 2002 07:03:34 -0000	1.6
  +++ demo.mf	30 Jul 2002 13:49:07 -0000	1.7
  @@ -21,3 +21,6 @@
   
   Name: org/apache/excalibur/playground/ExploitationManager.class
   Avalon-Facility: true
  +
  +Name: org/apache/excalibur/playground/DemoManager.class
  +Avalon-Facility: true
  
  
  
  1.3       +3 -2      jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ExploitationManager.java
  
  Index: ExploitationManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ExploitationManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExploitationManager.java	30 Jul 2002 07:03:34 -0000	1.2
  +++ ExploitationManager.java	30 Jul 2002 13:49:07 -0000	1.3
  @@ -5,6 +5,7 @@
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.excalibur.merlin.assembly.resource.Extension;
  +import org.apache.excalibur.merlin.assembly.resource.AbstractExtension;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Disposable;
   
  @@ -12,7 +13,7 @@
    * Definition of an extension type.
    * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
    */
  -public class ExploitationManager extends AbstractLogEnabled implements Initializable, Extension,
Disposable
  +public class ExploitationManager extends AbstractExtension implements Initializable, Disposable
   {
   
       //=======================================================================
  @@ -49,9 +50,9 @@
       public void extend( int stage, Object object, Context context )
           throws Exception
        {
  -        getLogger().debug( "extend stage: " + stage );
           if( object instanceof Exploitable )
           {
  +            super.extend( stage, object, context );
               if( stage == CREATE )
               {
                   ((Exploitable)object).exploit();
  
  
  
  1.2       +1 -1      jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ExploitationManager.xinfo
  
  Index: ExploitationManager.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ExploitationManager.xinfo,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExploitationManager.xinfo	30 Jul 2002 07:03:34 -0000	1.1
  +++ ExploitationManager.xinfo	30 Jul 2002 13:49:07 -0000	1.2
  @@ -19,7 +19,7 @@
       Each extension has a name, a versioned interface reference, and optional 
       attributes.
       -->
  -    <extension stage="CREATE">
  +    <extension stage="ALL">
         <name>exploit</name>
         <reference type="org.apache.excalibur.playground.Exploitable" version="1.0"/>
         <attributes>
  
  
  
  1.9       +11 -2     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SimpleComponent.java	30 Jul 2002 07:03:34 -0000	1.8
  +++ SimpleComponent.java	30 Jul 2002 13:49:07 -0000	1.9
  @@ -20,7 +20,7 @@
    */
   
   public class SimpleComponent extends AbstractLogEnabled 
  -implements Configurable, Serviceable, Initializable, Startable, SimpleService, Exploitable,
Disposable
  +implements Configurable, Serviceable, Initializable, Startable, SimpleService, Exploitable,
Demonstratable, Disposable
   {
   
       private String m_message;
  @@ -58,6 +58,15 @@
       }
   
       //=======================================================================
  +    // Demonstratable
  +    //=======================================================================
  +
  +    public void demo( int stage )
  +    {
  +        getLogger().info( "doing demo for stage: " + stage );
  +    }
  +
  +    //=======================================================================
       // Initializable
       //=======================================================================
   
  @@ -128,7 +137,7 @@
   
       public void doObjective()
       {
  -        getLogger().info( m_message );
  +        getLogger().info( "message: " + m_message );
       }
   
   
  
  
  
  1.2       +1 -1      jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.xconfig
  
  Index: SimpleComponent.xconfig
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.xconfig,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleComponent.xconfig	20 Jul 2002 00:54:55 -0000	1.1
  +++ SimpleComponent.xconfig	30 Jul 2002 13:49:07 -0000	1.2
  @@ -5,6 +5,6 @@
   -->
   
   <configuration>
  -   <message>This is the simple component configuration.</message>
  +   <message>Hello.</message>
   </configuration>
   
  
  
  
  1.6       +3 -0      jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.xinfo
  
  Index: SimpleComponent.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.xinfo,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SimpleComponent.xinfo	29 Jul 2002 06:14:28 -0000	1.5
  +++ SimpleComponent.xinfo	30 Jul 2002 13:49:07 -0000	1.6
  @@ -38,6 +38,9 @@
           <reference type="org.apache.excalibur.playground.Exploitable" version="1.0"/>
           <attributes/>
        </phase>
  +     <phase>
  +        <reference type="org.apache.excalibur.playground.Demonstratable"/>
  +     </phase>
     </phases>
   
   </component-info>
  
  
  
  1.9       +2 -2      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultController.java	29 Jul 2002 06:14:29 -0000	1.8
  +++ DefaultController.java	30 Jul 2002 13:49:07 -0000	1.9
  @@ -30,7 +30,7 @@
   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.ResourceDesignator;
  +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;
  
  
  
  1.3       +23 -23    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileManager.java
  
  Index: ProfileManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProfileManager.java	30 Jul 2002 07:05:55 -0000	1.2
  +++ ProfileManager.java	30 Jul 2002 13:49:07 -0000	1.3
  @@ -38,7 +38,7 @@
   import org.apache.excalibur.merlin.assembly.resource.ProfileDesignator;
   import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.Profile;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.merlin.model.builder.ProfileBuilder;
   import org.apache.excalibur.meta.info.PhaseDescriptor;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
  @@ -260,17 +260,17 @@
               Profile profile = profiles[i];
               if( profile.getActivationPolicy() )
               {
  -                ResourceDesignator resource = getResource( profile );
  -                if( resource.getState() == ResourceDesignator.NOT_STARTED )
  +                Resource resource = getResource( profile );
  +                if( resource.getState() == Resource.NOT_STARTED )
                   {
  -                   getLogger().info( "starting: " + profile ); 
  -                   resource.getInstance();
  +                    getLogger().info( "starting: " + profile ); 
  +                    resource.access();
                   }
               }
           }
       }
   
  -    public void stop() 
  +    public void stop()
       {
           Profile[] profiles = m_map.getShutdownGraph();
           for( int i=0; i<profiles.length; i++ )
  @@ -278,11 +278,11 @@
               Profile profile = profiles[i];
               try
               {
  -                ResourceDesignator resource = getResource( profile );
  -                if( resource.getState() == ResourceDesignator.STARTED )
  +                Resource resource = getResource( profile );
  +                if( resource.getState() == Resource.STARTED )
                   {
                      getLogger().info( "stopping: " + profile ); 
  -                   resource.release();    
  +                   resource.destroy();    
                   }
               }
               catch ( Throwable e )
  @@ -469,16 +469,16 @@
           return selector.select( profiles );
       }
   
  -    public ResourceDesignator getResource( Profile profile ) throws TypeException
  +    public Resource getResource( Profile profile ) throws TypeException
       {
           return getResource( profile, false );
       }
   
  -    public ResourceDesignator getResource( Profile profile, boolean create ) throws TypeException
  +    public Resource getResource( Profile profile, boolean create ) throws TypeException
       {
           if( isLocal( profile ) )
           {
  -            ResourceDesignator resource = getLocalResource( profile );
  +            Resource resource = getLocalResource( profile );
               if(( resource == null ) && create )
               {
                   final String name = getPath() + DELIMITER + profile.getName();
  @@ -521,7 +521,7 @@
       *
       * @return the resource sequence
       */
  -    public ResourceDesignator[] getStartupGraph()
  +    public Resource[] getStartupGraph()
       {
           ArrayList list = new ArrayList();
           Profile[] startup = m_map.getStartupGraph();
  @@ -533,7 +533,7 @@
               {
                   if( profile.getActivationPolicy() )
                   {
  -                    ResourceDesignator resource = getLocalResource( profile );
  +                    Resource resource = getLocalResource( profile );
                       if( resource != null )
                       {
                           list.add( resource );
  @@ -546,7 +546,7 @@
                   }
               }
           }
  -        return (ResourceDesignator[]) list.toArray( new ResourceDesignator[ list.size()
] );
  +        return (Resource[]) list.toArray( new Resource[ list.size() ] );
       }
   
      /**
  @@ -554,7 +554,7 @@
       *
       * @return the resource sequence
       */
  -    public ResourceDesignator[] getShutdownGraph()
  +    public Resource[] getShutdownGraph()
       {
           ArrayList list = new ArrayList();
           Profile[] shutdown = m_map.getShutdownGraph();
  @@ -563,14 +563,14 @@
               Profile profile = shutdown[i];
               if( isLocal( profile ) )
               {
  -                ResourceDesignator resource = getLocalResource( profile );
  +                Resource resource = getLocalResource( profile );
                   if( resource != null )
                   {
                       list.add( resource );
                   }
               }
           }
  -        return (ResourceDesignator[]) list.toArray( new ResourceDesignator[0] );
  +        return (Resource[]) list.toArray( new Resource[0] );
       }
   
      /**
  @@ -587,7 +587,7 @@
       *
       * @return the resource sequence
       */
  -    public ResourceDesignator[] getExport()
  +    public Resource[] getExport()
       {
           ArrayList list = new ArrayList();
           Profile[] startup = m_map.getStartupGraph();
  @@ -604,16 +604,16 @@
                   getLogger().warn( warning );
               }
           }
  -        return (ResourceDesignator[]) list.toArray( new ResourceDesignator[ list.size()
] );
  +        return (Resource[]) list.toArray( new Resource[ list.size() ] );
       }
   
       //=============================================================================
       // private
       //=============================================================================
   
  -    private ResourceDesignator getLocalResource( Profile profile )
  +    private Resource getLocalResource( Profile profile )
       {
  -        return (ResourceDesignator) m_resources.get( profile );
  +        return (Resource) m_resources.get( profile );
       }
   
   
  
  
  
  1.3       +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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProfileRegistry.java	30 Jul 2002 07:05:55 -0000	1.2
  +++ ProfileRegistry.java	30 Jul 2002 13:49:07 -0000	1.3
  @@ -33,7 +33,7 @@
   import org.apache.excalibur.meta.info.Facility;
   import org.apache.excalibur.meta.verifier.ComponentVerifier;
   import org.apache.excalibur.merlin.model.Profile;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.merlin.model.builder.ProfileBuilder;
   
   /**
  @@ -99,7 +99,7 @@
   
               final String name = 
                 m_classloader.getPath() + ProfileManager.DELIMITER + profile.getName();
  -            final ResourceDesignator resource = m_classloader.getResource( profile, true
);
  +            final Resource resource = m_classloader.getResource( profile, true );
               getLogger().debug( "created explicit resource for: " + name );
               m_map.add( profile );
           }
  @@ -200,7 +200,7 @@
                   //
   
                   getLogger().debug( pad + "  selection: " + supplier );
  -                ResourceDesignator resource = m_classloader.getResource( supplier, true
);
  +                Resource resource = m_classloader.getResource( supplier, true );
                   profile.addProvider( role, resource );
                   m_map.add( supplier );
               }
  @@ -252,7 +252,7 @@
                   //
   
                   getLogger().debug( pad + "  selection: " + supplier );
  -                ResourceDesignator resource = 
  +                Resource resource = 
                     m_classloader.getResource( supplier, true );
                   profile.addExtension( phase, supplier, resource );
                   m_map.add( supplier );
  
  
  
  1.2       +18 -6     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/doc-files/DependencyGraph.gif
  
  	<<Binary file>>
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultComponentManager.java
  
  Index: DefaultComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultComponentManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultComponentManager.java	29 Jul 2002 06:14:30 -0000	1.1
  +++ DefaultComponentManager.java	30 Jul 2002 13:49:07 -0000	1.2
  @@ -38,7 +38,7 @@
           Object object = null;
           try
           {
  -            object = super.resolve( role );
  +            object = super.get( role );
               if( object instanceof Component )
               {
                   return (Component)object;
  @@ -59,6 +59,6 @@
        */
       public void release( Component component )
       {
  -        super.disgard( component );
  +        super.put( component );
       }
   }
  
  
  
  1.2       +13 -6     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultManager.java	29 Jul 2002 06:14:30 -0000	1.1
  +++ DefaultManager.java	30 Jul 2002 13:49:07 -0000	1.2
  @@ -10,8 +10,9 @@
   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.excalibur.merlin.model.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.Resource;
   
   
   /**
  @@ -26,6 +27,12 @@
        */
       private Map m_providers;
   
  +    /**
  +     * A mappiong of resource instances keyed by the object is provided
  +     * and to which the object should be released.
  +     */
  +    private Hashtable m_mapping = new Hashtable();
  +
      /**
       * Creation of a new manager.
       * @param providers the resource map
  @@ -49,9 +56,9 @@
       * Returns the service object.
       * @return the service instance
       */
  -    public Object resolve( String role ) throws ResourceException
  +    public Object get( String role ) throws ResourceException
       {
  -        ResourceDesignator resource = (ResourceDesignator) m_providers.get( role );
  +        Resource resource = (Resource) m_providers.get( role );
           if( resource == null )
           {
               throw new ResourceException(
  @@ -61,7 +68,7 @@
           {
               try
               {
  -                return resource.getInstance();
  +                return resource.access();
               }
               catch( Throwable e )
               {
  @@ -76,9 +83,9 @@
        * Release a pooled object.
        * @param object a pooled object
        */
  -    public void disgard( Object object )
  +    public void put( Object object )
       {
  -       //
  +       // nothing to do in a singleton
       }
   
   }
  
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultServiceManager.java
  
  Index: DefaultServiceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultServiceManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultServiceManager.java	29 Jul 2002 06:14:30 -0000	1.1
  +++ DefaultServiceManager.java	30 Jul 2002 13:49:07 -0000	1.2
  @@ -50,7 +50,7 @@
       {
           try
           {
  -            return super.resolve( role );
  +            return super.get( role );
           }
           catch( ResourceException e )
           {
  @@ -65,6 +65,6 @@
        */
       public void release( Object object )
       {
  -        super.disgard( object );
  +        super.put( object );
       }
   }
  
  
  
  1.3       +5 -5      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LifecycleHelper.java	30 Jul 2002 07:05:55 -0000	1.2
  +++ LifecycleHelper.java	30 Jul 2002 13:49:07 -0000	1.3
  @@ -29,7 +29,7 @@
   import org.apache.avalon.framework.service.Serviceable;
   
   import org.apache.excalibur.merlin.model.Profile;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +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;
  @@ -159,8 +159,8 @@
                   final ExtensionDescriptor ext = facility.getExtension( phase );
                   if( ext.isApplicable( ExtensionDescriptor.CREATE ) )
                   {
  -                    ResourceDesignator resource = profile.getExtension( phase );
  -                    Extension extension = (Extension) resource.getInstance();
  +                    Resource resource = profile.getExtension( phase );
  +                    Extension extension = (Extension) resource.access();
                       try
                       {
                           getLogger().info("applying phase " + phase.getReference() + " to
" + name );
  @@ -263,8 +263,8 @@
               {
                   try
                   {
  -                    ResourceDesignator resource = profile.getExtension( phase );      
 
  -                    Extension extension = (Extension) resource.getInstance();
  +                    Resource resource = profile.getExtension( phase );        
  +                    Extension extension = (Extension) resource.access();
                       getLogger().info("applying '" + phase.getReference() 
                         + "' to '" + name + "'.");
                       extension.extend( Extension.DESTROY, object, new DefaultContext() );
  
  
  
  1.3       +109 -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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProfileDesignator.java	30 Jul 2002 07:05:55 -0000	1.2
  +++ ProfileDesignator.java	30 Jul 2002 13:49:07 -0000	1.3
  @@ -9,10 +9,15 @@
   
   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.excalibur.merlin.assembly.resource.LifecycleHelper;
   import org.apache.excalibur.merlin.model.Profile;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +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.
  @@ -20,9 +25,11 @@
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
  -public class ProfileDesignator implements ResourceDesignator
  +public class ProfileDesignator implements Resource
   {
   
  +    // ########################### SINGELTON ONLY ############################
  +
       public static final String HEADER = "service:";
   
       /**
  @@ -56,6 +63,11 @@
       private int m_state = NOT_STARTED;
   
       /**
  +     * Flag indicating if the singelton instance has been released.
  +     */
  +    private boolean m_released = false;
  +
  +    /**
        * Create a profile designator instance.
        *
        * @param path the path of the profile designator
  @@ -117,23 +129,50 @@
        * @return the service instance.
        * @exception LifecycleException if an error occurs while establishing the object
        */
  -    public Object getInstance() throws LifecycleException
  +    public Object create() throws Exception
       {
  -        if( m_service == null )
  -          m_service = m_helper.startup( m_path, m_profile, m_provider );
  +        if( getState() == STARTED )
  +          return m_service;
  +        m_service = m_helper.startup( m_path, m_profile, m_provider );
           setState( STARTED );
           return m_service;
       }
   
       /**
  -     * Release the service instance.
  +     * Get the resource instance.
        *
  -     * @exception LifecycleException if an error occurs while releasing the object
  +     * @return the service instance.
  +     * @exception LifecycleException if an error occurs while establishing the object
  +     */
  +    public Object access() throws Exception
  +    {
  +        if( m_service == null )
  +        {
  +            create();
  +        }
  +        handleExtensions( ExtensionDescriptor.ACCESS, m_service );
  +        return m_service;
  +    }
  +
  +    /**
  +     * Release the service instance.
  +     */
  +    public void release( Object object ) throws Exception
  +    {
  +        if( !m_released )
  +          handleExtensions( ExtensionDescriptor.RELEASE, object );
  +    }
  +
  +    /**
  +     * Destroy the service instance.
        */
  -    public void release() throws LifecycleException
  +    public void destroy() throws Exception
       {
           if( m_service != null )
  -          m_helper.shutdown( m_path, m_profile, m_service );
  +        {
  +            release( m_service );
  +            m_helper.shutdown( m_path, m_profile, m_service );
  +        }
           setState( STOPPED );
       }
   
  @@ -151,7 +190,6 @@
          m_state = state;
       }
   
  -
      /**
       * Return the profile.
       *
  @@ -161,6 +199,66 @@
       {
           return m_profile;
       }
  +
  +    private void handleExtensions( int stage, Object object ) throws Exception
  +    {
  +        //
  +        // apply creation phase extensions
  +        //
  +
  +        DefaultContext context = new DefaultContext();
  +        PhaseDescriptor[] phases = m_profile.getType().getPhases();
  +
  +        if( stage == ExtensionDescriptor.ACCESS )
  +        {
  +            //
  +            // process in forward order
  +            //
  +
  +            for( int i=0; i<phases.length; i++ )
  +            {
  +                 processExtension( stage, phases[i], object, context );
  +            }
  +        }
  +        else
  +        {
  +            //
  +            // process in backward order
  +            //
  +
  +            for( int i=(phases.length-1); i>-1; i-- )
  +            {
  +                 processExtension( stage, phases[i], object, context );
  +            }
  +        }
  +    }
  +
  +    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 );
  +            }
  +        }
  +    }
  +
   
       public String toString()
       {
  
  
  
  1.3       +2 -2      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceProvider.java	30 Jul 2002 07:05:55 -0000	1.2
  +++ ResourceProvider.java	30 Jul 2002 13:49:07 -0000	1.3
  @@ -66,7 +66,7 @@
   import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Association;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.merlin.model.Import;
   
   
  
  
  
  1.7       +3 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Container.java	29 Jul 2002 06:14:30 -0000	1.6
  +++ Container.java	30 Jul 2002 13:49:07 -0000	1.7
  @@ -9,7 +9,7 @@
   package org.apache.excalibur.merlin.container;
   
   import org.apache.excalibur.merlin.model.Profile;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
   import org.apache.excalibur.merlin.Verifiable;
   import org.apache.excalibur.merlin.Controller;
  @@ -38,6 +38,6 @@
       *
       * @return the set of available resources
       */
  -    ResourceDesignator[] getResources();
  +    Resource[] getResources();
   
   }
  
  
  
  1.18      +7 -24     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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DefaultContainer.java	29 Jul 2002 06:14:30 -0000	1.17
  +++ DefaultContainer.java	30 Jul 2002 13:49:07 -0000	1.18
  @@ -69,7 +69,7 @@
   import org.apache.excalibur.merlin.assembly.DefaultLoggerManager;
   import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.Profile;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.merlin.model.verifier.AssemblyVerifier;
   import org.apache.excalibur.merlin.model.verifier.MetaDataVerifier;
   import org.apache.excalibur.merlin.Verifiable;
  @@ -91,27 +91,10 @@
       //=======================================================================
   
      /**
  -    * Context key used to locate the parent container.
  -    */
  -    public static final String CONTAINER_KEY = "container";
  -
  -   /**
  -    * Context key used to locate the shared dependency map.
  -    */
  -    public static final String MAP_KEY = "map";
  -
  -   /**
       * Context key used to locate the container meta data model.
       */
       public static final String CONTAINER_DESCRIPTOR_KEY = "descriptor";
   
  -   /**
  -    * Context key used to locate the kernel supplied disctionary of context
  -    * entries available for import.
  -    */
  -    public static final String DICTIONARY_KEY = "dictionary";
  -
  -
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultContainer.class );
   
  @@ -327,13 +310,13 @@
       *
       * @return the set of exported resources
       */
  -    public ResourceDesignator[] getResources()
  +    public Resource[] getResources()
       {
           if( !m_initialized )
             throw new IllegalStateException("not-initialized");
   
           ArrayList list = new ArrayList();
  -        ResourceDesignator[] local = m_classloader.getExport();
  +        Resource[] local = m_classloader.getExport();
           for( int i=0; i<local.length; i++ )
           {
               list.add( local[i] );
  @@ -342,15 +325,15 @@
           while( iterator.hasNext() )
           {
               Container container = (Container)iterator.next();
  -            ResourceDesignator[] resources = container.getResources();
  +            Resource[] resources = container.getResources();
               for( int j=0; j<resources.length; j++ )
               {
  -                ResourceDesignator resource = resources[j];
  +                Resource resource = resources[j];
                   if( !list.contains( resource ) )
                     list.add( resources[j] );
               }
           }
  -        return (ResourceDesignator[]) list.toArray( new ResourceDesignator[0] );
  +        return (Resource[]) list.toArray( new Resource[0] );
       }
   
       //=======================================================================
  
  
  
  1.4       +8 -13     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/doc-files/Container.gif
  
  	<<Binary file>>
  
  
  1.5       +31 -29    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/doc-files/DefaultContainer.gif
  
  	<<Binary file>>
  
  
  1.2       +19 -29    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/doc-files/merlin.gif
  
  	<<Binary file>>
  
  
  1.24      +5 -5      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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- DefaultKernel.java	29 Jul 2002 06:14:32 -0000	1.23
  +++ DefaultKernel.java	30 Jul 2002 13:49:08 -0000	1.24
  @@ -68,7 +68,7 @@
   import org.apache.excalibur.merlin.container.model.DirsetDescriptor;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.container.model.ContainerDescriptor;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +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;
  @@ -117,7 +117,7 @@
           <font color="gray">//
           // Following initialization the assembly of components has been completed and 
           // resource descriptiors have been assigned.  Service exported by the kernel may

  -        // may be access via {@link ResourceDesignator} references exposed by the 
  +        // may be access via {@link Resource} references exposed by the 
           // {link #getResources()} method.  The following method start all resources 
           // declared as activatable on startup.
           //</font>
  @@ -221,7 +221,7 @@
               throw new KernelException( error, e );
           }
   
  -        ResourceDesignator[] resources = getResources();
  +        Resource[] resources = getResources();
           Logger export = getLogger().getChildLogger( "export" );
           for( int i=0; i<resources.length; i++ )
           {
  @@ -305,7 +305,7 @@
       // Kernel
       //=======================================================================
   
  -    public ResourceDesignator[] getResources()
  +    public Resource[] getResources()
       {
           return m_container.getResources();
       }
  
  
  
  1.10      +3 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Kernel.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Kernel.java	18 Jul 2002 03:40:11 -0000	1.9
  +++ Kernel.java	30 Jul 2002 13:49:08 -0000	1.10
  @@ -9,7 +9,7 @@
   package org.apache.excalibur.merlin.kernel;
   
   import org.apache.excalibur.merlin.Controller;
  -import org.apache.excalibur.merlin.model.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.excalibur.meta.info.EntryDescriptor;
   
  @@ -29,6 +29,6 @@
        *
        * @return the set of resource designators
        */
  -    ResourceDesignator[] getResources();
  +    Resource[] getResources();
       
   }
  
  
  
  1.2       +19 -17    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/doc-files/DefaultKernel.gif
  
  	<<Binary file>>
  
  
  1.6       +6 -6      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Association.java
  
  Index: Association.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Association.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Association.java	30 Jul 2002 07:05:55 -0000	1.5
  +++ Association.java	30 Jul 2002 13:49:08 -0000	1.6
  @@ -31,16 +31,16 @@
       /**
        * A reference to the component that is capable of fullfilling the dependency.
        */
  -    private final ResourceDesignator m_provider;
  +    private final Resource m_provider;
   
       /**
        * Create an Association with specified name and provider.
        *
        * @param role the name client uses to access component
  -     * @param provider the <code>ResourceDesignator</code> instance
  +     * @param provider the <code>Resource</code> instance
        *   that is associated as a service provider
        */
  -    public Association( final String role, final ResourceDesignator provider )
  +    public Association( final String role, final Resource provider )
       {
           m_role = role;
           m_provider = provider;
  @@ -59,12 +59,12 @@
       }
   
       /**
  -     * Return the <code>ResourceDesignator</code> that will used to
  +     * Return the <code>Resource</code> that will used to
        * fulfill the dependency.
        *
        * @return the profile that will fulfill the dependency.
        */
  -    public ResourceDesignator getProvider()
  +    public Resource getProvider()
       {
           return m_provider;
       }
  
  
  
  1.13      +5 -5      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java
  
  Index: Profile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Profile.java	30 Jul 2002 07:05:55 -0000	1.12
  +++ Profile.java	30 Jul 2002 13:49:08 -0000	1.13
  @@ -332,7 +332,7 @@
       * Add an association for a service dependecy.
       * @param association the association representing the provider
       */
  -    public Association addProvider( String role, ResourceDesignator resource )
  +    public Association addProvider( String role, Resource resource )
       {
           Association association = new Association( role, resource );
           m_dependencies.put( role, association );
  @@ -344,7 +344,7 @@
       * @param phase the identifier of the phase to assign the manager to
       * @param resource the reference to the manager
       */
  -    public void addExtension( PhaseDescriptor phase, Profile profile, ResourceDesignator
resource )
  +    public void addExtension( PhaseDescriptor phase, Profile profile, Resource resource
)
       {
           m_managers.put( phase, resource );
           m_extensions.put( phase, profile );
  @@ -356,9 +356,9 @@
       * @param phase the lifecycle phase specification
       * @return a reference to the phase extension
       */
  -    public ResourceDesignator getExtension( PhaseDescriptor phase )
  +    public Resource getExtension( PhaseDescriptor phase )
       {
  -        return (ResourceDesignator) m_managers.get( phase );
  +        return (Resource) m_managers.get( phase );
       }
   
      /**
  
  
  
  1.4       +28 -26    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/doc-files/uml.gif
  
  	<<Binary file>>
  
  
  1.3       +40 -5     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/ExtensionDescriptor.java
  
  Index: ExtensionDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/ExtensionDescriptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExtensionDescriptor.java	30 Jul 2002 07:05:56 -0000	1.2
  +++ ExtensionDescriptor.java	30 Jul 2002 13:49:08 -0000	1.3
  @@ -109,11 +109,11 @@
   
       public boolean isApplicable( int stage )
       {
  -        
  -
           final int policy = getStage();
  -        if( policy == ALL ) return true;
  -        if( policy == stage ) return true;
  +        if( policy == ALL ) 
  +          return true;
  +        if( policy == stage ) 
  +          return true;
           if(( stage == CREATE ) || ( stage == DESTROY ))
           {
               return ( policy == OUTER );
  @@ -125,5 +125,40 @@
           return false;
       } 
   
  +    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 if( stage == INNER )
  +       {
  +           return "INNER";
  +       }
  +       else if( stage == OUTER )
  +       {
  +           return "OUTER";
  +       }
  +       else if( stage == ALL )
  +       {
  +           return "ALL";
  +       }
  +       else
  +       {
  +           throw new IllegalArgumentException( "stage: " + stage );
  +       }
  +    }
   
   }
  
  
  

--
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