mcconnell 2003/08/22 11:00:08
Modified: merlin maven.xml
merlin/activation/src/java/org/apache/avalon/activation/appliance/impl
DefaultAppliance.java Resources.properties
merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl
AbstractLifestyleHandler.java
PooledLifestyleHandler.java
SingletonLifestyleHandler.java
ThreadLifestyleHandler.java
TransientLifestyleHandler.java
merlin/composition/src/java/org/apache/avalon/composition/logging/impl
DefaultLoggingManager.java
merlin/kernel/impl/conf kernel.xml
merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl
CLIKernelLoader.java DefaultKernelContext.java
merlin/merlin-platform/tutorials/hello/src/java/tutorial
HelloComponent.java
merlin/merlin-platform/xdocs/starting/tutorial creation.xml
execution.xml
Log:
Added disposal support for lifestyle handlers, improved kernel logic re. reopository
management and info reporting, and improved logging implementation.
Revision Changes Path
1.43 +12 -6 avalon-sandbox/merlin/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/maven.xml,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- maven.xml 21 Aug 2003 19:37:42 -0000 1.42
+++ maven.xml 22 Aug 2003 18:00:07 -0000 1.43
@@ -11,6 +11,13 @@
<ant:property name="pom.organization.identifier" value="ASF"/>
<ant:property name="pom.specificationVersion" value="1.0"/>
+ <goal name="package">
+ <attainGoal name="merlin-clean"/>
+ <attainGoal name="merlin-dist"/>
+ <attainGoal name="merlin-site"/>
+ <attainGoal name="merlin-package"/>
+ </goal>
+
<goal name="merlin-dist"
description="Build the Merlin distribution." >
@@ -95,13 +102,12 @@
<ant:chmod file="${merlin.build.inst.dir}/bin/merlin.sh" perm="ugo+rx"/>
- </goal>
+ <ant:copy toDir="${maven.build.dir}">
+ <fileset dir="${basedir}">
+ <include name="INSTALLATION.TXT"/>
+ </fileset>
+ </ant:copy>
- <goal name="package">
- <attainGoal name="merlin-clean"/>
- <attainGoal name="merlin-dist"/>
- <attainGoal name="merlin-site"/>
- <attainGoal name="merlin-package"/>
</goal>
<goal name="merlin-package">
1.6 +55 -15
avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/appliance/impl/DefaultAppliance.java
Index: DefaultAppliance.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/appliance/impl/DefaultAppliance.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultAppliance.java 19 Aug 2003 03:51:23 -0000 1.5
+++ DefaultAppliance.java 22 Aug 2003 18:00:07 -0000 1.6
@@ -79,6 +79,7 @@
import org.apache.avalon.composition.logging.LoggingManager;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.avalon.framework.activity.Executable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.activity.Disposable;
@@ -180,7 +181,9 @@
* Self reference to a component from this appliance if this
* appliance is operating under startup enabled policy.
*/
- private Object m_object;
+ //private Object m_object;
+
+ private Logger m_logger;
//-------------------------------------------------------------------
// constructor
@@ -189,8 +192,9 @@
public DefaultAppliance(
Logger logger, ServiceContext context, DeploymentModel model, Engine engine )
{
- super( logger, model );
+ super( logger.getChildLogger( "appliance" ), model );
+ m_logger = logger;
m_context = context;
m_model = (DeploymentModel) model;
m_engine = engine;
@@ -513,10 +517,11 @@
if( m_model.getActivationPolicy() )
{
- m_object = resolve( this );
+ Object instance = resolve( this );
if( getLogger().isDebugEnabled() )
{
- getLogger().debug( "resolved: " + m_object );
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "activated instance: " + id );
}
}
m_deployment.setEnabled( true );
@@ -533,15 +538,6 @@
{
if( !m_deployment.isEnabled() ) return;
getLogger().debug( "decommissioning phase" );
- if( m_object != null )
- {
- release( m_object, this );
- }
- if( m_contextProvider != null )
- {
- m_contextProvider.release( this, m_contextualization );
- m_contextualization = null;
- }
if( m_lifestyle != null )
{
if( m_lifestyle instanceof Disposable )
@@ -550,6 +546,11 @@
}
m_lifestyle = null;
}
+ if( m_contextProvider != null )
+ {
+ m_contextProvider.release( this, m_contextualization );
+ m_contextualization = null;
+ }
m_deployment.setEnabled( false );
}
}
@@ -657,6 +658,7 @@
{
if( instance == null ) return;
final int id = System.identityHashCode( instance );
+ getLogger().debug( "component disposal: " + id );
try
{
applyStop( instance );
@@ -711,7 +713,7 @@
int id = System.identityHashCode( instance );
getLogger().debug( "applying logger to: " + id );
}
- ((LogEnabled)instance).enableLogging( getLogger() );
+ ((LogEnabled)instance).enableLogging( m_logger );
}
}
@@ -940,6 +942,11 @@
{
if( instance instanceof Initializable )
{
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying initialization to: " + id );
+ }
try
{
((Initializable)instance).initialize();
@@ -959,6 +966,11 @@
{
if( instance instanceof Startable )
{
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "starting: " + id );
+ }
try
{
((Startable)instance).start();
@@ -970,12 +982,35 @@
throw new LifecycleException( error, e );
}
}
+ else if( instance instanceof Executable )
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "executing: " + id );
+ }
+ try
+ {
+ ((Executable)instance).execute();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString( "lifecycle.execute.component.error" );
+ throw new LifecycleException( error, e );
+ }
+ }
}
private void applyStop( Object instance )
{
if( instance instanceof Startable )
{
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "stopping: " + id );
+ }
try
{
((Startable)instance).stop();
@@ -993,6 +1028,11 @@
{
if( instance instanceof Disposable )
{
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "disposing of: " + id );
+ }
try
{
((Disposable)instance).dispose();
1.3 +1 -0
avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/appliance/impl/Resources.properties
Index: Resources.properties
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/appliance/impl/Resources.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Resources.properties 19 Aug 2003 03:51:23 -0000 1.2
+++ Resources.properties 22 Aug 2003 18:00:07 -0000 1.3
@@ -18,6 +18,7 @@
lifecycle.contextualization.custom.error=Unexpected error raised by the component,
supplied context object, or custom contextualizer during the component
contextulization phase.
lifecycle.initialize.component.error=Component initiated initialization failure.
lifecycle.start.component.error=Component initiated startup failure.
+lifecycle.execute.component.error=Component initiated execution failure.
lifecycle.stop.component.warn=Component initiated shutdown error (ignored).
lifecycle.stage.key.unknown.error=Cannot resolve stage provider in appliance [{0}]
because the stage key id [{1}] is unknown.
lifecycle.stage.creator.error=Creation stage handler error raised by extension id:
[{0}].
1.4 +1 -10
avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/AbstractLifestyleHandler.java
Index: AbstractLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/AbstractLifestyleHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractLifestyleHandler.java 17 Aug 2003 06:35:51 -0000 1.3
+++ AbstractLifestyleHandler.java 22 Aug 2003 18:00:07 -0000 1.4
@@ -85,13 +85,4 @@
return resolve( source, new Class[0] );
}
- /**
- * Release an object. The abstract implementation does nothing,
- *
- * @param source the context with respect the reclaimed object is qualified
- * @param object the object to be reclaimed
- */
- public void release( Object source, Object object )
- {
- }
}
1.2 +11 -1
avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/PooledLifestyleHandler.java
Index: PooledLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/PooledLifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PooledLifestyleHandler.java 7 Aug 2003 17:11:20 -0000 1.1
+++ PooledLifestyleHandler.java 22 Aug 2003 18:00:07 -0000 1.2
@@ -79,4 +79,14 @@
throw new UnsupportedOperationException();
}
+ /**
+ * Release an object. The abstract implementation does nothing,
+ *
+ * @param source the context with respect the reclaimed object is qualified
+ * @param object the object to be reclaimed
+ */
+ public void release( Object source, Object object )
+ {
+ }
+
}
1.2 +11 -1
avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/SingletonLifestyleHandler.java
Index: SingletonLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/SingletonLifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SingletonLifestyleHandler.java 7 Aug 2003 17:11:24 -0000 1.1
+++ SingletonLifestyleHandler.java 22 Aug 2003 18:00:07 -0000 1.2
@@ -96,6 +96,16 @@
return m_instance;
}
+ /**
+ * Release an object. The abstract implementation does nothing,
+ *
+ * @param source the context with respect the reclaimed object is qualified
+ * @param object the object to be reclaimed
+ */
+ public void release( Object source, Object object )
+ {
+ }
+
/**
* Dispose of the component.
*/
1.2 +26 -2
avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/ThreadLifestyleHandler.java
Index: ThreadLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/ThreadLifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ThreadLifestyleHandler.java 7 Aug 2003 17:11:24 -0000 1.1
+++ ThreadLifestyleHandler.java 22 Aug 2003 18:00:07 -0000 1.2
@@ -52,12 +52,13 @@
import org.apache.avalon.activation.lifecycle.Factory;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.activity.Disposable;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public class ThreadLifestyleHandler extends AbstractLifestyleHandler
+public class ThreadLifestyleHandler extends AbstractLifestyleHandler implements
Disposable
{
/**
* Internal utility class to hold the thread local instance.
@@ -116,4 +117,27 @@
}
return m_local.get();
}
+
+ /**
+ * Release an object. The abstract implementation does nothing,
+ *
+ * @param source the context with respect the reclaimed object is qualified
+ * @param object the object to be reclaimed
+ */
+ public void release( Object source, Object object )
+ {
+ }
+
+ /**
+ * Dispose of the component.
+ */
+ public void dispose()
+ {
+ if( m_local != null )
+ {
+ m_factory.destroy( m_local.get() );
+ }
+ m_local = null;
+ }
+
}
1.2 +36 -3
avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/TransientLifestyleHandler.java
Index: TransientLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/activation/src/java/org/apache/avalon/activation/lifestyle/impl/TransientLifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransientLifestyleHandler.java 7 Aug 2003 17:11:24 -0000 1.1
+++ TransientLifestyleHandler.java 22 Aug 2003 18:00:07 -0000 1.2
@@ -50,17 +50,23 @@
package org.apache.avalon.activation.lifestyle.impl;
+import java.util.ArrayList;
+
import org.apache.avalon.activation.lifecycle.Factory;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.activity.Disposable;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public class TransientLifestyleHandler extends AbstractLifestyleHandler
+public class TransientLifestyleHandler extends AbstractLifestyleHandler implements
Disposable
{
private final Factory m_factory;
+ // TODO: change this to weak references
+ private ArrayList m_list = new ArrayList();
+
public TransientLifestyleHandler( Logger logger, Factory factory )
{
super( logger );
@@ -78,7 +84,34 @@
*/
public Object resolve( Object source, Class[] ref ) throws Exception
{
- return m_factory.newInstance();
+ Object instance = m_factory.newInstance();
+ m_list.add( instance );
+ return instance;
+ }
+
+ /**
+ * Release an object. The abstract implementation does nothing,
+ *
+ * @param source the context with respect the reclaimed object is qualified
+ * @param object the object to be reclaimed
+ */
+ public void release( Object source, Object object )
+ {
+ m_list.remove( object );
+ m_factory.destroy( object );
+ }
+
+ /**
+ * Dispose of the component.
+ */
+ public synchronized void dispose()
+ {
+ Object[] instances = m_list.toArray();
+ for( int i=0; i<instances.length; i++ )
+ {
+ m_factory.destroy( instances[i] );
+ }
+ m_list.clear();
}
}
1.6 +16 -23
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/logging/impl/DefaultLoggingManager.java
Index: DefaultLoggingManager.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/logging/impl/DefaultLoggingManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultLoggingManager.java 19 Aug 2003 07:34:30 -0000 1.5
+++ DefaultLoggingManager.java 22 Aug 2003 18:00:07 -0000 1.6
@@ -158,19 +158,19 @@
// setup the hierarchy, default logging target, and default priority
//
+ String defaultPriority = DEFAULT_PRIORITY ;
getHierarchy().setDefaultLogTarget( DEFAULT_STREAM );
m_targets.put( DEFAULT_TARGET, DEFAULT_STREAM );
if( descriptor.getPriority() != null )
{
+ defaultPriority = descriptor.getPriority();
getHierarchy().setDefaultPriority(
- Priority.getPriorityForName( descriptor.getPriority() ) );
- if( m_debug ) log( "setting default priority: " +
descriptor.getPriority() );
+ Priority.getPriorityForName( defaultPriority ) );
}
else
{
getHierarchy().setDefaultPriority(
- Priority.getPriorityForName( DEFAULT_PRIORITY ) );
- if( m_debug ) log( "using default priority: " + DEFAULT_PRIORITY );
+ Priority.getPriorityForName( defaultPriority ) );
}
//
@@ -212,7 +212,10 @@
final String channel = descriptor.getName() + ".logging";
m_logger = getLoggerForCategory( channel );
- if( m_debug ) log( "logging category: " + channel );
+ if( m_debug )
+ {
+ log( "default priority: " + defaultPriority );
+ }
}
//===============================================================
@@ -307,24 +310,14 @@
*/
public org.apache.avalon.framework.logger.Logger getLoggerForCategory( final
String category )
{
- if( category == null )
- {
- return new LogKitLogger( getHierarchy().getLoggerFor( "" ) );
- }
- else
- {
- String cat = filter( category );
- try
- {
- return new LogKitLogger( getHierarchy().getLoggerFor( cat ) );
- }
- catch( Throwable e )
- {
- throw new RuntimeException( "Bad category: " + cat );
- }
- }
+ Logger log = addCategory( category, null, null );
+ return new LogKitLogger( log );
}
+ //===============================================================
+ // implementation
+ //===============================================================
+
private Logger addCategory( String path, String priority, String target )
{
return addCategory( path, priority, target, true );
@@ -335,7 +328,7 @@
final String name = filter( path );
final Logger logger;
- if( m_debug ) log( "add category: " + name );
+ if( m_debug ) log( "adding category: " + name + ", " + priority );
try
{
@@ -364,7 +357,7 @@
final LogTarget logTarget = (LogTarget) m_targets.get( target );
if( logTarget != null )
{
- logger.setLogTargets( new LogTarget[]{logTarget} );
+ logger.setLogTargets( new LogTarget[]{ logTarget } );
}
}
}
1.2 +2 -2 avalon-sandbox/merlin/kernel/impl/conf/kernel.xml
Index: kernel.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/kernel/impl/conf/kernel.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- kernel.xml 19 Aug 2003 08:58:48 -0000 1.1
+++ kernel.xml 22 Aug 2003 18:00:07 -0000 1.2
@@ -2,8 +2,8 @@
<kernel>
- <logging name="smp" target="default" priority="INFO">
- <category name="" priority="WARN"/>
+ <logging name="kernel" priority="INFO">
+ <category name="" priority="WARN"/>
</logging>
<repository>
1.11 +22 -19
avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/CLIKernelLoader.java
Index: CLIKernelLoader.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/CLIKernelLoader.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- CLIKernelLoader.java 20 Aug 2003 11:57:13 -0000 1.10
+++ CLIKernelLoader.java 22 Aug 2003 18:00:07 -0000 1.11
@@ -120,6 +120,7 @@
}
catch( KernelException e )
{
+ System.out.println( "KERNEL-ERROR: " + e.getMessage() );
final String error =
ExceptionHelper.packException( e.getMessage(), e.getCause(), true );
System.err.println( error );
@@ -437,19 +438,26 @@
private File getSystemPath( CommandLine command ) throws IOException
{
File file = getSysPath( command );
- if( !file.exists() )
+ if( file == null )
{
- final String error =
- "Supplied system path does not exist: " + file;
- throw new IllegalArgumentException( error );
+ return null;
}
- if( !file.isDirectory() )
+ else
{
- final String error =
- "Supplied system path does not refer to a directory: " + file;
- throw new IllegalArgumentException( error );
+ if( !file.exists() )
+ {
+ final String error =
+ "Supplied system path does not exist: " + file;
+ throw new IllegalArgumentException( error );
+ }
+ if( !file.isDirectory() )
+ {
+ final String error =
+ "Supplied system path does not refer to a directory: " + file;
+ throw new IllegalArgumentException( error );
+ }
+ return file;
}
- return file;
}
private File getSysPath( CommandLine command ) throws IOException
@@ -472,7 +480,7 @@
}
else
{
- return SYSTEM;
+ return null;
}
}
@@ -569,14 +577,9 @@
private static File getSystemDefaultDirectory()
{
- final String system = System.getProperty( "merlin.home" );
- if( system == null )
- {
- return new File( System.getProperty( "user.home" ), "merlin" );
- }
- else
- {
- return new File( system );
- }
+ final String local =
+ System.getProperty( "merlin.home",
+ System.getProperty( "user.home" ) + "/merlin" );
+ return new File( local );
}
}
1.16 +38 -28
avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelContext.java
Index: DefaultKernelContext.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelContext.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- DefaultKernelContext.java 20 Aug 2003 13:24:50 -0000 1.15
+++ DefaultKernelContext.java 22 Aug 2003 18:00:07 -0000 1.16
@@ -122,7 +122,7 @@
private final Repository m_repository;
/**
- * The system path
+ * The library path
*/
private final File m_system;
@@ -154,7 +154,7 @@
/**
* The kernel configuration url.
*/
- private final URL m_kernelURL;
+ private final String m_kernelURL;
/**
* The block url.
@@ -221,11 +221,10 @@
URL kernel, URL[] blocks, URL config, boolean server, boolean debug )
throws NullPointerException, KernelException
{
-
if( repository == null ) throw new NullPointerException( "repository" );
- m_system = system;
m_library = library;
+ m_system = system;
if( home != null )
{
@@ -241,21 +240,22 @@
if( kernel != null )
{
- m_kernelURL = kernel;
+ m_kernelURL = kernel.toString();
m_kernel = getKernelConfiguration( kernel );
}
else
{
Configuration kernelConfig = null;
- URL kernelURL = null;
+ String kernelURL = null;
try
{
- kernelURL = loadKernelDirective( repository );
- kernelConfig = getKernelConfiguration( kernelURL );
+ URL url = loadKernelDirective( repository );
+ kernelURL = url.toString();
+ kernelConfig = getKernelConfiguration( url );
}
catch( Throwable e )
{
- kernelURL = null;
+ kernelURL = "resource:/kernel.xml";
try
{
final InputStream stream =
@@ -367,18 +367,18 @@
private Repository createRepository( File root, Configuration config )
throws KernelException
{
- File base = null;
- String cache = config.getChild( "cache" ).getValue( null );
- if( cache != null )
- {
- base = new File( cache );
- getLogger().debug( "setting repository cache: " + base );
- }
- else
- {
- base = new File( root, "repository" );
- getLogger().debug( "setting repository to: " + base );
- }
+ File base = null;
+ String cache = config.getChild( "cache" ).getValue( null );
+ if( cache != null )
+ {
+ base = new File( cache );
+ getLogger().debug( "setting repository cache: " + base );
+ }
+ else
+ {
+ base = new File( root, "repository" );
+ getLogger().debug( "setting repository to: " + base );
+ }
if( !base.exists() ) base.mkdirs();
@@ -609,16 +609,26 @@
+ System.getProperty( "os.version" ) + " Java "
+ System.getProperty( "java.version" ) );
buffer.append( "\n Deployment Home: " + getHomePath() );
- buffer.append( "\n Runtime Repository: " + m_system );
- buffer.append( "\n Library Anchor: " + getLibraryPath() );
- if( m_kernelURL != null )
+ buffer.append( "\n Runtime Repository: " );
+ if( m_system != null )
{
- buffer.append( "\n Kernel Path: " + m_kernelURL );
+ buffer.append( m_system );
}
+ else
+ {
+ String fallback =
+ System.getProperty( "merlin.repository.local",
+ System.getProperty( "merlin.home",
+ System.getProperty( "user.dir" ) ) );
+ buffer.append( fallback );
+ }
+ buffer.append( "\n Library Anchor: " + getLibraryPath() );
+ buffer.append( "\n Kernel Path: " + m_kernelURL );
buffer.append( "\n Deployment Blocks: " + getInstallSequenceString() );
+ buffer.append( "\n Override Path: " );
if( getOverrideDirective() != null )
{
- buffer.append( "\n Override Path: " + getOverrideDirective() );
+ buffer.append( getOverrideDirective() );
}
buffer.append( "\n Server Flag: " + getServerFlag() );
buffer.append( "\n Debug Flag: " + getDebugFlag() );
@@ -726,7 +736,7 @@
Configuration config )
throws KernelException
{
- final String name = config.getAttribute( "name", "smp" );
+ final String name = config.getAttribute( "name", "kernel" );
CategoriesDirective categories = null;
try
{
1.5 +7 -6
avalon-sandbox/merlin/merlin-platform/tutorials/hello/src/java/tutorial/HelloComponent.java
Index: HelloComponent.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/hello/src/java/tutorial/HelloComponent.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HelloComponent.java 22 Jul 2003 08:57:59 -0000 1.4
+++ HelloComponent.java 22 Aug 2003 18:00:08 -0000 1.5
@@ -14,7 +14,8 @@
* 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).
+ * execution), and Disposable (componet disposal). PLease note
+ * that all lifecycle stages are optional.
*
* @avalon.component version="1.0" name="hello"
*/
@@ -36,7 +37,7 @@
public void enableLogging( final Logger logger )
{
m_logger = logger;
- getLogger().info( "logging stage" );
+ getLogger().info( "logging" );
}
/**
@@ -45,7 +46,7 @@
*/
public void initialize() throws Exception
{
- getLogger().info( "initialization stage" );
+ getLogger().info( "initialization" );
}
/**
@@ -54,7 +55,7 @@
*/
public void execute()
{
- getLogger().info( "execution stage" );
+ getLogger().info( "execution" );
}
/**
@@ -63,9 +64,9 @@
*/
public void dispose()
{
- getLogger().info( "disposal stage" );
+ getLogger().info( "disposal" );
m_logger = null;
- }
+ }
/**
* Return the logging channel assigned to us by the container.
1.3 +93 -9
avalon-sandbox/merlin/merlin-platform/xdocs/starting/tutorial/creation.xml
Index: creation.xml
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/merlin-platform/xdocs/starting/tutorial/creation.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- creation.xml 17 Aug 2003 04:19:15 -0000 1.2
+++ creation.xml 22 Aug 2003 18:00:08 -0000 1.3
@@ -31,19 +31,82 @@
<source><![CDATA[
package tutorial;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
+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;
-public class HelloComponent extends AbstractLogEnabled implements 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.
+ *
+ * @avalon.component version="1.0" name="hello"
+ */
+public class HelloComponent
+ implements LogEnabled, Initializable, Executable, Disposable
{
+
+ /**
+ * Internal reference to the logging channel supplied to us
+ * by the container.
+ */
+ private Logger m_logger;
+
+ /**
+ * Supply of a logging channel by the container.
+ *
+ * @param logger the logging channel for this component
+ */
+ public void enableLogging( final Logger logger )
+ {
+ m_logger = logger;
+ getLogger().info( "logging stage" );
+ }
+
/**
* Initialization of the component by the container.
* @exception Exception if an initialization error occurs
*/
public void initialize() throws Exception
{
- getLogger().info( "I've been initialized!" );
+ getLogger().info( "initialization stage" );
+ }
+
+ /**
+ * Component execution trigger by the container following
+ * completion of the initialization stage.
+ */
+ public void execute()
+ {
+ getLogger().info( "execution stage" );
+ }
+
+ /**
+ * Component disposal trigger by the container during which
+ * the component will release consumed resources.
+ */
+ public void dispose()
+ {
+ getLogger().info( "disposal stage" );
+ m_logger = null;
+ }
+
+ /**
+ * Return the logging channel assigned to us by the container.
+ * @return the logging channel
+ */
+ private Logger getLogger()
+ {
+ return m_logger;
}
+
}
]]></source>
</subsection>
@@ -51,16 +114,29 @@
<p>
In order for Merlin to recognize this class as a component, we need to
- declare it using a <classname>.xinfo file. The following text
+ generate a <classname>.xinfo file. </p>
+ <p>
+ The following text
is an example of a component type definition. It contains the declaration
- of the component name and the component implementation version.
+ of the component name and the component implementation version. It was
+ generated automatically for us by the pre-goal included in the maven.xml
+ file. The avalon:meta plugin looks for @avalon.component tags at class
level
+ and generates component descriptors for us automatically.
</p>
+<source><![CDATA[
+ <preGoal name="java:compile">
+ <attainGoal name="avalon:meta"/>
+ </preGoal>
+]]></source>
+ </subsection>
+ <subsection name="Generated Type Descriptor">
<source><![CDATA[
<type>
<info>
<name>hello</name>
- <version>1.0</version>
+ <version>1.0.0</version>
+ <lifestyle>transient</lifestyle>
</info>
</type>
]]></source>
@@ -68,12 +144,20 @@
</subsection>
<subsection name="Creating a block">
<p>
- A block is the definition of a composite component. It represents an
application made up of a set of components and the supporting resources. In our
example the block will container the single HelloComponent component. The following
XML description should be declared under a BLOCK-INF directory. It declares a block
named "tutorial". The root container includes the declaration of the hello component.
Based on this infromation Merlin will create a container and deploy the hello
component on startup.
+A block is the definition of a composite component. It represents an 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.
</p>
<source><![CDATA[
-<container name="banking">
+<container name="tutorial">
+
+ <classloader>
+ <classpath>
+ <repository>
+ <resource id="avalon-framework:avalon-framework-impl" version="SNAPSHOT"/>
+ </repository>
+ </classpath>
+ </classloader>
- <component name="hello" class="tutorial.HelloComponent" activation="startup"/>
+ <component name="hello" class="tutorial.HelloComponent"/>
</container>
]]></source>
1.2 +25 -24
avalon-sandbox/merlin/merlin-platform/xdocs/starting/tutorial/execution.xml
Index: execution.xml
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/merlin-platform/xdocs/starting/tutorial/execution.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- execution.xml 10 Jun 2003 02:14:33 -0000 1.1
+++ execution.xml 22 Aug 2003 18:00:08 -0000 1.2
@@ -9,49 +9,50 @@
</header>
<body>
<section name="Using Merlin">
- <subsection name="Running the Block">
+ <subsection name="Building the Block">
<p>
- Using the buildfile and sources included in the tutorials/hello directory
+ Using the sources included in the tutorials/hello directory
you can build and run the example using the following commands:
</p>
<source><![CDATA[
-$ cd tutorial\001
-$ ant
-$ merlin build\classes
+$ cd tutorial\hello
+$ maven
]]></source>
+ </subsection>
+ <subsection name="Running the Block">
<p>
- The output resulting from the execution of the block is as follows:
+To see Merlin in action, execute Merlin and give it either the
+jar file of the target/classes directory as the deployment
+argument. The following command deploys the component relative
+to the compiled classes in the target/classes directory.
</p>
-
<source><![CDATA[
-[INFO ] (sys): commencing block assembly phase
-[INFO ] (tutorial.hello): I've been initialized!
-[INFO ] (sys): Block hierarchy established.
+$ merlin -execute target\classes
]]></source>
<p>
- To terminate the session use ^C.
+Alternatively you can deploy the component from the jar file.
</p>
+
<source><![CDATA[
-[INFO ] (sys): commencing decommissioning phase
-[INFO ] (sys): bye
+$ merlin -execute target\merlin-hello-tutorial-1.0.jar
]]></source>
+
<p>
- Congratulations! You have build and deployed your first block.
- </p>
- </subsection>
- <subsection name="Running the Block from a Jar File">
- <p>
- In the above example we requested the deployment of the block
- based on a block.xml file included in the file system. In the
- following example we will execute the block by referencing the
- jar file. Merlin will attempt to locate the block.xml file
- under the path "/BLOCK-INF/block.xml".
+ The output resulting from the execution of the block is as follows:
</p>
+
<source><![CDATA[
-$ merlin tutorial.jar
+[INFO ] (tutorial.hello): logging
+[INFO ] (tutorial.hello): initialization
+[INFO ] (tutorial.hello): execution
+[INFO ] (tutorial.hello): disposal
]]></source>
+
+ <p>
+ Congratulations! You have build and deployed your first block.
+ </p>
</subsection>
</section>
</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]