avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl DefaultBlock.java
Date Tue, 18 Mar 2003 05:05:02 GMT
mcconnell    2003/03/17 21:05:02

  Modified:    merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
                        DefaultBlock.java
  Log:
  Impovement to suplimentary dependency declaration and state management.
  
  Revision  Changes    Path
  1.3       +76 -12    avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlock.java
  
  Index: DefaultBlock.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlock.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultBlock.java	17 Mar 2003 04:05:56 -0000	1.2
  +++ DefaultBlock.java	18 Mar 2003 05:05:02 -0000	1.3
  @@ -48,6 +48,7 @@
   import org.apache.avalon.meta.info.builder.XMLTypeCreator;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
  +import org.apache.avalon.meta.info.ServiceDescriptor;
   import org.apache.avalon.meta.model.builder.XMLProfileCreator;
   import org.apache.avalon.meta.model.Profile;
   import org.apache.avalon.merlin.kernel.impl.DefaultKernel;
  @@ -56,10 +57,8 @@
   
   /**
    * The default implementation of a Block.  The implementation provides 
  - * support for convinence operations related to its role as a container
  - * by delegating to the container it is managing. As an appliance it is 
  - * responsible for the establishment of a containment heirachy that 
  - * represents the implemetation model for the block.
  + * support for convinence operations related to its role as a containment
  + * handler by delegating to the container it is managing.
    */
   public class DefaultBlock extends DefaultAppliance implements Block, Runnable, StateListener
   {
  @@ -67,6 +66,19 @@
       // static
       //-------------------------------------------------------------------------------
   
  +   /**
  +    * Context key referencing optional block dependency criteria.
  +    */
  +    public static final String DEPENDENCIES_KEY = 
  +      "urn:merlin:container.dependencies"; 
  +
  +   /**
  +    * Context key referencing optional block services criteria.
  +    */
  +    public static final String SERVICES_KEY = 
  +      "urn:merlin:container.services";
  +
  +
       private static final int DISASSEMBLED = 1000;
       private static final int TERMINATED = 2000;
       private static final int DISPOSED = 3000;
  @@ -188,6 +200,16 @@
       */ 
       private boolean m_terminated = false;
   
  +   /**
  +    * The set of dependecies declared by the block.
  +    */ 
  +    private DependencyDescriptor[] m_dependencies;
  +
  +   /**
  +    * The set of services declared by the block.
  +    */ 
  +    private ServiceDescriptor[] m_services;
  +
       //=====================================================================
       // Contextualizable
       //=====================================================================
  @@ -212,6 +234,55 @@
             (List) context.get( "urn:merlin:container.containers" );
           m_repository = 
             (ApplianceRepository) context.get( "urn:assembly:appliance.repository" );
  +
  +        //
  +        // if dependecies are declared then use the supplied dependencies
  +        // together with any dependecies declared by the underlying 
  +        // containerment solution, otherwise we default to the underlying
  +        // container type
  +        //
  +
  +        if( context.hasEntry( DEPENDENCIES_KEY ) )
  +        {
  +            DependencyDescriptor[] dependencies = 
  +              (DependencyDescriptor[]) context.get( DEPENDENCIES_KEY );
  +            DependencyDescriptor[] classic = super.getDependencies();
  +
  +            ArrayList list = new ArrayList();
  +            for( int i=0; i<classic.length; i++ )
  +            {
  +                list.add( classic[i] );
  +            }
  +
  +            for( int i=0; i<dependencies.length; i++ )
  +            {
  +                list.add( dependencies[i] );
  +            }
  +
  +            m_dependencies = 
  +              (DependencyDescriptor[]) list.toArray( new DependencyDescriptor[0] );
  +        }
  +        else
  +        {
  +            m_dependencies = super.getDependencies();
  +        }
  +
  +        //
  +        // if services are declare we isolate available services to 
  +        // those declared here, otherwise all services established explicitly
  +        // within the block implementation will be visible as services
  +        // provided by the block
  +        //
  +
  +        if( context.hasEntry( SERVICES_KEY ) )
  +        {
  +            m_services = 
  +              (ServiceDescriptor[]) context.get( SERVICES_KEY );
  +        }
  +        else
  +        {
  +            m_services = null;
  +        }
       }
   
       //=====================================================================
  @@ -319,14 +390,7 @@
        */
       public DependencyDescriptor[] getDependencies()
       {
  -        DependencyDescriptor[] classic = super.getDependencies();
  -
  -        //
  -        // ## pending
  -        // ## add block level dependencies
  -        //
  -
  -        return classic;
  +        return m_dependencies;
       }
   
      /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message