donaldp 2002/11/06 23:15:13
Modified: component/src/java/org/apache/avalon/excalibur/component
DefaultComponentFactory.java
Log:
iUse ContainerUtil where possible.
Revision Changes Path
1.12 +17 -36
jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java
Index: DefaultComponentFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DefaultComponentFactory.java 7 Nov 2002 06:37:53 -0000 1.11
+++ DefaultComponentFactory.java 7 Nov 2002 07:15:13 -0000 1.12
@@ -31,6 +31,7 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.excalibur.container.legacy.ComponentProxyGenerator;
import org.apache.excalibur.instrument.InstrumentManageable;
import org.apache.excalibur.instrument.InstrumentManager;
@@ -178,7 +179,7 @@
{
if( null == m_loggerManager || null == m_configuration )
{
- ( (LogEnabled)component ).enableLogging( getLogger() );
+ ContainerUtil.enableLogging( component, getLogger() );
}
else
{
@@ -186,12 +187,12 @@
if( null == logger )
{
getLogger().debug( "no logger attribute available, using
standard logger" );
- ( (LogEnabled)component ).enableLogging( getLogger() );
+ ContainerUtil.enableLogging( component, getLogger() );
}
else
{
getLogger().debug( "logger attribute is " + logger );
- ( (LogEnabled)component ).enableLogging(
m_loggerManager.getLoggerForCategory( logger ) );
+ ContainerUtil.enableLogging( component,
m_loggerManager.getLoggerForCategory( logger ) );
}
}
}
@@ -232,7 +233,7 @@
if( component instanceof Contextualizable )
{
- ( (Contextualizable)component ).contextualize( m_context );
+ ContainerUtil.contextualize( component, m_context );
}
Object proxy = null;
@@ -242,7 +243,7 @@
// wrap the real CM with a proxy, see below for more info
final ComponentManagerProxy manager =
new ComponentManagerProxy( m_componentManager );
- ( (Composable)component ).compose( manager );
+ ContainerUtil.compose( component, manager );
proxy = manager;
}
@@ -251,7 +252,7 @@
// wrap the real CM with a proxy, see below for more info
final ServiceManagerProxy manager =
new ServiceManagerProxy( m_componentManager );
- ( (Serviceable)component ).service( manager );
+ ContainerUtil.service( component, manager );
proxy = manager;
}
@@ -265,21 +266,15 @@
( (LogKitManageable)component ).setLogKitManager(
m_loggerManager.getLogKitManager() );
}
- if( component instanceof Configurable )
- {
- ( (Configurable)component ).configure( m_configuration );
- }
+ ContainerUtil.configure( component, m_configuration );
if( component instanceof Parameterizable )
{
- ( (Parameterizable)component ).
- parameterize( Parameters.fromConfiguration( m_configuration ) );
+ final Parameters parameters = Parameters.fromConfiguration(
m_configuration );
+ ContainerUtil.parameterize( component, parameters );
}
- if( component instanceof Initializable )
- {
- ( (Initializable)component ).initialize();
- }
+ ContainerUtil.initialize( component );
// Register the component as an instrumentable now that it has been
initialized.
if( component instanceof Instrumentable )
@@ -291,11 +286,7 @@
(Instrumentable)component, m_instrumentableName );
}
}
-
- if( component instanceof Startable )
- {
- ( (Startable)component ).start();
- }
+ ContainerUtil.start( component );
m_components.put( component, proxy );
@@ -319,9 +310,7 @@
return m_componentClass;
}
- public final void decommission
- (
- final Object component )
+ public final void decommission( final Object component )
throws Exception
{
Object check = m_components.get( component );
@@ -342,15 +331,8 @@
m_componentClass.getName() + "." );
}
- if( decommission instanceof Startable )
- {
- ( (Startable)decommission ).stop();
- }
-
- if( component instanceof Disposable )
- {
- ( (Disposable)decommission ).dispose();
- }
+ ContainerUtil.stop( component );
+ ContainerUtil.dispose( component );
if( decommission instanceof Composable )
{
@@ -370,8 +352,7 @@
/*---------------------------------------------------------------
* Disposable Methods
*-------------------------------------------------------------*/
- public final void dispose
- ()
+ public final void dispose()
{
Component[] components = new Component[ m_components.keySet().size() ];
--
To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>