mcconnell 2003/11/22 05:23:51
Added: merlin/platform/tutorials/parameterization .cvsignore
README.txt project.xml
merlin/platform/tutorials/parameterization/conf block.xml
config.xml param.block
merlin/platform/tutorials/parameterization/src/java/tutorial
Hello.java HelloComponent.java
merlin/platform/tutorials/parameterization/src/test/tutorial
StandardTestCase.java
Log:
Addition of a parameterization tutorial.
Revision Changes Path
1.1 avalon/merlin/platform/tutorials/parameterization/.cvsignore
Index: .cvsignore
===================================================================
maven.log
velocity.log
build.xml
build.properties
target
maven.log
working
1.1 avalon/merlin/platform/tutorials/parameterization/README.txt
Index: README.txt
===================================================================
Hello
=====
The parameterization tutorial demonstrates a component implementing
the Avalon Parameterizable interface.
Build
-----
Build the project using the following command:
$ maven
The above command triggers the default goal jar:jar which will
create a jar file under the target directory named
parameters-1.0.jar. The jar file contains a single
component, generated .xinfo descriptor, and a bundled block.xml
deployment descriptor.
Runtime
-------
To see Merlin in action, execute Merlin and give it either the
jar file of the target/classes directory as the deployment
argument.
$ merlin target\classes -execute
Or:
$ merlin target\parameters-1.0.jar -execute
1.1 avalon/merlin/platform/tutorials/parameterization/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<extend>${basedir}/../project.xml</extend>
<groupId>merlin/tutorial</groupId>
<id>parameters</id>
<name>Merlin Parameterization Tutorial</name>
<package>tutorial</package>
<currentVersion>1.0</currentVersion>
<inceptionYear>2003</inceptionYear>
<shortDescription>Merlin Parameterization Tutorial</shortDescription>
<description>
'Hello' merlin tutorial
</description>
<dependencies>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>merlin</groupId>
<artifactId>merlin-unit</artifactId>
<version>3.2.3-dev</version>
</dependency>
</dependencies>
</project>
1.1 avalon/merlin/platform/tutorials/parameterization/conf/block.xml
Index: block.xml
===================================================================
<container name="tutorial">
<component name="hello" class="tutorial.HelloComponent">
<parameters>
<parameter name="color" value="magenta"/>
<parameter name="size" value="relative"/>
</parameters>
</component>
</container>
1.1
avalon/merlin/platform/tutorials/parameterization/conf/config.xml
Index: config.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<targets>
<target path="/tutorial/hello">
<categories priority="INFO"/>
</target>
</targets>
1.1
avalon/merlin/platform/tutorials/parameterization/conf/param.block
Index: param.block
===================================================================
<container name="tutorial">
<classloader>
<classpath>
<repository>
<resource id="merlin/tutorial:parameters" version="1.0"/>
</repository>
</classpath>
</classloader>
<component name="hello" class="tutorial.HelloComponent">
<parameters>
<parameter name="color" value="magenta"/>
<parameter name="size" value="relative"/>
</parameters>
</component>
</container>
1.1
avalon/merlin/platform/tutorials/parameterization/src/java/tutorial/Hello.java
Index: Hello.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package tutorial;
/**
* A sample service interface.
*/
public interface Hello
{
void sayHello();
}
1.1
avalon/merlin/platform/tutorials/parameterization/src/java/tutorial/HelloComponent.java
Index: HelloComponent.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package tutorial;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Executable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.parameters.ParameterException;
/**
* A sample component. This component implements a number
* of lifecycle interface. Each lifecycle interface is a stage
* that is processed by a container during the deployment of
* the component. The lifecycle stages demonstrated here include
* LogEnabled (association of a logging channel), Initializable
* (initialization of the component), Executable (component
* execution), and Disposable (componet disposal). Please note
* that all lifecycle stages are optional.
*
* @avalon.component version="1.0" name="hello" lifestyle="singleton"
* @avalon.service type="tutorial.Hello"
*/
public class HelloComponent extends AbstractLogEnabled
implements Parameterizable, Initializable, Hello
{
private String m_color = null;
private String m_size = null;
public void sayHello()
{
getLogger().info( "HELLO" );
}
/**
* Internal reference to the logging channel supplied to us
* by the container.
*/
private Logger m_logger;
/**
* Component execution trigger by the container following
* completion of the initialization stage.
*/
public void parameterize( Parameters params ) throws ParameterException
{
getLogger().info( "execution" );
m_color = params.getParameter( "color" );
m_size = params.getParameter( "size" );
}
/**
* Initialization of the component by the container.
* @exception Exception if an initialization error occurs
*/
public void initialize() throws Exception
{
getLogger().info( "initialization [" + m_color + ", " + m_size + "]" );
}
}
1.1
avalon/merlin/platform/tutorials/parameterization/src/test/tutorial/StandardTestCase.java
Index: StandardTestCase.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package tutorial;
import org.apache.avalon.merlin.unit.AbstractMerlinTestCase;
/**
* Hello Test Case.
*
* @author [EMAIL PROTECTED]
*/
public class StandardTestCase extends AbstractMerlinTestCase
{
//--------------------------------------------------------
// constructors
//--------------------------------------------------------
/**
* @param name the name of the test case
* @param root the merlin system install directory
*/
public StandardTestCase( String name )
{
super(
MAVEN_TARGET_CLASSES_DIR,
MERLIN_DEFAULT_CONFIG_FILE,
MERLIN_INFO_OFF,
MERLIN_DEBUG_OFF,
name );
}
//--------------------------------------------------------
// testcase
//--------------------------------------------------------
public void testServiceResolution() throws Exception
{
Object hello = resolve( "hello" );
assertTrue( hello != null );
getLogger().info( "Hello established." );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]