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/07/25 20:07:16 UTC
cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder ContainerCreator.java KernelCreator.java ProfileBuilder.java ProfileCreator.java Resources.properties TypeManager.java XMLContainerCreator.java XMLKernelCreator.java XMLProfileCreator.java
mcconnell 2002/07/25 11:07:16
Modified: assembly build.xml
assembly/src/etc kernel.xml sevak.xml
assembly/src/java/org/apache/excalibur/merlin
DefaultController.java Main.java
assembly/src/java/org/apache/excalibur/merlin/container
DefaultContainer.java DefaultContainer.xinfo
ResourceProvider.java Resources.properties
assembly/src/java/org/apache/excalibur/merlin/kernel
DefaultKernel.java DefaultKernel.xinfo
Resources.properties
assembly/src/java/org/apache/excalibur/merlin/model
ContainerDescriptor.java KernelDescriptor.java
LoggingDescriptor.java Parameter.java Parent.java
Profile.java
assembly/src/java/org/apache/excalibur/merlin/model/builder
ContainerCreator.java KernelCreator.java
ProfileBuilder.java ProfileCreator.java
Resources.properties TypeManager.java
XMLContainerCreator.java XMLKernelCreator.java
XMLProfileCreator.java
Log:
Updates related to logging fixes/enhancements and meta-data optinization.
Revision Changes Path
1.31 +7 -2 jakarta-avalon-excalibur/assembly/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/build.xml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- build.xml 21 Jul 2002 05:13:59 -0000 1.30
+++ build.xml 25 Jul 2002 18:07:15 -0000 1.31
@@ -297,8 +297,13 @@
<target name="patch">
<replace
- token="AbstractContainer"
- value="Parent" dir="src/java">
+ token="TypeManagerException"
+ value="TypeException" dir="src/java">
+ <include name="org/apache/excalibur/merlin/**/*.*"/>
+ </replace>
+ <replace
+ token="TypeManagerRuntimeException"
+ value="TypeRuntimeException" dir="src/java">
<include name="org/apache/excalibur/merlin/**/*.*"/>
</replace>
</target>
1.17 +14 -12 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- kernel.xml 24 Jul 2002 17:03:06 -0000 1.16
+++ kernel.xml 25 Jul 2002 18:07:15 -0000 1.17
@@ -25,16 +25,16 @@
<target name="kernel">
<file location="kernel.log" />
</target>
- <loggers priority="INFO">
- <category priority="WARN" name="logging" />
- <category priority="WARN" name="loader" />
- <category priority="WARN" name="installer" />
- <category priority="WARN" name="installer.types" />
- <category priority="WARN" name="installer.types.builder" />
- <category priority="INFO" name="export" />
- </loggers>
</logging>
+ <categories priority="INFO">
+ <category priority="WARN" name="logging" />
+ <category priority="INFO" name="export" />
+ <category priority="WARN" name="installer" />
+ <category priority="WARN" name="installer.types" />
+ <category priority="WARN" name="installer.types.builder" />
+ </categories>
+
<!--
Declaration of installed extension directories.
-->
@@ -58,7 +58,7 @@
for completness.
-->
- <loggers priority="INFO">
+ <categories priority="INFO">
<category priority="WARN" name="loader" />
<category priority="WARN" name="loader.types" />
<category priority="WARN" name="loader.types.builder" />
@@ -66,7 +66,9 @@
<category priority="WARN" name="assembly.selector" />
<category priority="WARN" name="provider" />
<category priority="WARN" name="lifecycle" />
- </loggers>
+ <category priority="INFO" name="sub" />
+ <category priority="INFO" name="sub.demo" />
+ </categories>
<!--
Declaration of the classpath for this container.
@@ -86,9 +88,9 @@
<component name="complex" class="org.apache.excalibur.playground.ComplexComponent" activation="true">
- <loggers priority="INFO">
+ <categories priority="INFO">
<category name="init" priority="DEBUG" />
- </loggers>
+ </categories>
<!--
Include the following context value in the context supplied a component using this
1.6 +5 -3 jakarta-avalon-excalibur/assembly/src/etc/sevak.xml
Index: sevak.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/sevak.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- sevak.xml 24 Jul 2002 21:26:08 -0000 1.5
+++ sevak.xml 25 Jul 2002 18:07:15 -0000 1.6
@@ -6,7 +6,7 @@
<kernel>
- <logging priority="WARN"/>
+ <logging priority="INFO"/>
<extensions>
<dirset dir=".">
@@ -17,9 +17,11 @@
</dirset>
</extensions>
+ <categories priority="WARN"/>
+
<container name="root">
- <loggers priority="DEBUG">
+ <categories priority="INFO">
<category priority="WARN" name="loader" />
<category priority="WARN" name="loader.types" />
<category priority="WARN" name="loader.types.builder" />
@@ -30,7 +32,7 @@
<category priority="WARN" name="verifier" />
<category priority="WARN" name="simple" />
<category priority="WARN" name="basic" />
- </loggers>
+ </categories>
<classpath>
<fileset dir="../../jakarta-avalon-apps/sevak/lib/tomcat-jars">
1.6 +14 -89 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.java
Index: DefaultController.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultController.java 20 Jul 2002 05:03:01 -0000 1.5
+++ DefaultController.java 25 Jul 2002 18:07:15 -0000 1.6
@@ -25,8 +25,8 @@
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.logger.Logger;
import org.apache.excalibur.merlin.kernel.DefaultKernel;
-import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
-import org.apache.excalibur.merlin.kernel.ContainerClassLoader;
+//import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
+import org.apache.excalibur.merlin.model.builder.DefaultTypeManager;
import org.apache.excalibur.merlin.kernel.KernelException;
import org.apache.excalibur.merlin.model.ResourceDesignator;
import org.apache.excalibur.merlin.model.builder.XMLKernelCreator;
@@ -126,109 +126,34 @@
Configuration config = null;
XMLKernelCreator creator = new XMLKernelCreator();
- ClasspathDescriptor classpath = null;
- ExtensionsDescriptor extensions = null;
- LoggingDescriptor loggingDescriptor = null;
+ KernelDescriptor descriptor = null;
try
{
- config = getProfile( m_path );
- classpath = creator.createClasspathDescriptor( config.getChild("classpath") );
- extensions = creator.createExtensionsDescriptor( config.getChild("extensions") );
- loggingDescriptor = creator.createLoggingDescriptor( config.getChild("logging"), "kernel" );
- }
- catch( Throwable e )
- {
- final String error = "Controller bootstrap failure.";
- throw new ControllerException( error, e );
- }
-
- //
- // log manager
- //
-
- DefaultLoggerManager logging = null;
- Logger logger = null;
- try
- {
- logging = new DefaultLoggerManager( loggingDescriptor );
- logger = logging.getLoggerForCategory( "kernel" );
- logger.info("commencing type installation");
- }
- catch( Throwable e )
- {
- final String error = "Logging manager establishment failure.";
- throw new ControllerException( error, e );
- }
-
- //
- // root classloader
- //
-
- final ContainerClassLoader loader = new ContainerClassLoader();
- try
- {
- loader.enableLogging( logger.getChildLogger( "loader" ) );
- DefaultContext context = new DefaultContext();
- context.put(
- ContainerClassLoader.EXTENSIONS_DESCRIPTOR_KEY,
- extensions );
- context.put(
- ContainerClassLoader.CLASSPATH_DESCRIPTOR_KEY,
- classpath );
- context.makeReadOnly();
- loader.contextualize( context );
- loader.initialize();
- }
- catch( Throwable e )
- {
- final String error = "Classloader establishment failure.";
- throw new ControllerException( error, e );
- }
- //
- // create a temporary installer classloader that we will use to build
- // a complete kernel and contain model
- //
+ //
+ // build the kernel descriptor
+ //
- ContainerClassLoader installer = new ContainerClassLoader( loader );
- try
- {
- installer.enableLogging( logger.getChildLogger( "installer" ) );
- DefaultContext context = new DefaultContext();
- installer.contextualize( context );
- installer.initialize();
- }
- catch( Throwable e )
- {
- installer = null;
- final String error = "Installer deployment failure.";
- throw new ControllerException( error, e );
- }
+ config = getProfile( m_path );
+ descriptor = creator.createKernelDescriptor(
+ config, Thread.currentThread().getContextClassLoader() );
+ descriptor.getLogger().info("kernel descriptor created");
- ContainerDescriptor container = null;
- try
- {
- container = creator.createContainerDescriptor( config.getChild("container"), installer );
- installer = null;
}
catch( Throwable e )
{
- installer = null;
- final String error = "Root container model establishment failure.";
+ final String error = "Controller bootstrap failure.";
throw new ControllerException( error, e );
}
// run it up
- logger.info("commencing kernel deployment");
DefaultContext context = new DefaultContext();
- context.put( DefaultKernel.ROOT_CONTAINER_DESCRIPTOR_KEY, container );
- context.put( DefaultKernel.CLASSLOADER_KEY, loader );
- context.put( DefaultKernel.LOG_MANAGER_KEY, logging );
+ context.put( DefaultKernel.KERNEL_DESCRIPTOR_KEY, descriptor );
context.makeReadOnly();
try
{
- m_kernel.enableLogging( logger );
+ m_kernel.enableLogging( descriptor.getLogger() );
m_kernel.contextualize( context );
m_kernel.initialize( );
}
1.8 +3 -3 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Main.java 16 Jul 2002 08:57:18 -0000 1.7
+++ Main.java 25 Jul 2002 18:07:15 -0000 1.8
@@ -68,8 +68,8 @@
import org.apache.excalibur.merlin.model.LoggingDescriptor;
import org.apache.excalibur.merlin.model.ContainerDescriptor;
import org.apache.excalibur.merlin.kernel.DefaultKernel;
-import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
-import org.apache.excalibur.merlin.kernel.ContainerClassLoader;
+//import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
+import org.apache.excalibur.merlin.model.builder.DefaultTypeManager;
import org.apache.excalibur.merlin.kernel.KernelException;
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
1.15 +17 -29 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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DefaultContainer.java 21 Jul 2002 05:03:10 -0000 1.14
+++ DefaultContainer.java 25 Jul 2002 18:07:15 -0000 1.15
@@ -67,13 +67,13 @@
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.merlin.model.ContainerDescriptor;
-import org.apache.excalibur.merlin.model.CategoryDescriptor;
import org.apache.excalibur.merlin.model.verifier.AssemblyVerifier;
import org.apache.excalibur.merlin.model.verifier.MetaDataVerifier;
import org.apache.excalibur.merlin.model.builder.ProfileBuilder;
+import org.apache.excalibur.merlin.model.builder.TypeManager;
import org.apache.excalibur.merlin.model.ResourceDesignator;
-import org.apache.excalibur.merlin.kernel.ContainerClassLoader;
-import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
+import org.apache.excalibur.merlin.model.builder.DefaultTypeManager;
+import org.apache.excalibur.merlin.model.builder.DefaultLoggerManager;
import org.apache.excalibur.merlin.Verifiable;
import org.apache.excalibur.merlin.Controller;
import org.apache.log.Hierarchy;
@@ -145,13 +145,13 @@
*/
private Container m_parent;
- private ContainerClassLoader m_classloader;
+ private TypeManager m_classloader;
private DependencyGraph m_map;
private ResourceProvider m_provider;
- private DefaultLoggerManager m_logging;
+ //private DefaultLoggerManager m_logging;
private ContainerDescriptor m_descriptor;
@@ -187,10 +187,11 @@
*/
public void contextualize( Context context ) throws ContextException
{
- m_classloader = (ContainerClassLoader) context.get( CLASSLOADER_KEY );
- m_logging = (DefaultLoggerManager) context.get( LOG_MANAGER_KEY );
+ //m_logging = (DefaultLoggerManager) context.get( LOG_MANAGER_KEY );
m_descriptor = (ContainerDescriptor) context.get( CONTAINER_DESCRIPTOR_KEY );
m_dictionary = (Context) context.get( DICTIONARY_KEY );
+ m_classloader = m_descriptor.getTypeManager();
+
try
{
m_parent = (Container) context.get( CONTAINER_KEY );
@@ -219,8 +220,11 @@
public void initialize() throws Exception
{
getLogger().debug("initialization");
+ getLogger().debug( "container creation using clasloader: " + m_classloader );
+
m_helper.enableLogging( getLogger().getChildLogger("lifecycle") );
- m_provider = new ResourceProvider( m_classloader, m_logging, this, m_dictionary );
+ //m_provider = new ResourceProvider( m_classloader, m_logging, this, m_dictionary );
+ m_provider = new ResourceProvider( m_classloader, this, m_dictionary );
m_provider.enableLogging( getLogger().getChildLogger("provider") );
//
@@ -251,7 +255,7 @@
Type[] types = m_classloader.getTypes();
for( int i=0; i<types.length; i++ )
{
- Profile[] profiles = m_builder.build( types[i], m_classloader );
+ Profile[] profiles = m_builder.build( m_descriptor, types[i] );
for( int j=0; j<profiles.length; j++ )
{
Profile profile = profiles[j];
@@ -728,37 +732,21 @@
private DefaultContainer createContainer( ContainerDescriptor descriptor ) throws Exception
{
- String name = descriptor.getName();
- CategoryDescriptor loggers = descriptor.getCategoryDescriptor();
- loggers.setParent( m_descriptor.getCategoryDescriptor() );
- m_logging.addCategories( loggers );
-
- Logger logger = getLogger().getChildLogger( name );
- Logger loaderLogger = logger.getChildLogger( "loader" );
-
- final ContainerClassLoader loader = new ContainerClassLoader( m_classloader );
- loader.enableLogging( loaderLogger );
- DefaultContext loaderContext = new DefaultContext();
- loaderContext.put(
- ContainerClassLoader.CLASSPATH_DESCRIPTOR_KEY,
- descriptor.getClasspathDescriptor() );
- loaderContext.makeReadOnly();
- loader.contextualize( loaderContext );
- loader.initialize();
+ String name = descriptor.getName();
+ getLogger().info("creating child container: " + name );
DependencyGraph map = new DependencyGraph( m_map );
m_map.addChild( map );
DefaultContext context = new DefaultContext();
- context.put( CLASSLOADER_KEY, loader );
context.put( CONTAINER_KEY, this );
context.put( MAP_KEY, map );
- context.put( LOG_MANAGER_KEY, m_logging );
context.put( CONTAINER_DESCRIPTOR_KEY, descriptor );
context.put( DICTIONARY_KEY, m_dictionary );
context.makeReadOnly();
DefaultContainer container = new DefaultContainer();
+ final Logger logger = getLogger().getChildLogger( name );
container.enableLogging( logger );
container.contextualize( context );
container.initialize( );
1.4 +1 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.xinfo
Index: DefaultContainer.xinfo
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.xinfo,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultContainer.xinfo 12 Jul 2002 19:09:26 -0000 1.3
+++ DefaultContainer.xinfo 25 Jul 2002 18:07:15 -0000 1.4
@@ -18,7 +18,7 @@
</component>
<context>
- <entry key="classloader" type="org.apache.excalibur.merlin.kernel.ContainerClassLoader" optional="false"/>
+ <entry key="classloader" type="org.apache.excalibur.merlin.model.builder.DefaultTypeManager" optional="false"/>
<entry key="logging" type="org.apache.excalibur.merlin.kernel.DefaultLoggerManager" optional="false"/>
<entry key="descriptor" type="org.apache.excalibur.merlin.model.ContainerDescriptor" optional="false"/>
<entry key="map" type="org.apache.excalibur.merlin.kernel.DependencyGraph" optional="false"/>
1.10 +8 -10 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ResourceProvider.java
Index: ResourceProvider.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ResourceProvider.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ResourceProvider.java 24 Jul 2002 17:03:07 -0000 1.9
+++ ResourceProvider.java 25 Jul 2002 18:07:15 -0000 1.10
@@ -66,10 +66,8 @@
import org.apache.excalibur.meta.info.ServiceDesignator;
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.merlin.model.Association;
-import org.apache.excalibur.merlin.model.CategoryDescriptor;
import org.apache.excalibur.merlin.model.ResourceDesignator;
import org.apache.excalibur.merlin.model.Import;
-import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
import org.apache.excalibur.configuration.ConfigurationUtil;
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
@@ -109,7 +107,7 @@
/**
* The log manager.
*/
- private DefaultLoggerManager m_logging;
+ //private DefaultLoggerManager m_logging;
private DefaultContainer m_locator;
@@ -119,11 +117,14 @@
// constructor
//=======================================================================
- public ResourceProvider( ClassLoader loader, DefaultLoggerManager manager,
+ //public ResourceProvider( ClassLoader loader, DefaultLoggerManager manager,
+ // DefaultContainer locator, Context dictionary )
+
+ public ResourceProvider( ClassLoader loader,
DefaultContainer locator, Context dictionary )
{
m_classloader = loader;
- m_logging = manager;
+ //m_logging = manager;
m_locator = locator;
m_dictionary = new DefaultContext( dictionary );
m_dictionary.put( "classloader", loader );
@@ -189,10 +190,7 @@
public Logger createLogger( Profile profile )
throws Exception
{
- final String name = profile.getName();
- CategoryDescriptor loggers = profile.getCategoryDescriptor();
- m_logging.addCategories( loggers );
- return m_logging.getLoggerForCategory( loggers );
+ return profile.getLogger();
}
/**
1.4 +0 -8 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Resources.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Resources.properties 12 Jul 2002 19:09:26 -0000 1.3
+++ Resources.properties 25 Jul 2002 18:07:15 -0000 1.4
@@ -11,13 +11,5 @@
dinfo-service-error="Could not create dependecy service delcaration (Reason: {0}).
dinfo-nocreate="Could not create dependecy delcaration from resource "{0}" (Reason: {1}).
-missing.extension=Unable to locate an extension that is required by application.\n Extension Name: {0}\n Specification Vendor: {1}\n Specification Version: {2}\n Implementation Vendor: {3}\n Implementation Vendor-Id: {4}\n Implementation Version: {5}\n Implementation URL: {6}
-unsatisfied.extensions=Missing {0} extensions and thus can not build ClassLoader for application.
-bad-classpath-entry=There is a bad entry ("{0}") on classpath that made it impossible to load a manifest.
-available-extensions=Available extensions: {0}
-required-extensions=The list of required extensions for application includes: {0}
-optional-packages-added=The list of "Optional Packages" added to the application include: {0}
-classpath-entries=The list of classpath entrys for the application include: {0}
-
lifecycle.stage.notice=Component named "{0}" is passing through the {1,choice,0#Creation|1#Logger initialization|2#Contextualization|3#Composing|4#Configuration|5#Parameterizing|6#Initialization|7#Starting|8#Stopping|9#Disposing|10#Destruction} stage.
lifecycle.fail.error=Component named "{0}" failed to pass through the {1,choice,0#Creation|1#Logger initialization|2#Contextualization|3#Composing|4#Configuration|5#Parameterizing|6#Initialization|7#Starting|8#Stopping|9#Disposing|10#Destruction} stage. (Reason: {2}).
1.21 +14 -55 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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- DefaultKernel.java 23 Jul 2002 15:10:40 -0000 1.20
+++ DefaultKernel.java 25 Jul 2002 18:07:15 -0000 1.21
@@ -68,7 +68,6 @@
import org.apache.excalibur.merlin.model.DirsetDescriptor;
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.merlin.model.ContainerDescriptor;
-import org.apache.excalibur.merlin.model.CategoryDescriptor;
import org.apache.excalibur.merlin.model.builder.TypeManager;
import org.apache.excalibur.merlin.model.ResourceDesignator;
import org.apache.excalibur.merlin.container.DefaultContainer;
@@ -87,9 +86,7 @@
//=======================================================================
public static final String AVALON_WORK_KEY = "avalon:work";
-
- public static final String ROOT_CONTAINER_DESCRIPTOR_KEY = "descriptor";
- public static final String CLASSLOADER_KEY = "classloader";
+ public static final String KERNEL_DESCRIPTOR_KEY = "descriptor";
public static final String LOG_MANAGER_KEY = "logmanager";
//=======================================================================
@@ -100,14 +97,10 @@
private boolean m_verified = false;
- private DefaultLoggerManager m_logging;
-
- private ContainerDescriptor m_descriptor;
+ private KernelDescriptor m_descriptor;
private boolean m_initialized = false;
- private ClassLoader m_classloader;
-
/**
* The context entries available from the kernel post startup.
*/
@@ -125,14 +118,12 @@
/**
* Invoked by the bootstrap process to supply to kernel defintion.
* @param context the context object containing the inital parameters
- * @exception ContextException if the supplied does not contain a CLASSLOADER_KEY,
- * LOG_MANAGER_KEY, or ROOT_CONTAINER_DESCRIPTOR_KEY value.
+ * @exception ContextException if the supplied does not contain a
+ * KERNEL_CONTAINER_DESCRIPTOR_KEY value.
*/
public void contextualize( Context context ) throws ContextException
{
- m_classloader = (ClassLoader) context.get( CLASSLOADER_KEY );
- m_logging = (DefaultLoggerManager) context.get( LOG_MANAGER_KEY );
- m_descriptor = (ContainerDescriptor) context.get( ROOT_CONTAINER_DESCRIPTOR_KEY );
+ m_descriptor = (KernelDescriptor) context.get( KERNEL_DESCRIPTOR_KEY );
}
//=======================================================================
@@ -141,59 +132,27 @@
public void initialize() throws Exception
{
- getLogger().debug( "initialize" );
-
- //
- // root container criteria
- //
-
-
- CategoryDescriptor loggers = m_descriptor.getCategoryDescriptor();
- m_logging.addCategories( loggers );
- Logger containerLogger = m_logging.getLoggerForCategory( m_descriptor.getName() );
-
- //
- // classloader setup
- //
-
- getLogger().debug( "root container classloader creation" );
- final ContainerClassLoader loader = new ContainerClassLoader( m_classloader );
- try
- {
- loader.enableLogging( containerLogger.getChildLogger( "loader" ) );
- DefaultContext loaderContext = new DefaultContext();
- loaderContext.put(
- ContainerClassLoader.CLASSPATH_DESCRIPTOR_KEY,
- m_descriptor.getClasspathDescriptor() );
- loaderContext.makeReadOnly();
- loader.contextualize( loaderContext );
- loader.initialize();
- }
- catch( Throwable e )
- {
- final String error = "Error during root container classloader creation.";
- if( getLogger() != null )
- getLogger().error( error, e );
- throw new KernelException( error, e );
- }
+ getLogger().debug(
+ "creating root container descriptor using classloader: "
+ + m_descriptor.getTypeManager() );
+ ContainerDescriptor descriptor = m_descriptor.getContainer();
//
// dictionary creation
//
+ getLogger().debug("container dictionary" );
DefaultContext dictionary = new DefaultContext();
dictionary.put( AVALON_WORK_KEY, new File( System.getProperty("user.dir") ) );
dictionary.makeReadOnly();
//
- // container context creation
+ // root container context creation
//
getLogger().debug( "root container context creation" );
DefaultContext context = new DefaultContext();
- context.put( DefaultContainer.CLASSLOADER_KEY, loader );
- context.put( DefaultContainer.LOG_MANAGER_KEY, m_logging );
- context.put( DefaultContainer.CONTAINER_DESCRIPTOR_KEY, m_descriptor );
+ context.put( DefaultContainer.CONTAINER_DESCRIPTOR_KEY, descriptor );
context.put( DefaultContainer.DICTIONARY_KEY, dictionary );
context.makeReadOnly();
@@ -205,7 +164,7 @@
try
{
m_container = new DefaultContainer();
- m_container.enableLogging( containerLogger );
+ m_container.enableLogging( descriptor.getLogger() );
m_container.contextualize( context );
m_container.initialize( );
m_container.verify();
1.6 +1 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.xinfo
Index: DefaultKernel.xinfo
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.xinfo,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultKernel.xinfo 12 Jul 2002 19:09:27 -0000 1.5
+++ DefaultKernel.xinfo 25 Jul 2002 18:07:15 -0000 1.6
@@ -18,7 +18,7 @@
</component>
<context>
- <entry key="classloader" type="org.apache.excalibur.merlin.kernel.ContainerClassLoader" optional="false"/>
+ <entry key="classloader" type="org.apache.excalibur.merlin.model.builder.DefaultTypeManager" optional="false"/>
<entry key="logging" type="org.apache.excalibur.merlin.kernel.DefaultLoggerManager" optional="false"/>
<entry key="descriptor" type="org.apache.excalibur.merlin.model.KernelDescriptor" optional="false"/>
</context>
1.8 +0 -11 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Resources.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Resources.properties 12 Jul 2002 19:09:27 -0000 1.7
+++ Resources.properties 25 Jul 2002 18:07:15 -0000 1.8
@@ -11,14 +11,6 @@
dinfo-service-error="Could not create dependecy service delcaration (Reason: {0}).
dinfo-nocreate="Could not create dependecy delcaration from resource "{0}" (Reason: {1}).
-missing.extension=Unable to locate an extension that is required by application.\n Extension Name: {0}\n Specification Vendor: {1}\n Specification Version: {2}\n Implementation Vendor: {3}\n Implementation Vendor-Id: {4}\n Implementation Version: {5}\n Implementation URL: {6}
-unsatisfied.extensions=Missing {0} extensions and thus can not build ClassLoader for application.
-bad-classpath-entry=There is a bad entry ("{0}") on classpath that made it impossible to load a manifest.
-available-extensions=Available extensions: {0}
-required-extensions=The list of required extensions for application includes: {0}
-optional-packages-added=The list of "Optional Packages" added to the application include: {0}
-classpath-entries=The list of classpath entrys for the application include: {0}
-
resource.missing-context-value.error=Missing {0,choice,1#Optional|2#Required} Context Entry with key "{1}" for component named "{2}".
resource.bad-value-type.error=Bad value retrieved for {0,choice,1#Optional|2#Required} Context Entry with key "{1}" for component named "{2}". Expected to be of type "{3}" but was of type "{4}".
resource.bad-context-type.error=The class of Contex object for component named "{2}" was expected to be of type {0} but was of tpye {1}.
@@ -27,6 +19,3 @@
resource.missing-parameters.error=Missing Parameters object for component named "{0}".
resource.missing-parameters.error=Missing Configuration for component named "{0}".
-target.nocreate=Error creating LogTarget named "{0}" for file {0}. (Reason: {2}).
-unknown-priority=Unknown priority "{0}" for Logger named "{1}".
-category-create=Creating a log category named "{0}" that writes to "{1}" target at priority "{2}".
1.7 +34 -86 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ContainerDescriptor.java 14 Jul 2002 00:55:12 -0000 1.6
+++ ContainerDescriptor.java 25 Jul 2002 18:07:16 -0000 1.7
@@ -8,10 +8,13 @@
package org.apache.excalibur.merlin.model;
import java.util.ArrayList;
+import org.apache.excalibur.merlin.model.builder.TypeManager;
+import org.apache.excalibur.merlin.model.builder.DefaultLoggerManager;
+
/**
* <p>A container descriptor is a description of the crieria supporting the
- * construction of a container. It may may include a classpath, multiple
+ * construction of a container. It may may include multiple
* component profile declarations, and multiple nested container declarations.</p>
*
* <p><b>XML</b><p>
@@ -75,7 +78,6 @@
* </pre>
*
* @see Profile
- * @see CategoryDescriptor
* @see ClasspathDescriptor
*
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
@@ -83,25 +85,11 @@
*/
public class ContainerDescriptor extends Parent
{
- /**
- * The parent.
- */
- private Parent m_parent;
-
- /**
- * The container name.
- */
- private final String m_name;
-
- /**
- * The loggers defintion.
- */
- private final CategoryDescriptor m_loggers;
/**
* The container classpath descriptor.
*/
- private final ClasspathDescriptor m_classpath;
+ private final TypeManager m_manager;
/**
* The component described within the scope of the container.
@@ -115,65 +103,51 @@
/**
* Create a ContainerDescriptor instance.
+ * @param parent the parent container
* @param name the container name
* @param loggers the logging category descriptors
- * @param classpath the containers local classpath
+ * @param manager the containers type manager
* @param components the set of components to be included in the container
* @param containers the set of subsidiary containers to include in the container
*/
- public ContainerDescriptor( final String name,
- final CategoryDescriptor loggers,
- final ClasspathDescriptor classpath,
- final Profile[] components,
- final ContainerDescriptor[] containers )
+ public ContainerDescriptor(
+ final Parent parent,
+ final String name,
+ final DefaultLoggerManager logging,
+ final TypeManager manager )
{
- super( name, loggers );
+ super( parent, name, logging );
- if( classpath == null )
- throw new NullPointerException("classpath");
+ if( manager == null )
+ throw new NullPointerException("manager");
- m_name = name;
- m_loggers = loggers;
- m_classpath = classpath;
+ m_manager = manager;
+ }
- for( int i=0; i<containers.length; i++ )
+ /**
+ * Returns the path name of this container descriptor.
+ * @return the container's path
+ */
+ public String getPath()
+ {
+ if( getParent() instanceof ContainerDescriptor )
{
- addContainer( containers[i] );
+ return getParent().getPath() + "/" + getName();
}
- for( int i=0; i<components.length; i++ )
+ else
{
- addComponent( components[i] );
+ return "/" + getName();
}
}
/**
- * Return the container name.
+ * Return the type manager assigned to the container.
*
- * @return the name of the container
+ * @return the {@link TypeManager} for the container.
*/
- public String getName()
+ public TypeManager getTypeManager()
{
- return m_name;
- }
-
- /**
- * Return the logging descriptor.
- *
- * @return the {@link CategoryDescriptor} for the component loggers.
- */
- public CategoryDescriptor getCategoryDescriptor()
- {
- return m_loggers;
- }
-
- /**
- * Return the classpath descriptor.
- *
- * @return the {@link ClasspathDescriptor} for the container.
- */
- public ClasspathDescriptor getClasspathDescriptor()
- {
- return m_classpath;
+ return m_manager;
}
/**
@@ -186,7 +160,7 @@
if( !m_components.contains( component ) )
{
m_components.add( component );
- component.getCategoryDescriptor().setParent( getCategoryDescriptor() );
+ component.setContainer( this );
}
}
@@ -203,7 +177,7 @@
/**
* Return the set of enabled or disable components based on the supplied criteria.
*
- * @param enabled TRUE to select enabled components, FALSE returs disabled components
+ * @param enabled TRUE to select enabled components, FALSE returns disabled components
* @return the descriptors matching the supplied enabled status
*/
public Profile[] getComponents( boolean enabled )
@@ -258,8 +232,6 @@
if( !m_containers.contains( container ) )
{
m_containers.add( container );
- container.getCategoryDescriptor().setParent( getCategoryDescriptor() );
- container.setParent( this );
}
}
@@ -271,30 +243,6 @@
public ContainerDescriptor[] getContainers()
{
return (ContainerDescriptor[]) m_containers.toArray( new ContainerDescriptor[0] );
- }
-
- /**
- * Set the parent container.
- *
- * @param the container containing this container.
- * @exception IllegalStateException if the parent is already set
- */
- public void setParent( Parent parent ) throws IllegalStateException
- {
- if( m_parent != null )
- throw new IllegalStateException("parent");
-
- m_parent = parent;
- }
-
- /**
- * Return the parent container.
- *
- * @return the container containing this container.
- */
- public Parent getParent()
- {
- return m_parent;
}
/**
1.5 +26 -49 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/KernelDescriptor.java
Index: KernelDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/KernelDescriptor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- KernelDescriptor.java 17 Jul 2002 13:48:37 -0000 1.4
+++ KernelDescriptor.java 25 Jul 2002 18:07:16 -0000 1.5
@@ -7,6 +7,10 @@
*/
package org.apache.excalibur.merlin.model;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.excalibur.merlin.model.builder.TypeManager;
+import org.apache.excalibur.merlin.model.builder.DefaultLoggerManager;
+
/**
* Kernel creation directive that includes a root container, an extensions directive,
* common application level classpath directive and logigng category descriptors.
@@ -96,19 +100,9 @@
{
/**
- * The logging defintion.
- */
- private final LoggingDescriptor m_logging;
-
- /**
- * The extensions defintion.
- */
- private final ExtensionsDescriptor m_extensions;
-
- /**
* The root container.
*/
- private ClasspathDescriptor m_classpath;
+ private TypeManager m_manager;
/**
* The root container.
@@ -119,68 +113,51 @@
* Create a KernelDescriptor instance.
*
* @param name the kernel name
- * @param logging the logging defaults and top level categories
- * @param extensions the declaration of the extensions directories
+ * @param logging the logging manager
+ * @param manager the type manager
* @param container the root container
*/
public KernelDescriptor( final String name,
- final LoggingDescriptor logging,
- final ExtensionsDescriptor extensions,
- final ContainerDescriptor container )
+ final DefaultLoggerManager logging,
+ final TypeManager manager )
{
- super( name, logging.getCategoryDescriptor() );
+ super( null, name, logging );
- if( name == null )
- throw new NullPointerException("name");
- if( logging == null )
- throw new NullPointerException("logging");
- if( extensions == null )
- throw new NullPointerException("extensions");
+ if( manager == null )
+ throw new NullPointerException("manager");
- m_logging = logging;
- m_extensions = extensions;
- m_container = container;
+ m_manager = manager;
}
/**
- * Return the logging descriptor.
+ * Return the kernel type manager.
*
- * @return the {@link LoggingDescriptor} for the component loggers.
+ * @return the {@link TypeManager } for the kernel.
*/
- public LoggingDescriptor getLoggingDescriptor()
+ public TypeManager getTypeManager()
{
- return m_logging;
+ return m_manager;
}
/**
- * Return the extensions descriptor.
+ * Return the root container.
*
- * @return the {@link ExtensionsDescriptor} for the kernel.
+ * @return the root {@link ContainerDescriptor}.
*/
- public ExtensionsDescriptor getExtensionsDescriptor()
+ public ContainerDescriptor getContainer()
{
- return m_extensions;
+ return m_container;
}
/**
- * Return the classpath descriptor.
+ * Set the root container.
*
- * @return the {@link ClasspathDescriptor} for the kernel.
+ * @param container {@link ContainerDescriptor}.
*/
- public ClasspathDescriptor getClasspathDescriptor()
+ public void setContainer( ContainerDescriptor container )
{
- return m_classpath;
- }
-
- /**
- * Return the root container.
- *
- * @return the root {@link ContainerDescriptor}.
- */
- public ContainerDescriptor getContainer()
- {
- return m_container;
+ m_container = container;
}
1.6 +12 -82 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/LoggingDescriptor.java
Index: LoggingDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/LoggingDescriptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LoggingDescriptor.java 21 Jul 2002 05:03:11 -0000 1.5
+++ LoggingDescriptor.java 25 Jul 2002 18:07:16 -0000 1.6
@@ -14,16 +14,11 @@
*
* <p><b>XML</b></p>
* <p>A logging element declares the top level defaults for priority and target name, a set of
- * targets to which logging events shall be directoed, and the root set of logging categories.
+ * targets to which logging events shall be directed.
* The logging element declares the application wide default logging priority.
* A target element enables defintion of a logging file to which log entries will
* be directed. The target name attribute is the name referenced by category elements
- * defined within the loggers element. Child category declarations must include a name
- * (the logging catagory), and may optionally include a target and a priority attribute.
- * The target defaults of "default" which corresponds to a internal default logging
- * target that issue messages to System.out (unless overriden by a target named default).
- * If the target is declared inside a catagory element, it must refer to a named target
- * element. The priority attribute may container one of the values
+ * defined within the loggers element. The priority attribute may container one of the values
* <code>DEBUG</code>, <code>INFO</code>, <code>WARN</code> or <code>ERROR</code>.
* The target must contain a single file element with the attribute <code>location</code>
* the corresponds to the name of the logging file.</p>
@@ -33,39 +28,19 @@
* Definition of a logging system.
* --></i></font>
*
- * <logging priority="<font color="darkred">INFO</font>" target="<font color="darkred">kernel</font>">
+ * <logging name="" priority="<font color="darkred">INFO</font>" target="<font color="darkred">kernel</font>">
* <target name="<font color="darkred">kernel</font>">
* <file location="<font color="darkred">kernel.log</font>" />
* </target>
- * <loggers priority="<font color="darkred">WARN</font>">
- * <category name="<font color="darkred">logging</font>"/>
- * <category name="<font color="darkred">loader</font>"/>
- * <category name="<font color="darkred">installer</font>"/>
- * </loggers>
* </logging>
* </pre>
*
- * @see CategoryDescriptor
* @see TargetDescriptor
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public final class LoggingDescriptor extends CategoryDescriptor implements Serializable
+public final class LoggingDescriptor extends Category implements Serializable
{
- /**
- * The root category hierachy.
- */
- private CategoryDescriptor m_category;
-
- /**
- * The defaulr priority.
- */
- private String m_priority;
-
- /**
- * The default target.
- */
- private String m_target;
/**
* The dependencies keyed by role name.
@@ -75,20 +50,18 @@
/**
* Create a LoggingDescriptor instance.
*
- * @param priority the system wide default logging priority
- * @param target the system wide default logging target
+ * @param root the root logger category name
+ * @param priority the default logging priority
+ * @param target the default logging target
* @param targets the set of logging targets
- * @param category the root logging category descriptor
*/
- public LoggingDescriptor( final String priority,
+ public LoggingDescriptor( final String root,
+ final String priority,
final String target,
- final TargetDescriptor[] targets,
- final CategoryDescriptor category )
+ final TargetDescriptor[] targets )
{
- super( "", priority, target );
+ super( root, priority, target );
m_targets = targets;
- m_category = category;
- m_category.setParent( this );
}
/**
@@ -100,48 +73,5 @@
{
return m_targets;
}
-
- /**
- * Return the root catagory descriptor.
- *
- * @return the target descriptors
- */
- public CategoryDescriptor getCategoryDescriptor()
- {
- return m_category;
- }
-
- /**
- * Sets the parent category. Empty implementation.
- * @param parent the parent category from which the category name is relative
- * and from which default priority and target information is derived
- */
- public void setParent( CategoryDescriptor parent )
- {
- // null operation
- }
-
- /**
- * Return the category path. A category path is a result of the concatination of
- * the names of the parent category names with this category name. Names are seperated
- * by the period character.
- *
- * @return the category path
- */
- public String getPath()
- {
- return "";
- }
-
- /**
- * Return the set of logging categories locally container in the category descriptor.
- *
- * @return the set of service provider assignments.
- */
- public CategoryDescriptor[] getCategories()
- {
- return m_category.getCategories();
- }
-
}
1.6 +2 -5 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Parameter.java
Index: Parameter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Parameter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Parameter.java 23 Jul 2002 15:36:04 -0000 1.5
+++ Parameter.java 25 Jul 2002 18:07:16 -0000 1.6
@@ -333,13 +333,10 @@
}
catch( NoSuchMethodException e )
{
- final String stack = new String( this.toString() );
- System.out.println( stack );
- System.out.println( getClassesAsString( params ) );
final String error =
"Supplied parameters for " + m_classname
+ " does not match an available constructor. Cause: " + e.toString()
- + "\n" + stack;
+ + "\n" + this;
throw new ModelException( error );
}
1.2 +74 -14 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Parent.java
Index: Parent.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Parent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Parent.java 14 Jul 2002 10:40:40 -0000 1.1
+++ Parent.java 25 Jul 2002 18:07:16 -0000 1.2
@@ -8,6 +8,8 @@
package org.apache.excalibur.merlin.model;
import java.io.Serializable;
+import org.apache.excalibur.merlin.model.builder.DefaultLoggerManager;
+import org.apache.avalon.framework.logger.Logger;
/**
* Abstract class for types that can act as logical parents.
@@ -17,7 +19,8 @@
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public abstract class Parent implements Serializable
+public abstract class Parent
+ implements Serializable
{
/**
* The kernel name
@@ -27,7 +30,12 @@
/**
* The logging categories.
*/
- private CategoryDescriptor m_categories;
+ private DefaultLoggerManager m_logging;
+
+ /**
+ * The parent of this parent.
+ */
+ private Parent m_parent;
/**
* Abstract constructor that handles name and logging category assignment. The logging
@@ -37,37 +45,89 @@
* @param name the name of the instance
* @param categories the logging categories descriptor
*/
- public Parent( final String name,
- final CategoryDescriptor categories )
+ public Parent( final Parent parent, final String name, final DefaultLoggerManager logging )
{
- if( name == null )
+ if( name == null )
throw new NullPointerException("name");
- if( categories == null )
- throw new NullPointerException("loggers");
+ if( logging == null )
+ throw new NullPointerException("logging");
m_name = name;
- m_categories = categories;
+ m_logging = logging;
+ m_parent = parent;
}
+
/**
* Return the instance name.
*
* @return the name of the container
*/
- String getName()
+ public String getName()
{
return m_name;
}
+ /**
+ * Returns the path name of this container descriptor.
+ * @return the container's path
+ */
+ public String getPath()
+ {
+ if( getParent() == null )
+ {
+ return "/" + getName();
+ }
+ else
+ {
+ return getParent().getPath() + "/" + getName();
+ }
+ }
+
/**
- * Return the logging catagory descriptor.
+ * Set the parent container.
*
- * @return the {@link CategoryDescriptor}.
+ * @param the container containing this container.
+ * @exception IllegalStateException if the parent is already set
*/
- CategoryDescriptor getCategoryDescriptor()
+ public void setParent( Parent parent ) throws IllegalStateException
{
- return m_categories;
+ if( m_parent != null )
+ throw new IllegalStateException("parent");
+
+ m_parent = parent;
}
+ /**
+ * Return the parent container.
+ *
+ * @return the container containing this container.
+ */
+ public Parent getParent()
+ {
+ return m_parent;
+ }
+
+ /**
+ * Return the default logger.
+ *
+ * @return the {@link Logger}.
+ */
+ public Logger getLogger()
+ {
+ return m_logging.getLoggerForCategory(
+ getPath().replace('/','.').substring(1) );
+ }
+
+ /**
+ * Add a set of categories to the logging system as direct sub-categrories
+ * of the category representing this container.
+ *
+ * @parem categories {@link CategoriesDescriptor} set
+ */
+ public void addCategories( CategoriesDescriptor categories )
+ {
+ m_logging.addCategories( this, categories );
+ }
}
1.9 +57 -20 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Profile.java 20 Jul 2002 00:54:07 -0000 1.8
+++ Profile.java 25 Jul 2002 18:07:16 -0000 1.9
@@ -9,6 +9,7 @@
import java.io.Serializable;
import java.util.Hashtable;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.context.Context;
@@ -103,12 +104,22 @@
public static final int EXPLICIT = 2;
/**
+ * The container container.
+ */
+ private ContainerDescriptor m_container;
+
+ /**
* The name of the component profile. This is an
* abstract name used during assembly.
*/
private final String m_name;
/**
+ * The profile assigned logger.
+ */
+ private final Logger m_logger;
+
+ /**
* The dependencies keyed by role name.
*/
private final Hashtable m_dependencies = new Hashtable();
@@ -134,11 +145,6 @@
private final ContextDirective m_context;
/**
- * The logging descriptor.
- */
- private final CategoryDescriptor m_loggers;
-
- /**
* The creation mode.
*/
private final int m_mode;
@@ -171,7 +177,7 @@
final Parameters parameters,
final Configuration configuration,
final ContextDirective context,
- final CategoryDescriptor loggers,
+ final Logger logger,
final Type type,
final boolean enabled,
final boolean activation,
@@ -187,20 +193,41 @@
}
if( null == type )
- {
throw new NullPointerException( "type" );
- }
+ if( null == logger )
+ throw new NullPointerException( "logger" );
m_parameters = parameters;
m_configuration = configuration;
+ m_logger = logger;
m_type = type;
m_context = context;
- m_loggers = loggers;
m_enabled = enabled;
m_activation = activation;
m_mode = mode;
}
+ /**
+ * Return the container that this profile is container within.
+ *
+ * @return the parent {@link ContainerDescriptor }
+ */
+ public ContainerDescriptor getContainer()
+ {
+ return m_container;
+ }
+
+ /**
+ * Set the container containing this profile.
+ *
+ * @parent the container descriptor containing this profile
+ */
+ public void setContainer( ContainerDescriptor container )
+ {
+ m_container = container;
+ }
+
+
/**
* Test is this profile is enabled. A profile is enabled unless explicitly disabled by an
* assembly directive, or implicity disabled as a result of an assembly failure.
@@ -233,6 +260,26 @@
}
/**
+ * Return the logger for the profile.
+ *
+ * @return the logger
+ */
+ public Logger getLogger()
+ {
+ return m_logger;
+ }
+
+
+ /**
+ * Returns the path name of this container descriptor.
+ * @return the container's path
+ */
+ public String getPath()
+ {
+ return m_container.getPath() + "/" + getName();
+ }
+
+ /**
* Return the info for component.
*
* @return the info for component type.
@@ -280,16 +327,6 @@
public Configuration getConfiguration()
{
return m_configuration;
- }
-
- /**
- * Return the logging descriptor.
- *
- * @return the {@link CategoryDescriptor} for the component loggers.
- */
- public CategoryDescriptor getCategoryDescriptor()
- {
- return m_loggers;
}
/**
1.3 +5 -4 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerCreator.java
Index: ContainerCreator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerCreator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContainerCreator.java 12 Jul 2002 19:09:27 -0000 1.2
+++ ContainerCreator.java 25 Jul 2002 18:07:16 -0000 1.3
@@ -7,9 +7,10 @@
*/
package org.apache.excalibur.merlin.model.builder;
-import org.apache.excalibur.merlin.model.ContainerDescriptor;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.excalibur.merlin.model.builder.TypeManager;
+import org.apache.excalibur.merlin.model.ContainerDescriptor;
+import org.apache.excalibur.merlin.model.Parent;
/**
* Simple interface used to create {@link org.apache.excalibur.merlin.model.ContainerDescriptor}
@@ -27,7 +28,7 @@
* @return the newly created {@link org.apache.excalibur.merlin.model.ContainerDescriptor}
* @throws Exception
*/
- ContainerDescriptor createContainerDescriptor( Configuration config, TypeManager manager )
+ ContainerDescriptor createContainerDescriptor( Parent parent, Configuration config, TypeManager manager, DefaultLoggerManager logging )
throws Exception;
}
1.4 +3 -3 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/KernelCreator.java
Index: KernelCreator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/KernelCreator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- KernelCreator.java 14 Jul 2002 10:40:40 -0000 1.3
+++ KernelCreator.java 25 Jul 2002 18:07:16 -0000 1.4
@@ -7,9 +7,9 @@
*/
package org.apache.excalibur.merlin.model.builder;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.excalibur.merlin.model.KernelDescriptor;
-import org.apache.excalibur.merlin.model.builder.TypeManager;
/**
* Simple interface used to create {@link org.apache.excalibur.merlin.model.KernelDescriptor}
@@ -27,7 +27,7 @@
* @return the newly created {@link org.apache.excalibur.merlin.model.KernelDescriptor}
* @throws Exception
*/
- KernelDescriptor createKernelDescriptor( Configuration config, TypeManager manager )
+ KernelDescriptor createKernelDescriptor( Configuration config, ClassLoader loader )
throws Exception;
}
1.3 +6 -6 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileBuilder.java
Index: ProfileBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ProfileBuilder.java 20 Jul 2002 00:54:07 -0000 1.2
+++ ProfileBuilder.java 25 Jul 2002 18:07:16 -0000 1.3
@@ -18,6 +18,7 @@
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.meta.info.builder.TypeBuilder;
import org.apache.excalibur.merlin.model.Profile;
+import org.apache.excalibur.merlin.model.ContainerDescriptor;
import org.xml.sax.InputSource;
/**
@@ -42,16 +43,16 @@
* @return the created Type
* @throws Exception if an error occurs
*/
- public Profile[] build( Type type, final ClassLoader classLoader )
+ public Profile[] build( ContainerDescriptor container, Type type )
throws Exception
{
final String xprofile =
type.getInfo().getImplementationKey().replace( '.', '/' ) + ".xprofile";
final InputStream inputStream =
- classLoader.getResourceAsStream( xprofile );
+ container.getTypeManager().getResourceAsStream( xprofile );
final ProfileCreator creator = getXMLProfileCreator( xprofile );
- return creator.createProfiles( classLoader, type, inputStream );
+ return creator.createProfiles( container, type, inputStream );
}
@@ -71,8 +72,7 @@
else
{
final String message =
- REZ.getString( "builder.missing-xml-creator.error",
- classname );
+ REZ.getString( "builder.missing-xml-creator.error", classname );
throw new Exception( message );
}
}
1.3 +4 -3 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileCreator.java
Index: ProfileCreator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileCreator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ProfileCreator.java 20 Jul 2002 00:54:07 -0000 1.2
+++ ProfileCreator.java 25 Jul 2002 18:07:16 -0000 1.3
@@ -11,6 +11,7 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.merlin.model.Profile;
+import org.apache.excalibur.merlin.model.ContainerDescriptor;
/**
* Simple interface used to create {@link Profile}
@@ -29,7 +30,7 @@
* @return the newly created {@link Type}
* @throws Exception
*/
- Profile[] createProfiles( ClassLoader loader, Type type, InputStream inputStream )
+ Profile[] createProfiles( ContainerDescriptor container, Type type, InputStream inputStream )
throws Exception;
/**
@@ -39,7 +40,7 @@
* @return the profile
* @exception Exception if an error occurs during profile creation
*/
- Profile createProfile( ClassLoader loader, Type type, Configuration config )
+ Profile createProfile( ContainerDescriptor container, Type type, Configuration config )
throws Exception;
}
1.2 +13 -0 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/Resources.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Resources.properties 12 Jul 2002 12:04:55 -0000 1.1
+++ Resources.properties 25 Jul 2002 18:07:16 -0000 1.2
@@ -6,3 +6,16 @@
builder.missing-xml-creator.error=Unable to create XMLTypeCreator, usually due to not having XML classes on Classpath. Thus unable to lookup XML descriptor for component type "{0}".
builder.creating-profile.notice=Creating Profiles for class "{0}".
+
+target.nocreate=Error creating LogTarget named "{0}" for file {0}. (Reason: {2}).
+unknown-priority=Unknown priority "{0}" for Logger named "{1}".
+category-create=Creating a log category named "{0}" that writes to "{1}" target at priority "{2}".
+
+missing.extension=Unable to locate an extension that is required by application.\n Extension Name: {0}\n Specification Vendor: {1}\n Specification Version: {2}\n Implementation Vendor: {3}\n Implementation Vendor-Id: {4}\n Implementation Version: {5}\n Implementation URL: {6}
+unsatisfied.extensions=Missing {0} extensions and thus can not build ClassLoader for application.
+bad-classpath-entry=There is a bad entry ("{0}") on classpath that made it impossible to load a manifest.
+available-extensions=Available extensions: {0}
+required-extensions=The list of required extensions for application includes: {0}
+optional-packages-added=The list of "Optional Packages" added to the application include: {0}
+classpath-entries=The list of classpath entrys for the application include: {0}
+
1.3 +5 -12 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/TypeManager.java
Index: TypeManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/TypeManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TypeManager.java 20 Jul 2002 00:54:07 -0000 1.2
+++ TypeManager.java 25 Jul 2002 18:07:16 -0000 1.3
@@ -22,6 +22,9 @@
*/
public abstract class TypeManager extends URLClassLoader
{
+ public static final String EXTENSIONS_DESCRIPTOR_KEY = "extensions";
+ public static final String CLASSPATH_DESCRIPTOR_KEY = "classpath";
+
public TypeManager( )
{
@@ -43,7 +46,7 @@
* @param classpath the classpath descriptor
* @exception Exception if an exception occurs during class loading
*/
- public abstract void addClasspath( ClasspathDescriptor classpath ) throws Exception;
+ abstract void addClasspath( ClasspathDescriptor classpath ) throws Exception;
/**
* Resolve a {@link Type} from a classname.
@@ -52,16 +55,6 @@
* @return the component type
*/
public abstract Type lookup( String classname ) throws Exception;
-
- /**
- * Register a potential supplier component type. The implementation will
- * create a component type instance for the entry if not already known and
- * return the existing or new instance to the invoking client.
- *
- * @param classname the component class name
- * @return the component type
- */
- public abstract Type register( String classname ) throws Exception;
/**
* Returns the set of component types know to the registry.
1.6 +86 -40 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerCreator.java
Index: XMLContainerCreator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerCreator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLContainerCreator.java 20 Jul 2002 00:54:07 -0000 1.5
+++ XMLContainerCreator.java 25 Jul 2002 18:07:16 -0000 1.6
@@ -17,17 +17,21 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.configuration.ContextFactory;
import org.apache.excalibur.merlin.model.Profile;
-import org.apache.excalibur.merlin.model.CategoryDescriptor;
-import org.apache.excalibur.merlin.model.IncludeDescriptor ;
+import org.apache.excalibur.merlin.model.CategoriesDescriptor;
+import org.apache.excalibur.merlin.model.Category;
+import org.apache.excalibur.merlin.model.IncludeDescriptor;
import org.apache.excalibur.merlin.model.FilesetDescriptor;
import org.apache.excalibur.merlin.model.ClasspathDescriptor;
import org.apache.excalibur.merlin.model.ContainerDescriptor;
-import org.apache.excalibur.merlin.model.builder.TypeManager;
+import org.apache.excalibur.merlin.model.ModelException;
+import org.apache.excalibur.merlin.model.Parent;
/**
* Handles internalization of an XML based description of a {@link ContainerDescriptor}
@@ -43,54 +47,96 @@
private static final Resources REZ =
ResourceManager.getPackageResources( XMLContainerCreator.class );
-
- public ContainerDescriptor[] createContainerDescriptors( Configuration[] configs, TypeManager manager )
+ /**
+ * Create a new container descriptor.
+ * @param config the container configuration
+ * @param manager the parent type manager
+ * @param logger the parent logger
+ * @exception Exception is a error occurs during container descriptor creation
+ */
+ public ContainerDescriptor createContainerDescriptor(
+ Parent parent, Configuration config, TypeManager manager, DefaultLoggerManager logging )
throws Exception
{
- ArrayList list = new ArrayList();
- for( int i=0; i<configs.length; i++ )
+
+ //
+ // create the logging categories for this container
+ //
+
+ final String name = config.getAttribute("name");
+ CategoriesDescriptor categories = super.createCategoriesDescriptor(
+ name, config.getChild("categories") );
+ Logger logger;
+ if( parent instanceof ContainerDescriptor )
{
- Configuration config = configs[i];
- list.add( createContainerDescriptor( config, manager ) );
+ parent.addCategories( categories );
+ logger = parent.getLogger().getChildLogger( name );
+ }
+ else
+ {
+ logging.addCategories( categories );
+ logger = logging.getLoggerForCategory( name );
}
- return (ContainerDescriptor[]) list.toArray( new ContainerDescriptor[0] );
- }
- /**
- * Create a {@link ContainerDescriptor} from configuration
- *
- * @param config the confiugration source
- * @return the newly created {@link ContainerDescriptor}
- * @throws Exception
- */
- public ContainerDescriptor createContainerDescriptor( Configuration config, TypeManager manager )
- throws Exception
- {
- final String name = config.getAttribute("name");
- CategoryDescriptor loggers = createCategoryDescriptor( config.getChild("loggers"), name );
- ClasspathDescriptor classpath = createClasspathDescriptor( config.getChild("classpath") );
+ //
+ // create a new classloader for this container
+ //
- manager.addClasspath( classpath );
- Profile[] components = createComponentProfiles(
- manager, config.getChildren("component") );
+ logger.info("preparing type manager");
+ ClasspathDescriptor classpath = createClasspathDescriptor( config.getChild("classpath") );
+ final DefaultTypeManager loader = new DefaultTypeManager( manager );
+ try
+ {
+ loader.enableLogging( logger.getChildLogger( "loader" ) );
+ DefaultContext context = new DefaultContext();
+ context.put(
+ TypeManager.CLASSPATH_DESCRIPTOR_KEY,
+ classpath );
+ context.makeReadOnly();
+ loader.contextualize( context );
+ loader.initialize();
+ }
+ catch( Throwable e )
+ {
+ final String error = "Classloader establishment failure.";
+ throw new ModelException( error, e );
+ }
- ContainerDescriptor[] containers = createContainerDescriptors(
- config.getChildren("container"), manager );
+ //
+ // create an empty container
+ //
+
+ logger.info("container descriptor creation");
+ ContainerDescriptor container = new ContainerDescriptor(
+ parent, name, logging, loader );
+
+ //
+ // add all of the profiles declared within the container using the container's
+ // type manager
+ //
+
+ logger.info("component creation");
+ Configuration[] children = config.getChildren("component");
+ for( int i=0; i<children.length; i++ )
+ {
+ Configuration child = children[i];
+ Type type = loader.lookup( child.getAttribute("class") );
+ Profile profile = createProfile( container, type, child );
+ container.addComponent( profile );
+ }
- return new ContainerDescriptor( name, loggers, classpath, components, containers );
- }
+ //
+ // add all of the nested containers
+ //
- public Profile[] createComponentProfiles( TypeManager manager, Configuration[] configs )
- throws Exception
- {
- ArrayList list = new ArrayList();
+ final Configuration[] configs = config.getChildren("container");
for( int i=0; i<configs.length; i++ )
{
- Configuration config = configs[i];
- Type type = manager.lookup( config.getAttribute("class") );
- list.add( super.createProfile( manager, type, config ) );
+ final Configuration conf = configs[i];
+ container.addContainer( createContainerDescriptor( container, conf, loader, logging ) );
}
- return (Profile[]) list.toArray( new Profile[0] );
+
+ return container;
}
public ClasspathDescriptor createClasspathDescriptor( Configuration config )
1.6 +46 -12 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLKernelCreator.java
Index: XMLKernelCreator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLKernelCreator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLKernelCreator.java 17 Jul 2002 13:48:37 -0000 1.5
+++ XMLKernelCreator.java 25 Jul 2002 18:07:16 -0000 1.6
@@ -14,11 +14,14 @@
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.Version;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.DefaultContext;
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.merlin.model.Profile;
-import org.apache.excalibur.merlin.model.CategoryDescriptor;
+import org.apache.excalibur.merlin.model.Category;
+import org.apache.excalibur.merlin.model.CategoriesDescriptor;
import org.apache.excalibur.merlin.model.IncludeDescriptor ;
import org.apache.excalibur.merlin.model.FilesetDescriptor;
import org.apache.excalibur.merlin.model.ClasspathDescriptor;
@@ -30,7 +33,7 @@
import org.apache.excalibur.merlin.model.FileTargetProvider;
import org.apache.excalibur.merlin.model.TargetProvider;
import org.apache.excalibur.merlin.model.LoggingDescriptor;
-import org.apache.excalibur.merlin.model.builder.TypeManager;
+import org.apache.excalibur.merlin.model.ModelException;
/**
* Handles internalization of an XML based description of a {@link KernelDescriptor}
@@ -49,28 +52,60 @@
/**
* Create a {@link KernelDescriptor} from configuration
*
- * @param config the confiugration source
+ * @param config the configration source
+ * @param loader the parent classloader
* @return the newly created {@link ContainerDescriptor}
* @throws Exception
*/
- public KernelDescriptor createKernelDescriptor( Configuration config, TypeManager manager )
+ public KernelDescriptor createKernelDescriptor( Configuration config, ClassLoader loader )
throws Exception
{
+
final String name = config.getName();
- LoggingDescriptor logging = createLoggingDescriptor( config.getChild("logging"), name );
+ LoggingDescriptor loggingDescriptor = createLoggingDescriptor( config.getChild("logging"), name );
+ DefaultLoggerManager logging = new DefaultLoggerManager( loggingDescriptor );
+ CategoriesDescriptor categories = super.createCategoriesDescriptor(
+ name, config.getChild("categories") );
+ logging.addCategories( categories );
+ Logger logger = logging.getLoggerForCategory( name );
+
+ logger.info("preparing kernel type manager");
ExtensionsDescriptor extensions = createExtensionsDescriptor( config.getChild("extensions") );
ClasspathDescriptor classpath = createClasspathDescriptor( config.getChild("classpath") );
+ final DefaultTypeManager manager = new DefaultTypeManager( loader );
+ try
+ {
+ manager.enableLogging( logger.getChildLogger( "loader" ) );
+ DefaultContext context = new DefaultContext();
+ context.put(
+ TypeManager.EXTENSIONS_DESCRIPTOR_KEY,
+ extensions );
+ context.put(
+ TypeManager.CLASSPATH_DESCRIPTOR_KEY,
+ classpath );
+ context.makeReadOnly();
+ manager.contextualize( context );
+ manager.initialize();
+ }
+ catch( Throwable e )
+ {
+ final String error = "Classloader establishment failure.";
+ throw new TypeException( error, e );
+ }
- manager.addClasspath( classpath );
- ContainerDescriptor container = createContainerDescriptor( config.getChild("container"), manager );
- return new KernelDescriptor( name, logging, extensions, container );
+ logger.info("preparing kernel descriptor");
+ KernelDescriptor kernel = new KernelDescriptor( name, logging, manager );
+ ContainerDescriptor container = createContainerDescriptor(
+ kernel, config.getChild("container"), manager, logging );
+ kernel.setContainer( container );
+ return kernel;
}
public LoggingDescriptor createLoggingDescriptor( Configuration config, String name )
throws ConfigurationException
{
final String target = config.getAttribute(
- "target", CategoryDescriptor.DEFAULT_LOGGING_TARGET );
+ "target", Category.DEFAULT_LOGGING_TARGET );
final String priority = config.getAttribute( "priority", null );
ArrayList list = new ArrayList();
@@ -81,8 +116,7 @@
list.add( createTargetDescriptor( c ) );
}
TargetDescriptor[] targets = (TargetDescriptor[]) list.toArray( new TargetDescriptor[0] );
- CategoryDescriptor loggers = super.createCategoryDescriptor( config.getChild("loggers"), name );
- return new LoggingDescriptor( priority, target, targets, loggers );
+ return new LoggingDescriptor( name, priority, target, targets );
}
public TargetDescriptor createTargetDescriptor( Configuration config )
1.10 +67 -38 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XMLProfileCreator.java 23 Jul 2002 15:10:40 -0000 1.9
+++ XMLProfileCreator.java 25 Jul 2002 18:07:16 -0000 1.10
@@ -19,11 +19,14 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.meta.info.builder.XMLTypeCreator;
import org.apache.excalibur.meta.ConfigurationBuilder;
import org.apache.excalibur.merlin.model.Profile;
-import org.apache.excalibur.merlin.model.CategoryDescriptor;
+import org.apache.excalibur.merlin.model.ContainerDescriptor;
+import org.apache.excalibur.merlin.model.Category;
+import org.apache.excalibur.merlin.model.CategoriesDescriptor;
import org.apache.excalibur.merlin.model.ContextDirective;
import org.apache.excalibur.merlin.model.Import;
import org.apache.excalibur.merlin.model.Entry;
@@ -56,18 +59,19 @@
* @return the created set of profiles
* @throws ConfigurationException if an error occurs
*/
- public Profile[] createProfiles( ClassLoader loader, Type type, InputStream inputStream )
- throws Exception
+ public Profile[] createProfiles(
+ ContainerDescriptor container, Type type, InputStream inputStream )
+ throws Exception
{
if( inputStream != null )
{
final InputSource input = new InputSource( inputStream );
final Configuration configuration = ConfigurationBuilder.build( input );
- return createPackagedProfiles( loader, type, configuration );
+ return createPackagedProfiles( container, type, configuration );
}
else
{
- Profile profile = createImplicitProfile( loader, type );
+ Profile profile = createImplicitProfile( container, type );
return new Profile[]{ profile };
}
}
@@ -79,10 +83,11 @@
* @return the profile
* @exception Exception if an error occurs during profile creation
*/
- public Profile createProfile( ClassLoader loader, Type type, Configuration config )
- throws Exception
+ public Profile createProfile(
+ ContainerDescriptor container, Type type, Configuration config )
+ throws Exception
{
- return buildProfile( loader, type, config, Profile.EXPLICIT );
+ return buildProfile( container, type, config, Profile.EXPLICIT );
}
/**
@@ -94,35 +99,55 @@
* @return the created set of profiles
* @throws ConfigurationException if an error occurs
*/
- private Profile[] createPackagedProfiles( ClassLoader loader, Type type, final Configuration info )
- throws Exception
+ private Profile[] createPackagedProfiles(
+ ContainerDescriptor container, Type type, final Configuration info )
+ throws Exception
{
Vector vector = new Vector();
Configuration[] profiles = info.getChildren("component");
if( profiles.length == 0 )
{
- Profile profile = createImplicitProfile( loader, type );
+ Profile profile = createImplicitProfile( container, type );
return new Profile[]{ profile };
}
for( int i=0; i<profiles.length; i++ )
{
- vector.add( buildProfile( loader, type, profiles[i], Profile.PACKAGED ) );
+ vector.add( buildProfile( container, type, profiles[i], Profile.PACKAGED ) );
}
return (Profile[]) vector.toArray( new Profile[0] );
}
private Profile buildProfile(
- ClassLoader loader, Type type, Configuration profile, int mode ) throws Exception
+ ContainerDescriptor container, Type type, Configuration profile, int mode )
+ throws Exception
{
+
+ //
+ // create the logging categories for this profile
+ //
+
+ Logger logger;
final String name = profile.getAttribute("name");
+ CategoriesDescriptor categories = createCategoriesDescriptor( name, profile.getChild("categories") );
+ container.addCategories( categories );
+ logger = container.getLogger().getChildLogger( name );
+
+ //
+ // build the profile directives
+ //
+
final boolean enabled = profile.getAttributeAsBoolean( "enabled", true );
final boolean activation = profile.getAttributeAsBoolean( "activation", false );
final Parameters params = Parameters.fromConfiguration( profile.getChild("parameters") );
- final Configuration loggersConfig = profile.getChild("loggers");
- final CategoryDescriptor loggers = createCategoryDescriptor( loggersConfig, name );
final ContextDirective context = createContextDirective( profile.getChild("context") );
- final Configuration config = createConfiguration( loader, type, profile.getChild("configuration") );
- return new Profile( name, params, config, context, loggers, type, enabled, activation, mode );
+ final Configuration config = createConfiguration(
+ container.getTypeManager(), type, profile.getChild("configuration") );
+
+ //
+ // create the profile instance
+ //
+
+ return new Profile( name, params, config, context, logger, type, enabled, activation, mode );
}
public Configuration createConfiguration( ClassLoader loader, Type type, Configuration config )
@@ -257,40 +282,44 @@
}
}
-
- public CategoryDescriptor createCategoryDescriptor( Configuration config, String fallback )
- throws ConfigurationException
+ public CategoriesDescriptor createCategoriesDescriptor( String name, Configuration config )
+ throws Exception
{
- final String name = config.getAttribute( "name", fallback );
final String priority = config.getAttribute( "priority", null );
final String target = config.getAttribute( "target", null );
- CategoryDescriptor[] categories = createCategoryDescriptors( config );
- return new CategoryDescriptor( name, priority, target, categories );
- }
-
- private CategoryDescriptor[] createCategoryDescriptors( Configuration config )
- throws ConfigurationException
- {
ArrayList list = new ArrayList();
- Configuration[] categories = config.getChildren( "category" );
- for( int i=0; i<categories.length; i++ )
+ Configuration[] configs = config.getChildren( "category" );
+ for( int i=0; i<configs.length; i++ )
{
- CategoryDescriptor category = createCategoryDescriptor( categories[i], null );
+ Category category = createCategory( configs[i] );
list.add( category );
}
- return (CategoryDescriptor[]) list.toArray( new CategoryDescriptor[0] );
+ Category[] categories = (Category[]) list.toArray( new Category[0] );
+ return new CategoriesDescriptor( name, priority, target, categories );
}
- private Profile createImplicitProfile( ClassLoader loader, Type type ) throws Exception
+ private Category createCategory( Configuration config )
+ throws ConfigurationException
{
- CategoryDescriptor loggers = new CategoryDescriptor(
- type.getInfo().getName(), null, null );
+ final String name = config.getAttribute( "name" );
+ final String priority = config.getAttribute( "priority", null );
+ final String target = config.getAttribute( "target", null );
+ return new Category( name, priority, target );
+ }
+
+ private Profile createImplicitProfile(
+ ContainerDescriptor container, Type type ) throws Exception
+ {
+ Logger logger = container.getLogger().getChildLogger( type.getInfo().getName() );
ContextDirective context = new ContextDirective(
ContextDirective.DEFAULT_CONTEXT_CLASS, new Import[0], new Entry[0] );
- final Configuration defaults = type.getDefaultConfiguration( loader );
+ final Configuration defaults = type.getDefaultConfiguration( container.getTypeManager() );
+
return new Profile(
- type.getInfo().getName(), null, defaults, context, loggers, type, true, false,
+ type.getInfo().getName(), null, defaults, context, logger, type, true, false,
Profile.IMPLICIT
);
}
+
+
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>