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/src/test/org/apache/avalon/playground StandardComponent.xinfo
Date Tue, 17 Dec 2002 09:59:48 GMT
mcconnell    2002/12/17 01:59:48

  Modified:    merlin/src/java/org/apache/avalon/merlin/block
                        BlockLoader.java
               merlin/src/java/org/apache/avalon/merlin/container
                        ContainerLoader.java DefaultContainer.java
                        DefaultContainer.xinfo
               merlin/src/java/org/apache/avalon/merlin/kernel
                        DefaultKernel.java
               merlin/src/test/config block.xml
               merlin/src/test/org/apache/avalon/playground
                        StandardComponent.xinfo
  Log:
  Integration of service registration support and synchronization with assembly revisions.
  
  Revision  Changes    Path
  1.6       +7 -5      avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/block/BlockLoader.java
  
  Index: BlockLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/block/BlockLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BlockLoader.java	17 Dec 2002 04:45:21 -0000	1.5
  +++ BlockLoader.java	17 Dec 2002 09:59:47 -0000	1.6
  @@ -97,6 +97,7 @@
   import org.apache.avalon.merlin.container.ContainerException;
   import org.apache.avalon.merlin.container.DefaultContainer;
   import org.apache.avalon.merlin.container.builder.XMLContainerCreator;
  +import org.apache.avalon.merlin.service.Registry;
   import org.apache.avalon.meta.info.Type;
   import org.apache.avalon.meta.model.LoggingDirective;
   import org.apache.avalon.meta.model.Profile;
  @@ -146,7 +147,8 @@
       * @return the set of block appliance instances
       * @exception Exception if an installation failure occurs
       */
  -    protected Block[] loadBlocks( EngineClassLoader parent, File home, URL[] urls, Context
system ) throws Exception
  +    protected Block[] loadBlocks( 
  +      EngineClassLoader parent, Registry registry, File home, URL[] urls, Context system
) throws Exception
       {
           int n = urls.length;
           if( n > 0 )
  @@ -167,7 +169,7 @@
               URL url = urls[i];
               try
               {
  -                Block block = loadBlock( parent, home, url, system );
  +                Block block = loadBlock( parent, registry, home, url, system );
                   blocks.add( block );
               }
               catch( Throwable e )
  @@ -202,7 +204,7 @@
       }
   
       private Block loadBlock( 
  -      EngineClassLoader parent, File home, URL url, Context system ) 
  +      EngineClassLoader parent, Registry registry, File home, URL url, Context system )

         throws Exception
       {
           if( getLogger().isDebugEnabled() )
  @@ -245,7 +247,7 @@
           //
   
           Configuration containerConfig = config.getChild( "container" );
  -        Appliance appliance = createContainer( engine, name, home, containerConfig, logger
);
  +        Appliance appliance = createContainer( engine, registry, name, home, containerConfig,
logger );
           Logger child = getLogger().getChildLogger( name );
           DefaultBlock block = new DefaultBlock( appliance, url, manifest );
           block.enableLogging( child );
  
  
  
  1.4       +10 -6     avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/ContainerLoader.java
  
  Index: ContainerLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/ContainerLoader.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContainerLoader.java	17 Dec 2002 04:46:04 -0000	1.3
  +++ ContainerLoader.java	17 Dec 2002 09:59:48 -0000	1.4
  @@ -87,6 +87,7 @@
   import org.apache.avalon.merlin.block.Block;
   import org.apache.avalon.merlin.block.DefaultBlock;
   import org.apache.avalon.merlin.container.builder.XMLContainerCreator;
  +import org.apache.avalon.merlin.service.Registry;
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.appliance.ApplianceContext;
   import org.apache.avalon.assembly.appliance.ApplianceManager;
  @@ -127,10 +128,10 @@
       * @param logger the logging channel to assign to the container
       */
       protected Appliance createContainer( 
  -      EngineClassLoader engine, String name, File home, Configuration config, Logger logger
)
  +      EngineClassLoader engine, Registry registry, String name, File home, Configuration
config, Logger logger )
         throws Exception
       {
  -        return createContainer( engine, name, home, config, logger, null );
  +        return createContainer( engine, registry, name, home, config, logger, null );
       }
   
      /**
  @@ -145,7 +146,7 @@
       *   the block's engine, logging channel, and name are applied to the container
       */
       protected Appliance createContainer( 
  -      EngineClassLoader engine, String name, File home, Configuration config, Logger logger,
String partition )
  +      EngineClassLoader engine, Registry registry, String name, File home, Configuration
