mcconnell 2004/04/19 03:43:14
Modified: merlin/site/xdocs/starting/tutorial creation.xml
execution.xml internal.xml
Log:
Bring totorial details up to date.
Revision Changes Path
1.4 +47 -49 avalon/merlin/site/xdocs/starting/tutorial/creation.xml
Index: creation.xml
===================================================================
RCS file: /home/cvs/avalon/merlin/site/xdocs/starting/tutorial/creation.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- creation.xml 12 Mar 2004 14:49:57 -0000 1.3
+++ creation.xml 19 Apr 2004 10:43:14 -0000 1.4
@@ -40,70 +40,68 @@
</subsection>
<subsection name="Creating a component">
<p>
- The following code is a minimal component. It simply log a
- message during the initialization stage. We will progressively
- extend this component to do more creative things as we proceed
- through this tutorial.
+ The following code is a minimal component. It simply logs a
+ message. We will progressively extend this component to do
+ more creative things as we proceed through this tutorial.
</p>
<source><![CDATA[
package tutorial;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Executable;
-import org.apache.avalon.framework.activity.Initializable;
/**
- * 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.
+ * A sample component.
*
- * @avalon.component version="1.0" name="hello"
+ * @avalon.component
+ * version="1.0"
+ * name="hello"
+ * lifestyle="singleton"
+ * @avalon.service type="tutorial.Hello"
*/
public class HelloComponent
- implements LogEnabled, Initializable, Executable, Disposable
+ implements Hello, Disposable
{
+ //-------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------
/**
* Internal reference to the logging channel supplied to us
* by the container.
*/
- private Logger m_logger;
+ private final Logger m_logger;
+
+ //-------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------
/**
- * Supply of a logging channel by the container.
+ * Creation of a new hello component instance.
*
- * @param logger the logging channel for this component
+ * @param logger the logging channel supplied by the container
*/
- public void enableLogging( final Logger logger )
+ public HelloComponent( Logger logger )
{
m_logger = logger;
- getLogger().info( "logging stage" );
+ m_logger.info( "instantiated" );
}
+ //-------------------------------------------------------
+ // Hello service implementation
+ //-------------------------------------------------------
+
/**
- * Initialization of the component by the container.
- * @exception Exception if an initialization error occurs
+ * The hello service implementation.
*/
- public void initialize() throws Exception
+ public void sayHello()
{
- getLogger().info( "initialization stage" );
+ getLogger().info( "HELLO" );
}
- /**
- * Component execution trigger by the container following
- * completion of the initialization stage.
- */
- public void execute()
- {
- getLogger().info( "execution stage" );
- }
+ //-------------------------------------------------------
+ // Disposable lifecycle interface
+ //-------------------------------------------------------
/**
* Component disposal trigger by the container during which
@@ -111,9 +109,12 @@
*/
public void dispose()
{
- getLogger().info( "disposal stage" );
- m_logger = null;
- }
+ getLogger().info( "disposal" );
+ }
+
+ //-------------------------------------------------------
+ // internal utilities
+ //-------------------------------------------------------
/**
* Return the logging channel assigned to us by the container.
@@ -123,7 +124,6 @@
{
return m_logger;
}
-
}
]]></source>
</subsection>
@@ -131,7 +131,7 @@
<p>
In order for Merlin to recognize this class as a component, we need to
- generate a <classname>.xinfo file. However, this can be done
+ generate a <classname>.xinfo file. This can be done
automatically by including a pre-goal as shown below into the
maven.xml file.
</p>
@@ -161,8 +161,12 @@
<info>
<name>hello</name>
<version>1.0.0</version>
- <lifestyle>transient</lifestyle>
+ <lifestyle>singleton</lifestyle>
+ <collection>hard</collection>
</info>
+ <services>
+ <service type="tutorial.Hello"/>
+ </services>
</type>
]]></source>
@@ -173,18 +177,12 @@
application made up of a set of components and the supporting
resources. In our example the block will contain the single
HelloComponent component. Based on this information Merlin will
- create a container and deploy the hello component on startup.
+ create a container named "tutorial", create a component model
+ named "hello" and deploy an instance of the component on
+ startup.
</p>
<source><![CDATA[
<container name="tutorial">
-
- <classloader>
- <classpath>
- <repository>
- <resource id="avalon-framework:avalon-framework-impl" version="4.1.5"/>
- </repository>
- </classpath>
- </classloader>
<component name="hello" class="tutorial.HelloComponent"/>
1.3 +2 -4 avalon/merlin/site/xdocs/starting/tutorial/execution.xml
Index: execution.xml
===================================================================
RCS file: /home/cvs/avalon/merlin/site/xdocs/starting/tutorial/execution.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- execution.xml 25 Jan 2004 13:28:50 -0000 1.2
+++ execution.xml 19 Apr 2004 10:43:14 -0000 1.3
@@ -52,7 +52,7 @@
</p>
<source><![CDATA[
-$ merlin -execute target\merlin-hello-tutorial-1.0.jar
+$ merlin -execute target\hello-1.1.jar
]]></source>
<p>
@@ -60,9 +60,7 @@
</p>
<source><![CDATA[
-[INFO ] (tutorial.hello): logging
-[INFO ] (tutorial.hello): initialization
-[INFO ] (tutorial.hello): execution
+[INFO ] (tutorial.hello): instantiated
[INFO ] (tutorial.hello): disposal
]]></source>
1.6 +143 -151 avalon/merlin/site/xdocs/starting/tutorial/internal.xml
Index: internal.xml
===================================================================
RCS file: /home/cvs/avalon/merlin/site/xdocs/starting/tutorial/internal.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- internal.xml 14 Mar 2004 11:12:45 -0000 1.5
+++ internal.xml 19 Apr 2004 10:43:14 -0000 1.6
@@ -34,22 +34,49 @@
modifier.
</p>
<source><![CDATA[
-$ merlin -execute target\classes -info
-
- Version: Merlin SMP 3.0
- Environment: Windows NT 4.0 Java 1.4.2
- Deployment Home: ${user.dir}/home
- Runtime Repository: F:\system\maven
- Library Anchor: ${user.dir}
- Kernel Path: resource:/kernel.xml
- Deployment Blocks: file:/${user.dir}/target/classes/
- Override Path:
- Server Flag: false
- Debug Flag: true
-
-[INFO ] (tutorial.hello): logging
-[INFO ] (tutorial.hello): initialization
-[INFO ] (tutorial.hello): execution
+[INFO ] (kernel): info report
+-----------------------------------------------------------
+Merlin Kernel Environment Listing
+-----------------------------------------------------------
+
+ ${user.dir} == D:\dev\avalon\tutorials\hello
+ ${user.home} == C:\WINNT\Profiles\mcconnell
+
+ ${avalon.repository.cache} == D:\merlin\system
+ ${avalon.repository.online} == true
+ ${avalon.repository.hosts} == http://www.dpml.net,http://www.ibiblio.org/maven
+
+ ${merlin.lang} == null
+ ${merlin.home} == D:\merlin
+ ${merlin.system} == D:\merlin\system
+ ${merlin.config} == D:\merlin\config
+ ${merlin.kernel} == file:/D:/merlin/config/kernel.xml
+ ${merlin.logging.implementation} ==
+ artifact:avalon-logging/avalon-logging-logkit-impl#1.0.dev-0
+ ${merlin.logging.config} == null
+ ${merlin.runtime} ==
+ artifact:avalon-activation/avalon-activation-impl#2.0.dev-0
+ ${merlin.override} == null
+ ${merlin.dir} == D:\dev\avalon\tutorials\hello
+ ${merlin.temp} == C:\TEMP
+ ${merlin.context} == D:\dev\avalon\tutorials\hello\home
+ ${merlin.anchor} == D:\dev\avalon\tutorials\hello
+ ${merlin.info} == true
+ ${merlin.debug} == false
+ ${merlin.audit} == false
+ ${merlin.server} == false
+ ${merlin.autostart} == true
+ ${merlin.code.security.enabled} == false
+ ${merlin.deployment.timeout} == 1000
+ ${merlin.repository} == D:\avalon\repository
+ ${merlin.repository.hosts} == http://www.dpml.net/,http://www.ibiblio.org/maven/
+ ${merlin.deployment} == file:/${user.dir}/target/classes/
+
+-----------------------------------------------------------
+[INFO ] (kernel): building application model
+[INFO ] (kernel): install phase
+[INFO ] (kernel): installing: file:/${user.dir}/target/classes/
+[INFO ] (tutorial.hello): instantiated
[INFO ] (tutorial.hello): disposal
]]></source>
@@ -58,12 +85,13 @@
<p>
We can also override the logging priority for the component using
- a target override directive.
+ a target override directive. The following target tells merlin
+ to assign logging at DEBUG prioririty for the "tutorial" container.
</p>
<p><i>${basedir}\conf\config.xml</i></p>
<source><![CDATA[
<targets>
- <target path="/tutorial/hello">
+ <target path="/tutorial">
<categories priority="DEBUG"/>
</target>
</targets>
@@ -76,24 +104,16 @@
<source><![CDATA[
$ merlin -execute target\classes -config conf\config.xml
-[DEBUG ] (tutorial.hello.appliance): assembly phase
-[DEBUG ] (tutorial.hello.appliance): deployment (transient) [true]
-[DEBUG ] (tutorial.hello.appliance): new instance: 24531886
-[DEBUG ] (tutorial.hello.appliance): applying logger to: 24531886
-[INFO ] (tutorial.hello): logging
-[DEBUG ] (tutorial.hello.appliance): applying initialization to: 24531886
-[INFO ] (tutorial.hello): initialization
-[DEBUG ] (tutorial.hello.appliance): executing: 24531886
-[INFO ] (tutorial.hello): execution
-[DEBUG ] (tutorial.hello.appliance): component established: 24531886
-[DEBUG ] (tutorial.hello.appliance): activated instance: 24531886
-[DEBUG ] (tutorial.hello.appliance): decommissioning phase
-[DEBUG ] (tutorial.hello.appliance): component disposal: 24531886
-[DEBUG ] (tutorial.hello.appliance): disposing of: 24531886
+[DEBUG ] (tutorial): assembly phase
+[DEBUG ] (tutorial): commissioning component [hello]
+[DEBUG ] (tutorial.hello.lifecycle): incarnation
+[DEBUG ] (tutorial.hello.lifecycle): instantiating component with 1 arguments.
+[INFO ] (tutorial.hello): instantiated
+[DEBUG ] (tutorial): commissioning of [hello] completed in 93 milliseconds
+[DEBUG ] (tutorial): decommissioning
+[DEBUG ] (tutorial.hello.lifecycle): etherialization
+[DEBUG ] (tutorial.hello.lifecycle): applying disposal
[INFO ] (tutorial.hello): disposal
-[DEBUG ] (tutorial.hello.appliance): destroyed instance: 24531886
-[DEBUG ] (tutorial.hello.appliance): dissassembly phase
-[DEBUG ] (tutorial.hello.appliance): disposal
]]></source>
<p>
@@ -103,7 +123,8 @@
<p>
Launch merlin in execute mode using the "target\classes" directory
as an implicit classpath entry and a deployment scenario defined in
- the file target\classes\BLOCK-INF\block.xml.
+ the file target\classes\BLOCK-INF\block.xml using an overriding
+ configuration qualifying the logging priorities.
</p>
<source><![CDATA[
$ merlin -execute target\classes -config conf\config.xml
@@ -111,23 +132,23 @@
<p>
The assembly phase checks the component for any service dependencies
- and reolves them automatically. In our demonstration component there
- are not dependencies. Later tutorials will revisit this aspect.
+ and resolves them automatically. In our demonstration component there
+ are no dependencies. Later tutorials will revisit this aspect.
</p>
<source><![CDATA[
-[DEBUG ] (tutorial.hello.appliance): assembly phase
+[DEBUG ] (tutorial): assembly phase
]]></source>
<p>
- As the compoent has been declared in the block.xml file, the default
- deployment policy is to deploy it on startup. In this example the
- component is a transient component. The logging message details
- the lifestyle and policy during activation on startup.
+ As the component has been declared in the block.xml file, the default
+ deployment policy is to deploy on startup. The following log entry
+ is issued by the container responsible for commissioning of the
+ hello component.
</p>
<source><![CDATA[
-[DEBUG ] (tutorial.hello.appliance): deployment (transient) [true]
+[DEBUG ] (tutorial): commissioning component [hello]
]]></source>
@@ -136,41 +157,20 @@
</p>
<source><![CDATA[
-[DEBUG ] (tutorial.hello.appliance): new instance: 24531886
-]]></source>
-
- <p>
- A logger is assigned because the component implements the
- LogEnabled interface.
- </p>
-
-<source><![CDATA[
-[DEBUG ] (tutorial.hello.appliance): applying logger to: 24531886
-[INFO ] (tutorial.hello): logging
+[DEBUG ] (tutorial.hello.lifecycle): incarnation
+[DEBUG ] (tutorial.hello.lifecycle): instantiating component with 1 arguments.
+[INFO ] (tutorial.hello): instantiated
]]></source>
<p>
- A component is initialized because it implements the
- Initializable interface.
+ If the component implements any lifecycle interfaces, the container
+ will process the stages following instance instiation. In our example
+ we have already supplied arguments via a constructor so no additional
+ lifecycle processing is required.
</p>
<source><![CDATA[
-[DEBUG ] (tutorial.hello.appliance): applying initialization to: 24531886
-[INFO ] (tutorial.hello): initialization
-]]></source>
-
- <p>
- If the component implemeted the Startable interface it would be
- started at this point. If it dowes not implement Startable,
- Merlin will check to see if it implements Executable and if so, the
- container invokes execute on the component.
- </p>
-
-<source><![CDATA[
-[DEBUG ] (tutorial.hello.appliance): executing: 24531886
-[INFO ] (tutorial.hello): execution
-[DEBUG ] (tutorial.hello.appliance): component established: 24531886
-[DEBUG ] (tutorial.hello.appliance): activated instance: 24531886
+[DEBUG ] (tutorial): commissioning of [hello] completed in 93 milliseconds
]]></source>
<p>
@@ -186,21 +186,20 @@
</p>
<source><![CDATA[
-[DEBUG ] (tutorial.hello.appliance): decommissioning phase
-[DEBUG ] (tutorial.hello.appliance): component disposal: 24531886
-[DEBUG ] (tutorial.hello.appliance): disposing of: 24531886
-[INFO ] (tutorial.hello): disposal
-[DEBUG ] (tutorial.hello.appliance): destroyed instance: 24531886
+[DEBUG ] (tutorial): decommissioning
+[DEBUG ] (tutorial.hello.lifecycle): etherialization
+[DEBUG ] (tutorial.hello.lifecycle): applying disposal
]]></source>
<p>
- Internally the appliance instance managing the deployment scenario
- is taken down during which it is dissassembled and disposed of.
+ The hello component implements the Disposable lifecycle
+ interface and the following log entry raised by the
+ component signals that it has completed it's own end-of-life
+ processing.
</p>
<source><![CDATA[
-[DEBUG ] (tutorial.hello.appliance): dissassembly phase
-[DEBUG ] (tutorial.hello.appliance): disposal
+[INFO ] (tutorial.hello): disposal
]]></source>
</subsection>
@@ -216,79 +215,72 @@
<source><![CDATA[
$ merlin -execute target\classes -debug
-[DEBUG ] (kernel.logging): default priority: DEBUG
-[DEBUG ] (kernel.logging): adding category: kernel, null
-[DEBUG ] (kernel.context): logging system established
-[DEBUG ] (kernel.context): using bootstrap repository
-[DEBUG ] (kernel.logging): adding category: kernel, null
-[DEBUG ] (kernel.context): model factory established
-[DEBUG ] (kernel): creating root containment context
-[DEBUG ] (kernel.classloader): base: ${user.dir}
-[DEBUG ] (kernel.classloader): classpath:
-[DEBUG ] (kernel.classloader.types): type install count: 0
-[DEBUG ] (kernel): construction phase
+[DEBUG ] (kernel.logger): logging system established
+[DEBUG ] (kernel.logger): adding category [kernel]
+[DEBUG ] (kernel): logging system established
+[DEBUG ] (kernel): repository established:
+ D:\system\maven\repository, http://www.dpml.net/,
+ http://www.ibiblio.org/maven/
+[DEBUG ] (kernel.logger): adding category [kernel]
+[DEBUG ] (kernel): building application model
+[DEBUG ] (kernel.logger): adding root category
+[DEBUG ] (kernel.logger): adding root category
+[DEBUG ] (kernel.logger): adding root category
+[DEBUG ] (classloader): base: ${user.dir}
+[DEBUG ] (classloader): base=[D:\dev\avalon\tutorials\hello]
+[DEBUG ] (classloader): classpath:
+[DEBUG ] (classloader.types): type install count: 0
+[DEBUG ] (classloader.types): type registration complete
+[DEBUG ] (kernel): state: initializing
+[DEBUG ] (kernel): kernel established
+[DEBUG ] (kernel): state: initialized
[DEBUG ] (kernel): install phase
-[INFO ] (kernel): installing: file:/${user.dir}/target/classes/
-[DEBUG ] (kernel): installing: tutorial
-[DEBUG ] (kernel.tutorial.classloader): base: ${user.dir}
-[DEBUG ] (kernel.tutorial): implicit entries: 1
-[DEBUG ] (kernel.tutorial): repository declarations: 1
-[DEBUG ] (kernel.tutorial): repository 0 contains 1 entries.
-[DEBUG ] (kernel.tutorial.classloader): classpath:
- file:/${user.dir}/target/classes/;
- file:/${merlin.home}/repository/avalon-framework/jars/
- avalon-framework-impl-SNAPSHOT.jar
-[DEBUG ] (kernel.tutorial.classloader.scanner): scanning:
-file:/${user.dir}/target/classes/
-[DEBUG ] (kernel.tutorial.classloader.scanner): type: tutorial.HelloComponent
-[DEBUG ] (kernel.tutorial.classloader.scanner): scanning:
- file:/${merlin.home}/repository/avalon-framework/
-jars/avalon-framework-impl-SNAPSHOT.jar
-[DEBUG ] (kernel.tutorial.classloader.types): type install count: 1
-[DEBUG ] (kernel.tutorial.classloader.types): registered
- [type:tutorial.HelloComponent/1].
-[DEBUG ] (kernel.tutorial): installing: hello
-[DEBUG ] (kernel): customization phase
-[DEBUG ] (kernel): composition phase
-[DEBUG ] (kernel.logging): adding category: , null
-[DEBUG ] (): creating block: /tutorial
-[DEBUG ] (kernel.logging): adding category: tutorial, null
-[DEBUG ] (tutorial): creating appliance: /tutorial/hello
-[DEBUG ] (kernel.logging): adding category: tutorial.hello, null
-[DEBUG ] (kernel): assembly phase
+[DEBUG ] (kernel): installing: file:/${user.dir}/target/classes/
+[DEBUG ] (): including composite block:
+ file:/D:/dev/avalon/tutorials/hello/target/classes/BLOCK-INF/block.xml
+[DEBUG ] (): installing: tutorial
+[DEBUG ] (kernel.logger): adding category [tutorial]
+[DEBUG ] (kernel.logger): adding category [tutorial]
+[DEBUG ] (tutorial): creating child classloader for: [tutorial]
+[DEBUG ] (tutorial.classloader): base: ${user.dir}
+[DEBUG ] (tutorial): implicit entries: 1
+[DEBUG ] (tutorial.classloader): base=[D:\dev\avalon\tutorials\hello]
+[DEBUG ] (tutorial.classloader): classpath: file:/${user.dir}/target/classes/
+[DEBUG ] (tutorial.classloader.scanner): scanning:
file:/${user.dir}/target/classes/
+[DEBUG ] (tutorial.classloader.scanner): type: tutorial.HelloComponent
+[DEBUG ] (tutorial.classloader.types): type install count: 1
+[DEBUG ] (tutorial.classloader.types): registered [type:tutorial.HelloComponent/1].
+[DEBUG ] (tutorial.classloader.types): type registration complete
+[DEBUG ] (kernel.logger): adding category [tutorial]
+[DEBUG ] (kernel.logger): adding category [tutorial.hello]
+[DEBUG ] (kernel): customize phase
+[DEBUG ] (kernel): startup phase
+[DEBUG ] (kernel): application assembly
+[DEBUG ] (kernel): state: assembly
[DEBUG ] (): assembly phase
[DEBUG ] (tutorial): assembly phase
-[DEBUG ] (tutorial.hello.appliance): assembly phase
-[DEBUG ] (kernel): deployment phase
-[DEBUG ] (): deployment: block:/tutorial
-[DEBUG ] (tutorial): deployment: appliance:/tutorial/hello
-[DEBUG ] (tutorial.hello.appliance): deployment (transient) [true]
-[DEBUG ] (tutorial.hello.appliance): new instance: 10040639
-[DEBUG ] (tutorial.hello.appliance): applying logger to: 10040639
-[INFO ] (tutorial.hello): logging
-[DEBUG ] (tutorial.hello.appliance): applying initialization to: 10040639
-[INFO ] (tutorial.hello): initialization
-[DEBUG ] (tutorial.hello.appliance): executing: 10040639
-[INFO ] (tutorial.hello): execution
-[DEBUG ] (tutorial.hello.appliance): component established: 10040639
-[DEBUG ] (tutorial.hello.appliance): activated instance: 10040639
-[INFO ] (kernel): decommissioning phase
-[DEBUG ] (): decommissioning: block:/tutorial
-[DEBUG ] (tutorial): decommissioning: appliance:/tutorial/hello
-[DEBUG ] (tutorial.hello.appliance): decommissioning phase
-[DEBUG ] (tutorial.hello.appliance): component disposal: 10040639
-[DEBUG ] (tutorial.hello.appliance): disposing of: 10040639
+[DEBUG ] (kernel): application deployment
+[DEBUG ] (kernel): state: deployment
+[DEBUG ] (): commissioning container [tutorial]
+[DEBUG ] (tutorial): commissioning component [hello]
+[DEBUG ] (tutorial.hello.lifecycle): incarnation
+[DEBUG ] (tutorial.hello.lifecycle): instantiating component with 1 arguments.
+[INFO ] (tutorial.hello): instantiated
+[DEBUG ] (tutorial): commissioning of [hello] completed in 94 milliseconds
+[DEBUG ] (): commissioning of [tutorial] completed in 156 milliseconds
+[DEBUG ] (kernel): state: started
+[DEBUG ] (kernel): shutdown phase
+[DEBUG ] (kernel): state: stopping
+[DEBUG ] (kernel): state: decommissioning
+[DEBUG ] (): decommissioning
+[DEBUG ] (tutorial): decommissioning
+[DEBUG ] (tutorial.hello.lifecycle): etherialization
+[DEBUG ] (tutorial.hello.lifecycle): applying disposal
[INFO ] (tutorial.hello): disposal
-[DEBUG ] (tutorial.hello.appliance): destroyed instance: 10040639
-[INFO ] (kernel): dissassembly phase
-[DEBUG ] (): dissassembly phase
-[DEBUG ] (tutorial): dissassembly phase
-[DEBUG ] (tutorial.hello.appliance): dissassembly phase
-[INFO ] (kernel): disposal phase
-[DEBUG ] (): disposal phase
-[DEBUG ] (tutorial): disposal phase
-[DEBUG ] (tutorial.hello.appliance): disposal
-[INFO ] (kernel): bye (1)
+[DEBUG ] (kernel): state: stopped
+[DEBUG ] (kernel): disposal
+[DEBUG ] (kernel): shutdown event
+[DEBUG ] (kernel): disposal
]]></source>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]