You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2002/08/08 12:02:36 UTC
cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder XMLProfileCreator.java
mcconnell 2002/08/08 03:02:36
Modified: assembly build.xml
assembly/demo/src/java/org/apache/excalibur/playground
EmbeddedDemo.java EmbeddedDemo.xinfo
assembly/src/etc kernel.xml
assembly/src/java/org/apache/excalibur/merlin/assembly
ContainerManager.java DefaultLoggerManager.java
ProfileRegistry.java TypeManager.java
assembly/src/java/org/apache/excalibur/merlin/container
Container.java DefaultContainer.java
assembly/src/java/org/apache/excalibur/merlin/kernel
DefaultKernel.java
assembly/src/java/org/apache/excalibur/merlin/model
ContainerDescriptor.java Profile.java
assembly/src/java/org/apache/excalibur/merlin/model/builder
XMLProfileCreator.java
Log:
General updates to support container variations and management of embedded kernels.
Revision Changes Path
1.36 +1 -1 jakarta-avalon-excalibur/assembly/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/build.xml,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- build.xml 2 Aug 2002 06:36:09 -0000 1.35
+++ build.xml 8 Aug 2002 10:02:34 -0000 1.36
@@ -128,7 +128,7 @@
<include name="**/merlin/**/*.xml"/>
<include name="**/merlin/**/*.properties"/>
<include name="**/merlin/**/*.xinfo"/>
- <include name="**/merlin/**/*.xprofiles"/>
+ <include name="**/merlin/**/*.xprofile"/>
<include name="**/merlin/**/*.xconfig"/>
</fileset>
</copy>
1.7 +57 -21 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/EmbeddedDemo.java
Index: EmbeddedDemo.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/EmbeddedDemo.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- EmbeddedDemo.java 5 Aug 2002 12:39:37 -0000 1.6
+++ EmbeddedDemo.java 8 Aug 2002 10:02:34 -0000 1.7
@@ -27,8 +27,8 @@
import org.apache.excalibur.meta.info.ReferenceDescriptor;
/**
- * This is a minimal demonstration component that implements the
- * <code>BasicService</code> interface and has no dependencies.
+ * This is a demonstration of the embedding of a new kernel into the container
+ * container this component.
*
* @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
*/
@@ -43,7 +43,6 @@
public void contextualize( Context context ) throws ContextException
{
- m_home = (File) context.get("avalon:home");
m_context = context;
}
@@ -56,34 +55,72 @@
getLogger().info("initialize");
//
- // create the kernel and get the root container
+ // Grap a reference to the container class loader.
+ //
+
+ ContainerManager manager;
+ if( Thread.currentThread().getContextClassLoader() instanceof ContainerManager )
+ {
+ manager = (ContainerManager) Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ final String error = "Attempting to execute demo outside of a container context.";
+ throw new IllegalStateException( error );
+ }
+
+ //
+ // Create the kernel with a root container named "work".
//
m_kernel = new DefaultKernel( );
- m_kernel.enableLogging( getLogger().getChildLogger( "system" ) );
- m_kernel.contextualize( m_context );
- m_kernel.configure( new DefaultConfiguration( "config", null ) );
+ DefaultContext context = new DefaultContext( m_context );
+ context.put( DefaultKernel.PATH_KEY, "work" );
+ m_kernel.contextualize( context );
+ m_kernel.configure( new DefaultConfiguration( "", null ) );
m_kernel.initialize();
//
- // get the manager and the root container
+ // Get the root container from the kernel we just created.
//
- ContainerManager manager = (ContainerManager) Thread.currentThread().getContextClassLoader();
- Container container = m_kernel.getRootContainer();
+ Container root = m_kernel.getRootContainer();
+
+ //
+ // Add a container to our root container programatically. First,
+ // get a container profile using an versioned interface reference then
+ // add this to the root container to define another new sub-container.
+ //
+
+ ReferenceDescriptor containerInterface =
+ new ReferenceDescriptor( "org.apache.excalibur.merlin.container.Container" );
+ ContainerDescriptor cd = (ContainerDescriptor) manager.getProfile( containerInterface );
+ Container container;
+ if( cd != null )
+ {
+ container = root.createSubContainer( "admin", cd, new ClasspathDescriptor() );
+ }
+ else
+ {
+ throw new IllegalStateException("Manager returned a null container profile.");
+ }
//
- // we can either locate or create a profile - in the following example we will
- // attempt to locate an existing profile and add it to the container - if we wanted
- // to we could dynamically build the profile and add it to the container
+ // Add a component to the container programatically.
+ // We can either locate or create a profile - in the following example we will
+ // attempt to locate an existing component profile and add it to the container -
+ // if we wanted to we could dynamically build the profile and add it to the
+ // container.
//
- DependencyDescriptor descriptor =
- new DependencyDescriptor(
- "my-component",
- new ReferenceDescriptor( "org.apache.excalibur.playground.SimpleService" )
- );
- Profile profile = manager.getProfile( descriptor );
+ //DependencyDescriptor descriptor =
+ // new DependencyDescriptor(
+ // "my-component",
+ // new ReferenceDescriptor( "org.apache.excalibur.playground.SimpleService" ) );
+ //Profile profile = manager.getProfile( descriptor );
+
+ Profile profile = manager.getProfile(
+ new ReferenceDescriptor( "org.apache.excalibur.playground.SimpleService" ) );
//
// install the profile into the container triggering profile assembly
@@ -91,7 +128,7 @@
if( profile != null )
{
- getLogger().info("dynamic profile: " + profile );
+ getLogger().info( "dynamic profile: " + profile );
container.install( new Profile[]{ profile } );
getLogger().info("installation sucessfull" );
}
@@ -99,7 +136,6 @@
{
getLogger().warn("manager return a null profile - cannot proceed");
}
-
}
//=======================================================================
1.2 +1 -1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/EmbeddedDemo.xinfo
Index: EmbeddedDemo.xinfo
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/EmbeddedDemo.xinfo,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EmbeddedDemo.xinfo 2 Aug 2002 06:29:20 -0000 1.1
+++ EmbeddedDemo.xinfo 8 Aug 2002 10:02:34 -0000 1.2
@@ -6,7 +6,7 @@
<component-info>
<component>
- <name>embedded</name>
+ <name>embeddor</name>
</component>
<context>
1.26 +1 -1 jakarta-avalon-excalibur/assembly/src/etc/kernel.xml
Index: kernel.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/kernel.xml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- kernel.xml 6 Aug 2002 06:24:16 -0000 1.25
+++ kernel.xml 8 Aug 2002 10:02:34 -0000 1.26
@@ -158,7 +158,7 @@
<!--
Demonstration of a component that contains an embedded kernel.
-->
- <component name="embedded"
+ <component name="embedder"
class="org.apache.excalibur.playground.EmbeddedDemo" activation="true">
<context>
<import key="avalon:home" name="avalon:home"/>
1.7 +83 -139 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java
Index: ContainerManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ContainerManager.java 5 Aug 2002 12:39:37 -0000 1.6
+++ ContainerManager.java 8 Aug 2002 10:02:35 -0000 1.7
@@ -48,6 +48,7 @@
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.merlin.model.Resource;
import org.apache.excalibur.merlin.model.builder.ProfileBuilder;
+import org.apache.excalibur.merlin.model.builder.ContainerBuilder;
import org.apache.excalibur.meta.info.PhaseDescriptor;
import org.apache.excalibur.meta.info.ServiceDescriptor;
import org.apache.excalibur.meta.info.ReferenceDescriptor;
@@ -117,12 +118,16 @@
private List m_services = new LinkedList();
/**
- * Utility class used to create type meta info for components not explicity declared
- * in the meta data model.
+ * Utility class used to create component profile meta data.
*/
private ProfileBuilder m_builder = new ProfileBuilder();
/**
+ * Utility class used to create container profile meta data.
+ */
+ private ContainerBuilder m_containerBuilder = new ContainerBuilder();
+
+ /**
* Utility class that manages supply of context, config, services, etc. during
* startup of a profile.
*/
@@ -182,11 +187,8 @@
* The container model that contains the container's classpath declaration,
* explicit profile declarations, and defintions of the subsidiary containers.
*/
-
private CategoriesDescriptor m_categories;
- private final boolean m_root;
-
//===================================================================
// constructor
//===================================================================
@@ -194,68 +196,39 @@
/**
* Creation of a new Profile Manager.
* @param parent the parent classloader
- * @param name the name to assign to this classloader (used with logging)
- * @param root if TRUE, logging catagories are top level, otherwise logging
- * catagories are subsidary to the parent
- */
- public ContainerManager( )
- {
- this( "root" );
- }
-
- /**
- * Creation of a new <code>ContainerManager</code>.
- * @param name the name to assign to this classloader (used with logging)
- */
- public ContainerManager( String name )
- {
- this( Thread.currentThread().getContextClassLoader(), name );
- }
-
- /**
- * Creation of a new <code>ContainerManager</code>.
- * @param parent the parent classloader
- * @param name the name to assign to this classloader (used with logging)
- */
- public ContainerManager( ClassLoader parent, String name )
- {
- this( parent, name, true );
- }
-
- /**
- * Creation of a new Profile Manager.
- * @param parent the parent classloader
- * @param name the name to assign to this classloader (used with logging)
- * @param root if TRUE, logging catagories are top level, otherwise logging
- * catagories are subsidary to the parent
+ * @param path the path to assign to this classloader
*/
- public ContainerManager( ClassLoader parent, String name, boolean root )
+ public ContainerManager( ClassLoader parent, String path )
{
super( parent );
- m_root = root;
- m_name = name;
+ m_name = path.replace('/','.');
if( parent instanceof ContainerManager )
{
m_parent = (ContainerManager) parent;
m_map = m_parent.getDependencyMap();
}
- else
+ else
{
m_map = new DependencyGraph();
}
- if( !root )
+ if( parent instanceof KernelManager )
+ {
+ m_path = m_parent.getPath();
+ }
+ else if( parent instanceof ContainerManager )
{
- m_path = m_parent.getPath() + DELIMITER + m_name;
+ m_path = m_parent.getPath() + DELIMITER + path;
}
else
{
- m_path = DELIMITER + m_name;
+ m_path = DELIMITER + path;
}
}
+
//=======================================================================
// Contextualizable
//=======================================================================
@@ -270,15 +243,6 @@
try
{
- m_loggingDescriptor = (LoggingDescriptor) context.get( LOGGING_DESCRIPTOR_KEY );
- }
- catch( ContextException f )
- {
- // optional
- }
-
- try
- {
m_categories = (CategoriesDescriptor) context.get( CATEGORIES_DESCRIPTOR_KEY );
}
catch( ContextException e )
@@ -298,30 +262,6 @@
XMLContainerUtil creator = new XMLContainerUtil();
//
- // setup the logging if we are root
- //
-
- try
- {
- getLoggingManager();
- }
- catch( Throwable e )
- {
- if( m_loggingDescriptor == null )
- m_loggingDescriptor = new LoggingDescriptor();
-
- try
- {
- m_logging = new DefaultLoggerManager( m_loggingDescriptor );
- }
- catch( Throwable g )
- {
- throw new ContextException(
- "logging establishment failure", g );
- }
- }
-
- //
// take care of logging category declarations from the configuration
// if not already supplied under the context
//
@@ -339,12 +279,6 @@
String path = getPath().replace('/','.').substring(1);
getLoggingManager().addCategories( path, m_categories );
- if( getLogger() == null )
- {
- enableLogging( getLoggingManager().getLoggerForCategory( path ) );
- getLocalLogger().info("logging established: " + getPath() );
- }
-
//
// start internal initialization
//
@@ -383,7 +317,20 @@
getLocalLogger().debug("type count: " + types.length );
for( int i=0; i<types.length; i++ )
{
- Profile[] profiles = m_builder.build( this, types[i] );
+ Type type = types[i];
+ String classname = type.getInfo().getImplementationKey();
+ Class clazz = loadClass( classname );
+
+ Profile[] profiles;
+ if( Container.class.isAssignableFrom( clazz ) )
+ {
+ profiles = m_containerBuilder.build( this, type );
+ }
+ else
+ {
+ profiles = m_builder.build( this, type );
+ }
+
for( int j=0; j<profiles.length; j++ )
{
addProfile( profiles[j] );
@@ -471,7 +418,7 @@
public void dispose()
{
// need to complete this ...
- // if stop has ben invoked then disops has already been invoked on
+ // if stop has ben invoked then dispose has already been invoked on
// all of the component we are managing (see LifecycleHelper) - but
// aside from that, we should be going though and cleaning up state
// locally
@@ -481,25 +428,21 @@
// ContainerManager
//===================================================================
- public ContainerManager createContainerManager( ContainerDescriptor descriptor, boolean root )
+ public ContainerManager createContainerManager(
+ String name,
+ ContainerDescriptor descriptor,
+ ClasspathDescriptor classpath,
+ Logger logger )
{
try
{
- final String name = descriptor.getName();
- ContainerManager loader = new ContainerManager( this, name, root );
+ ContainerManager loader = new ContainerManager( this, name );
DefaultContext context = new DefaultContext( m_context );
context.put( ContainerManager.CATEGORIES_DESCRIPTOR_KEY, descriptor.getCategories() );
- context.put( TypeManager.CLASSPATH_DESCRIPTOR_KEY, descriptor.getClasspath() );
+ context.put( TypeManager.CLASSPATH_DESCRIPTOR_KEY, classpath );
+
context.makeReadOnly();
- if( root )
- {
- Logger logger = getLoggingManager().getLoggerForCategory( descriptor.getName() );
- loader.enableLogging( logger );
- }
- else
- {
- loader.enableLogging( getLogger().getChildLogger( descriptor.getName() ) );
- }
+ loader.enableLogging( logger );
loader.contextualize( context );
loader.initialize();
return loader;
@@ -522,23 +465,16 @@
return m_path;
}
- public DefaultLoggerManager getLoggingManager()
+ protected DefaultLoggerManager getLoggingManager()
{
- if( m_logging != null )
+ ContainerManager parent = getParentManager();
+ if( parent != null )
{
- return m_logging;
+ return parent.getLoggingManager();
}
else
{
- ContainerManager parent = getParentManager();
- if( parent != null )
- {
- return parent.getLoggingManager();
- }
- else
- {
- throw new NullPointerException("logging");
- }
+ throw new NullPointerException("logging");
}
}
@@ -672,13 +608,30 @@
/**
* Return a single profile matching a supplied versioned interface spec
- * using a supplied selector.
+ * using a default selector.
*
* @param reference a consumer component dependency declaration
* @return the selected profile
*/
+ public Profile getProfile( ReferenceDescriptor reference )
+ {
+ return getProfile( reference, m_selector );
+ }
+
+
+ /**
+ * Return a single profile matching a supplied versioned interface spec
+ * using a supplied selector.
+ *
+ * @param reference the version interface reference
+ * @param selector the profile selector to use
+ * @return the selected profile
+ */
public Profile getProfile( ReferenceDescriptor reference, Selector selector )
{
+ if( selector == null )
+ throw new NullPointerException("selector");
+
Profile[] profiles = getProfiles( reference );
return selector.select( profiles );
}
@@ -849,7 +802,7 @@
* Returns the parent profile manager or null if this is the root manager.
* @return the parent
*/
- private ContainerManager getParentManager()
+ protected ContainerManager getParentManager()
{
return m_parent;
}
@@ -897,16 +850,12 @@
return table;
}
- private Selector getSelector( PhaseDescriptor phase )
+ private Selector getSelector( ReferenceDescriptor reference, String selectorClassName )
{
- // if the phase declares a selector class then use that,
- // otherwise, look for a default phase type selector - if none
- // use the DefaultSelector
-
- String selectorName = phase.getAttribute("avalon:selector");
+ String selectorName = selectorClassName;
if( selectorName == null )
- selectorName = phase.getReference().getClassname() + "Selector";
+ selectorName = reference.getClassname() + "Selector";
try
{
Class clazz = loadClass( selectorName );
@@ -923,6 +872,17 @@
}
}
+
+ private Selector getSelector( PhaseDescriptor phase )
+ {
+
+ // if the phase declares a selector class then use that,
+ // otherwise, look for a default phase type selector - if none
+ // use the DefaultSelector
+
+ return getSelector( phase.getReference(), phase.getAttribute("avalon:selector") );
+ }
+
private Selector getSelector( DependencyDescriptor dependency )
{
@@ -930,22 +890,6 @@
// otherwise, look for a default service type selector - if none
// use the DefaultSelector
- String selectorName = dependency.getAttribute("avalon:selector");
- if( selectorName == null )
- selectorName = dependency.getService().getClassname() + "Selector";
- try
- {
- Class clazz = loadClass( selectorName );
- Selector selector = (Selector) clazz.newInstance();
- if( selector instanceof LogEnabled )
- {
- ((LogEnabled)selector).enableLogging( getLocalLogger().getChildLogger("selector") );
- }
- return selector;
- }
- catch( Throwable e )
- {
- return m_selector;
- }
+ return getSelector( dependency.getService(), dependency.getAttribute("avalon:selector") );
}
}
1.4 +12 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java
Index: DefaultLoggerManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultLoggerManager.java 4 Aug 2002 12:04:00 -0000 1.3
+++ DefaultLoggerManager.java 8 Aug 2002 10:02:35 -0000 1.4
@@ -309,7 +309,18 @@
}
else
{
- return new LogKitLogger( getHierarchy().getLoggerFor( category ) );
+ String cat;
+ if( category.indexOf("/") > -1 )
+ {
+ cat = category.replace('/','.');
+ if( cat.startsWith(".") )
+ cat = cat.substring(1);
+ }
+ else
+ {
+ cat = category;
+ }
+ return new LogKitLogger( getHierarchy().getLoggerFor( cat ) );
}
}
1.7 +15 -11 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileRegistry.java
Index: ProfileRegistry.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileRegistry.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ProfileRegistry.java 5 Aug 2002 12:39:37 -0000 1.6
+++ ProfileRegistry.java 8 Aug 2002 10:02:35 -0000 1.7
@@ -84,21 +84,24 @@
* @param profiles the set of profiles to assemble
* @exception Exception if an error occurs during assembly
*/
- public void assemble( Profile[] profiles ) throws Exception
+ public DependencyGraph assemble( Profile[] profiles ) throws Exception
{
+ DependencyGraph map = new DependencyGraph();
for( int i=0; i<profiles.length; i++ )
{
Profile profile = profiles[i];
getLogger().debug("assembly target: " + profile );
ArrayList visited = new ArrayList();
- assembleProfile( profile, visited, "" );
+ assembleProfile( map, profile, visited, "" );
final String name =
m_manager.getPath() + ContainerManager.DELIMITER + profile.getName();
final Resource resource = m_manager.getResource( profile, true );
getLogger().debug( "created explicit resource for: " + name );
m_map.add( profile );
+ map.add( profile );
}
+ return map;
}
@@ -131,7 +134,7 @@
* @param pad used in formatting log messages
*/
private void assembleProfile(
- Profile profile, List visited, String pad ) throws Exception
+ DependencyGraph map, Profile profile, List visited, String pad ) throws Exception
{
getLogger().debug( pad + "assemble: " + profile );
String pad2 = pad + " ";
@@ -158,7 +161,7 @@
// have at least one solution
//
- boolean ok = assembleProviders( profile, dependency, visited, pad2 );
+ boolean ok = assembleProviders( map, profile, dependency, visited, pad2 );
if( !ok )
{
final String message =
@@ -199,6 +202,7 @@
Resource resource = m_manager.getResource( supplier, true );
profile.addProvider( role, resource );
m_map.add( supplier );
+ map.add( supplier );
}
}
@@ -213,7 +217,7 @@
PhaseDescriptor phase = phases[i];
if( profile.getExtension( phase ) == null )
{
- boolean ok = assembleManagers( profile, phase, visited, pad2 );
+ boolean ok = assembleManagers( map, profile, phase, visited, pad2 );
if( !ok )
{
final String message = "Could not locate an extension for the phase: "
@@ -252,13 +256,13 @@
m_manager.getResource( supplier, true );
profile.addExtension( phase, supplier, resource );
m_map.add( supplier );
-
+ map.add( supplier );
}
}
}
private boolean assembleManagers(
- Profile source, PhaseDescriptor phase, List visited, String pad )
+ DependencyGraph map, Profile source, PhaseDescriptor phase, List visited, String pad )
throws Exception
{
boolean ok = false;
@@ -276,7 +280,7 @@
{
try
{
- assembleProfile( profile, visited, pad + " " );
+ assembleProfile( map, profile, visited, pad + " " );
ok = true;
getLogger().debug( pad + " extension: " + profile );
}
@@ -294,7 +298,7 @@
}
private boolean assembleProviders(
- Profile source, DependencyDescriptor dependency, List visited, String pad )
+ DependencyGraph map, Profile source, DependencyDescriptor dependency, List visited, String pad )
throws Exception
{
boolean ok = false;
@@ -307,7 +311,7 @@
{
try
{
- assembleProfile( profile, visited, pad + " " );
+ assembleProfile( map, profile, visited, pad + " " );
ok = true;
getLogger().debug( pad + " provider: " + profile );
}
1.7 +12 -11 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java
Index: TypeManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TypeManager.java 5 Aug 2002 12:39:37 -0000 1.6
+++ TypeManager.java 8 Aug 2002 10:02:35 -0000 1.7
@@ -83,8 +83,9 @@
*/
public static final String CLASSPATH_DESCRIPTOR_KEY = "classpath";
- private static final String DEFAULT_CONTAINER_CLASS =
- "org/apache/excalibur/merlin/container/DefaultContainer";
+ public static final String DEFAULT_CONTAINER_CLASS =
+ "org.apache.excalibur.merlin.container.DefaultContainer";
+
//===================================================================
// state
@@ -233,24 +234,24 @@
}
//
- // make sure the Merlin default container type is declared if this is the
- // root classloader
+ // install the classpath
//
- if( !( getParent() instanceof TypeManager ))
+ if( m_classpath != null )
{
- m_types.addType( DEFAULT_CONTAINER_CLASS );
+ getLocalLogger().debug("installing classpath");
+ addClasspath( m_classpath );
}
//
- // install the classpath
+ // declare bootstrap types
//
- if( m_classpath != null )
+ if( !( getParent() instanceof TypeManager ))
{
- getLocalLogger().debug("installing classpath");
- addClasspath( m_classpath );
+ Type type = m_types.addType( DEFAULT_CONTAINER_CLASS );
}
+
}
/**
1.10 +13 -29 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java
Index: Container.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Container.java 4 Aug 2002 06:43:20 -0000 1.9
+++ Container.java 8 Aug 2002 10:02:35 -0000 1.10
@@ -11,6 +11,8 @@
import org.apache.excalibur.merlin.Controller;
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.merlin.model.Resource;
+import org.apache.excalibur.merlin.model.ContainerDescriptor;
+import org.apache.excalibur.merlin.model.ClasspathDescriptor;
import org.apache.excalibur.meta.info.ReferenceDescriptor;
import org.apache.excalibur.meta.info.Type;
@@ -77,34 +79,6 @@
int getState();
/**
- * Adds a <code>StateListener</code> to the container. A state listener
- * will be informaed of changes to the state of the container it is listening to.
- *
- * @param listener the listener to add to the container
- */
- void addStateListener( StateListener listener );
-
- /**
- * Removes a <code>StateListener</code> from the container.
- *
- * @param listener the listener to remove from the container
- */
- void removeStateListener( StateListener listener );
-
- /**
- * Adds a <code>ContainerListener</code> to the container. The listener will be
- * informed of the addition and removal of containers from/to the tartget container.
- *
- * @param listener the container listener to add
- */
- void addContainerListener( ContainerListener listener );
-
- /**
- * Removes a <code>ContainerListener</code>.
- */
- void removeContainerListener( ContainerListener listener );
-
- /**
* Returns the set of subsidiary continers container within this container.
*
* @return the containers
@@ -125,5 +99,15 @@
*/
public void install( Profile[] profiles ) throws Exception;
+ /**
+ * Creation of a new empty container associated as a subsidiary of this container.
+ *
+ * @param name the name to apply to the new container
+ * @param descriptor the container meta descriptor
+ * @param classpath the container classpath
+ * @exception Exception is an error occurs
+ */
+ public Container createSubContainer(
+ String name, ContainerDescriptor descriptor, ClasspathDescriptor classpath ) throws Exception;
}
1.26 +203 -77 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java
Index: DefaultContainer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- DefaultContainer.java 5 Aug 2002 12:39:37 -0000 1.25
+++ DefaultContainer.java 8 Aug 2002 10:02:35 -0000 1.26
@@ -76,6 +76,7 @@
import org.apache.excalibur.merlin.model.CategoriesDescriptor;
import org.apache.excalibur.merlin.model.builder.XMLContainerUtil;
import org.apache.excalibur.merlin.Controller;
+import org.apache.excalibur.configuration.ConfigurationUtil;
/**
* Default container implementation that manages a registry of componet providers and
@@ -102,6 +103,21 @@
*/
public static final String DESCRIPTOR_KEY = "descriptor";
+ /**
+ * Context key used to locate a state listener.
+ */
+ public static final String STATE_LISTENER_KEY = "state-listener";
+
+ /**
+ * Context key used to locate a content listener.
+ */
+ public static final String CONTAINER_LISTENER_KEY = "container-listener";
+
+ /**
+ * Context key used to locate subsidiary container configurations.
+ */
+ public static final String CONFIGURATIONS_KEY = "configurations";
+
private static final Resources REZ =
ResourceManager.getPackageResources( DefaultContainer.class );
@@ -167,15 +183,27 @@
*/
private Thread m_thread;
+ private Configuration[] m_configs;
+
//=======================================================================
// Contextualizable
//=======================================================================
/**
- * <p>Service context from which the container meta data model is provided.</p>
+ * <p>Service context from which the container meta data model,
+ * container manager, subsidiary container configurations, and a state listener
+ * is supplied.</p>
* <ul>
* <li>{@link #MANAGER_KEY} the container manager
* a {@link ContainerManager} (REQUIRED}</li>
+ * <li>{@link #DESCRIPTOR_KEY} the container meta data
+ * {@link ContainerDescriptor} (REQUIRED}</li>
+ * <li>{@link #CONFIGURATIONS_KEY} the set of subsidiary container
+ * configurations {@link Configuration}[] (OPTIONAL}</li>
+ * <li>{@link #STATE_LISTENER_KEY} a container state listener
+ {@link StateListener} (OPTIONAL}</li>
+ * <li>{@link #CONTAINER_LISTENER_KEY} a container container listener
+ {@link ContainerListener} (OPTIONAL}</li>
* </ul>
* @param context the service context value
*/
@@ -183,6 +211,35 @@
{
m_manager = (ContainerManager) context.get( MANAGER_KEY );
m_descriptor = (ContainerDescriptor) context.get( DESCRIPTOR_KEY );
+
+ try
+ {
+ m_configs = (Configuration[]) context.get( CONFIGURATIONS_KEY );
+ }
+ catch( ContextException e )
+ {
+ m_configs = new Configuration[0];
+ }
+
+ try
+ {
+ StateListener listener = (StateListener) context.get( STATE_LISTENER_KEY );
+ addStateListener( listener );
+ }
+ catch( ContextException e )
+ {
+ // optional
+ }
+
+ try
+ {
+ ContainerListener listener = (ContainerListener) context.get( CONTAINER_LISTENER_KEY );
+ addContainerListener( listener );
+ }
+ catch( ContextException e )
+ {
+ // optional
+ }
}
//=======================================================================
@@ -191,7 +248,12 @@
/**
* Provision of a configuration to the container that is used to establish
- * the EXPLICIT components to be included and defintion of subcontainers.
+ * the EXPLICIT components to be included and defintion of subcontainers.
+ * NOTE: The configuration of the actual container is not supplied here.
+ * Instead, the implementation may access the configuration supplied under the
+ * {@link ContainerDescriptor} instance supplied during the contextualization
+ * phase.
+ *
* @param config the container configuration
*/
public void configure( Configuration config )
@@ -283,32 +345,11 @@
getLogger().debug( "initialization" );
- Configuration[] components = m_configuration.getChildren("component");
- for( int i=0; i<components.length; i++ )
- {
- Configuration config = components[i];
- final String classname = config.getAttribute("class");
- try
- {
- Type type = m_manager.getType( classname );
- Profile profile = m_creator.createProfile( type, config );
- m_descriptor.addComponent( profile );
- m_manager.addProfile( profile );
- }
- catch( TypeException e )
- {
- final String warning =
- "Ignoring component declaration at " + config.getLocation()
- + " due to unknown type: " + classname;
- getLogger().warn( warning );
- }
- }
-
//
// initiate component assembly
//
- getLogger().debug("explicit profile registration");
+ getLogger().debug("assembly");
Profile[] profiles = m_descriptor.getComponents( Profile.EXPLICIT, true );
try
{
@@ -327,12 +368,14 @@
getLogger().debug("subsidiary container creation" );
- final Configuration[] configs = m_configuration.getChildren("container");
- for( int i=0; i<configs.length; i++ )
+ if( m_configs == null )
+ m_configs = new Configuration[0];
+
+ for( int i=0; i<m_configs.length; i++ )
{
- final Configuration conf = configs[i];
- Container container = createContainer( conf );
- m_containers.add( container );
+ final Configuration conf = m_configs[i];
+ final Container container = createContainer( conf );
+ //m_containers.add( container );
}
getLogger().debug("commence wait" );
@@ -541,10 +584,10 @@
case DISPOSED:
getLogger().debug(
"removing subsidiary container: " + container.getName() );
- container.removeStateListener( this );
+ //container.removeStateListener( this );
m_containers.remove( container );
fireStructuralChange(
- new ContainerEvent( this, container, ContainerEvent.REMOVE ) );
+ new ContainerEvent( this, container, ContainerEvent.REMOVE ) );
}
}
@@ -575,7 +618,7 @@
/**
* Adds a <code>StateListener</code>.
*/
- public void addStateListener( StateListener listener )
+ protected void addStateListener( StateListener listener )
{
synchronized( m_stateListeners )
{
@@ -586,7 +629,7 @@
/**
* Removes a <code>StateListener</code>.
*/
- public void removeStateListener( StateListener listener )
+ protected void removeStateListener( StateListener listener )
{
synchronized( m_stateListeners )
{
@@ -597,7 +640,7 @@
/**
* Adds a <code>ContainerListener</code>.
*/
- public void addContainerListener( ContainerListener listener )
+ protected void addContainerListener( ContainerListener listener )
{
synchronized( m_containerListeners )
{
@@ -608,7 +651,7 @@
/**
* Removes a <code>ContainerListener</code>.
*/
- public void removeContainerListener( ContainerListener listener )
+ protected void removeContainerListener( ContainerListener listener )
{
synchronized( m_containerListeners )
{
@@ -808,68 +851,151 @@
}
/**
+ * Creation of a new empty container associated as a subsidiary of this container.
+ *
+ * @param descriptor the container meta descriptor
+ * @exception Exception is an error occurs
+ */
+ public Container createSubContainer(
+ String name,
+ ContainerDescriptor descriptor,
+ ClasspathDescriptor classpath )
+ throws Exception
+ {
+ return createContainer( name, descriptor, classpath, new Configuration[0], new Configuration[0] );
+ }
+
+ /**
+ * Internal utility to create and add a new subsidiary container.
+ *
+ * @param config the subsidiary container configuration
+ * @exception Exception is an error occurs
+ */
+ private DefaultContainer createContainer(
+ String name,
+ ContainerDescriptor descriptor,
+ ClasspathDescriptor classpath,
+ Configuration[] components,
+ Configuration[] containers )
+ throws Exception
+ {
+
+ try
+ {
+ //
+ // create the manager
+ //
+
+ final ContainerManager manager =
+ m_manager.createContainerManager(
+ name, descriptor, classpath, getLogger().getChildLogger( name ) );
+
+ //
+ // populate the descriptor with the components it contains
+ //
+
+ for( int i=0; i<components.length; i++ )
+ {
+ final Configuration component = components[i];
+ final String cn = component.getAttribute("class");
+ try
+ {
+ final Type t = manager.getType( cn );
+ final Profile profile = m_creator.createProfile( t, component );
+ manager.addProfile( profile );
+ descriptor.addComponent( profile );
+ }
+ catch( TypeException e )
+ {
+ final String warning =
+ "Ignoring component declaration at " + component.getLocation()
+ + " due to unknown type: " + cn;
+ getLogger().warn( warning );
+ }
+ }
+
+ //
+ // create the container
+ //
+
+ getLogger().debug("creating subsidiary container: " + name );
+ DefaultContext context = new DefaultContext();
+ context.put( MANAGER_KEY, manager );
+ context.put( DESCRIPTOR_KEY, descriptor );
+ context.put( CONFIGURATIONS_KEY, containers );
+ context.put( STATE_LISTENER_KEY, this );
+ context.makeReadOnly();
+
+ DefaultContainer container =
+ createContainerInstance(
+ manager, descriptor.getType().getInfo().getImplementationKey() );
+
+ synchronized( m_containers )
+ {
+ m_containers.add( container );
+ }
+
+ final Logger logger = getLogger().getChildLogger( name );
+ container.enableLogging( logger );
+ container.contextualize( context );
+ container.configure( descriptor.getConfiguration( manager ) );
+ container.initialize( );
+ return container;
+ }
+ catch( Throwable e )
+ {
+ final String error = "Error creating a subsidiary container.";
+ throw new ContainerException( error, e );
+ }
+ }
+
+ /**
* Internal utility to create a subsidiary container.
*
- * @param descriptor the subsidiary container descriptor
+ * @param config the subsidiary container configuration
* @exception Exception is an error occurs
*/
private DefaultContainer createContainer( Configuration config ) throws Exception
{
- ContainerManager manager;
- ContainerDescriptor descriptor;
- String name = null;
try
{
- name = config.getAttribute("name");
- Type type = m_manager.getType( this.getClass().getName() );
+ final String name = config.getAttribute("name");
+ final String classname =
+ config.getAttribute( "class", DefaultContainer.class.getName() );
+ final Type type = m_manager.getType( classname );
- ClasspathDescriptor classpath =
- m_creator.createClasspathDescriptor( config.getChild("classpath") );
- CategoriesDescriptor categories =
+ final CategoriesDescriptor categories =
m_creator.createCategoriesDescriptor( name, config.getChild("categories") );
final boolean enabled =
- config.getAttributeAsBoolean( "enabled", true );
+ config.getAttributeAsBoolean( "enabled", m_descriptor.isEnabled() );
final boolean activation =
- config.getAttributeAsBoolean( "activation", false );
+ config.getAttributeAsBoolean( "activation", m_descriptor.getActivationPolicy() );
final Parameters params =
Parameters.fromConfiguration( config.getChild("parameters") );
- final ContextDirective context =
+ final ContextDirective contextDirective =
m_creator.createContextDirective( config.getChild("context") );
final Configuration conf = config.getChild("configuration");
- descriptor =
+ //
+ // create the descriptor
+ //
+
+ final ContainerDescriptor descriptor =
new ContainerDescriptor(
- name, params, conf, context, categories, type, enabled,
- activation, ContainerDescriptor.EXPLICIT, classpath
+ name, params, conf, contextDirective, categories, type, enabled,
+ activation, ContainerDescriptor.EXPLICIT
);
- manager = m_manager.createContainerManager( descriptor, false );
- }
- catch( Throwable e )
- {
- final String error = "Error establishing subsidiary container manager.";
- throw new ContainerException( error, e );
- }
-
- try
- {
- getLogger().debug("creating subsidiary container: " + name );
- DefaultContext context = new DefaultContext();
- context.put( MANAGER_KEY, manager );
- context.put( DESCRIPTOR_KEY, descriptor );
- context.makeReadOnly();
-
- final String classname =
- config.getAttribute( "class", DefaultContainer.class.getName() );
- DefaultContainer container = createContainerInstance( manager, classname );
+ final ClasspathDescriptor classpath =
+ m_creator.createClasspathDescriptor( config.getChild("classpath") );
- final Logger logger = getLogger().getChildLogger( name );
- container.enableLogging( logger );
- container.contextualize( context );
- container.configure( config );
- container.addStateListener( this );
- container.initialize( );
- return container;
+ return createContainer(
+ name,
+ descriptor,
+ classpath,
+ config.getChildren("component"),
+ config.getChildren("container")
+ );
}
catch( Throwable e )
{
1.31 +170 -54 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java
Index: DefaultKernel.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- DefaultKernel.java 5 Aug 2002 13:37:45 -0000 1.30
+++ DefaultKernel.java 8 Aug 2002 10:02:35 -0000 1.31
@@ -77,13 +77,17 @@
import org.apache.excalibur.merlin.model.ContextDirective;
import org.apache.excalibur.merlin.model.Resource;
import org.apache.excalibur.merlin.assembly.TypeManager;
+import org.apache.excalibur.merlin.assembly.TypeException;
import org.apache.excalibur.merlin.assembly.ContainerManager;
+import org.apache.excalibur.merlin.assembly.KernelManager;
+import org.apache.excalibur.merlin.assembly.DefaultLoggerManager;
import org.apache.excalibur.merlin.model.builder.XMLContainerUtil;
import org.apache.excalibur.merlin.model.LoggingDescriptor;
import org.apache.excalibur.merlin.container.Container;
import org.apache.excalibur.merlin.container.DefaultContainer;
import org.apache.excalibur.merlin.container.StateListener;
import org.apache.excalibur.merlin.container.StateEvent;
+import org.apache.excalibur.configuration.ConfigurationUtil;
/**
* Default kernel implementation.
@@ -124,10 +128,10 @@
<strong>kernel</strong>.initialize();
<font color="gray">//
- // Following initialization the assembly of components has been completed and
- // resource descriptiors have been assigned. Service exported by the kernel may
+ // Component assembly and resource descriptior assignment is completed during
+ // the initialization phase. Services exported by the kernel may
// may be access via {@link Resource} references exposed by the
- // {link #getResources()} method. The following method start all resources
+ // {link #getResources()} method. The following method starts all resources
// declared as activatable on startup.
//</font>
@@ -140,7 +144,7 @@
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public class DefaultKernel extends AbstractLogEnabled
+public class DefaultKernel
implements Kernel, Contextualizable, Configurable, Initializable, Startable, Disposable, StateListener
{
//=======================================================================
@@ -149,6 +153,8 @@
public static final String DIR_KEY = "avalon:home";
+ public static final String PATH_KEY = "path";
+
//=======================================================================
// state
//=======================================================================
@@ -169,8 +175,6 @@
private ContainerManager m_manager;
- private Logger m_logger;
-
private Configuration m_config;
private Context m_context;
@@ -189,11 +193,38 @@
/**
* Flag indicating is this kernel is really a root kernel or a kernel embeded in
- * another container. If we are embeded then loging infoprmation is realative
+ * another container. If we are embeded then logging information is realative
* otherwise the kernel's root container logs at top level.
*/
private boolean m_root = true;
+ /**
+ * Logging channel for the container.
+ */
+ private Logger m_logger;
+
+ /**
+ * Logging channel for the kernel;
+ */
+ private Logger m_localLogger;
+
+ /**
+ * The kernel path.
+ */
+ private String m_path;
+
+ /**
+ * The kernel name.
+ */
+ private String m_name;
+
+ /**
+ * The logging manager that we use to construct logging catagories
+ * and logging channels.
+ */
+ private static DefaultLoggerManager m_logging;
+
+
//=======================================================================
// Contextualizable
//=======================================================================
@@ -208,6 +239,24 @@
{
m_context = context;
context.get( DIR_KEY );
+
+ try
+ {
+ m_path = (String) context.get( PATH_KEY );
+ }
+ catch( Throwable e )
+ {
+ m_path = "root";
+ }
+
+ if( m_path.indexOf("/") > -1 )
+ {
+ m_name = m_path.substring( m_path.lastIndexOf("/") + 1 );
+ }
+ else
+ {
+ m_name = m_path;
+ }
}
//=======================================================================
@@ -225,11 +274,26 @@
public void initialize() throws Exception
{
+ final Configuration config = m_config.getChild("container");
+
try
{
- DefaultContext ctx = new DefaultContext( m_context );
+ String name = m_name;
+ if( Thread.currentThread().getContextClassLoader() instanceof ContainerManager )
+ {
+ m_root = false;
+ }
+ else
+ {
+ m_root = true;
+ LoggingDescriptor logging =
+ m_creator.createLoggingDescriptor( m_config.getChild("logging"), name );
+ CategoriesDescriptor categories =
+ m_creator.createCategoriesDescriptor( name, m_config.getChild("categories") );
+ m_logging = new DefaultLoggerManager( logging );
+ }
- String name = m_config.getName();
+ DefaultContext ctx = new DefaultContext( m_context );
ExtensionsDescriptor extensions =
m_creator.createExtensionsDescriptor( m_config.getChild("extensions") );
@@ -240,37 +304,32 @@
CategoriesDescriptor categories =
m_creator.createCategoriesDescriptor( name, m_config.getChild("categories") );
- if( Thread.currentThread().getContextClassLoader() instanceof ContainerManager )
- {
- m_root = true;
- }
- else
- {
- m_root = false;
- }
+ m_logger = getLoggingManager().getLoggerForCategory( m_path );
+ m_localLogger = m_logger.getChildLogger("kernel");
- m_manager = new ContainerManager( name );
- ctx.put( ContainerManager.LOGGING_DESCRIPTOR_KEY, loggingDescriptor );
+ m_manager = new KernelManager( m_path );
+ m_manager.enableLogging( m_logger );
+ ctx.put( KernelManager.LOGGING_KEY, m_logging );
ctx.put( ContainerManager.CATEGORIES_DESCRIPTOR_KEY, categories );
ctx.put( ContainerManager.EXTENSIONS_DESCRIPTOR_KEY, extensions );
ctx.put( ContainerManager.CLASSPATH_DESCRIPTOR_KEY, classpath );
m_manager.contextualize( ctx );
m_manager.initialize();
+
Thread.currentThread().setContextClassLoader( m_manager );
- if( getLogger() == null )
- enableLogging( m_manager.getLoggingManager().getLoggerForCategory( name ) );
- getLogger().info("kernel established");
+
+ getLogger().info("kernel established: " + name );
+
+ m_container = createContainer( config );
}
catch( Throwable e )
{
- final String error = "manager establishment failure";
- throw new KernelException( error );
+ final String error = "kernel establishment failure";
+ throw new KernelException( error, e );
}
- final Configuration config = m_config.getChild("container");
- m_container = createContainer( config );
while( !m_initialized )
sleep();
@@ -278,6 +337,31 @@
}
/**
+ * Return the singleton logging manager.
+ * @return the system wide logging manager
+ */
+ protected DefaultLoggerManager getLoggingManager()
+ {
+ if( m_logging != null )
+ {
+ return m_logging;
+ }
+ else
+ {
+ throw new NullPointerException("logging");
+ }
+ }
+
+ /**
+ * Return the internal kernel logging channel
+ * @return the loging channel
+ */
+ private Logger getLogger()
+ {
+ return m_localLogger;
+ }
+
+ /**
* Internal utility to create the root container.
*
* @param descriptor the subsidiary container descriptor
@@ -285,17 +369,16 @@
*/
private DefaultContainer createContainer( Configuration config ) throws Exception
{
- ContainerManager manager;
- ContainerDescriptor descriptor;
- String name = null;
- String classname = null;
try
{
- name = config.getAttribute( "name", "root" );
- classname = config.getAttribute( "class", DefaultContainer.class.getName() );
+ //
+ // collect the information defining the root container
+ // descriptor
+ //
+
+ final String name = config.getAttribute( "name", "root" );
+ final String classname = config.getAttribute( "class", DefaultContainer.class.getName() );
final Type type = m_manager.getType( classname );
- final ClasspathDescriptor classpath =
- m_creator.createClasspathDescriptor( config.getChild("classpath") );
final CategoriesDescriptor categories =
m_creator.createCategoriesDescriptor( name, config.getChild("categories") );
final boolean enabled =
@@ -304,38 +387,71 @@
config.getAttributeAsBoolean( "activation", false );
final Parameters params =
Parameters.fromConfiguration( config.getChild("parameters") );
- final ContextDirective context =
+ final ContextDirective contextDirective =
m_creator.createContextDirective( config.getChild("context") );
final Configuration conf = config.getChild("configuration");
- descriptor =
+ //
+ // create the descriptor
+ //
+
+ final ContainerDescriptor descriptor =
new ContainerDescriptor(
- name, params, conf, context, categories, type, enabled,
- activation, ContainerDescriptor.EXPLICIT, classpath
+ name, params, conf, contextDirective, categories, type, enabled,
+ activation, ContainerDescriptor.EXPLICIT
);
- manager = m_manager.createContainerManager( descriptor, m_root );
- }
- catch( Throwable e )
- {
- final String error = "Error establishing subsidiary container manager.";
- throw new KernelException( error, e );
- }
+ //
+ // create the container manager
+ //
+
+ final ClasspathDescriptor classpath =
+ m_creator.createClasspathDescriptor( config.getChild("classpath") );
+ final ContainerManager manager =
+ m_manager.createContainerManager( name, descriptor, classpath, m_logger );
+
+ //
+ // populate the descriptor with the components it contains
+ //
+
+ final Configuration[] components = config.getChildren("component");
+ for( int i=0; i<components.length; i++ )
+ {
+ final Configuration component = components[i];
+ final String c = component.getAttribute("class");
+ try
+ {
+ final Type t = manager.getType( c );
+ final Profile profile = m_creator.createProfile( t, component );
+ manager.addProfile( profile );
+ descriptor.addComponent( profile );
+ }
+ catch( TypeException e )
+ {
+ final String warning =
+ "Ignoring component declaration at " + config.getLocation()
+ + " due to unknown type: " + classname;
+ getLogger().warn( warning );
+ }
+ }
+
+ //
+ // create the container instance
+ //
- try
- {
getLogger().debug("creating root container: " + name );
- DefaultContext context = new DefaultContext();
+ final DefaultContext context = new DefaultContext();
context.put( DefaultContainer.MANAGER_KEY, manager );
context.put( DefaultContainer.DESCRIPTOR_KEY, descriptor );
+ context.put( DefaultContainer.CONFIGURATIONS_KEY, config.getChildren("container") );
+ context.put( DefaultContainer.STATE_LISTENER_KEY, this );
context.makeReadOnly();
- DefaultContainer container = createContainerInstance( m_manager, classname );
- Logger logger = manager.getLoggingManager().getLoggerForCategory( name );
- container.enableLogging( logger );
+ final DefaultContainer container = createContainerInstance( m_manager, classname );
+ //final Logger logger = manager.getLoggingManager().getLoggerForCategory( name );
+ container.enableLogging( m_logger );
container.contextualize( context );
- container.configure( config );
- container.addStateListener( this );
+ container.configure( descriptor.getConfiguration( manager ) );
container.initialize( );
return container;
}
1.12 +2 -24 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ContainerDescriptor.java
Index: ContainerDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ContainerDescriptor.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ContainerDescriptor.java 5 Aug 2002 12:39:37 -0000 1.11
+++ ContainerDescriptor.java 8 Aug 2002 10:02:35 -0000 1.12
@@ -102,11 +102,6 @@
public static final String DELIMITER = "/";
/**
- * The container classpath
- */
- private final ClasspathDescriptor m_classpath;
-
- /**
* Create a ContainerDescriptor instance.
*
* @param name the abstract name of component meta data instance
@@ -118,7 +113,6 @@
* @param enabled the enabled state of the component profile
* @param activation TRUE if activation on startup, FALSE to activate on request
* @param mode the creation mode (either IMPLICIT, PACKAGED, or EXPLICIT)
- * @param mode the classpath descriptor
*/
public ContainerDescriptor( final String name,
final Parameters parameters,
@@ -128,28 +122,12 @@
final Type type,
final boolean enabled,
final boolean activation,
- final int mode,
- final ClasspathDescriptor classpath )
+ final int mode )
{
super(
name, parameters, configuration, context, categories, type, enabled,
activation, mode
);
-
- if( classpath == null )
- throw new NullPointerException("classpath");
-
- m_classpath = classpath;
- }
-
- /**
- * Return the classpath descriptor
- *
- * @return the classpath descriptor
- */
- public ClasspathDescriptor getClasspath()
- {
- return m_classpath;
}
/**
1.19 +9 -4 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java
Index: Profile.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Profile.java 5 Aug 2002 12:39:37 -0000 1.18
+++ Profile.java 8 Aug 2002 10:02:35 -0000 1.19
@@ -360,7 +360,7 @@
}
/**
- * Return the Configuration for the profile.
+ * Return the base Configuration for the profile.
*
* @return the base Configuration for profile.
*/
@@ -370,7 +370,11 @@
}
/**
- * Return the derived Configuration for the profile.
+ * Return the derived Configuration for the profile as a
+ * {@link CascadingConfiguration}. The primary configuration
+ * is either the base configuration of a configuration referenced
+ * by the attribute <code>src</code> and the default configuration
+ * is resolved from the <classname>.xconfig resourse.
*
* @return the Configuration for profile.
*/
@@ -407,7 +411,8 @@
catch( Throwable e )
{
final String error =
- "Unexpected exception while attempting to resolve configuration fro src : " + src;
+ "Unexpected exception while attempting to resolve configuration from src : "
+ + src;
throw new ConfigurationException( error );
}
}
1.14 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLProfileCreator.java
Index: XMLProfileCreator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLProfileCreator.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XMLProfileCreator.java 4 Aug 2002 11:49:36 -0000 1.13
+++ XMLProfileCreator.java 8 Aug 2002 10:02:36 -0000 1.14
@@ -265,7 +265,7 @@
);
}
- private CategoriesDescriptor createDefaultCategoriesDescriptor( Type type )
+ protected CategoriesDescriptor createDefaultCategoriesDescriptor( Type type )
{
final String name = type.getInfo().getName();
return new CategoriesDescriptor( name, null, null, new Category[0] );
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>