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 2003/04/05 12:05:26 UTC

cvs commit: avalon-sandbox/merlin/merlin-smp/src/tutorial/007/src/java/tutorial HelloComponent.java HelloComponent.xinfo RandomGenerator.java RandomGeneratorProvider.java RandomGeneratorProvider.xinfo RandomGeneratorProvider.xprofile

mcconnell    2003/04/05 02:05:26

  Added:       merlin/merlin-smp/src/tutorial/007 .cvsignore build.xml
               merlin/merlin-smp/src/tutorial/007/src/config block.xml
               merlin/merlin-smp/src/tutorial/007/src/java/tutorial
                        HelloComponent.java HelloComponent.xinfo
                        RandomGenerator.java RandomGeneratorProvider.java
                        RandomGeneratorProvider.xinfo
                        RandomGeneratorProvider.xprofile
  Log:
  Tutorial - creating a deployment profile.
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  build
  logs
  tutorial.jar
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/build.xml
  
  Index: build.xml
  ===================================================================
  
  <!-- 
  Test application
  -->
  
  <project name="tutorial" default="jar" basedir=".">
  
    <property name="src.dir"  value="${basedir}/src" />
    <property name="java.dir"  value="${src.dir}/java" />
    <property name="build.dir"  value="${basedir}/build" />
    <property name="classes.dir"  value="${build.dir}/classes" />
    <property name="config.dir"  value="${src.dir}/config" />
  
    <property environment="env"/>
    <property name="merlin.home"  value="${env.MERLIN_HOME}"/>
  
    <property name="framework.jar"
      value="${merlin.home}/lib/shared/avalon-framework-4.1.4.jar" />
  
    <path id="project.class.path">
      <pathelement path="${java.class.path}" />
      <pathelement location="${framework.jar}"/>
      <fileset dir="${classes.dir}"/>
    </path>
  
    <target name="compile" >
      <mkdir dir="${classes.dir}" />
      <copy toDir="${classes.dir}">
        <fileset dir="${java.dir}">
          <include name="**/*.xinfo"/>
          <include name="**/*.xprofile"/>
        </fileset>
      </copy>
      <mkdir dir="${classes.dir}/BLOCK-INF" />
      <copy toDir="${classes.dir}/BLOCK-INF">
        <fileset dir="${config.dir}">
          <include name="*.xml"/>
        </fileset>
      </copy>
      <mkdir dir="${classes.dir}" />
      <javac debug="on" destdir="${classes.dir}" >
          <classpath>
            <path refid="project.class.path"/>
  	  </classpath>
          <src path="${src.dir}" />
      </javac>
    </target>
  
    <target name="jar" depends="compile">
      <jar jarfile="tutorial.jar" basedir="${classes.dir}"/>
    </target>
  
    <target name="clean">
      <delete dir="${build.dir}"/>
      <delete file="tutorial.jar"/>
    </target>
  
   </project>
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/src/config/block.xml
  
  Index: block.xml
  ===================================================================
  
  <block name="tutorial">
     <container>
       <component name="hello" class="tutorial.HelloComponent" activation="startup"/>
    </container>
  </block>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/src/java/tutorial/HelloComponent.java
  
  Index: HelloComponent.java
  ===================================================================
  package tutorial;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  
  public class HelloComponent extends AbstractLogEnabled 
    implements Serviceable
  {
  
     /**
      * Servicing of the component by the container during 
      * which service dependencies declared under the component
      * can be resolved using the supplied service manager.
      */
      public void service( ServiceManager manager )
        throws ServiceException
      {
          RandomGenerator random = (RandomGenerator) manager.lookup( "random" );
          getLogger().info( "random: " + random.getRandom() );
      }
  }
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/src/java/tutorial/HelloComponent.xinfo
  
  Index: HelloComponent.xinfo
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE type
        PUBLIC "-//AVALON/Type DTD Version 1.0//EN"
               "http://avalon.apache.org/dtds/meta/type_1_1.dtd" >
  <type>
    <info>
      <name>hello</name>
      <version>1.0</version>
    </info>
    <dependencies>
      <dependency key="random" type="tutorial.RandomGenerator"/>
    </dependencies>
  </type>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/src/java/tutorial/RandomGenerator.java
  
  Index: RandomGenerator.java
  ===================================================================
  
  package tutorial;
  
  /**
   * A service that provides access to a random number.
   */
  public interface RandomGenerator
  {
  
     /**
      * Return a random integer
      * @return the random number
      */
      int getRandom();
  
  }
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/src/java/tutorial/RandomGeneratorProvider.java
  
  Index: RandomGeneratorProvider.java
  ===================================================================
  
  package tutorial;
  
  import java.util.Random;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  
  /**
   * An implementation of a random number generator.
   */
  public class RandomGeneratorProvider extends AbstractLogEnabled 
    implements Configurable, RandomGenerator
  {
  
      private Random m_random = null;
  
     /**
      * Configuration of the component by the container.  The 
      * implementation get a child element named 'source' and 
      * assigns the value of the element to a local variable.
      *
      * @param config the component configuration
      * @exception ConfigurationException if a configuration error occurs
      */
      public void configure( Configuration config ) throws ConfigurationException
      {
          getLogger().info( "configuration stage" );
          long seed = config.getChild( "seed" ).getValueAsLong( 0 );
          getLogger().info( "seed: " + seed );
          m_random = new Random( System.currentTimeMillis() * seed );
      }
  
     /**
      * Return a random integer
      * @return the random number
      */
      public int getRandom()
      {
          return m_random.nextInt();
      }
  }
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/src/java/tutorial/RandomGeneratorProvider.xinfo
  
  Index: RandomGeneratorProvider.xinfo
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE type
        PUBLIC "-//AVALON/Type DTD Version 1.0//EN"
               "http://avalon.apache.org/dtds/meta/type_1_1.dtd" >
  <type>
    <info>
      <name>random-provider</name>
      <version>1.0</version>
    </info>
    <services>
      <service type="tutorial.RandomGenerator"/>
    </services>
  </type>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/src/tutorial/007/src/java/tutorial/RandomGeneratorProvider.xprofile
  
  Index: RandomGeneratorProvider.xprofile
  ===================================================================
  <?xml version="1.0"?>
  
  <profiles>
    <profile name="randomizer">
      <configuration>
        <seed>1024</seed>
      </configuration>
    </profile>
  </profiles>
  
  
  

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