donaldp 2002/11/10 23:02:22
Modified: fortress/src/java/org/apache/excalibur/fortress/handler
ComponentFactory.java
Log:
calc logger once
Revision Changes Path
1.37 +30 -23
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/ComponentFactory.java
Index: ComponentFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/ComponentFactory.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- ComponentFactory.java 10 Nov 2002 12:00:17 -0000 1.36
+++ ComponentFactory.java 11 Nov 2002 07:02:22 -0000 1.37
@@ -120,6 +120,7 @@
/** InstrumentManager
*/
private final InstrumentManager m_instrumentManager;
+ private Logger m_componentLogger;
/**
* Construct a new component factory for the specified component.
@@ -147,6 +148,7 @@
enableLogging( m_loggerManager.getLoggerForCategory( "system.factory" ) );
m_instrumentManager = instrumentManager;
m_instrumentableName = configuration.getAttribute( "id",
componentClass.getName() );
+ m_componentLogger = aquireLogger();
m_newInstance = new CounterInstrument( "creates" );
m_dispose = new CounterInstrument( "destroys" );
@@ -168,30 +170,10 @@
if( component instanceof LogEnabled ||
component instanceof Loggable )
{
- Logger logger;
- final String name = ( m_configuration == null ? null :
m_configuration.getAttribute( "name", null ) );
- if( null == name )
- {
- if( getLogger().isDebugEnabled() )
- {
- final String message = "no name attribute available, using
standard name";
- getLogger().debug( message );
- }
- logger = m_loggerManager.getDefaultLogger();
- }
- else
- {
- if( getLogger().isDebugEnabled() )
- {
- final String message = "name attribute is " + name;
- getLogger().debug( message );
- }
- logger = m_loggerManager.getLoggerForCategory( name );
- }
if( component instanceof LogEnabled )
{
- ContainerUtil.enableLogging( component, logger );
+ ContainerUtil.enableLogging( component, m_componentLogger );
}
else
{
@@ -203,7 +185,7 @@
System.out.println( message );
final org.apache.log.Logger logkitLogger =
- LogKit2AvalonLoggerAdapter.createLogger( logger );
+ LogKit2AvalonLoggerAdapter.createLogger( m_componentLogger );
( (Loggable)component ).setLogger( logkitLogger );
}
}
@@ -244,6 +226,31 @@
}
return component;
+ }
+
+ private Logger aquireLogger()
+ {
+ Logger logger;
+ final String name = ( m_configuration == null ? null :
m_configuration.getAttribute( "name", null ) );
+ if( null == name )
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message = "no name attribute available, using standard
name";
+ getLogger().debug( message );
+ }
+ logger = m_loggerManager.getDefaultLogger();
+ }
+ else
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message = "name attribute is " + name;
+ getLogger().debug( message );
+ }
+ logger = m_loggerManager.getLoggerForCategory( name );
+ }
+ return logger;
}
public final Class getCreatedClass()
--
To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>