mcconnell 2004/01/11 16:17:20
Modified:
merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl
Tag: Ver_3_4 AbstractAppliance.java
AbstractBlock.java DefaultAppliance.java
DefaultBlock.java DefaultBlockContext.java
Deployer.java
merlin/activation/impl/src/test/org/apache/avalon/activation/appliance
Tag: Ver_3_4 RuntimeTestCase.java
merlin/activation/spi/src/java/org/apache/avalon/activation/appliance
Tag: Ver_3_4 BlockContext.java
merlin/composition/api/src/java/org/apache/avalon/composition/model
Tag: Ver_3_4 DeploymentModel.java
merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
Tag: Ver_3_4 DefaultComponentContext.java
DefaultContainmentModel.java
DefaultContextModel.java
DefaultDeploymentModel.java
merlin/kernel/api/src/java/org/apache/avalon/merlin/event
Tag: Ver_3_4 KernelEvent.java
merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl
Tag: Ver_3_4 DefaultFactory.java DefaultKernel.java
Log:
A bunch of updates that address a cleaner seperation between the model related
concerns and the runtime concerns.
Revision Changes Path
No revision
No revision
1.2.2.3 +3 -3
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/AbstractAppliance.java
Index: AbstractAppliance.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/AbstractAppliance.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- AbstractAppliance.java 7 Jan 2004 12:57:25 -0000 1.2.2.2
+++ AbstractAppliance.java 12 Jan 2004 00:17:19 -0000 1.2.2.3
@@ -92,9 +92,9 @@
// constructor
//-------------------------------------------------------------------
- public AbstractAppliance( Logger logger, DeploymentModel model )
+ public AbstractAppliance( DeploymentModel model )
{
- enableLogging( logger );
+ enableLogging( model.getLogger() );
m_model = model;
m_model.setHandler( this );
}
1.10.2.7 +10 -34
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/AbstractBlock.java
Index: AbstractBlock.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/AbstractBlock.java,v
retrieving revision 1.10.2.6
retrieving revision 1.10.2.7
diff -u -r1.10.2.6 -r1.10.2.7
--- AbstractBlock.java 8 Jan 2004 12:51:16 -0000 1.10.2.6
+++ AbstractBlock.java 12 Jan 2004 00:17:19 -0000 1.10.2.7
@@ -105,23 +105,16 @@
* @param model the root containment model
* @return the appliance
*/
- public static Block createRootBlock(
- SystemContext system, ContainmentModel model ) throws Exception
+ public static Block createRootBlock( ContainmentModel model ) throws Exception
{
- if( null == system )
- {
- throw new NullPointerException( "system" );
- }
if( null == model )
{
throw new NullPointerException( "model" );
}
- Logger logger =
- system.getLoggingManager().getLoggerForCategory( "" );
- BlockContext context = new DefaultBlockContext(
- logger, model, system, null );
- return new CompositeBlock( context );
+ BlockContext context =
+ new DefaultBlockContext( model, null );
+ return new DefaultBlock( context );
}
//-------------------------------------------------------------------
@@ -146,7 +139,7 @@
*/
AbstractBlock( BlockContext context )
{
- super( context.getLogger(), context.getContainmentModel() );
+ super( context.getContainmentModel() );
m_context = context;
@@ -396,37 +389,20 @@
Appliance appliance = null;
final String path = model.getPath() + model.getName();
- final SystemContext services = m_context.getSystemContext();
- final LoggingManager logging = services.getLoggingManager();
+ Logger logger = model.getLogger();
if( model instanceof ComponentModel )
{
getLogger().debug( "creating appliance: " + path );
- ComponentModel deployment = (ComponentModel) model;
- CategoriesDirective categories = deployment.getCategories();
- if( categories != null )
- {
- logging.addCategories( path, categories );
- }
- Logger logger = logging.getLoggerForCategory( path );
- appliance = new DefaultAppliance( logger, deployment, this );
+ ComponentModel component = (ComponentModel) model;
+ appliance = new DefaultAppliance( component, this );
}
else if( model instanceof ContainmentModel )
{
getLogger().debug( "creating block: " + path );
ContainmentModel containment = (ContainmentModel) model;
- CategoriesDirective categories = containment.getCategories();
- if( categories != null )
- {
- logging.addCategories( path, categories );
- }
-
- Logger logger = logging.getLoggerForCategory( path );
-
BlockContext context =
- new DefaultBlockContext(
- logger, containment, services, this );
-
+ new DefaultBlockContext( containment, this );
appliance = new CompositeBlock( context );
}
else
1.15.2.6 +5 -7
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/DefaultAppliance.java
Index: DefaultAppliance.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/DefaultAppliance.java,v
retrieving revision 1.15.2.5
retrieving revision 1.15.2.6
diff -u -r1.15.2.5 -r1.15.2.6
--- DefaultAppliance.java 8 Jan 2004 10:40:53 -0000 1.15.2.5
+++ DefaultAppliance.java 12 Jan 2004 00:17:19 -0000 1.15.2.6
@@ -182,12 +182,9 @@
// constructor
//-------------------------------------------------------------------
- public DefaultAppliance(
- Logger logger, ComponentModel model, Engine engine )
+ public DefaultAppliance( ComponentModel model, Engine engine )
{
- super( logger.getChildLogger( "appliance" ), model );
-
- m_logger = logger;
+ super( model );
m_model = (ComponentModel) model;
m_engine = engine;
}
@@ -527,7 +524,8 @@
int id = System.identityHashCode( instance );
getLogger().debug( "applying logger to: " + id );
}
- ((LogEnabled)instance).enableLogging( m_logger );
+ final Logger logger = m_model.getLogger();
+ ((LogEnabled)instance).enableLogging( logger );
}
}
1.7.2.5 +2 -21
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Attic/DefaultBlock.java
Index: DefaultBlock.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Attic/DefaultBlock.java,v
retrieving revision 1.7.2.4
retrieving revision 1.7.2.5
diff -u -r1.7.2.4 -r1.7.2.5
--- DefaultBlock.java 8 Jan 2004 10:40:53 -0000 1.7.2.4
+++ DefaultBlock.java 12 Jan 2004 00:17:19 -0000 1.7.2.5
@@ -108,8 +108,8 @@
try
{
- final Logger log = context.getLogger().getChildLogger( "proxy" );
final ContainmentModel model = context.getContainmentModel();
+ final Logger log = model.getLogger().getChildLogger( "proxy" );
final BlockInvocationHandler handler =
new BlockInvocationHandler( log, this );
final Class[] classes = getInterfaceClasses();
@@ -241,25 +241,6 @@
//
// if the invocation is against java.lang.Object then
// delegate the operation to the block
- //
-
- if( method.getDeclaringClass().equals( java.lang.Object.class ) )
- {
- m_logger.debug( "invocation: " + method.getName() );
- try
- {
- return method.invoke( m_block, args );
- }
- catch( InvocationTargetException e )
- {
- final String error =
- "Unexpected delegation error on java.lang.Object";
- throw new ApplianceException( error, e.getTargetException() );
- }
- }
-
- //
- // otherwise we are delegating to an implementation component
//
final ContainmentModel model = m_context.getContainmentModel();
1.3.2.3 +3 -28
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/DefaultBlockContext.java
Index: DefaultBlockContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/DefaultBlockContext.java,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -u -r1.3.2.2 -r1.3.2.3
--- DefaultBlockContext.java 7 Jan 2004 20:34:42 -0000 1.3.2.2
+++ DefaultBlockContext.java 12 Jan 2004 00:17:19 -0000 1.3.2.3
@@ -64,12 +64,8 @@
*/
public class DefaultBlockContext implements BlockContext
{
- private final Logger m_logger;
-
private final ContainmentModel m_model;
- private final SystemContext m_context;
-
private final Engine m_engine;
/**
@@ -81,42 +77,21 @@
* instances may be resolved
*/
public DefaultBlockContext(
- Logger logger, ContainmentModel model,
- SystemContext context, Engine engine )
+ ContainmentModel model, Engine engine )
{
- if( context == null ) throw new NullPointerException( "context" );
+ if( model == null ) throw new NullPointerException( "model" );
- m_logger = logger;
m_model = model;
- m_context = context;
m_engine = engine;
}
/**
- * Returns the logging channel to assign to the block.
- * @return the logging channel
- */
- public Logger getLogger()
- {
- return m_logger;
- }
-
- /**
* Returns the containment model assigned to the block.
* @return the containment model
*/
public ContainmentModel getContainmentModel()
{
return m_model;
- }
-
- /**
- * Returns the system context assigned to the block.
- * @return the system context
- */
- public SystemContext getSystemContext()
- {
- return m_context;
}
/**
1.2.2.5 +20 -10
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Deployer.java
Index: Deployer.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Deployer.java,v
retrieving revision 1.2.2.4
retrieving revision 1.2.2.5
diff -u -r1.2.2.4 -r1.2.2.5
--- Deployer.java 8 Jan 2004 12:51:16 -0000 1.2.2.4
+++ Deployer.java 12 Jan 2004 00:17:19 -0000 1.2.2.5
@@ -81,13 +81,13 @@
//------------------------------------------------------------
private final Logger m_logger;
- private final SimpleFIFO m_deploymentFIFO;
+ private final SimpleFIFO m_deploymentFIFO = new SimpleFIFO();
//------------------------------------------------------------
// mutable static
//------------------------------------------------------------
- private Thread m_deploymentThread;
+ private Thread m_deploymentThread;
//------------------------------------------------------------
// constructor
@@ -96,8 +96,6 @@
Deployer( Logger logger )
{
m_logger = logger;
- m_deploymentFIFO = new SimpleFIFO();
-
m_deploymentThread =
new Thread( this, "Deployer " + m_ThreadCounter++ );
m_deploymentThread.start();
@@ -136,10 +134,19 @@
{
m_logger.debug( "deploying: " + deployable );
}
- DeploymentRequest req =
- new DeploymentRequest( deployable, m_deploymentThread );
- m_deploymentFIFO.put( req );
- req.waitForCompletion();
+ if( null != m_deploymentThread )
+ {
+ DeploymentRequest req =
+ new DeploymentRequest( deployable, m_deploymentThread );
+ m_deploymentFIFO.put( req );
+ req.waitForCompletion();
+ }
+ else
+ {
+ final String warning =
+ "Ignoring attempt to deploy a component on a disposed deployer.";
+ m_logger.warn( warning );
+ }
}
/**
@@ -153,7 +160,10 @@
{
m_logger.debug( "disposal" );
}
- m_deploymentThread.interrupt();
+ if( null != m_deploymentThread )
+ {
+ m_deploymentThread.interrupt();
+ }
}
public void run()
No revision
No revision
1.3.2.4 +1 -1
avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/appliance/RuntimeTestCase.java
Index: RuntimeTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/appliance/RuntimeTestCase.java,v
retrieving revision 1.3.2.3
retrieving revision 1.3.2.4
diff -u -r1.3.2.3 -r1.3.2.4
--- RuntimeTestCase.java 8 Jan 2004 12:51:16 -0000 1.3.2.3
+++ RuntimeTestCase.java 12 Jan 2004 00:17:19 -0000 1.3.2.4
@@ -75,7 +75,7 @@
//
getLogger().debug( "creating root block" );
- Block block = AbstractBlock.createRootBlock( m_system, m_model );
+ Block block = AbstractBlock.createRootBlock( m_model );
getLogger().debug( "block: " + block );
//
No revision
No revision
1.2.2.2 +1 -13
avalon/merlin/activation/spi/src/java/org/apache/avalon/activation/appliance/BlockContext.java
Index: BlockContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/spi/src/java/org/apache/avalon/activation/appliance/BlockContext.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- BlockContext.java 7 Jan 2004 12:57:26 -0000 1.2.2.1
+++ BlockContext.java 12 Jan 2004 00:17:19 -0000 1.2.2.2
@@ -63,22 +63,10 @@
public interface BlockContext
{
/**
- * Returns the logging channel to assign to the block.
- * @return the logging channel
- */
- Logger getLogger();
-
- /**
* Returns the containment model assigned to the block.
* @return the containment model
*/
ContainmentModel getContainmentModel();
-
- /**
- * Returns the service context assigned to the block.
- * @return the service context
- */
- SystemContext getSystemContext();
/**
* Returns the assigned engine.
No revision
No revision
1.7.2.6 +10 -2
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/DeploymentModel.java
Index: DeploymentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/DeploymentModel.java,v
retrieving revision 1.7.2.5
retrieving revision 1.7.2.6
diff -u -r1.7.2.5 -r1.7.2.6
--- DeploymentModel.java 8 Jan 2004 12:51:17 -0000 1.7.2.5
+++ DeploymentModel.java 12 Jan 2004 00:17:19 -0000 1.7.2.6
@@ -51,10 +51,13 @@
package org.apache.avalon.composition.model;
import org.apache.avalon.composition.data.Mode;
+
import org.apache.avalon.meta.info.DependencyDescriptor;
import org.apache.avalon.meta.info.ServiceDescriptor;
import org.apache.avalon.meta.info.StageDescriptor;
+import org.apache.avalon.framework.logger.Logger;
+
/**
* Model desribing a deployment scenario.
*
@@ -101,6 +104,12 @@
*/
Object getHandler();
+ /**
+ * Return the assigned logging channel.
+ * @return the logging channel
+ */
+ Logger getLogger();
+
//-----------------------------------------------------------
// service production
//-----------------------------------------------------------
@@ -173,6 +182,5 @@
* long a deployment may take.
**/
long getDeploymentTimeout();
-
}
No revision
No revision
1.1.2.6 +2 -2
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentContext.java
Index: DefaultComponentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentContext.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- DefaultComponentContext.java 9 Jan 2004 20:29:49 -0000 1.1.2.5
+++ DefaultComponentContext.java 12 Jan 2004 00:17:19 -0000 1.1.2.6
@@ -331,7 +331,7 @@
key = entry.getKey();
}
- if( key.startsWith( "urn:merlin:" ) )
+ if( key.startsWith( "urn:composition:" ) )
{
return getSystemContext().get( key );
}
1.13.2.14 +9 -163
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
Index: DefaultContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
retrieving revision 1.13.2.13
retrieving revision 1.13.2.14
diff -u -r1.13.2.13 -r1.13.2.14
--- DefaultContainmentModel.java 9 Jan 2004 20:29:49 -0000 1.13.2.13
+++ DefaultContainmentModel.java 12 Jan 2004 00:17:19 -0000 1.13.2.14
@@ -279,16 +279,10 @@
* stage dependency. The containment model implementation will
* allways return FALSE.
*
- * @return FALSE containers don't export stage handling support
+ * @return FALSE containers don't export stage handling
*/
public boolean isaCandidate( StageDescriptor stage )
{
- //
- // TODO-LATER: requires declaration of extension handling
- // export within the container meta-data - for now a container
- // only exports services
- //
-
return false;
}
@@ -949,8 +943,14 @@
final String name = profile.getName();
final String partition = getPartition();
- final Logger logger = getLogger().getChildLogger( name );
+ LoggingManager logging = m_context.getSystemContext().getLoggingManager();
+ CategoriesDirective categories = profile.getCategories();
+ if( null != categories )
+ {
+ logging.addCategories( partition, profile.getCategories() );
+ }
+ Logger logger = logging.getLoggerForCategory( partition + name );
if( getLogger().isDebugEnabled() )
{
final String message =
@@ -1042,7 +1042,6 @@
getLogger().debug( message );
}
-
LoggingManager logging = m_context.getSystemContext().getLoggingManager();
final String base = partition + name;
logging.addCategories( base, profile.getCategories() );
@@ -1556,159 +1555,6 @@
{
return path.substring( name.length() + 1 );
}
-
- /**
- * Get a local model relative to a supplied service dependency.
- * @param dependency the service dependency descriptor
- * @exception ModelRuntimeException if an error occurs during model establishment
- */
- /*
- public DeploymentModel getModel( DependencyDescriptor dependency )
- throws ModelRuntimeException
- {
- //
- // if an existing model exists return it
- //
-
- DeploymentModel[] models = getModels();
- ModelSelector modelSelector = new DefaultModelSelector();
- DeploymentModel model = modelSelector.select( models, dependency );
- if( model != null ) return model;
-
- //
- // otherwise, check for any packaged profiles that
- // we could use to construct the model
- //
-
- TypeRepository repository =
- m_context.getClassLoaderModel().getTypeRepository();
- ArrayList list = new ArrayList();
- try
- {
- Type[] types = repository.getTypes( dependency );
- for( int i=0; i<types.length; i++ )
- {
- DeploymentProfile[] profiles =
- repository.getProfiles( types[i] );
- for( int j=0; j<profiles.length; j++ )
- {
- list.add( profiles[j] );
- }
- }
-
- //
- // TODO: update this to handle meta-data directed selector
- // creation (e.g. an extension urn) - problem is that we either
- // declare that this method is invoked when we are auto
- // creating a model on demand - in effect what we need is a
- // DependencyDirective instead of the descriptor.
- //
-
- DeploymentProfile[] collection = (DeploymentProfile[]) list.toArray(
new DeploymentProfile[0] );
- ProfileSelector selector = new DefaultProfileSelector();
- DeploymentProfile profile = selector.select( collection, dependency );
- if( profile != null )
- {
- return addModel( profile );
- }
- }
- catch( Throwable e )
- {
- // should not happen
- final String error =
- REZ.getString(
- "containment.model.create.error",
- getPath(),
- dependency.toString() );
- throw new ModelRuntimeException( error, e );
- }
-
- //
- // check the parent
- //
-
- return m_context.getModel( dependency );
- }
- */
-
- /**
- * Return a model relative to a supplied stage descriptor.
- * @param stage the stage descriptor
- * @return model of a an stage handler or null if the
- * stage is unresolvable
- * @exception ModelRuntimeException if an error occurs
- * during model establishment
- */
- /*
- public DeploymentModel getModel( StageDescriptor stage )
- throws ModelRuntimeException
- {
- //
- // if an existing model exists return it
- //
-
- DeploymentModel[] models = getModels();
- ModelSelector modelSelector = new DefaultModelSelector();
- DeploymentModel model = modelSelector.select( models, stage );
- if( model != null ) return model;
-
- //
- // otherwise, check for any packaged profiles that
- // we could use to construct the model
- //
-
- TypeRepository repository =
- m_context.getClassLoaderModel().getTypeRepository();
-
- ArrayList list = new ArrayList();
- try
- {
- Type[] types = repository.getTypes( stage );
- for( int i=0; i<types.length; i++ )
- {
- DeploymentProfile[] profiles =
- repository.getProfiles( types[i] );
- for( int j=0; j<profiles.length; j++ )
- {
- list.add( profiles[j] );
- }
- }
-
- //
- // TODO: update this to handle meta-data directed selector
- // creation (e.g. an extension urn) - problem is that we either
- // declare that this method is invoked when we are auto
- // creating a model on demand - in effect what we need is a
- // DependencyDirective instead of the descriptor.
- //
-
- DeploymentProfile[] collection =
- (DeploymentProfile[]) list.toArray( new DeploymentProfile[0] );
- ProfileSelector selector = new DefaultProfileSelector();
- DeploymentProfile profile = selector.select( collection, stage );
- if( profile != null )
- {
- return addModel( profile );
- }
- }
- catch( Throwable e )
- {
- // should not happen
- final String error =
- REZ.getString(
- "containment.model.create.error",
- getPath(),
- stage.toString() );
- throw new ModelRuntimeException( error, e );
- }
-
- //
- // check the parent
- //
-
- return m_context.getModel( stage );
- }
- */
/**
* Return the set of service export mappings
1.3.2.5 +2 -2
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContextModel.java
Index: DefaultContextModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContextModel.java,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -u -r1.3.2.4 -r1.3.2.5
--- DefaultContextModel.java 4 Jan 2004 21:28:59 -0000 1.3.2.4
+++ DefaultContextModel.java 12 Jan 2004 00:17:19 -0000 1.3.2.5
@@ -178,7 +178,7 @@
}
}
}
- else if( key.startsWith( "urn:merlin:" ) )
+ else if( key.startsWith( "urn:composition:" ) )
{
try
{
1.9.2.9 +8 -8
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java
Index: DefaultDeploymentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java,v
retrieving revision 1.9.2.8
retrieving revision 1.9.2.9
diff -u -r1.9.2.8 -r1.9.2.9
--- DefaultDeploymentModel.java 8 Jan 2004 12:51:17 -0000 1.9.2.8
+++ DefaultDeploymentModel.java 12 Jan 2004 00:17:19 -0000 1.9.2.9
@@ -190,18 +190,18 @@
return m_handler;
}
- //--------------------------------------------------------------
- // implementation
- //--------------------------------------------------------------
-
/**
- * Return the logging channel.
- * @return the logger
+ * Return the assigned logging channel.
+ * @return the logging channel
*/
- protected Logger getLogger()
+ public Logger getLogger()
{
return m_context.getLogger();
}
+
+ //--------------------------------------------------------------
+ // implementation
+ //--------------------------------------------------------------
public String toString()
{
No revision
No revision
1.1.2.2 +2 -3
avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/event/Attic/KernelEvent.java
Index: KernelEvent.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/event/Attic/KernelEvent.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- KernelEvent.java 9 Jan 2004 20:29:49 -0000 1.1.2.1
+++ KernelEvent.java 12 Jan 2004 00:17:20 -0000 1.1.2.2
@@ -70,8 +70,7 @@
/**
* Create a CompositionEvent event.
*
- * @param source the comtainment model raising the event
- * @param child the model that is the subject of composition
+ * @param kernel the kernel instance raising the event
*/
public KernelEvent( final Kernel kernel )
{
No revision
No revision
1.7.2.7 +278 -179
avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java
Index: DefaultFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java,v
retrieving revision 1.7.2.6
retrieving revision 1.7.2.7
diff -u -r1.7.2.6 -r1.7.2.7
--- DefaultFactory.java 9 Jan 2004 23:03:09 -0000 1.7.2.6
+++ DefaultFactory.java 12 Jan 2004 00:17:20 -0000 1.7.2.7
@@ -147,8 +147,6 @@
private Logger m_logger;
- private LoggingManager m_logging;
-
private InitialContext m_context;
private ClassLoader m_classloader;
@@ -210,7 +208,7 @@
throw new NullPointerException( "map" );
KernelCriteria criteria = null;
- if( map instanceof KernelCriteria)
+ if( map instanceof KernelCriteria )
{
criteria = (KernelCriteria) map;
}
@@ -221,20 +219,7 @@
throw new IllegalArgumentException( error );
}
- //
- // set the language code
- //
-
- String language = criteria.getLanguageCode();
- if( null != language )
- {
- ResourceManager.clearResourceCache();
- Locale locale = new Locale( language, "" );
- Locale.setDefault( locale );
- REZ =
- ResourceManager.getPackageResources(
- DefaultFactory.class );
- }
+ setupLanguageCode( criteria );
//
// create the kernel configuration
@@ -242,7 +227,6 @@
URL kernelURL = (URL) criteria.getKernelURL();
Configuration kernelConfig = getKernelConfiguration( kernelURL );
- String listing = ConfigurationUtil.list( kernelConfig );
//
// create the logging subsystem
@@ -252,191 +236,82 @@
kernelConfig.getChild( "logging" );
LoggingDescriptor loggingDescriptor =
createLoggingDescriptor( loggingConfig );
-
- m_logging =
- new DefaultLoggingManager(
- criteria.getWorkingDirectory(),
- loggingDescriptor,
- criteria.isDebugEnabled() );
+ final String name = loggingDescriptor.getName();
+ LoggingManager logging =
+ createLoggingManager( criteria, loggingDescriptor );
m_logger =
- m_logging.getLoggerForCategory(
- loggingDescriptor.getName() );
+ logging.getLoggerForCategory( name );
getLogger().debug( "logging system established" );
- if( criteria.isInfoEnabled() )
- {
- StringBuffer buffer =
- new StringBuffer( REZ.getString( "info.listing" ) );
-
- buffer.append( "\n" );
- buffer.append(
- "\n ${user.dir} == "
- + System.getProperty( "user.dir" ) );
- buffer.append(
- "\n ${user.home} == "
- + System.getProperty( "user.home" ) );
-
- buffer.append( "\n" );
- buffer.append( "\n ${avalon.repository.cache} == "
- + m_context.getInitialCacheDirectory() );
- buffer.append( "\n ${avalon.repository.hosts} == " );
- String[] hosts = m_context.getInitialHosts();
- for( int i=0; i<hosts.length; i++ )
- {
- if( i>0 ) buffer.append( "," );
- buffer.append( hosts[i] );
- }
-
- buffer.append( "\n" );
-
- buffer.append(
- "\n ${merlin.repository} == "
- + criteria.getRepositoryDirectory() );
-
- buffer.append(
- "\n ${merlin.lang} == "
- + criteria.getLanguageCode() );
-
- buffer.append(
- "\n ${merlin.home} == "
- + criteria.getHomeDirectory() );
-
- buffer.append(
- "\n ${merlin.system} == "
- + criteria.getSystemDirectory() );
-
- buffer.append(
- "\n ${merlin.config} == "
- + criteria.getConfigDirectory() );
-
- buffer.append(
- "\n ${merlin.kernel} == "
- + criteria.getKernelURL() );
-
- buffer.append(
- "\n ${merlin.override} == "
- + criteria.getOverridePath() );
-
- buffer.append(
- "\n ${merlin.dir} == "
- + criteria.getWorkingDirectory() );
-
- buffer.append(
- "\n ${merlin.temp} == "
- + criteria.getTempDirectory() );
-
- buffer.append(
- "\n ${merlin.context} == "
- + criteria.getContextDirectory() );
-
- buffer.append(
- "\n ${merlin.anchor} == "
- + criteria.getAnchorDirectory() );
-
- buffer.append(
- "\n ${merlin.info} == "
- + criteria.isInfoEnabled() );
-
- buffer.append(
- "\n ${merlin.debug} == "
- + criteria.isDebugEnabled() );
-
- buffer.append(
- "\n ${merlin.server} == "
- + criteria.isServerEnabled() );
-
- buffer.append(
- "\n ${merlin.autostart} == "
- + criteria.isAutostartEnabled() );
-
- buffer.append( "\n ${merlin.deployment} == " );
- URL[] urls = criteria.getDeploymentURLs();
- for( int i=0; i<urls.length; i++ )
- {
- if( i>0 ) buffer.append( "," );
- buffer.append( StringHelper.toString( urls[i] ) );
- }
- buffer.append( "\n" );
- getLogger().info( buffer.toString() );
- }
-
- //
- // create the common repository
- //
-
- Configuration repositoryConfig =
- kernelConfig.getChild( "repository" );
- File cache = criteria.getRepositoryDirectory();
- CacheManager manager =
- createCacheManager( m_context, cache, repositoryConfig );
- Repository repository = manager.createRepository();
- getLogger().debug(
- "repository established: " + repository );
-
//
- // create the <parameters>
+ // with the logging system established, check if the
+ // info listing mode is set and if so, generate a report
+ // of the current parameters
//
- Configuration paramsConfig = kernelConfig.getChild( "parameters" );
- Parameters params = Parameters.fromConfiguration(
- paramsConfig, "parameter" );
+ if( criteria.isInfoEnabled() )
+ {
+ String report = createInfoListing( m_context, criteria );
+ getLogger().info( report );
+ }
//
- // create the system context
+ // Create the system context.
//
- File anchor = criteria.getAnchorDirectory();
-
- DefaultSystemContext systemContext =
- new DefaultSystemContext(
- m_logging,
- anchor,
- criteria.getContextDirectory(),
- criteria.getTempDirectory(),
- repository,
- loggingDescriptor.getName(),
- criteria.isDebugEnabled(),
- params );
+ SystemContext systemContext =
+ createSystemContext(
+ m_context, criteria, logging, kernelConfig, name );
//
- // create the application model
+ // Create the application model. Normally the application
+ // model is empty and we will not get any errors in this
+ // process. Development errors will normally occur when
+ // adding block directives to the application model.
//
- getLogger().info( "building application model" );
- final Logger applicationLogger = m_logging.getLoggerForCategory("");
- ClassLoader api = systemContext.getCommonClassLoader();
+ Configuration appConfig =
+ kernelConfig.getChild( "container" );
ContainmentModel application =
- new DefaultContainmentModel(
- createContainmentContext(
- systemContext, applicationLogger, api,
- getContainmentProfile(
- kernelConfig.getChild( "container" ) ) ) );
+ createApplicationModel( systemContext, appConfig );
//
- // create the system model and add the application model
- // as an available system context entry
- //
+ // Create the containment model describing all of the
+ // system facilities. These facilities may include model
+ // listeners and dependent components that facilitate the
+ // customization of the runtime merlin system. The
+ // facilities model receives a privaliged system context
+ // that contains a reference to the root application model
+ // enabling listeners to register themselves for model
+ // changes.
+ //
getLogger().info( "facilities deployment" );
-
Configuration facilitiesConfig =
- kernelConfig.getChild( "system" );
+ kernelConfig.getChild( "facilities" );
+ Logger facilitiesLogger = getLogger();
- DelegatingSystemContext facilitiesContext =
+ DelegatingSystemContext system =
new DelegatingSystemContext( systemContext );
- facilitiesContext.put( "urn:merlin:dir", criteria.getWorkingDirectory() );
- facilitiesContext.put( "urn:merlin:anchor", criteria.getAnchorDirectory() );
- facilitiesContext.put( "urn:merlin:model", application );
- facilitiesContext.makeReadOnly();
+ system.put( "urn:composition:dir", criteria.getWorkingDirectory() );
+ system.put( "urn:composition:anchor", criteria.getAnchorDirectory() );
+ system.put( "urn:composition:application", application );
+ system.makeReadOnly();
- ClassLoader spi = BlockContext.class.getClassLoader();
- final Logger systemLogger = getLogger();
ContainmentModel facilities =
- new DefaultContainmentModel(
- createContainmentContext(
- facilitiesContext, systemLogger, spi,
- getContainmentProfile( facilitiesConfig ) ) );
+ createFacilitiesModel(
+ system, facilitiesLogger, facilitiesConfig );
+
+ //
+ // Assembly of the system containment model. Note .. its not sure
+ // if this function should be a part of the kernel initialization
+ // or if this belongs here in the factory. The current view is
+ // the factory does the work of constructing the artifacts for
+ // the kernel and the kernel implements the kernel
+ // startup/shutdown behaviour and the embeddor handles any post
+ // kernel management logic.
+ //
try
{
@@ -452,7 +327,8 @@
try
{
- m_system = AbstractBlock.createRootBlock( facilitiesContext, facilities
);
+ m_system =
+ AbstractBlock.createRootBlock( facilities );
}
catch( Throwable e )
{
@@ -588,6 +464,100 @@
}
/**
+ * If the kernel criteria includes a language code
+ * then set the current local to the declared value.
+ *
+ * @param criteria the kernel criteria
+ */
+ public void setupLanguageCode( KernelCriteria criteria )
+ {
+ String language = criteria.getLanguageCode();
+ if( null != language )
+ {
+ ResourceManager.clearResourceCache();
+ Locale locale = new Locale( language, "" );
+ Locale.setDefault( locale );
+ REZ =
+ ResourceManager.getPackageResources(
+ DefaultFactory.class );
+ }
+ }
+
+ /**
+ * Utility method to construct the system context.
+ * @param criteria the kernel criteria
+ * @param logging the logging manager
+ * @param config the kernel configuration
+ * @param name not sure - need to check
+ */
+ private SystemContext createSystemContext(
+ InitialContext context, KernelCriteria criteria, LoggingManager logging,
+ Configuration config, String name ) throws Exception
+ {
+
+ //
+ // create the application repository
+ //
+
+ Configuration repositoryConfig =
+ config.getChild( "repository" );
+ Repository repository =
+ createRepository( context, criteria, repositoryConfig );
+ getLogger().debug(
+ "repository established: " + repository );
+
+ //
+ // create the kernel <parameters>
+ //
+
+ Configuration paramsConfig =
+ config.getChild( "parameters" );
+ Parameters params =
+ Parameters.fromConfiguration(
+ paramsConfig, "parameter" );
+
+ //
+ // create the system context
+ //
+
+ File anchor = criteria.getAnchorDirectory();
+
+ return new DefaultSystemContext(
+ logging,
+ anchor,
+ criteria.getContextDirectory(),
+ criteria.getTempDirectory(),
+ repository,
+ name,
+ criteria.isDebugEnabled(),
+ params );
+ }
+
+ private ContainmentModel createApplicationModel(
+ SystemContext system, Configuration config ) throws Exception
+ {
+ getLogger().info( "building application model" );
+ LoggingManager logging = system.getLoggingManager();
+ final Logger logger = logging.getLoggerForCategory("");
+ ClassLoader api = system.getCommonClassLoader();
+ ContainmentProfile profile = getContainmentProfile( config );
+ ContainmentContext context =
+ createContainmentContext( system, logger, api, profile );
+ return new DefaultContainmentModel( context );
+ }
+
+ private ContainmentModel createFacilitiesModel(
+ SystemContext system, Logger logger, Configuration config )
+ throws Exception
+ {
+ ClassLoader spi = BlockContext.class.getClassLoader();
+ ContainmentProfile profile = getContainmentProfile( config );
+ return new DefaultContainmentModel(
+ createContainmentContext(
+ system, logger, spi, profile ) );
+ }
+
+ /**
* Creation of a new root containment context.
*
* @param profile a containment profile
@@ -637,6 +607,23 @@
}
}
+ /**
+ * Utility method to create the application repository.
+ * @param context the initial context
+ * @param criteria the supplied factory criteria
+ * @param config the repositotry configuration element
+ * @return the repository
+ */
+ private Repository createRepository(
+ InitialContext context, KernelCriteria criteria, Configuration config )
+ throws KernelException
+ {
+ File cache = criteria.getRepositoryDirectory();
+ CacheManager manager =
+ createCacheManager( context, cache, config );
+ return manager.createRepository();
+ }
+
private CacheManager createCacheManager(
InitialContext context, File root, Configuration config )
throws KernelException
@@ -745,6 +732,20 @@
return (String[]) list.toArray( new String[0] );
}
+ /**
+ * Utility method to create the LoggingManager.
+ * @param criteria the kernel criteria
+ * @param descriptor the logging descriptor
+ * @return the logging manager
+ */
+ private LoggingManager createLoggingManager(
+ KernelCriteria criteria, LoggingDescriptor descriptor ) throws Exception
+ {
+ File dir = criteria.getWorkingDirectory();
+ boolean debug = criteria.isDebugEnabled();
+ return new DefaultLoggingManager( dir, descriptor, debug );
+ }
+
/**
* Utility method to create a new logging descriptor from a
* configuration instance.
@@ -959,6 +960,104 @@
return new FileTargetProvider( file );
}
+ private String createInfoListing(
+ InitialContext context, KernelCriteria criteria )
+ {
+ StringBuffer buffer =
+ new StringBuffer( REZ.getString( "info.listing" ) );
+
+ buffer.append( "\n" );
+ buffer.append(
+ "\n ${user.dir} == "
+ + System.getProperty( "user.dir" ) );
+ buffer.append(
+ "\n ${user.home} == "
+ + System.getProperty( "user.home" ) );
+
+ buffer.append( "\n" );
+ buffer.append( "\n ${avalon.repository.cache} == "
+ + context.getInitialCacheDirectory() );
+ buffer.append( "\n ${avalon.repository.hosts} == " );
+ String[] hosts = context.getInitialHosts();
+ for( int i=0; i<hosts.length; i++ )
+ {
+ if( i>0 ) buffer.append( "," );
+ buffer.append( hosts[i] );
+ }
+
+ buffer.append( "\n" );
+
+ buffer.append(
+ "\n ${merlin.repository} == "
+ + criteria.getRepositoryDirectory() );
+
+ buffer.append(
+ "\n ${merlin.lang} == "
+ + criteria.getLanguageCode() );
+
+ buffer.append(
+ "\n ${merlin.home} == "
+ + criteria.getHomeDirectory() );
+
+ buffer.append(
+ "\n ${merlin.system} == "
+ + criteria.getSystemDirectory() );
+
+ buffer.append(
+ "\n ${merlin.config} == "
+ + criteria.getConfigDirectory() );
+
+ buffer.append(
+ "\n ${merlin.kernel} == "
+ + criteria.getKernelURL() );
+
+ buffer.append(
+ "\n ${merlin.override} == "
+ + criteria.getOverridePath() );
+
+ buffer.append(
+ "\n ${merlin.dir} == "
+ + criteria.getWorkingDirectory() );
+
+ buffer.append(
+ "\n ${merlin.temp} == "
+ + criteria.getTempDirectory() );
+
+ buffer.append(
+ "\n ${merlin.context} == "
+ + criteria.getContextDirectory() );
+
+ buffer.append(
+ "\n ${merlin.anchor} == "
+ + criteria.getAnchorDirectory() );
+
+ buffer.append(
+ "\n ${merlin.info} == "
+ + criteria.isInfoEnabled() );
+
+ buffer.append(
+ "\n ${merlin.debug} == "
+ + criteria.isDebugEnabled() );
+
+ buffer.append(
+ "\n ${merlin.server} == "
+ + criteria.isServerEnabled() );
+
+ buffer.append(
+ "\n ${merlin.autostart} == "
+ + criteria.isAutostartEnabled() );
+
+ buffer.append( "\n ${merlin.deployment} == " );
+ URL[] urls = criteria.getDeploymentURLs();
+ for( int i=0; i<urls.length; i++ )
+ {
+ if( i>0 ) buffer.append( "," );
+ buffer.append( StringHelper.toString( urls[i] ) );
+ }
+ buffer.append( "\n" );
+
+ return buffer.toString();
+ }
/**
* Create a shutdown hook that will trigger shutdown of the supplied kernel.
1.1.2.5 +3 -2
avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultKernel.java
Index: DefaultKernel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultKernel.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- DefaultKernel.java 9 Jan 2004 20:29:49 -0000 1.1.2.4
+++ DefaultKernel.java 12 Jan 2004 00:17:20 -0000 1.1.2.5
@@ -242,7 +242,7 @@
try
{
m_application =
- AbstractBlock.createRootBlock( m_context, m_model );
+ AbstractBlock.createRootBlock( m_model );
setState( INITIALIZED );
}
catch( Throwable e )
@@ -398,4 +398,5 @@
{
return m_logger;
}
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]