mcconnell 2003/04/04 06:37:23
Added: merlin/merlin-smp/src/tutorial/006 .cvsignore build.xml
merlin/merlin-smp/src/tutorial/006/src/config block.xml
merlin/merlin-smp/src/tutorial/006/src/java/tutorial
HelloComponent.java HelloComponent.xinfo
RandomGenerator.java RandomGeneratorProvider.java
RandomGeneratorProvider.xinfo
Log:
Tutorial 006 covering basics of service and dependency declarations.
Revision Changes Path
1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/006/.cvsignore
Index: .cvsignore
===================================================================
build
logs
tutorial.jar
1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/006/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"/>
</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/006/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/006/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/006/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/006/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/006/src/java/tutorial/RandomGeneratorProvider.java
Index: RandomGeneratorProvider.java
===================================================================
package tutorial;
import java.util.Random;
/**
* An implementation of a random number generator.
*/
public class RandomGeneratorProvider implements RandomGenerator
{
private Random m_random = new Random();
/**
* Return a random integer
* @return the random number
*/
public int getRandom()
{
return m_random.nextInt();
}
}
1.1
avalon-sandbox/merlin/merlin-smp/src/tutorial/006/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>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]