although the pooled lifestyle is already in the documentation, but was not completly integrated.
the attached patch fixes some issues with the pool. apparently the appliance is not assembled inside the initialize-method, so that is not the right place for initializing the pool. thus I shifted the pool initliaization to the access-method and made it lazy.
the configure method is still unused, I just don't know from where to get the configruration object. anyway the question for me would be:
is the pool size part of the xconfig file or part of the xtype file (as attribute similar to the lifestyle attribute) ?
hope the patch helps as it is
with best wishes Kristian
Index: src/java/org/apache/avalon/assembly/lifestyle/impl/DefaultLifestyleService.java
===================================================================
RCS file:
/home/cvspublic/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/DefaultLifestyleService.java,v
retrieving revision 1.3
diff -u -r1.3 DefaultLifestyleService.java
--- src/java/org/apache/avalon/assembly/lifestyle/impl/DefaultLifestyleService.java
8 May 2003 03:02:39 -0000 1.3
+++ src/java/org/apache/avalon/assembly/lifestyle/impl/DefaultLifestyleService.java
17 Jun 2003 06:33:15 -0000
@@ -232,6 +232,21 @@
"Internal error while attempting to establish the transient
lifestyle handler.";
throw new LifestyleRuntimeException( error, e );
}
+ } else if( policy.equals( "pooled" ) )
+ {
+ try
+ {
+ PooledLifestyleHandler pooled = new PooledLifestyleHandler();
+ pooled.enableLogging( getLogger() );
+ pooled.contextualize( context );
+ pooled.initialize();
+ return pooled;
+ } catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to establish the pooled lifestyle
handler.";
+ throw new LifestyleRuntimeException( error, e );
+ }
} else
{
final String error =
Index: src/java/org/apache/avalon/assembly/lifestyle/impl/PooledLifestyleHandler.java
===================================================================
RCS file:
/home/cvspublic/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/PooledLifestyleHandler.java,v
retrieving revision 1.2
diff -u -r1.2 PooledLifestyleHandler.java
--- src/java/org/apache/avalon/assembly/lifestyle/impl/PooledLifestyleHandler.java
9 Jun 2003 01:11:17 -0000 1.2
+++ src/java/org/apache/avalon/assembly/lifestyle/impl/PooledLifestyleHandler.java
17 Jun 2003 06:33:15 -0000
@@ -107,7 +107,7 @@
/**
* The object pool size.
*/
- private int m_size;
+ private int m_size = 5;
/**
* The class of object managed by the pool.
@@ -127,9 +127,9 @@
{
if( config == null )
{
- throw new NullPointerException( "config" );
+ throw new NullPointerException( "config" );
}
- m_size = config.getAttributeAsInteger( "size", 5 );
+ else m_size = config.getAttributeAsInteger( "size", 5 );
}
//==============================================================
@@ -161,7 +161,6 @@
public void initialize() throws Exception
{
super.initialize();
- m_pool = m_poolManager.getManagedPool( this, m_size );
m_appliance = (Appliance) m_context.get( "urn:assembly:appliance.target" );
ClassLoader classloader = (ClassLoader) m_context.get(
"urn:avalon:classloader" );
m_class = classloader.loadClass(
m_appliance.getType().getInfo().getClassname() );
@@ -190,9 +189,19 @@
*/
private Object access() throws LocatorException
{
- try
+ try
{
- Object object = m_pool.acquire();
+ if( m_pool == null )
+ {
+ synchronized( m_pool )
+ {
+ if( m_pool == null )
+ {
+ m_pool = m_poolManager.getManagedPool( this, m_size );
+ }
+ }
+ }
+ Object object = m_pool.acquire();
super.processAccessStage( object );
return object;
} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
