Applied and committed.

:=D

Gary Shea wrote:

On Tue, 19 Nov 2002, at 06:43 [+0100], Stephen McConnell ([EMAIL PROTECTED]:

Umm, ... give me a couple of hours and I'll start digging.

Cheers, Steve.

Not to worry, I hope to be asleep long before that!

Attached find some patches. I've edited out some of the worst crap that
should not be admitted to in public.

DefaultLifestyleManager and PooledLifestyleHander -- this code was broken.
Turns out that the attempt to get the pool setup from inside the
PooledLifestyleHandler constructor caused a self-call which wanted to
print a log message. Tough when enableLogging() hasn't been called yet.
Moved the pool setup to (new method) initialize(). Obvious fix.

The rest is just trying to push errors into sight. The error stuff has
no 'finished product' polish, I still haven't stumbled on where the
error formatting is coming from.

Apologies in advance if I've got Avalon style problems, I just
discovered that netbeans has a nasty habit of reformatting stuff.
Uggh. I think I fixed most of the disasters!

Pick and choose as desired.

Good night...

Gary

------------------------------------------------------------------------

Index: src/java/org/apache/excalibur/merlin/assembly/TypeManager.java
===================================================================
RCS file: /home/cvspublic/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java,v
retrieving revision 1.28
diff -u -r1.28 TypeManager.java
--- src/java/org/apache/excalibur/merlin/assembly/TypeManager.java 19 Nov 2002 03:12:20 -0000 1.28
+++ src/java/org/apache/excalibur/merlin/assembly/TypeManager.java 19 Nov 2002 06:54:37 -0000
@@ -576,13 +576,17 @@
public Type getType( String classname ) throws TypeException
{
getLocalLogger().debug( "load: " + classname );
+ + // m_types is a TypeRegistry object.
Type type = m_types.getType( classname );
+ if( type != null )
{
return type;
}
else
{
+ getLocalLogger().debug( "add new type: " + classname );

//
// try to construct the type
@@ -590,6 +594,7 @@

try
{
+ // Ask the type registry to load the type from the classloader.
return m_types.addType( classname );
}
catch( Throwable e )
@@ -606,7 +611,7 @@
else
{
throw new TypeException(
- "Type not found, classname: " + classname );
+ "Type not found, classname: " + classname, e );
}
}
}
Index: src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java
===================================================================
RCS file: /home/cvspublic/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java,v
retrieving revision 1.21
diff -u -r1.21 TypeRegistry.java
--- src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java 19 Nov 2002 03:12:20 -0000 1.21
+++ src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java 19 Nov 2002 06:54:38 -0000
@@ -156,9 +156,13 @@
final String classname = path.replace( '/', '.' );

getLogger().debug( "type: " + classname );
+ + // Try loading it from the local collection of known Types.
Type type = getType( classname );
+
if( type == null )
{
+ // Ask a TypeBuilder object to build the Type from a file in the filesystem.
type = m_typeBuilder.build( classname, m_classloader );
verify( type );
register( type );
@@ -330,6 +334,7 @@
*/
public Type getType( String classname )
{
+ // m_types is a hash table of registered Types.
return (Type)m_types.get( classname );
}

Index: src/java/org/apache/excalibur/merlin/container/ContainerHelper.java
===================================================================
RCS file: /home/cvspublic/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerHelper.java,v
retrieving revision 1.8
diff -u -r1.8 ContainerHelper.java
--- src/java/org/apache/excalibur/merlin/container/ContainerHelper.java 18 Nov 2002 10:52:53 -0000 1.8
+++ src/java/org/apache/excalibur/merlin/container/ContainerHelper.java 19 Nov 2002 06:54:40 -0000
@@ -234,7 +234,7 @@
"Ignoring component declaration at "
+ component.getLocation()
+ " due to unknown type: " + c;
- getLogger().warn( warning );
+ getLogger().warn( warning, e );
}
}

Index: src/java/org/apache/excalibur/merlin/resource/DefaultLifestyleManager.java
===================================================================
RCS file: /home/cvspublic/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultLifestyleManager.java,v
retrieving revision 1.10
diff -u -r1.10 DefaultLifestyleManager.java
--- src/java/org/apache/excalibur/merlin/resource/DefaultLifestyleManager.java 23 Oct 2002 16:33:08 -0000 1.10
+++ src/java/org/apache/excalibur/merlin/resource/DefaultLifestyleManager.java 19 Nov 2002 06:54:43 -0000
@@ -55,6 +55,7 @@