config, Logger logger, String partition )
         throws Exception
       {
           String classname = config.getAttribute( "class", DefaultContainer.class.getName()
);
  @@ -176,6 +177,7 @@
               Logger childLogger;
               EngineClassLoader childEngine;
               String childPartition;
  +            Registry childRegistry;
   
               if( partition == null )
               {
  @@ -183,6 +185,7 @@
                   childLogger = logger;
                   childEngine = engine;
                   childPartition = name;
  +                childRegistry = registry;
               }
               else
               {
  @@ -190,6 +193,7 @@
                   childLogger = logger.getChildLogger( childName );
                   childEngine = childEngine = createChildEngine( engine, home, childConfig,
childLogger );
                   childPartition = partition + "/" + name;
  +                childRegistry = registry.createChild( name );
               }
   
               //
  @@ -198,7 +202,7 @@
   
               Appliance container = 
                 createContainer( 
  -                childEngine, childName, home, childConfig, childLogger, childPartition
);
  +                childEngine, childRegistry, childName, home, childConfig, childLogger,
childPartition );
               list.add( container );
           }
   
  @@ -210,6 +214,7 @@
           map.put("urn:assembly:engine.classloader", engine );
           map.put("urn:merlin:container.containers", list );
           map.put("urn:merlin:container.descriptor", descriptor );
  +        map.put("urn:merlin:container.registry", registry );
           if( partition != null )
           {
               map.put("urn:merlin:container.partition", partition );
  @@ -220,7 +225,6 @@
           }
           ApplianceContext context = new ApplianceContext( descriptor );
           context.setDeploymentContext( map );
  -
           if( partition != null )
           {
               context.setPartitionName( partition );
  
  
  
  1.3       +6 -1      avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/DefaultContainer.java
  
  Index: DefaultContainer.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/DefaultContainer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultContainer.java	17 Dec 2002 04:46:04 -0000	1.2
  +++ DefaultContainer.java	17 Dec 2002 09:59:48 -0000	1.3
  @@ -72,6 +72,7 @@
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.merlin.container.ContainerDescriptor;
  +import org.apache.avalon.merlin.service.Registry;
   import org.apache.avalon.meta.model.Profile;
   
   /**
  @@ -94,6 +95,8 @@
   
       private ContainerDescriptor m_descriptor;
   
  +    private Registry m_registry;
  +
      /**
       * List of the appliance instances that the container is 
       * holding.  Each appliance instance is a contained component.
  @@ -142,6 +145,7 @@
           m_containers = (List) context.get( "urn:merlin:container.containers" );
           m_descriptor = (ContainerDescriptor) context.get( "urn:merlin:container.descriptor"
);
           m_partition = (String) context.get( "urn:merlin:container.partition" );
  +        m_registry = (Registry) context.get( "urn:merlin:container.registry" );
       }
   
       //==============================================================
  @@ -182,6 +186,7 @@
               context.setPartitionName( m_path );
               Appliance appliance = createAppliance( context, true );
               m_components.add( appliance );
  +            m_registry.bind( appliance );
           }
   
           Iterator iterator = m_containers.iterator();
  
  
  
  1.3       +2 -0      avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/DefaultContainer.xinfo
  
  Index: DefaultContainer.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/DefaultContainer.xinfo,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultContainer.xinfo	17 Dec 2002 04:46:04 -0000	1.2
  +++ DefaultContainer.xinfo	17 Dec 2002 09:59:48 -0000	1.3
  @@ -27,6 +27,8 @@
         type="java.util.List"/>
       <entry key="urn:merlin:container.descriptor"
         type="org.apache.avalon.merlin.container.ContainerDescriptor"/>
  +    <entry key="urn:merlin:container.registry"
  +      type="org.apache.avalon.merlin.service.Registry"/>
       <entry key="urn:merlin:container.partition"/>
     </context>
   
  
  
  
  1.12      +36 -7     avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/DefaultKernel.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultKernel.java	17 Dec 2002 04:46:34 -0000	1.11
  +++ DefaultKernel.java	17 Dec 2002 09:59:48 -0000	1.12
  @@ -99,6 +99,8 @@
   import org.apache.avalon.merlin.block.DefaultBlock;
   import org.apache.avalon.merlin.block.BlockLoader;
   import org.apache.avalon.merlin.container.Container;
  +import org.apache.avalon.merlin.service.DefaultRegistry;
  +import org.apache.avalon.merlin.service.Registry;
   
   /**
    * Default kernel implementation.  The implementation provides support for
  @@ -173,7 +175,9 @@
       /**
        * A map of root containers keyed by the block it is contained by.
        */
  -    private Map m_containers = new Hashtable();   
  +    private Map m_containers = new Hashtable();
  +
  +    private DefaultRegistry m_registry;
   
       //==============================================================
       // Contextualizable
  @@ -263,6 +267,9 @@
               throw new CascadingException( error, e );
           }
   
  +        String domain = m_config.getChild( "system" ).getChild( "host" ).getValue( "localhost"
);
  +        m_registry = new DefaultRegistry( domain );
  +        
           //
           // announce initialization
           //
  @@ -311,7 +318,7 @@
                 CREATOR.createClasspathDescriptor( m_config.getChild( "blocks" ) );
               URL[] urls = ClasspathDescriptor.expand( m_home, path );
               Context system = getSystemContext();
  -            blocks = loadBlocks( m_engine, m_home, urls, system );
  +            blocks = loadBlocks( m_engine, m_registry, m_home, urls, system );
               for( int i=0; i<blocks.length; i++ )
               {
                   m_blocks.add( blocks[i] );
  @@ -364,12 +371,33 @@
           // Initiate component assembly on all blocks.
           //
   
  +        if( getLogger().isInfoEnabled() )
  +        {
  +            getLogger().info( "commencing composite assembly phase" ); 
  +        }
           for( int i=0; i<blocks.length; i++ )
           {
               Block block = blocks[i];
               Container container = (Container) m_containers.get( block );
               container.assemble();
           }
  +
  +        //
  +        // list the registered services
  +        //
  +
  +        Appliance[] appliances = m_registry.getAppliances();
  +        if( appliances.length == 0 )
  +        {
  +            getLogger().info( "empty registry" ); 
  +        }
  +        else
  +        {
  +            for( int i=0; i<appliances.length; i++ )
  +            {
  +               getLogger().info("registry: " + appliances[i].getURL() ); 
  +            }
  +        }
       }
   
       //==============================================================
  @@ -385,9 +413,9 @@
       {
           if( getLogger() != null ) 
           {
  -            if( getLogger().isDebugEnabled() )
  +            if( getLogger().isInfoEnabled() )
               {
  -                getLogger().debug( "startup" );
  +                getLogger().info( "commencing startup phase" );
               }
           }
   
  @@ -412,9 +440,9 @@
       {
           if( getLogger() != null ) 
           {
  -            if( getLogger().isDebugEnabled() )
  +            if( getLogger().isInfoEnabled() )
               {
  -                getLogger().debug( "shutdown" );
  +                getLogger().info( "commencing shutdown phase" );
               }
           }
   
  @@ -569,6 +597,7 @@
           {
               DefaultContext context = new DefaultContext();
               context.put( "urn:avalon:home", m_home );
  +            context.put( "urn:merlin:domain", m_registry.getBase().getHost() );
               context.makeReadOnly();
               m_system = context;
           }
  
  
  
  1.6       +4 -4      avalon-sandbox/merlin/src/test/config/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/config/block.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- block.xml	17 Dec 2002 04:48:11 -0000	1.5
  +++ block.xml	17 Dec 2002 09:59:48 -0000	1.6
  @@ -5,18 +5,18 @@
   
   <block>
   
  -   <container>
  +   <services>
  +     <service type="org.apache.avalon.playground.StandardService:1.1" />
  +   </services>
   
  +   <container>
        <component name="default" class="org.apache.avalon.playground.StandardComponent"
activation="startup">
          <context class="org.apache.avalon.playground.StandardContext">
            <entry key="location">New York</entry>
            <import name="urn:avalon:home" key="home" />
          </context>
        </component>
  -
        <container name="test"/>
  -
      </container>
  -
   
   </block>
  
  
  
  1.3       +1 -14     avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xinfo
  
  Index: StandardComponent.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xinfo,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardComponent.xinfo	17 Dec 2002 04:40:39 -0000	1.2
  +++ StandardComponent.xinfo	17 Dec 2002 09:59:48 -0000	1.3
  @@ -25,21 +25,8 @@
     </context>
   
     <services>
  -    <service> 
  -      <reference type="org.apache.avalon.playground.StandardService" version="1.1"/>
  -    </service> 
  +    <service type="org.apache.avalon.playground.StandardService:1.1" />
     </services>
  -
  -  <dependencies>
  -      <!-- 
  -      Declaration of the services that this component type is 
  -      dependent on.
  -      <dependency>
  -        <role>fake</role>
  -        <reference type="Xxx" version="1.1"/>
  -      </dependency>
  -      -->
  -  </dependencies>
   
   </type>
   
  
  
  

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