donaldp 2002/11/07 16:16:56
Modified: fortress/src/java/org/apache/excalibur/fortress/handler
AbstractComponentHandler.java
FactoryComponentHandler.java
PerThreadComponentHandler.java
PoolableComponentHandler.java
ThreadSafeComponentHandler.java
Log:
Homogenize initialize handling and allow subclasses to overide a doInitialize()
Revision Changes Path
1.20 +27 -1
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/AbstractComponentHandler.java
Index: AbstractComponentHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/AbstractComponentHandler.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- AbstractComponentHandler.java 8 Nov 2002 00:06:34 -0000 1.19
+++ AbstractComponentHandler.java 8 Nov 2002 00:16:56 -0000 1.20
@@ -167,6 +167,32 @@
}
/**
+ * Initialize the ComponentHandler.
+ */
+ public synchronized void initialize()
+ throws Exception
+ {
+ if( m_initialized )
+ {
+ return;
+ }
+
+ doInitialize();
+
+ if( m_logger.isDebugEnabled() )
+ {
+ final String message = "ComponentHandler initialized for: " +
+ m_factory.getCreatedClass().getName();
+ m_logger.debug( message );
+ }
+
+ m_initialized = true;
+ }
+
+ protected abstract void doInitialize()
+ throws Exception;
+
+ /**
* Get a reference of the desired Component
*/
public Object get()
1.29 +3 -13
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/FactoryComponentHandler.java
Index: FactoryComponentHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/FactoryComponentHandler.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- FactoryComponentHandler.java 8 Nov 2002 00:06:34 -0000 1.28
+++ FactoryComponentHandler.java 8 Nov 2002 00:16:56 -0000 1.29
@@ -87,19 +87,9 @@
/**
* Initialize the ComponentHandler.
*/
- public void initialize()
+ protected void doInitialize()
+ throws Exception
{
- if( m_initialized )
- {
- return;
- }
-
- if( m_logger.isDebugEnabled() )
- {
- m_logger.debug( "ComponentHandler initialized for: "
- + this.m_factory.getCreatedClass().getName() );
- }
- m_initialized = true;
}
/**
1.32 +4 -26
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/PerThreadComponentHandler.java
Index: PerThreadComponentHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/PerThreadComponentHandler.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- PerThreadComponentHandler.java 8 Nov 2002 00:06:34 -0000 1.31
+++ PerThreadComponentHandler.java 8 Nov 2002 00:16:56 -0000 1.32
@@ -88,32 +88,9 @@
setInstrumentableName( "PerThreadComponentHandler" );
}
- /**
- * Initialize the ComponentHandler.
- */
- public void initialize()
+ protected void doInitialize()
throws Exception
{
- if( m_initialized )
- {
- return;
- }
-
- if( m_logger.isDebugEnabled() )
- {
- if( this.m_factory != null )
- {
- m_logger.debug( "ComponentHandler initialized for: "
- + this.m_factory.getCreatedClass().getName() );
- }
- else
- {
- m_logger.debug( "ComponentHandler initialized for: "
- + this.m_instance.getClass().getName() );
- }
- }
-
- m_initialized = true;
}
/**
@@ -147,7 +124,8 @@
super.dispose();
}
- private static final class ThreadLocalComponent extends ThreadLocal
+ private static final class ThreadLocalComponent
+ extends ThreadLocal
{
private final ComponentFactory m_factory;
private final Logger m_logger;
1.33 +2 -14
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/PoolableComponentHandler.java
Index: PoolableComponentHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/PoolableComponentHandler.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- PoolableComponentHandler.java 8 Nov 2002 00:06:34 -0000 1.32
+++ PoolableComponentHandler.java 8 Nov 2002 00:16:56 -0000 1.33
@@ -101,22 +101,10 @@
/**
* Initialize the ComponentHandler.
*/
- public void initialize()
+ protected void doInitialize()
throws Exception
{
- if( m_initialized )
- {
- return;
- }
-
m_pool = m_poolManager.getManagedPool( m_factory, m_poolMin );
-
- if( m_logger.isDebugEnabled() )
- {
- m_logger.debug( "ComponentHandler initialized for: " +
- m_factory.getCreatedClass().getName() );
- }
- m_initialized = true;
}
/**
1.32 +2 -16
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/ThreadSafeComponentHandler.java
Index: ThreadSafeComponentHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/ThreadSafeComponentHandler.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- ThreadSafeComponentHandler.java 8 Nov 2002 00:10:57 -0000 1.31
+++ ThreadSafeComponentHandler.java 8 Nov 2002 00:16:56 -0000 1.32
@@ -90,24 +90,10 @@
/**
* Initialize the ComponentHandler.
*/
- public synchronized void initialize()
+ protected void doInitialize()
throws Exception
{
- if( m_initialized )
- {
- return;
- }
-
m_instance = m_factory.newInstance();
-
- if( m_logger.isDebugEnabled() )
- {
- final String message = "ComponentHandler initialized for: " +
- m_factory.getCreatedClass().getName();
- m_logger.debug( message );
- }
-
- m_initialized = true;
}
/**
--
To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>