package org.apache.excalibur.merlin.resource;

+import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
@@ -66,14 +67,16 @@
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.mpool.PoolManager;

+
/**
* Utility class that handles the establishment of an appropriate lifestyle
* handler based on a supplied profile.
*
* @author <a href="mailto:[EMAIL PROTECTED]";>Stephen McConnell</a>
*/
-public class DefaultLifestyleManager extends AbstractLogEnabled
- implements LifestyleManager, Configurable, Contextualizable, Initializable
+public class DefaultLifestyleManager
+ extends AbstractLogEnabled
+ implements LifestyleManager, Initializable, Configurable, Contextualizable
{
/**
* The supplied configuration.
@@ -84,6 +87,7 @@
* The pool manager aquired via the supplied context.
*/
private PoolManager m_poolManager;
+
/**
* Configuration of the lifestyle manager (not used at this time)
@@ -152,12 +156,11 @@
DeploymentHelper deployment,
LifecycleHelper helper,
Profile profile,
- Context context )
- throws Exception
+ Context context ) throws Exception
{
final String policy =
profile.getType().getInfo().getAttribute( AVALON_LIFESTYLE_KEY, "singleton" );
-
+ if( policy.equalsIgnoreCase( "singleton" ) )
{
//
@@ -197,19 +200,25 @@
// create a pooled lifestyle handler
//

+ if ( getLogger().isDebugEnabled() ) {
+ getLogger().debug (
+ "m_poolManager is "
+ + (m_poolManager == null ? "null" : "not null") );
+ }
+ try
{
PooledLifestyleHandler handler =
new PooledLifestyleHandler( manager, deployment, helper, profile, context, m_poolManager );
handler.enableLogging( getLogger() );
+ handler.initialize();
return handler;
}
catch( Exception e )
{
final String error =
- "Unable to handle the 'pooled' lifestyle policy due to an error\n"
- + e.getMessage();
- throw new IllegalArgumentException( error );
+ "Unable to handle the 'pooled' lifestyle policy";
+ throw new CascadingRuntimeException( error, e );
}
}
else
Index: src/java/org/apache/excalibur/merlin/resource/PooledLifestyleHandler.java
===================================================================
RCS file: /home/cvspublic/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/PooledLifestyleHandler.java,v
retrieving revision 1.8
diff -u -r1.8 PooledLifestyleHandler.java
--- src/java/org/apache/excalibur/merlin/resource/PooledLifestyleHandler.java 24 Oct 2002 04:12:45 -0000 1.8
+++ src/java/org/apache/excalibur/merlin/resource/PooledLifestyleHandler.java 19 Nov 2002 06:54:43 -0000
@@ -56,6 +56,7 @@
package org.apache.excalibur.merlin.resource;

import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.context.Context;
import org.apache.excalibur.merlin.assembly.ContainerManager;
import org.apache.excalibur.merlin.model.Profile;
@@ -71,8 +72,9 @@
* @author <a href="mailto:[EMAIL PROTECTED]";>Stephen McConnell</a>
* @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
*/
-public class PooledLifestyleHandler extends AbstractLifestyleHandler implements ObjectFactory
+public class PooledLifestyleHandler extends AbstractLifestyleHandler implements Initializable, ObjectFactory
{
+ private PoolManager m_poolManager;
private Profile m_profile;
private ContainerManager m_manager;
private Context m_context;
@@ -99,10 +101,9 @@
throws Exception
{
super( manager, deployment, helper, profile, context );
+ m_poolManager = poolManager;
m_profile = profile;
m_manager = manager;
- // get a pool for our component with 5 initial entries
- m_pool = poolManager.getManagedPool( this, 5 );
m_context = context;
}

@@ -134,6 +135,17 @@
return object;

}
+ + /**
+ * Set up the pool.
+ *
+ * @exception Exception if an error occurs setting up the pool
+ */
+ public void initialize () throws Exception
+ {
+ // get a pool for our component with 5 initial entries
+ m_pool = m_poolManager.getManagedPool( this, 5 );
+ }

/**
* Invoked by a client to return an instance of the object type previously
@@ -212,6 +224,7 @@
}

m_pool = null;
+ m_poolManager = null;
m_profile = null;
m_manager = null;


------------------------------------------------------------------------

--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:[EMAIL PROTECTED]
http://www.osm.net




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to