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 DefaultBlockLoader.java
Date Sun, 13 Apr 2003 02:36:06 GMT
mcconnell    2003/04/12 19:36:05

  Modified:    merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
                        DefaultBlock.java DefaultBlockLoader.java
  Log:
  Improving terminology.
  
  Revision  Changes    Path
  1.7       +66 -33    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultBlock.java	10 Apr 2003 14:19:49 -0000	1.6
  +++ DefaultBlock.java	13 Apr 2003 02:36:05 -0000	1.7
  @@ -25,7 +25,7 @@
   import org.apache.avalon.merlin.block.BlockException;
   import org.apache.avalon.merlin.block.Library;
   import org.apache.avalon.merlin.container.Container;
  -import org.apache.avalon.merlin.container.ContainerDescriptor;
  +import org.apache.avalon.merlin.container.ContainmentProfile;
   import org.apache.avalon.merlin.container.StateEvent;
   import org.apache.avalon.merlin.container.StateListener;
   import org.apache.avalon.meta.info.DependencyDescriptor;
  @@ -114,11 +114,6 @@
       private ApplianceContext m_applianceContext;
   
      /**
  -    * The container meta info descriptor.
  -    */
  -    private ContainerDescriptor m_descriptor;
  -
  -   /**
       * The block configuration.
       */
       private Library m_library;
  @@ -181,6 +176,11 @@
       */ 
       private ServiceDescriptor[] m_services;
   
  +   /**
  +    * The set of profiles declared for this block.
  +    */ 
  +    private Profile[] m_profiles;
  +
       //=====================================================================
       // Contextualizable
       //=====================================================================
  @@ -197,12 +197,12 @@
             (ApplianceContext) context.get( "urn:assembly:appliance.context" );
           m_engine = 
             (EngineClassLoader) context.get( "urn:assembly:engine" );
  -        m_descriptor = 
  -          (ContainerDescriptor) context.get( "urn:merlin:container.descriptor" );
  +        m_profiles = 
  +          (Profile[]) context.get( "urn:merlin:container.profiles" );
           m_library = 
             (Library) context.get( "urn:merlin:container.library" );
           m_blocks = 
  -          (List) context.get( "urn:merlin:container.containers" );
  +          (List) context.get( "urn:merlin:container.blocks" );
           m_repository = 
             (ApplianceRepository) context.get( "urn:assembly:appliance.repository" );
   
  @@ -278,7 +278,7 @@
           // construct the appliance instances managed by this block
           //
   
  -        Profile[] profiles = m_descriptor.getComponents();
  +        Profile[] profiles = m_profiles;
           for( int i=0; i<profiles.length; i++ )
           {
               Profile profile = profiles[i];
  @@ -303,6 +303,20 @@
               Appliance appliance = m_engine.createAppliance( context, true );
               m_appliances.add( appliance );
           }
  +
  +        // ## 
  +        // ## TODO clean up the duplication of references to appliances.  This 
  +        // ## should be driven by the content in the appliance repository and 
  +        // ## and local references should be dropped.
  +        // ##
  +
  +        //System.out.println( "## APPLIANCE LIST: " + this );
  +        ApplianceRepository rep = m_engine.getApplianceRepository();
  +        Appliance[] appliances = rep.getAppliances();
  +        for( int a=0; a<appliances.length; a++ )
  +        {
  +            //System.out.println( "## APPLIANCE: " + appliances[a] ); 
  +        }
       }
   
       //-------------------------------------------------------------------------------
  @@ -315,6 +329,12 @@
       */
       private Appliance[] getAppliances()
       {
  +        // ## 
  +        // ## TODO clean up the duplication of references to appliances.  This 
  +        // ## should be driven by the content in the appliance repository and 
  +        // ## and local references should be dropped.
  +        // ##
  +
           return (Appliance[]) m_appliances.toArray( new Appliance[0] );
       }
   
  @@ -324,31 +344,14 @@
       */
       private Block[] getBlocks()
       {
  -        return (Block[]) m_blocks.toArray( new Block[0] );
  -    }
  +        // ## 
  +        // ## TODO clean up the duplication of references to appliances.  This 
  +        // ## should be driven by the content in the appliance repository and 
  +        // ## and local references should be dropped.
  +        // ##
   
  -    /*
  -    private URL[] getURLs()
  -    {
  -        List list = new ArrayList();
  -        list.add( getURL() );
  -        Appliance[] appliances = getAppliances();
  -        for( int i=0; i<appliances.length; i++ )
  -        {
  -            list.add( appliances[i].getURL() );
  -        }
  -        Block[] blocks = getBlocks();
  -        for( int j=0; j<blocks.length; j++ )
  -        {
  -            URL[] expanded = blocks[j].getURLs();
  -            for( int k=0; k<expanded.length; k++ )
  -            {
  -                list.add( expanded[k] );
  -            }
  -        }
  -        return (URL[]) list.toArray( new URL[0] );
  +        return (Block[]) m_blocks.toArray( new Block[0] );
       }
  -    */
   
       //-------------------------------------------------------------------------------
       // Appliance
  @@ -425,6 +428,12 @@
           // assemble the subsidiary blocks
           //
   
  +        // ## 
  +        // ## TODO clean up the duplication of references to appliances.  This 
  +        // ## should be driven by the content in the appliance repository and 
  +        // ## and local references should be dropped.
  +        // ##
  +
           Iterator iterator = m_blocks.iterator();
           while( iterator.hasNext() )
           {
  @@ -481,6 +490,12 @@
       */
       private void assembleComponents( DependencyGraph graph ) throws ApplianceException
       {
  +        // ## 
  +        // ## TODO clean up the duplication of references to appliances.  This 
  +        // ## should be driven by the content in the appliance repository and 
  +        // ## and local references should be dropped.
  +        // ##
  +
           Iterator iterator = m_appliances.iterator();
           while( iterator.hasNext() )
           {
  @@ -758,6 +773,12 @@
   
       private void handleDecommissioning()
       {
  +        // ## 
  +        // ## TODO clean up the duplication of references to appliances.  This 
  +        // ## should be driven by the content in the appliance repository and 
  +        // ## and local references should be dropped.
  +        // ##
  +
           //
           // decommission the subsidiary blocks
           //
  @@ -820,6 +841,12 @@
               }
           }
   
  +        // ## 
  +        // ## TODO clean up the duplication of references to appliances.  This 
  +        // ## should be driven by the content in the appliance repository and 
  +        // ## and local references should be dropped.
  +        // ##
  +
           Iterator iterator = m_blocks.iterator();
           while( iterator.hasNext() )
           {
  @@ -865,6 +892,12 @@
               Appliance appliance = m_shutdown[i];
               appliance.terminate();
           }
  +
  +        // ## 
  +        // ## TODO clean up the duplication of references to appliances.  This 
  +        // ## should be driven by the content in the appliance repository and 
  +        // ## and local references should be dropped.
  +        // ##
   
           m_appliances = null;
   
  
  
  
  1.7       +48 -43    avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlockLoader.java
  
  Index: DefaultBlockLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlockLoader.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultBlockLoader.java	6 Apr 2003 19:24:51 -0000	1.6
  +++ DefaultBlockLoader.java	13 Apr 2003 02:36:05 -0000	1.7
  @@ -111,7 +111,7 @@
   import org.apache.avalon.merlin.block.BlockRuntimeException;
   import org.apache.avalon.merlin.block.BlockLoader;
   import org.apache.avalon.merlin.container.builder.XMLContainerCreator;
  -import org.apache.avalon.merlin.container.ContainerDescriptor;
  +import org.apache.avalon.merlin.container.ContainmentProfile;
   import org.apache.avalon.merlin.container.Container;
   import org.apache.avalon.merlin.container.ContainerException;
   import org.apache.avalon.merlin.container.impl.DefaultContainer;
  @@ -200,8 +200,7 @@
       //==============================================================
   
      /**
  -    * Contextualization of the block loader during which the root 
  -    * engine along with the system context.
  +    * Contextualization of the block loader.
       */
       public void contextualize( Locator context ) throws ContextException
       {
  @@ -297,7 +296,7 @@
       * @param overrides the URL to a configuration containing configuration overrides
       * @return the block
       */
  -    public Block install( URL path, URL overrides )
  +    public Block install( final URL path, final URL overrides )
         throws BlockException
       {
           return installSource( m_engine, Container.PATH_SEPERATOR, path, overrides );
  @@ -312,7 +311,8 @@
       * @param overrides the URL to a configuration containing configuration overrides
       * @return the block
       */
  -    private Block installSource( EngineClassLoader loader, String root, URL path, URL overrides
)
  +    private Block installSource( 
  +      final EngineClassLoader loader, final String root, final URL path, final URL overrides
)
         throws BlockException
       {
   
  @@ -366,11 +366,12 @@
           }
   
           //
  -        // create the containment profile
  +        // create the containment profile and extract the list of
  +        // container profiles
           //
   
  -        ContainerDescriptor descriptor = 
  -          createContainerDescriptor( name, engine, implementation );
  +        ContainmentProfile descriptor = 
  +          createContainmentProfile( name, engine, implementation );
   
           //
           // create the block dependencies
  @@ -419,7 +420,7 @@
           //
   
           String partition = root + name + Container.PATH_SEPERATOR;
  -        List children = 
  +        List blocks = 
             createChildBlocks( engine, partition, implementation, config, base );
   
           //
  @@ -427,7 +428,7 @@
           //
   
           return createBlock( 
  -          dependencies, services, engine, children, descriptor, name, root, config );
  +          dependencies, services, engine, blocks, descriptor, name, root, config );
       }
   
       //==============================================================
  @@ -439,7 +440,7 @@
       * @param url the url to the targets configuration file (normally config.xml)
       * @return the configuration containing the targets
       */
  -    private Configuration getTargetsConfiguration( URL url ) throws BlockException
  +    private Configuration getTargetsConfiguration( final URL url ) throws BlockException
       {
           if( url == null )
           {
  @@ -500,7 +501,7 @@
           }
       }
   
  -    private Configuration getSourceConfiguration( URL url ) throws BlockException
  +    private Configuration getSourceConfiguration( final URL url ) throws BlockException
       {
           String uri = url.toString();
           if( url.getProtocol().equals( "jar" ) )
  @@ -550,11 +551,13 @@
       * @param config the configuration describing the block implementation
       * @return the container descriptor
       */
  -    private ContainerDescriptor createContainerDescriptor( 
  -      String name, EngineClassLoader engine, Configuration config )
  +    private ContainmentProfile createContainmentProfile( 
  +      final String name, final EngineClassLoader engine, final Configuration config )
         throws BlockException
       {
  -        String classname = config.getAttribute( "class", DefaultContainer.class.getName()
);
  +        final String classname = 
  +          config.getAttribute( "class", DefaultContainer.class.getName() );
  +
           Type type = null;
           try
           {
  @@ -574,10 +577,10 @@
               throw new BlockException( error, e );
           }
   
  -        ContainerDescriptor descriptor = null;
           try
           {
  -            descriptor = CREATOR.createContainerDescriptor( type, config, name );
  +            ContainmentProfile descriptor = 
  +              CREATOR.createContainmentProfile( type, config, name );
   
               //
               // from the container implementor point of view a block is all 
  @@ -627,20 +630,21 @@
       * @param config the parent block configuration 
       * @param custom override targets
       * @param base the base url
  +    *
       * @return a list of appliance instances each representing a subsidiary container
       */
       private List createChildBlocks( 
  -      EngineClassLoader engine, String partition,
  -      Configuration config, Configuration custom, URL base )
  +      final EngineClassLoader engine, final String partition,
  +      final Configuration config, final Configuration custom, final URL base )
         throws BlockException
       {
  -        List list = new ArrayList();
  +        final List list = new ArrayList();
   
           //
           // build the set of included blocks
           //
   
  -        Configuration[] includes = config.getChildren( "include" );
  +        final Configuration[] includes = config.getChildren( "include" );
           
           for( int j=0; j<includes.length; j++ )
           {
  @@ -682,12 +686,12 @@
           // build the set of embedded blocks
           //
   
  -        Configuration[] children = config.getChildren( "container" );
  +        final Configuration[] children = config.getChildren( "container" );
   
           for( int i=0; i<children.length; i++ )
           {
  -            Configuration child = children[i];
  -            String name = getBlockName( child );
  +            final Configuration child = children[i];
  +            final String name = getBlockName( child );
               EngineClassLoader loader;
               try
               {
  @@ -701,7 +705,7 @@
                   throw new BlockException( error, ce );
               }
   
  -            Block block = createContainmentBlock( 
  +            final Block block = createContainmentBlock( 
                 loader, partition, name, child, custom, base );
               list.add( block );
           }
  @@ -722,17 +726,19 @@
       * @exception BlockException if an error occurs during creation of the block
       */
       private Block createContainmentBlock( 
  -      EngineClassLoader engine, String partition, String name, 
  -      Configuration config, Configuration custom, URL base )
  +      final EngineClassLoader engine, final String partition, final String name, 
  +      final Configuration config, final Configuration custom, final URL base )
         throws BlockException
       {
  -        String subPartition = partition + name + Container.PATH_SEPERATOR;
  -        List list = createChildBlocks( engine, subPartition, config, custom, base );
  +        final String subPartition = partition + name + Container.PATH_SEPERATOR;
  +        final List blocks = createChildBlocks( engine, subPartition, config, custom, base
);
   
  -        ContainerDescriptor descriptor;
           try
           {
  -            descriptor = createContainerDescriptor( name, engine, config );
  +            final ContainmentProfile descriptor = 
  +              createContainmentProfile( name, engine, config );
  +            return createBlock( 
  +              null, null, engine, blocks, descriptor, name, partition, custom ); 
           }
           catch( Throwable e )
           {
  @@ -741,17 +747,15 @@
               throw new BlockException( error, e );
           }
   
  -        return createBlock( 
  -          null, null, engine, list, descriptor, name, partition, custom ); 
       }
   
      /**
       * Create a block.
       *
  -    * @param dependencies block dependencies
  -    * @param services block services
  +    * @param dependencies virtual block dependencies
  +    * @param services virtual block services
       * @param engine the containers classloader
  -    * @param containers the list of subsidiary blocks
  +    * @param blocks the list of subsidiary blocks
       * @param descriptor the container descriptor
       * @param name the block name
       * @param partition the partition to assign to the container
  @@ -760,9 +764,9 @@
       * @exception BlockException if an error occurs during creation of the block
       */
       private Block createBlock( 
  -      DependencyDescriptor[] dependencies, ServiceDescriptor[] services, 
  -      EngineClassLoader engine, List containers, ContainerDescriptor descriptor, 
  -      String name, String partition, Configuration custom )
  +      final DependencyDescriptor[] dependencies, final ServiceDescriptor[] services, 
  +      final EngineClassLoader engine, final List blocks, final ContainmentProfile descriptor,

  +      final String name, final String partition, final Configuration custom )
         throws BlockException
       {
           //
  @@ -773,14 +777,15 @@
           // to be applied to the block.
           //
   
  -        DefaultApplianceContext context = new DefaultApplianceContext( descriptor );
  +        final DefaultApplianceContext context = new DefaultApplianceContext( descriptor
);
  +        final Profile[] profiles = descriptor.getComponents();
   
           context.setName( name );
           context.setPartitionName( partition );
           context.setApplianceClassname( DefaultBlock.class.getName() );
  -        context.put("urn:merlin:container.descriptor", descriptor );
  +        context.put("urn:merlin:container.profiles", profiles );
           context.put("urn:merlin:container.library", this );
  -        context.put("urn:merlin:container.containers", containers );
  +        context.put("urn:merlin:container.blocks", blocks );
           if( dependencies != null )
           {
               context.put("urn:merlin:container.dependencies", dependencies );
  
  
  

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


Mime
View raw message