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-platform/tutorials/dependencies/src/java/tutorial HelloComponent.java RandomGeneratorProvider.java
Date Thu, 21 Aug 2003 00:03:44 GMT
mcconnell    2003/08/20 17:03:44

  Modified:    merlin/merlin-platform/tutorials/dependencies project.xml
               merlin/merlin-platform/tutorials/dependencies/conf block.xml
               merlin/merlin-platform/tutorials/dependencies/src/java/tutorial
                        HelloComponent.java RandomGeneratorProvider.java
  Added:       merlin/merlin-platform/tutorials/dependencies README.txt
  Removed:     merlin/merlin-platform/tutorials/dependencies maven.xml
  Log:
  Bring up-to-date with Merlin 3.0.
  
  Revision  Changes    Path
  1.3       +4 -27     avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/project.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project.xml	20 Jun 2003 05:25:27 -0000	1.2
  +++ project.xml	21 Aug 2003 00:03:44 -0000	1.3
  @@ -2,7 +2,8 @@
   
   <project>
   
  -  <groupId>merlin</groupId>
  +  <extend>${basedir}/../project.xml</extend>
  +
     <id>merlin-tutorial-dependencies</id>
     <name>Merlin Dependencies Tutorial</name>
     <package>tutorial</package>
  @@ -15,38 +16,14 @@
       <dependency>
         <groupId>avalon-framework</groupId>
         <artifactId>avalon-framework-api</artifactId>
  -      <version>4.1.5-dev</version>
  +      <version>SNAPSHOT</version>
       </dependency>
   
       <dependency>
         <groupId>avalon-framework</groupId>
         <artifactId>avalon-framework-impl</artifactId>
  -      <version>4.1.5-dev</version>
  +      <version>SNAPSHOT</version>
       </dependency>
     </dependencies>
     
  -  <build>
  -
  -    <sourceDirectory>${basedir}/src/java</sourceDirectory>
  -
  -    <resources>
  -      <resource>
  -        <directory>${maven.conf.dir}</directory>
  -        <targetPath>BLOCK-INF</targetPath>
  -        <includes>
  -          <include>block.xml</include>
  -        </includes>
  -      </resource>
  -      <resource>
  -        <directory>${maven.src.dir}/java</directory>
  -        <includes>
  -          <include>**/*.x*</include>
  -        </includes>
  -      </resource>
  -    </resources>
  -
  -    <jars></jars>
  -
  -  </build>
  -
   </project>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/README.txt
  
  Index: README.txt
  ===================================================================
  
  Dependency Management
  =====================
  
  Overview
  --------
  
  The dependencies tutorial covers the declaration of service dependencies
  that a component has, the resolution of dependecies by the container, and 
  the application of dependent service by the container to the component 
  via a ServiceManager.  
  
  Service dependecies are declared in the component sources using the javadoc
  tag:
  
    @avalon.dependency type="org.somewhere.MyInterface"
  
  Components that provide services declare the service export using the 
  tag @avalon.service. Merlin build and validates a dependency graph before  
  component initialization, and ensures that componets are actived in the  
  correct order.  Consumers are always activated after suppliers and 
  deactivated before deactivation of respective suppliers.
  
  Build instructions
  ------------------
  
    $ maven
  
  Runtime
  -------
  
    $ merlin target\classes -execute
  
    [INFO   ] (tutorial.random): initialization
    [INFO   ] (tutorial.hello): initialization
    [INFO   ] (tutorial.random): processing request
    [INFO   ] (tutorial.hello): received random value: -1591330260
    [INFO   ] (tutorial.hello): disposal
    [INFO   ] (tutorial.random): disposal
  
  Summary
  -------
  
  The purpose of this demonstration is to show the following:
  
    1. usage of @avalon.dependency tags
    2. usage of @avalon.service tags
    3. functionality of the container in handling assembly
    4. orderly commissioning and decommissioning provided 
       by the container
  
  While the demonstration deals with the very simple case of a
  single supplier and a single consumer component, Merlin provides
  complete support for n-n relationships across arbitarily deep
  dependency graphs.  Using the Merlin plugin for Maven, you can 
  validate deployment scenarios by simulating deployment as part 
  of a componet suite test and validation phase.  The following 
  command demonstrates Maven based deployment using the Merlin 
  plugin.
  
    $ maven merlin:simulate
  
  
  
  
  
  1.3       +10 -1     avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/conf/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/conf/block.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- block.xml	16 Aug 2003 11:16:33 -0000	1.2
  +++ block.xml	21 Aug 2003 00:03:44 -0000	1.3
  @@ -1,6 +1,15 @@
   
   <container name="tutorial">
   
  +     <classloader>
  +       <classpath>
  +         <repository>
  +           <resource id="avalon-framework:avalon-framework-api" version="SNAPSHOT"/>
  +           <resource id="avalon-framework:avalon-framework-impl" version="SNAPSHOT"/>
  +         </repository>
  +       </classpath>
  +     </classloader>
  +
        <component name="hello" class="tutorial.HelloComponent" activation="startup"/>
   
  -</block>
  +</container>
  
  
  
  1.4       +18 -5     avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/src/java/tutorial/HelloComponent.java
  
  Index: HelloComponent.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/src/java/tutorial/HelloComponent.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HelloComponent.java	22 Jul 2003 08:57:58 -0000	1.3
  +++ HelloComponent.java	21 Aug 2003 00:03:44 -0000	1.4
  @@ -4,14 +4,17 @@
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.activity.Disposable;
   
   /**
    * The HelloComponent is dependent on a RandomGenerator service.
    * @avalon.component version="1.0" name="simple" lifestyle="singleton"
    */
   public class HelloComponent extends AbstractLogEnabled 
  -  implements Serviceable
  +  implements Initializable, Serviceable, Disposable
   {
  +    RandomGenerator m_random = null;
   
      /**
       * Servicing of the component by the container during 
  @@ -19,14 +22,24 @@
       * can be resolved using the supplied service manager.
       *
       * @param manager the service manager
  -    * @avalon.meta.dependency 
  -    *    type="tutorial.RandomGenerator:1.0"
  +    * @avalon.dependency type="tutorial.RandomGenerator:1.0"
       *    key="random"
       */
       public void service( ServiceManager manager )
         throws ServiceException
       {
  -        RandomGenerator random = (RandomGenerator) manager.lookup( "random" );
  -        getLogger().info( "random: " + random.getRandom() );
  +        m_random = (RandomGenerator) manager.lookup( "random" );
       }
  +
  +    public void initialize()
  +    {
  +        getLogger().info( "initialization" );
  +        getLogger().info( "received random value: " + m_random.getRandom() );
  +    }
  +
  +    public void dispose()
  +    {
  +        getLogger().info( "disposal" );
  +    }
  +
   }
  
  
  
  1.4       +18 -1     avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/src/java/tutorial/RandomGeneratorProvider.java
  
  Index: RandomGeneratorProvider.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/dependencies/src/java/tutorial/RandomGeneratorProvider.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RandomGeneratorProvider.java	22 Jul 2003 08:57:58 -0000	1.3
  +++ RandomGeneratorProvider.java	21 Aug 2003 00:03:44 -0000	1.4
  @@ -3,23 +3,40 @@
   
   import java.util.Random;
   
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.activity.Disposable;
  +
   /**
    * An implementation of a random number generator.
    *
    * @avalon.component version="1.0" name="random" lifestyle="singleton"
    * @avalon.service type="tutorial.RandomGenerator" version="1.0"
    */
  -public class RandomGeneratorProvider implements RandomGenerator
  +public class RandomGeneratorProvider extends AbstractLogEnabled 
  +  implements Initializable, RandomGenerator, Disposable
   {
   
       private Random m_random = new Random();
   
  +    public void initialize()
  +    {
  +        getLogger().info( "initialization" );
  +    }
  +
      /**
       * Return a random integer
       * @return the random number
       */
       public int getRandom()
       {
  +        getLogger().info( "processing request" );
           return m_random.nextInt();
       }
  +
  +    public void dispose()
  +    {
  +        getLogger().info( "disposal" );
  +    }
  +
   }
  
  
  

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


Mime
View raw message