mcconnell 2002/08/09 08:28:05
Modified: assembly/demo/src/java/org/apache/excalibur/playground
EmbeddedDemo.java
assembly/src/etc kernel.xml
assembly/src/java/org/apache/excalibur/merlin/assembly
ContainerManager.java DefaultLoggerManager.java
ProfileRegistry.java
assembly/src/java/org/apache/excalibur/merlin/container
DefaultContainer.java
assembly/src/java/org/apache/excalibur/merlin/kernel
DefaultKernel.java
assembly/src/java/org/apache/excalibur/merlin/model
LoggingDescriptor.java
assembly/src/java/org/apache/excalibur/merlin/model/builder
ContainerBuilder.java XMLContainerUtil.java
XMLProfileCreator.java
Log:
Enhancements to the logging messages related to assembly and cleaner defintion of
the bootstrap logging channel for the loging system.
Revision Changes Path
1.9 +2 -2
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- EmbeddedDemo.java 8 Aug 2002 21:30:16 -0000 1.8
+++ EmbeddedDemo.java 9 Aug 2002 15:28:04 -0000 1.9
@@ -114,9 +114,9 @@
if( profile != null )
{
- getLogger().debug( "dynamic profile: " + profile );
+ getLogger().info( "dynamic profile: " + profile );
container.install( new Profile[]{ profile } );
- getLogger().debug("installation sucessfull" );
+ getLogger().info("installation sucessfull" );
}
else
{
1.28 +9 -13 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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- kernel.xml 8 Aug 2002 21:30:17 -0000 1.27
+++ kernel.xml 9 Aug 2002 15:28:04 -0000 1.28
@@ -10,29 +10,25 @@
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.
+ defined within the loggers element.
+
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
<code>DEBUG</code>
- <code>DEBUG</code>, <code>INFO</code>, <code>WARN</code> or <code>ERROR</code>.
+ element. The priority attribute may contain 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.
-->
- <logging priority="INFO" target="default">
+ <logging priority="DEBUG" target="default">
+ <category priority="WARN" name="logging" />
<target name="kernel">
<file location="kernel.log" />
</target>
</logging>
- <categories priority="INFO">
- <category priority="WARN" name="logging" />
- <category priority="WARN" name="loader" />
- <category priority="WARN" name="export" />
- </categories>
-
<!--
Declaration of installed extension directories.
-->
@@ -44,7 +40,7 @@
</extensions>
<!--
- Declaration of root kernel classpath available to all containers.
+ Declaration of the root container.
-->
<container name="root">
@@ -59,6 +55,7 @@
<categories priority="INFO">
<category priority="WARN" name="loader" />
<category priority="WARN" name="loader.assembly" />
+ <category priority="WARN" name="kernel" />
</categories>
<!--
@@ -165,7 +162,6 @@
<categories priority="INFO"/>
<context>
<import key="avalon:home" name="avalon:home"/>
- <import key="classloader" name="classloader"/>
</context>
</component>
1.9 +91 -20
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ContainerManager.java 8 Aug 2002 21:30:17 -0000 1.8
+++ ContainerManager.java 9 Aug 2002 15:28:04 -0000 1.9
@@ -351,32 +351,71 @@
public void stop()
{
- Profile[] profiles = m_map.getShutdownGraph();
+ Profile[] shutdown = m_map.getShutdownGraph();
+ if( shutdown.length == 0 )
+ {
+ getLogger().info( "shutdown" );
+ return;
+ }
+
+ //
+ // reduce the shutdown graph to the local components
+ //
+
+ ArrayList local = new ArrayList();
+ for( int i=0; i<shutdown.length; i++ )
+ {
+ final Profile profile = shutdown[i];
+ if( isLocal( profile ) )
+ local.add( profile );
+ }
+ Profile[] profiles = (Profile[]) local.toArray( new Profile[0] );
if( profiles.length == 0 )
- return;
+ {
+ getLogger().info( "shutdown" );
+ return;
+ }
+
+ //
+ // list the local components we are stopping
+ //
+
+ if( getLogger().isInfoEnabled() )
+ {
+ StringBuffer buffer = new StringBuffer();
+ for( int i=0; i<profiles.length; i++ )
+ {
+ Profile profile = profiles[i];
+ buffer.append( profiles[i].getName() );
+ if( i<(profiles.length-1) )
+ buffer.append(", ");
+ }
+ getLogger().info("shutdown: " + buffer.toString() );
+ }
+
+ //
+ // stop the local components
+ //
for( int i=0; i<profiles.length; i++ )
{
Profile profile = profiles[i];
- if( isLocal( profile ) )
+ try
{
- try
- {
- Resource resource = getResource( profile );
- if( resource.getState() == Resource.STARTED )
- {
- getLocalLogger().info( "stopping: " + profile );
- resource.destroy();
- }
- }
- catch ( Throwable e )
+ Resource resource = getResource( profile );
+ if( resource.getState() == Resource.STARTED )
{
- final String warning =
- "Could not shutdown a service derived from profile: '"
- + profile.getName() + "'.";
- getLocalLogger().warn( warning, e );
+ getLocalLogger().info( "stopping: " + profile );
+ resource.destroy();
}
}
+ catch ( Throwable e )
+ {
+ final String warning =
+ "Could not shutdown a service derived from profile: '"
+ + profile.getName() + "'.";
+ getLocalLogger().warn( warning, e );
+ }
}
}
@@ -651,9 +690,41 @@
* @param profiles the set of profiles constituting the core components
* from which the associations between components will be based
*/
- public void assemble( Profile[] profiles ) throws Exception
+ public Profile[] assemble( Profile[] profiles ) throws Exception
{
- m_registry.assemble( profiles );
+ if( profiles.length == 0 )
+ return profiles;
+
+ DependencyGraph map = new DependencyGraph( m_map );
+ m_registry.assemble( map, profiles );
+ Profile[] result = map.getStartupGraph();
+ if( getLogger().isInfoEnabled() )
+ {
+ if( result.length > 0 )
+ {
+ StringBuffer buffer = new StringBuffer();
+ for( int i=0; i<result.length; i++ )
+ {
+ Profile profile = result[i];
+ if( isLocal( profile ) )
+ {
+ buffer.append( result[i].getName() );
+ }
+ else
+ {
+ buffer.append( "[" + result[i].getName() + "]" );
+ }
+ if( i<(result.length-1) )
+ buffer.append(", ");
+ }
+ getLogger().info("assembly: " + buffer.toString() );
+ }
+ else
+ {
+ getLogger().info( "assembly (empty)" );
+ }
+ }
+ return result;
}
/**
1.5 +20 -5
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultLoggerManager.java 8 Aug 2002 10:02:35 -0000 1.4
+++ DefaultLoggerManager.java 9 Aug 2002 15:28:04 -0000 1.5
@@ -28,7 +28,6 @@
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.AvalonFormatter;
import org.apache.avalon.framework.logger.LogKitLogger;
-//import org.apache.excalibur.merlin.model.Parent;
import org.apache.excalibur.merlin.model.TargetDescriptor;
import org.apache.excalibur.merlin.model.LoggingDescriptor;
import org.apache.excalibur.merlin.model.TargetProvider;
@@ -94,7 +93,10 @@
*/
public DefaultLoggerManager() throws Exception
{
- this( new LoggingDescriptor( "", null, null, new TargetDescriptor[0] ) );
+ this(
+ new LoggingDescriptor(
+ "", null, null, new TargetDescriptor[0],
+ new Category("logging", "WARN", null ) ) );
}
/**
@@ -128,6 +130,15 @@
}
//
+ // setup the bootstrap logging category
+ //
+
+ Category bootstrap = descriptor.getBootstrapCategory();
+ m_logger = new LogKitLogger(
+ addCategory(
+ bootstrap.getName(), bootstrap.getPriority(), bootstrap.getTarget(),
false ));
+
+ //
// build targets based on the information contained in the descriptor
//
@@ -195,6 +206,11 @@
private Logger addCategory( String path, String priority, String target )
{
+ return addCategory( path, priority, target, true );
+ }
+
+ private Logger addCategory( String path, String priority, String target,
boolean notify )
+ {
final Logger logger = getHierarchy().getLoggerFor( path );
if( priority != null )
{
@@ -218,12 +234,13 @@
logger.setLogTargets( new LogTarget[]{ (LogTarget) m_targets.get(
DEFAULT_TARGET ) } );
}
- if( getLogger().isDebugEnabled() )
+ if( notify && getLogger().isDebugEnabled() )
{
final String message =
REZ.getString( "category-create", path, target,
logger.getPriority() );
getLogger().info( message );
}
+
return logger;
}
@@ -340,8 +357,6 @@
*/
private org.apache.avalon.framework.logger.Logger getLogger( )
{
- if( m_logger == null )
- m_logger = getLoggerForCategory("kernel.logging");
return m_logger;
}
1.8 +4 -4
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ProfileRegistry.java 8 Aug 2002 10:02:35 -0000 1.7
+++ ProfileRegistry.java 9 Aug 2002 15:28:04 -0000 1.8
@@ -81,12 +81,13 @@
* The implementation will attempt to assembly each profile in the order
* supplied.
*
+ * @param map the dependency graph containing candidates and into which asemble
+ * profiles will be added
* @param profiles the set of profiles to assemble
* @exception Exception if an error occurs during assembly
*/
- public DependencyGraph assemble( Profile[] profiles ) throws Exception
+ public void assemble( DependencyGraph map, Profile[] profiles ) throws Exception
{
- DependencyGraph map = new DependencyGraph();
for( int i=0; i<profiles.length; i++ )
{
Profile profile = profiles[i];
@@ -101,7 +102,6 @@
m_map.add( profile );
map.add( profile );
}
- return map;
}
1.28 +16 -69
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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- DefaultContainer.java 8 Aug 2002 21:30:17 -0000 1.27
+++ DefaultContainer.java 9 Aug 2002 15:28:04 -0000 1.28
@@ -382,15 +382,18 @@
getLogger().debug("assembly");
Profile[] profiles = m_descriptor.getComponents( Profile.EXPLICIT, true );
- try
+ if( profiles.length > 0 )
{
- getLogger().debug("profile assembly (" + profiles.length + ")");
- m_manager.assemble( profiles );
- }
- catch( Throwable e )
- {
- final String error = "Assembly failure.";
- throw new ContainerException( error, e );
+ try
+ {
+ getLogger().debug("profile assembly (" + profiles.length + ")");
+ m_manager.assemble( profiles );
+ }
+ catch( Throwable e )
+ {
+ final String error = "Assembly failure.";
+ throw new ContainerException( error, e );
+ }
}
//
@@ -522,36 +525,11 @@
throw new IllegalStateException(
"Container has already passed through start phase.");
- if( getLogger().isDebugEnabled() )
- getLogger().debug("container startup");
-
- //
- // list the profiles in the startup graph
- //
-
if( getLogger().isInfoEnabled() )
- {
- Profile[] profiles = m_manager.getStartupGraph( false );
- if( profiles.length > 0 )
- {
- StringBuffer buffer = new StringBuffer();
- for( int i=0; i<profiles.length; i++ )
- {
- Profile profile = profiles[i];
- buffer.append( profiles[i].getName() );
- if( i<(profiles.length-1) )
- buffer.append(", ");
- }
- getLogger().info("startup: " + buffer.toString() );
- }
- else
- {
- getLogger().info( "startup" );
- }
- }
+ getLogger().info( "startup" );
//
- // request startup of any unstarted compoents
+ // request startup of any unstarted components
//
m_manager.start();
@@ -571,13 +549,10 @@
((Startable)next).start();
}
}
-
- while( !hasAchievedState( STARTED ) )
- sleep();
}
- getLogger().debug("container startup complete");
m_state = STARTED;
+ getLogger().debug("container startup complete");
fireStateChange( new StateEvent( this, STARTED ) );
}
@@ -624,34 +599,6 @@
}
}
}
- while( !hasAchievedState( STOPPED ) )
- sleep();
- }
-
- //
- // list all of the local components to stop
- //
-
- if( getLogger().isInfoEnabled() )
- {
- Profile[] profiles = m_manager.getShutdownGraph();
-
- if( profiles.length > 0 )
- {
- StringBuffer buffer = new StringBuffer();
- for( int i=0; i<profiles.length; i++ )
- {
- Profile profile = profiles[i];
- buffer.append( profiles[i].getName() );
- if( i<(profiles.length-1) )
- buffer.append(", ");
- }
- getLogger().info("shutdown: " + buffer.toString() );
- }
- else
- {
- getLogger().info( "shutdown" );
- }
}
//
@@ -660,8 +607,8 @@
m_manager.stop();
- getLogger().debug("container shutdown complete");
m_state = STOPPED;
+ getLogger().debug("container shutdown complete");
fireStateChange( new StateEvent( this, STOPPED ) );
}
1.33 +4 -3
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.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- DefaultKernel.java 8 Aug 2002 21:30:17 -0000 1.32
+++ DefaultKernel.java 9 Aug 2002 15:28:04 -0000 1.33
@@ -304,11 +304,12 @@
}
//
- // Setup the logging categories for the kernel
+ // Setup the logging categories
//
+ Configuration categoriesConfig = config.getChild("categories" );
CategoriesDescriptor categories =
- m_creator.createCategoriesDescriptor( name,
m_config.getChild("categories") );
+ m_creator.createCategoriesDescriptor( name, categoriesConfig );
getLoggingManager().addCategories( m_base, categories );
//
1.9 +25 -3
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- LoggingDescriptor.java 2 Aug 2002 06:34:51 -0000 1.8
+++ LoggingDescriptor.java 9 Aug 2002 15:28:04 -0000 1.9
@@ -30,6 +30,7 @@
* --></i></font>
*
* <logging name="" priority="<font color="darkred">INFO</font>"
target="<font color="darkred">kernel</font>">
+ * <category name="logging" priority="<font
color="darkred">WARN</font>"/>
* <target name="<font color="darkred">kernel</font>">
* <file location="<font color="darkred">kernel.log</font>" />
* </target>
@@ -49,11 +50,16 @@
private final TargetDescriptor[] m_targets;
/**
+ * The bootstrap logging category.
+ */
+ private final Category m_bootstrap;
+
+ /**
* Create a LoggingDescriptor instance.
*/
public LoggingDescriptor( )
{
- this( "", null, null, new TargetDescriptor[0] );
+ this( "", null, null, new TargetDescriptor[0], new Category("logging") );
}
/**
@@ -63,14 +69,18 @@
* @param priority the default logging priority
* @param target the default logging target
* @param targets the set of logging targets
+ * @param bootstrap the bootstrap category to use to log mesages
+ * from the logging system
*/
public LoggingDescriptor( final String root,
final String priority,
final String target,
- final TargetDescriptor[] targets )
+ final TargetDescriptor[] targets,
+ final Category bootstrap )
{
super( root, priority, target );
m_targets = targets;
+ m_bootstrap = bootstrap;
}
/**
@@ -82,5 +92,17 @@
{
return m_targets;
}
+
+ /**
+ * Return the bootstrap logging category to which the logging manager will
+ * log information about its own activities.
+ *
+ * @return the category
+ */
+ public Category getBootstrapCategory()
+ {
+ return m_bootstrap;
+ }
+
}
1.3 +2 -2
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerBuilder.java
Index: ContainerBuilder.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContainerBuilder.java 8 Aug 2002 21:30:18 -0000 1.2
+++ ContainerBuilder.java 9 Aug 2002 15:28:04 -0000 1.3
@@ -19,7 +19,7 @@
import org.apache.excalibur.merlin.model.ContainerDescriptor;
/**
- * A ProfileBuilder is responsible for building {@link ContainerDescriptor}
+ * A ContainerCreator is responsible for building {@link ContainerDescriptor}
* objects from Configuration objects.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
@@ -57,7 +57,7 @@
* Utility to get xml info builder, else throw
* an exception if missing descriptor.
*
- * @return the ProfileCreator
+ * @return the ContainerCreator
*/
private ContainerCreator getXMLContainerCreator( final String classname )
throws Exception
1.2 +3 -2
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerUtil.java
Index: XMLContainerUtil.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLContainerUtil.java 2 Aug 2002 12:31:38 -0000 1.1
+++ XMLContainerUtil.java 9 Aug 2002 15:28:04 -0000 1.2
@@ -85,6 +85,7 @@
final String target = config.getAttribute(
"target", Category.DEFAULT_LOGGING_TARGET );
final String priority = config.getAttribute( "priority", null );
+ Category category = createCategory( config.getChild("category") );
ArrayList list = new ArrayList();
Configuration[] configs = config.getChildren("target");
@@ -94,7 +95,7 @@
list.add( createTargetDescriptor( c ) );
}
TargetDescriptor[] targets = (TargetDescriptor[]) list.toArray( new
TargetDescriptor[0] );
- return new LoggingDescriptor( name, priority, target, targets );
+ return new LoggingDescriptor( name, priority, target, targets, category );
}
public TargetDescriptor createTargetDescriptor( Configuration config )
1.15 +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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XMLProfileCreator.java 8 Aug 2002 10:02:36 -0000 1.14
+++ XMLProfileCreator.java 9 Aug 2002 15:28:04 -0000 1.15
@@ -243,7 +243,7 @@
return new CategoriesDescriptor( name, priority, target, categories );
}
- private Category createCategory( Configuration config )
+ public Category createCategory( Configuration config )
throws ConfigurationException
{
final String name = config.getAttribute( "name" );
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>