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/07/18 05:40:12 UTC

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

mcconnell    2002/07/17 20:40:12

  Modified:    assembly/src/etc kernel.xml
               assembly/src/java/org/apache/excalibur/merlin
                        DefaultController.java
               assembly/src/java/org/apache/excalibur/merlin/container
                        Container.java DefaultContainer.java
                        DependencyGraph.java ProfileDesignator.java
                        ProfileRegistry.java ResourceProvider.java
               assembly/src/java/org/apache/excalibur/merlin/container/doc-files
                        Container.gif DefaultContainer.gif
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java Kernel.java
               assembly/src/java/org/apache/excalibur/merlin/model
                        Association.java Profile.java
               assembly/src/java/org/apache/excalibur/merlin/model/verifier
                        AssemblyVerifier.java
  Log:
  enhancement/rationalization of the profile to resource relationships (which
  will lead to delayed component deployment under a service manager).
  
  Revision  Changes    Path
  1.12      +2 -3      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- kernel.xml	15 Jul 2002 02:12:23 -0000	1.11
  +++ kernel.xml	18 Jul 2002 03:40:11 -0000	1.12
  @@ -57,8 +57,7 @@
        <loggers priority="INFO">
          <category priority="DEBUG"  name="loader" />
          <category priority="DEBUG"  name="types" />
  -       <category priority="WARN"  name="types.builder" />
  -       <category priority="WARN"  name="profiles" />
  +       <category priority="INFO"  name="assembly" />
          <category priority="WARN"  name="lifecycle" />
          <category priority="WARN"  name="verifier" />
        </loggers>
  @@ -123,7 +122,7 @@
   
          <loggers priority="INFO">
            <category priority="WARN"  name="loader" />
  -         <category priority="WARN"  name="types" />
  +         <category priority="INFO"  name="assembly" />
            <category priority="WARN"  name="profiles" />
            <category priority="WARN"  name="lifecycle" />
          </loggers>
  
  
  
  1.4       +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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultController.java	16 Jul 2002 08:57:18 -0000	1.3
  +++ DefaultController.java	18 Jul 2002 03:40:11 -0000	1.4
  @@ -28,7 +28,7 @@
   import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
   import org.apache.excalibur.merlin.kernel.ContainerClassLoader;
   import org.apache.excalibur.merlin.kernel.KernelException;
  -import org.apache.excalibur.merlin.kernel.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.ResourceDesignator;
   import org.apache.excalibur.merlin.model.builder.XMLKernelCreator;
   import org.apache.excalibur.merlin.model.KernelDescriptor;
   import org.apache.excalibur.merlin.model.ClasspathDescriptor;
  
  
  
  1.4       +32 -13    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Container.java	15 Jul 2002 02:12:24 -0000	1.3
  +++ Container.java	18 Jul 2002 03:40:11 -0000	1.4
  @@ -9,6 +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.meta.info.ServiceDesignator;
   import org.apache.excalibur.merlin.Verifiable;
   import org.apache.excalibur.merlin.Controller;
  @@ -30,29 +31,47 @@
    */
   public interface Container extends Controller, Verifiable
   {
  -   /**
  -    * Return the set of potential profiles of installed component matching a dependency.
  -    * @param dependency a consumer component dependecy declaration
  -    * @return the set of potential supplier profile
  -    */
  -    Profile[] getProviders( ServiceDesignator service );
   
      /**
  -    * Get a service instance.
  -    * @param profile the service provider constraint information
  +    * Assembly function that return an establish candidate resource from a parent or local
  +    * container matching a supplied profile.
  +    *
  +    * @param profile a supplier profile
  +    * @return the corresponding candidate resource or null if no matching resource
       */
  -    Object lookup( Profile profile );
  +    ResourceDesignator getCandidateResource( Profile profile );
   
      /**
  -    * Notification by a client that it no longer requies an object.
  -    * @param provider the key to the provider instance
  +    * Assembly function that returns the set of potential profiles 
  +    * matching a dependency that may be applied as candidates to an assembly 
  +    * process.
  +    *
  +    * @param dependency a consumer component dependency declaration
  +    * @return the set of available potential supplier profiles
       */
  -    void release( Object object );
  +    Profile[] getProviders( ServiceDesignator service );
   
      /**
       * Returns the path name of this container.
       * @return the container's path
       */
       String getPath();
  +
  +   /**
  +    * Post-assembly function that returns the set of resources available in this 
  +    * container and all subsidary containers.
  +    *
  +    * @return the set of available resources
  +    */
  +    ResourceDesignator[] getResources();
  +
  +   /**
  +    * Post-assembly function that return the set of resources available in this 
  +    * container and all subsidary containers that match the supplied service type.
  +    *
  +    * @param service the service type
  +    * @return the set of available resources matching the service type
  +    */
  +    ResourceDesignator[] getResources( ServiceDesignator service );
   
   }
  
  
  
  1.11      +141 -54   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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultContainer.java	16 Jul 2002 08:58:19 -0000	1.10
  +++ DefaultContainer.java	18 Jul 2002 03:40:11 -0000	1.11
  @@ -14,6 +14,7 @@
   import java.net.URL;
   import java.net.JarURLConnection;
   import java.net.URLClassLoader;
  +import java.util.Map;
   import java.util.List;
   import java.util.LinkedList;
   import java.util.Hashtable;
  @@ -70,9 +71,9 @@
   import org.apache.excalibur.merlin.model.verifier.AssemblyVerifier;
   import org.apache.excalibur.merlin.model.verifier.MetaDataVerifier;
   import org.apache.excalibur.merlin.model.builder.ProfileBuilder;
  +import org.apache.excalibur.merlin.model.ResourceDesignator;
   import org.apache.excalibur.merlin.kernel.ContainerClassLoader;
   import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
  -import org.apache.excalibur.merlin.kernel.ResourceDesignator;
   import org.apache.excalibur.merlin.Verifiable;
   import org.apache.excalibur.merlin.Controller;
   import org.apache.log.Hierarchy;
  @@ -140,16 +141,12 @@
   
       private ContainerClassLoader m_classloader;
   
  -    private Logger m_logger;
  -
       private DependencyGraph m_map;
   
       private ResourceProvider m_provider;
   
       private DefaultLoggerManager m_logging;
   
  -    private String m_path;
  -
       private ContainerDescriptor m_descriptor;
   
      /**
  @@ -163,8 +160,7 @@
       */
       private ProfileRegistry m_profiles; 
   
  -    private Hashtable m_profileToObjectMap = new Hashtable();
  -    private ArrayList m_designators = new ArrayList();
  +    private Hashtable m_mapping = new Hashtable();
   
       private ProfileBuilder m_builder = new ProfileBuilder();
   
  @@ -210,7 +206,7 @@
       */
       public void initialize() throws Exception
       {
  -        getLogger().debug("initilization");
  +        getLogger().debug("initialization");
           m_helper.enableLogging( getLogger().getChildLogger("lifecycle") );
           m_provider = new ResourceProvider( m_classloader, m_logging, this );
   
  @@ -219,8 +215,9 @@
           //
   
           m_profiles = new ProfileRegistry( 
  -          m_descriptor, m_classloader, m_classloader, m_parent, m_map );
  -        m_profiles.enableLogging( getLogger().getChildLogger( "profiles") );
  +          m_descriptor, m_classloader, getPath(), m_parent, m_map, m_helper, m_provider, 
  +          m_mapping );
  +        m_profiles.enableLogging( getLogger().getChildLogger( "assembly") );
   
           // 
           // explicit component profile registration
  @@ -253,7 +250,7 @@
           try
           {
               getLogger().debug("profile assembly");
  -            m_profiles.assembleProfiles();
  +            m_profiles.assemble();
           }
           catch( Throwable e )
           {
  @@ -261,8 +258,13 @@
               throw new AssemblyException( error, e );
           }
   
  -        setupResources( m_designators );
  +        //
  +        // Place the profiles into resource designators so that we can publish 
  +        // the service to service/component managers and finsh up initialization
  +        // with the creation of the subsidiary containers.
  +        //
   
  +        validateResourceMapping( m_mapping );
           getLogger().debug("subsidiary container creation");
           ContainerDescriptor[] containers = m_descriptor.getContainers();
           for( int i=0; i<containers.length; i++ )
  @@ -271,6 +273,10 @@
               m_containers.add( createContainer( containers[i] ) );
           }
   
  +        //
  +        // declare initialization completed
  +        //
  +
           m_initialized = true;
   
       }
  @@ -311,12 +317,13 @@
                   final String name = profile.getName();
                   try
                   {
  +                    ResourceDesignator resource = 
  +                      (ResourceDesignator) m_mapping.get( profile );
                       if( getLogger().isDebugEnabled() )
  -                      getLogger().debug("starting: " + name );
  -                    Object object = m_helper.startup( name, profile, m_provider );
  -                    m_profileToObjectMap.put( profile, object );
  +                      getLogger().debug("starting: " + resource.getPath() );
  +                    Object object = resource.getInstance();
                       if( getLogger().isInfoEnabled() )
  -                      getLogger().info("started: " + name );
  +                      getLogger().info("started: " + resource.getPath() );
                   }
                   catch( LifecycleException le )
                   {
  @@ -344,22 +351,19 @@
                   if( getLogger().isDebugEnabled() )
                     getLogger().debug("stopping: " + name );
                   
  -                Object object = m_profileToObjectMap.get( profile );
  -                if( object != null )
  +                ResourceDesignator resource = 
  +                  (ResourceDesignator) m_mapping.get( profile );
  +                try
                   {
  -                    try
  -                    {
  -                        m_helper.shutdown( name, object );
  -                        m_profileToObjectMap.remove( profile );
  -                        if( getLogger().isInfoEnabled() )
  -                          getLogger().info("stopped: " + name );
  -                    }
  -                    catch( LifecycleException le )
  -                    {
  -                        final String warning = 
  -                          "Could not shutdown a service derived from profile: " + profile;
  -                        getLogger().warn( warning, le );
  -                    }
  +                    resource.release();
  +                    if( getLogger().isInfoEnabled() )
  +                       getLogger().info("stopped: " + resource.getPath() );
  +                }
  +                catch( Exception le )
  +                {
  +                    final String warning = 
  +                       "Could not shutdown a service derived from profile: " + profile;
  +                    getLogger().warn( warning, le );
                   }
               }
           }
  @@ -370,6 +374,9 @@
       // Controller
       //======================================================================
   
  +   /**
  +    * Request the startup of the managable unit.
  +    */
       public void startup() throws Exception
       {
   
  @@ -391,6 +398,9 @@
           getLogger().info("container startup complete");
       }
   
  +   /**
  +    * Request the shutdown of the managable unit.
  +    */
       public void shutdown()
       {
   
  @@ -414,9 +424,30 @@
       // Container
       //=======================================================================
   
  +   /**
  +    * Return an establish candidate resource from a parent or local
  +    * container matching a supplied profile.
  +    *
  +    * @param profile a supplier profile
  +    * @return the corresponding candidate resource or null if no matching resource
  +    */
  +    public ResourceDesignator getCandidateResource( Profile profile )
  +    {
  +        ResourceDesignator resource = (ResourceDesignator) m_mapping.get( profile );
  +        if(( resource == null) && (m_parent != null ))
  +          resource = m_parent.getCandidateResource( profile );
  +        return resource; 
  +    }
  +
  +   /**
  +    * Return the set of available potential profiles matching a dependency that 
  +    * may be applied as candidates to an assembly.
  +    * @param dependency a consumer component dependency declaration
  +    * @return the set of available potential supplier profiles
  +    */
       public Profile[] getProviders( ServiceDesignator designator )
       {
  -        Profile[] local = m_profiles.getProviders( designator );
  +        Profile[] local = getLocalProviders( designator );
           if( m_parent != null )
           {
               Profile[] facilities = m_parent.getProviders( designator );
  @@ -435,29 +466,35 @@
       }
   
      /**
  -    * Get a service instance for the supplied profile.
  -    * @param provider the key to the provider instance
  +    * Return the set of explicit, packed and implict providers capable of handling the 
  +    * supplied service.
  +    * @param designator the service designator
  +    * @return the set of candidate profiles
       */
  -    public Object lookup( Profile provider )
  +    private Profile[] getLocalProviders( ServiceDesignator designator )
       {
  -        Object object = m_profileToObjectMap.get( provider );
  -        if( object == null )
  +        ArrayList list = new ArrayList();
  +        Profile[] local = m_descriptor.getComponents( true );
  +        for( int i=0; i<local.length; i++ )
           {
  -            object = m_parent.lookup( provider );
  +            Profile profile = local[i];
  +            ServiceDescriptor[] services = profile.getType().getServices();
  +            for( int j=0; j<services.length; j++ )
  +            {
  +                if( services[j].getService().matches( designator ) )
  +                {
  +                   list.add( profile );
  +                   break;
  +                }
  +            }
           }
  -        return object;
  +        return (Profile[]) list.toArray( new Profile[0] );
       }
   
      /**
  -    * Requests to release all references to a profile and associated 
  -    * service instances.
  -    * @param profile the profile to release
  +    * Returns the path name of this container.
  +    * @return the container's path
       */
  -    public void release( Object object )
  -    {
  -       // only dealing with singletons for now
  -    }
  -
       public String getPath()
       {
           if( m_parent == null ) return "/" + m_descriptor.getName();
  @@ -465,8 +502,9 @@
       }
   
      /**
  -    * Return the set of exportable services from this container.
  -    * @return the exporable service descriptors
  +    * Return the set of resources available in this container and all subsidary containers.
  +    *
  +    * @return the set of available resources
       */
       public ResourceDesignator[] getResources()
       {
  @@ -480,7 +518,7 @@
   
       protected void getResources( List list )
       {
  -        list.addAll( m_designators );
  +        list.addAll( m_mapping.values() );
           Iterator iterator = m_containers.iterator();
           while( iterator.hasNext() )
           {
  @@ -489,10 +527,53 @@
       }
   
      /**
  +    * Return the set of resources available in this container and all subsidary containers
  +    * that match the supplied service type
  +    *
  +    * @param service the service type
  +    * @return the set of available resources matching the service type
  +    */
  +    public ResourceDesignator[] getResources( ServiceDesignator service )
  +    {
  +        if( !m_initialized )
  +          throw new IllegalStateException("not-initialized");
  +
  +        ArrayList list = new ArrayList();
  +        getResources( list, service );
  +        return (ResourceDesignator[]) list.toArray( new ResourceDesignator[0] );
  +    }
  +
  +    protected void getResources( List list, ServiceDesignator service )
  +    {
  +        ResourceDesignator[] resources = 
  +          (ResourceDesignator[]) m_mapping.values().toArray( new ResourceDesignator[0] );
  +        
  +        for( int i=0; i<resources.length; i++ )
  +        {
  +            ResourceDesignator resource = resources[i];
  +            ServiceDescriptor[] services = resource.getServices();
  +            for( int j=0; j<services.length; j++ )
  +            {
  +                if( services[j].getService().matches( service ) )
  +                {
  +                   list.add( resource );
  +                   break;
  +                }
  +            }
  +        }
  +        Iterator iterator = m_containers.iterator();
  +        while( iterator.hasNext() )
  +        {
  +            ((DefaultContainer)iterator.next()).getResources( list, service );
  +        }
  +    }
  +
  +
  +   /**
       * Return the set of exportable services from this container.
       * @return the exporable service descriptors
       */
  -    private void setupResources( List list )
  +    private void validateResourceMapping( Map map )
       {
           Profile[] profiles = m_map.getStartupGraph();
           for( int i=0; i<profiles.length; i++ )
  @@ -500,8 +581,14 @@
               Profile profile = profiles[i];
               if( this.contains( profile ) )
               {
  -                String name = getPath() + "/" + profile.getName();
  -                m_designators.add( new ProfileDesignator( name, profile, m_helper, m_provider ) );
  +                ResourceDesignator resource = (ResourceDesignator) map.get( profile );
  +                if( resource == null )
  +                {
  +                    String name = getPath() + "/" + profile.getName();
  +                    resource = new ProfileDesignator( name, profile, m_helper, m_provider );
  +                    m_mapping.put( profile, resource );
  +                    getLogger().info("added suppliment: " + name );
  +                }
               }
           }
       }
  
  
  
  1.3       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DependencyGraph.java
  
  Index: DependencyGraph.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DependencyGraph.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DependencyGraph.java	12 Jul 2002 19:09:26 -0000	1.2
  +++ DependencyGraph.java	18 Jul 2002 03:40:11 -0000	1.3
  @@ -254,7 +254,7 @@
   
               if( assignment != null ) 
               {
  -                final Profile provider = assignment.getProvider();
  +                final Profile provider = assignment.getProvider().getProfile();
                   visitcomponent( provider, true, done, order );
               }
               else
  
  
  
  1.2       +27 -5     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ProfileDesignator.java
  
  Index: ProfileDesignator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ProfileDesignator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProfileDesignator.java	15 Jul 2002 02:12:24 -0000	1.1
  +++ ProfileDesignator.java	18 Jul 2002 03:40:11 -0000	1.2
  @@ -8,7 +8,7 @@
   package org.apache.excalibur.merlin.container;
   
   import org.apache.excalibur.merlin.model.Profile;
  -import org.apache.excalibur.merlin.kernel.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.ResourceDesignator;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   
   /**
  @@ -102,15 +102,37 @@
       }
   
       /**
  -     * Return the resource instance.
  +     * Get the resource instance.
        *
  -     * @return the profile
  +     * @return the service instance.
  +     * @exception LifecycleException if an error occurs while establishing the object
        */
  -    public Object getInstance() throws Exception
  +    public Object getInstance() throws LifecycleException
       {
           if( m_service == null )
             m_service = m_helper.startup( m_path, m_profile, m_provider );
           return m_service;
  +    }
  +
  +    /**
  +     * Release the service instance.
  +     *
  +     * @exception LifecycleException if an error occurs while releasing the object
  +     */
  +    public void release() throws LifecycleException
  +    {
  +        if( m_service == null )
  +          m_helper.shutdown( m_path, m_service );
  +    }
  +
  +   /**
  +    * Return the profile.
  +    *
  +    * @return the profile
  +    */
  +    public Profile getProfile()
  +    {
  +        return m_profile;
       }
   
       public String toString()
  
  
  
  1.8       +89 -83    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ProfileRegistry.java
  
  Index: ProfileRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ProfileRegistry.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProfileRegistry.java	13 Jul 2002 21:28:18 -0000	1.7
  +++ ProfileRegistry.java	18 Jul 2002 03:40:11 -0000	1.8
  @@ -8,6 +8,7 @@
   package org.apache.excalibur.merlin.container;
   
   import java.util.List;
  +import java.util.Map;
   import java.util.ArrayList;
   import java.util.LinkedList;
   import java.util.Hashtable;
  @@ -33,6 +34,7 @@
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.builder.ProfileBuilder;
  +import org.apache.excalibur.merlin.model.ResourceDesignator;
   
   /**
    * Internal table that holds available component type keyed relative
  @@ -48,38 +50,59 @@
       // state
       //=======================================================================
   
  -    private ProfileBuilder m_builder = new ProfileBuilder();
  +   /**
  +    * Classloader used to load a service profile selector.
  +    */
       private ClassLoader m_classloader;
  -    private TypeManager m_types;
  -    private Container m_parent;
   
      /**
  -    * Component profiles keyed by name.
  +    * The parent container from which we can resolve the available facilities
  +    * (profiles) that are already established.
       */
  -    private Hashtable m_profiles = new Hashtable();
  +    private Container m_parent;
   
      /**
  -    * List of ServiceTable instances.
  +    * The container path (used when creating resource designators).
       */
  -    private List m_services = new LinkedList();
  -
  -    private final Configuration[] m_directives = new Configuration[0];
  +    private String m_path;
   
      /**
  -    * The set of local explicitly declared profiles.
  +    * The lifecycle helper (used when creating resource designators).
       */
  -    private Vector m_assembly = new Vector();
  +    private LifecycleHelper m_helper;
   
      /**
  -    * The set of locally installed profiles.
  +    * The resource provider (used when creating resource designators).
       */
  -    private ArrayList m_installed = new ArrayList();
  +    private ResourceProvider m_provider;
   
  +   /**
  +    * The dependency map that is populated during the assembly process.
  +    */
       private DependencyGraph m_map;
   
  +   /**
  +    * The container descriptor used to establish the set of explicit profiles
  +    * to assemble.
  +    */
       private ContainerDescriptor m_descriptor;
   
  -   //=======================================================================
  +   /**
  +    * Component profiles keyed by name.
  +    */
  +    private Hashtable m_profiles = new Hashtable();
  +
  +   /**
  +    * List of ServiceTable instances.
  +    */
  +    private List m_services = new LinkedList();
  +
  +   /**
  +    * The mapping of profiles to resource designators
  +    */
  +    private Map m_mapping;
  +
  +    //=======================================================================
       // constructor
       //=======================================================================
   
  @@ -89,73 +112,30 @@
       * @param loader the registry class loader
       * @param profiles the configuration fragment containing explicit component profiles
       */
  -    public ProfileRegistry( 
  -      ContainerDescriptor descriptor, TypeManager registry, ClassLoader loader, 
  -      Container container, DependencyGraph map )
  +    ProfileRegistry( 
  +      ContainerDescriptor descriptor, ClassLoader loader, 
  +      String path, Container parent, DependencyGraph map, LifecycleHelper helper, 
  +      ResourceProvider provider, Map mapping)
       {
           m_classloader = loader;
  -        m_types = registry;
           m_descriptor = descriptor;
  -        m_parent = container;
  +        m_parent = parent;
  +        m_path = path;
           m_map = map;
  +        m_helper = helper;
  +        m_provider = provider;
  +        m_mapping = mapping;
       }
   
       //=======================================================================
  -    // PrifileRegistry
  +    // ProfileRegistry
       //=======================================================================
   
      /**
  -    * Return the set of explicit, packed and implict providers capable of handling the 
  -    * supplied service.
  -    * @param designator the service designator
  -    * @return the set of candidate profiles
  -    */
  -    public Profile[] getProviders( ServiceDesignator designator )
  -    {
  -        ArrayList list = new ArrayList();
  -        Profile[] local = m_descriptor.getComponents( true );
  -        for( int i=0; i<local.length; i++ )
  -        {
  -            Profile profile = local[i];
  -            ServiceDescriptor[] services = profile.getType().getServices();
  -            for( int j=0; j<services.length; j++ )
  -            {
  -                if( services[j].getService().matches( designator ) )
  -                {
  -                   list.add( profile );
  -                   break;
  -                }
  -            }
  -        }
  -        return (Profile[]) list.toArray( new Profile[0] );
  -    }
  -
  -   /**
  -    * Register a potential supplier component type.  The implementation will
  -    * create a component profile instance for the type if not already known and 
  -    * return the existing or new instance to the invoking client based on packaged
  -    * profiles associated with the type.
  -    *
  -    * @param classname the component class name
  -    * @return the component type
  -    */
  -    public Profile[] register( Type type ) throws Exception
  -    {
  -        Profile[] profiles = m_builder.build( type, m_classloader );
  -        for( int i=0; i<profiles.length; i++ )
  -        {
  -            Profile profile = profiles[i];
  -            
  -            register( profile );
  -        }
  -        return profiles;
  -    }
  -
  -   /**
       * Register the type resulting in the cross-referencing of the type with the set of 
       * service tables that the type is is capable of supporting.
       */
  -    public Profile register( Profile profile )
  +    Profile register( Profile profile )
       {
           String name = profile.getName();
           m_profiles.put( name, profile );
  @@ -171,7 +151,7 @@
      /**
       * For all of the explicity declared profiles, initiate dependency correlation.
       */
  -    public void assembleProfiles() throws Exception
  +    void assemble() throws Exception
       {
           Profile[] profiles = m_descriptor.getComponents( Profile.EXPLICIT, true );
           for( int i=0; i<profiles.length; i++ )
  @@ -179,13 +159,16 @@
               Profile profile = profiles[i];
               getLogger().debug("assembly target: " + profile );
               ArrayList visited = new ArrayList();
  -            assemble( profile, visited, "" );
  +            assembleProfile( profile, visited, "" );
  +
  +            final String name = m_path + "/" + profile.getName();
  +            m_mapping.put( profile, new ProfileDesignator( name, profile, m_helper, m_provider ) );
  +            getLogger().info( "created explicit resource for: " + name );
               m_map.add( profile );
  -            m_installed.add( profile );
           }
       }
   
  -    public boolean isLocalProfile( Profile profile )
  +    boolean isLocalProfile( Profile profile )
       {
           return m_profiles.values().contains( profile );
       }
  @@ -194,7 +177,7 @@
       * Returns the set of component types know to the registry.
       * @return the set of component types registered with the registry
       */
  -    public Profile[] getProfiles()
  +    Profile[] getProfiles()
       {
           return (Profile[]) m_profiles.values().toArray( new Profile[0] );
       }
  @@ -204,7 +187,7 @@
       * supporting the supplied service.
       * @return the set of candidate component types
       */
  -    public Profile[] getProfiles( ServiceDesignator service )
  +    Profile[] getProfiles( ServiceDesignator service )
       {
           return getTable( service ).getProfiles();
       }
  @@ -213,12 +196,12 @@
       * Returns a registered component type.
       * @return the component type from the registry or null if the type is unknown
       */
  -    public Profile getProfile( String name ) 
  +    Profile getProfile( String name ) 
       {
           return (Profile) m_profiles.get( name );
       }
   
  -    private void assemble( Profile profile, List visited, String pad ) throws Exception
  +    private void assembleProfile( Profile profile, List visited, String pad ) throws Exception
       {
           getLogger().debug( pad + "assemble: " + profile );
           String pad2 = pad + "  ";
  @@ -231,7 +214,7 @@
               String role = dependency.getRole();
               if( profile.getAssociation( role ) == null )
               {
  -                Profile[] candidates = assemble( profile, dependency, visited, pad2 );
  +                Profile[] candidates = assembleProfile( profile, dependency, visited, pad2 );
                   Profile[] facilities = getFacilities( dependency.getService() );
                   Profile provider = selectProfile( dependency, facilities, candidates );
                   if( provider == null )
  @@ -242,19 +225,42 @@
                        + role + "'.";
                       throw new UnresolvedProviderException( warning, dependency );
                   }
  -                profile.addProvider( provider, role );
  +                final String path = m_path + "/" + provider.getName();
  +                ResourceDesignator resource = getCandidateResource( provider );
  +                if( resource == null )
  +                {
  +                    resource = new ProfileDesignator( 
  +                      path, provider, m_helper, m_provider );
  +                    getLogger().info( "created dependent resource for: " + path );
  +                }
  +                profile.addProvider( role, resource );
                   if( isLocalProfile( provider ) ) 
                   {
  +                    m_mapping.put( provider, resource );
                       m_map.add( provider );
  -                    m_installed.add( provider );
                   }
               }
           }
       }
   
  +   /**
  +    * Return an establish candidate resource from a parent or local
  +    * container matching a supplied profile.
  +    *
  +    * @param profile a supplier profile
  +    * @return the corresponding candidate resource or null if no matching resource
  +    */
  +    private ResourceDesignator getCandidateResource( Profile profile )
  +    {
  +        ResourceDesignator resource = (ResourceDesignator) m_mapping.get( profile );
  +        if(( resource == null) && (m_parent != null ))
  +          resource = m_parent.getCandidateResource( profile );
  +        return resource; 
  +    }
   
  -    private Profile[] assemble( Profile source, DependencyDescriptor dependency, List visited, String pad )
  -       throws Exception
  +    private Profile[] assembleProfile( 
  +      Profile source, DependencyDescriptor dependency, List visited, String pad )
  +      throws Exception
       {
           getLogger().debug( pad + "dependency: " + dependency.getRole() );
           Vector vector = new Vector();
  @@ -267,7 +273,7 @@
               {
                   try
                   {
  -                    assemble( provider, visited, pad2 );
  +                    assembleProfile( provider, visited, pad2 );
                       vector.add( provider );
                       getLogger().debug( pad + "candidate: " + provider );
                   }
  
  
  
  1.4       +17 -34    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ResourceProvider.java
  
  Index: ResourceProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ResourceProvider.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResourceProvider.java	16 Jul 2002 08:58:34 -0000	1.3
  +++ ResourceProvider.java	18 Jul 2002 03:40:11 -0000	1.4
  @@ -112,13 +112,13 @@
       */
       private DefaultLoggerManager m_logging;
   
  -    private Container m_locator;
  +    private DefaultContainer m_locator;
   
       //=======================================================================
       // constructor
       //=======================================================================
   
  -    public ResourceProvider( ClassLoader loader, DefaultLoggerManager manager, Container locator )
  +    public ResourceProvider( ClassLoader loader, DefaultLoggerManager manager, DefaultContainer locator )
       {
           m_classloader = loader;
           m_logging = manager;
  @@ -318,43 +318,23 @@
           {
               DependencyDescriptor dependency = dependencies[i];
               final String role = dependency.getRole();
  -            final Association association = profile.getAssociation( role );
  -            final Profile provider = association.getProvider();
  -            final boolean required = type.getDependency( role ).isRequired();
  -            final String classname = type.getDependency( role ).getService().getClassname();
  -
  -            final Object service = lookup( provider, classname );
  -            if(( null == service ) && ( required ))
  +            try
               {
  -                final String message =
  -                    REZ.getString( "resource.missing-dependency.error",
  -                                   !required ? "1" : "2",
  -                                   role,
  -                                   profile.getName() );
  -                throw new Exception( message );
  +                final Association association = profile.getAssociation( role );
  +                Object service = association.getProvider().getInstance();
  +                services.put( role, service );
  +            }
  +            catch( Throwable e )
  +            {
  +                final String error = 
  +                  "Unexpected exception while attempting to locate a service to fulfill a dependency for "
  +                  + "the role: " + role + " in profile: " + profile.getName() + ".";
  +                throw new ContainerException( error, e );
               }
  -            services.put( role, service );
           }
           return services;
       }
   
  -   /**
  -    * Get a service instance for the supplied profile, and validate that the returned 
  -    * service instance implements the supplied service classname.
  -    * @param provider the key to the provider instance
  -    * @param service the classname of the service requested
  -    */
  -    private Object lookup( Profile provider, String service ) throws Exception
  -    {
  -        Object object = m_locator.lookup( provider );
  -        if( objectImplementsType( object, service ) )
  -           return object;
  -        final String error = 
  -           "Unable to locate an instantiated service instance implementing the interface: "
  -              + service + ", from the provider: " + provider;
  -        throw new ContainerException( error );
  -    }
  -
       /**
        * Check whether the specified value is compatible with specified type.
        *
  @@ -362,8 +342,10 @@
        * @param type the desired type
        * @return true if value is compatible with type, false otherwise
        */
  +    /*
       private boolean objectImplementsType( final Object value, final String type ) throws Exception
       {
  +        // ######### need to handle this sort of checking inside a service manager
           if( value == null ) 
             return false;
           try
  @@ -381,4 +363,5 @@
           }
           return false;
       }
  +    */
   }
  
  
  
  1.2       +13 -8     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/doc-files/Container.gif
  
  	<<Binary file>>
  
  
  1.2       +33 -26    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/doc-files/DefaultContainer.gif
  
  	<<Binary file>>
  
  
  1.17      +2 -1      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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultKernel.java	16 Jul 2002 08:58:34 -0000	1.16
  +++ DefaultKernel.java	18 Jul 2002 03:40:11 -0000	1.17
  @@ -70,6 +70,7 @@
   import org.apache.excalibur.merlin.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.CategoryDescriptor;
   import org.apache.excalibur.merlin.model.builder.TypeManager;
  +import org.apache.excalibur.merlin.model.ResourceDesignator;
   import org.apache.excalibur.merlin.container.DefaultContainer;
   
   /**
  
  
  
  1.9       +2 -1      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Kernel.java	15 Jul 2002 02:12:24 -0000	1.8
  +++ Kernel.java	18 Jul 2002 03:40:11 -0000	1.9
  @@ -9,6 +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.meta.info.ServiceDescriptor;
   import org.apache.excalibur.meta.info.EntryDescriptor;
   
  
  
  
  1.4       +5 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Association.java	14 Jul 2002 00:55:12 -0000	1.3
  +++ Association.java	18 Jul 2002 03:40:11 -0000	1.4
  @@ -32,17 +32,16 @@
        * the name of the component metadata instance that represents a component
        * type that is capable of fullfilling the dependency.
        */
  -    private final Profile m_provider;
  +    private final ResourceDesignator m_provider;
   
       /**
        * Create an Association with specified name and provider.
        *
        * @param role the name client uses to access component
  -     * @param provider the <code>Profile</code> instance
  +     * @param provider the <code>ResourceDesignator</code> instance
        *   that is associated as a service provider
        */
  -    public Association( final String role,
  -                               final Profile provider )
  +    public Association( final String role, final ResourceDesignator provider )
       {
           m_role = role;
           m_provider = provider;
  @@ -66,7 +65,7 @@
        *
        * @return the profile that will fulfill the dependency.
        */
  -    public Profile getProvider()
  +    public ResourceDesignator getProvider()
       {
           return m_provider;
       }
  
  
  
  1.6       +5 -6      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Profile.java	14 Jul 2002 00:55:12 -0000	1.5
  +++ Profile.java	18 Jul 2002 03:40:11 -0000	1.6
  @@ -304,13 +304,12 @@
       }
   
      /**
  -    * Add a provider for a service dependecy role.
  -    * @param provider the compenont provider profile
  -    * @param role the dependent role
  +    * Add an association for a service dependecy.
  +    * @param association the association representing the provider
       */
  -    public Association addProvider( Profile provider, String role )
  +    public Association addProvider( String role, ResourceDesignator resource )
       {
  -        Association association = new Association( role, provider );
  +        Association association = new Association( role, resource );
           m_dependencies.put( role, association );
           return association;
       }
  
  
  
  1.3       +3 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/AssemblyVerifier.java
  
  Index: AssemblyVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/AssemblyVerifier.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AssemblyVerifier.java	12 Jul 2002 19:09:28 -0000	1.2
  +++ AssemblyVerifier.java	18 Jul 2002 03:40:11 -0000	1.3
  @@ -210,7 +210,7 @@
   
           for( int i = 0; i < deps.length; i++ )
           {
  -            final String name = deps[ i ].getProvider().getName();
  +            final String name = deps[ i ].getProvider().getProfile().getName();
               final Profile other = getProfile( name, components );
               dependencies.add( other );
           }
  @@ -249,7 +249,7 @@
   
           for( int i = 0; i < roles.length; i++ )
           {
  -            final String providerName = roles[ i ].getProvider().getName();
  +            final String providerName = roles[ i ].getProvider().getProfile().getName();
               final String roleName = roles[ i ].getRole();
               final ServiceDesignator service =
                   info.getDependency( roleName ).getService();
  
  
  

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