You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2003/04/11 22:14:23 UTC
cvs commit: avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle AbstractLifestyleHandler.java DefaultLifestyleService.java LifestyleException.java LifestyleHandler.java LifestyleRuntimeException.java LifestyleService.java PooledLifestyleHandler.java SingletonLifestyleHandler.java ThreadLocalLifestyleHandler.java TransientLifestyleHandler.java package.html
leosimons 2003/04/11 13:14:23
Modified: merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle
AbstractLifestyleHandler.java
DefaultLifestyleService.java
LifestyleException.java LifestyleHandler.java
LifestyleRuntimeException.java
LifestyleService.java PooledLifestyleHandler.java
SingletonLifestyleHandler.java
ThreadLocalLifestyleHandler.java
TransientLifestyleHandler.java package.html
Log:
formatting, imports, style.
Revision Changes Path
1.3 +102 -140 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java
Index: AbstractLifestyleHandler.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractLifestyleHandler.java 10 Apr 2003 04:36:13 -0000 1.2
+++ AbstractLifestyleHandler.java 11 Apr 2003 20:14:22 -0000 1.3
@@ -50,34 +50,22 @@
package org.apache.avalon.assembly.lifestyle;
-import java.util.Map;
-import java.util.Hashtable;
-
+import org.apache.avalon.assembly.appliance.Appliance;
+import org.apache.avalon.assembly.lifecycle.DeploymentService;
+import org.apache.avalon.assembly.locator.Contextualizable;
+import org.apache.avalon.assembly.locator.Locator;
+import org.apache.avalon.assembly.locator.LocatorException;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.meta.info.ReferenceDescriptor;
-import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.ExtensionDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
-import org.apache.avalon.meta.info.Type;
-import org.apache.avalon.meta.model.Profile;
-import org.apache.avalon.assembly.appliance.Appliance;
-import org.apache.avalon.assembly.lifecycle.DeploymentService;
-import org.apache.avalon.assembly.locator.Contextualizable;
-import org.apache.avalon.assembly.locator.LocatorException;
-import org.apache.avalon.assembly.locator.Locator;
import org.apache.avalon.lifecycle.Accessor;
+import org.apache.avalon.meta.info.StageDescriptor;
/**
- * The abstract lifestyle handler provides support for object instantiation and
+ * The abstract lifestyle handler provides support for object instantiation and
* lifecycle processing.
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
@@ -89,90 +77,70 @@
// state
//==============================================================
- /**
- * The appliance that this handler is handling.
- */
+ /**
+ * The appliance that this handler is handling.
+ */
private Appliance m_appliance;
- /**
- * The classloader to use to when instantiating new instances
- * of the component implementation class.
- */
+ /**
+ * The classloader to use to when instantiating new instances
+ * of the component implementation class.
+ */
private ClassLoader m_classloader;
- /**
- * The deplyment service to handle lifecycle processing of
- * component implementations established by this handler.
- */
+ /**
+ * The deplyment service to handle lifecycle processing of
+ * component implementations established by this handler.
+ */
protected DeploymentService m_deployment;
- /**
- * The deplyment context.
- */
- private Locator m_context;
-
- /**
- * The implementation class.
- */
- private Class m_class;
-
- private Map m_map;
-
//==============================================================
// Contextualizable
//==============================================================
- /**
- * <p>Application of a runtime context to this component.
- * Context entries that may be supplied to a lifestyle handler
- * are detailed in the following table.</p>
- * <table>
- * <tr>
- * <td>key</td><td>type</td><td>description</td>
- * </tr>
- * <tr>
- * <td>urn:assembly:appliance.target</td>
- * <td>{@link org.apache.avalon.assembly.appliance.Appliance}</td>
- * <td>The appliance that this manager is managing.</td>
- * </tr>
- * </table>
- * @param context the runtime context
- */
+ /**
+ * <p>Application of a runtime context to this component.
+ * Context entries that may be supplied to a lifestyle handler
+ * are detailed in the following table.</p>
+ * <table>
+ * <tr>
+ * <td>key</td><td>type</td><td>description</td>
+ * </tr>
+ * <tr>
+ * <td>urn:assembly:appliance.target</td>
+ * <td>{@link org.apache.avalon.assembly.appliance.Appliance}</td>
+ * <td>The appliance that this manager is managing.</td>
+ * </tr>
+ * </table>
+ * @param context the runtime context
+ */
public void contextualize( Locator context ) throws ContextException
{
m_classloader = (ClassLoader) context.get( "urn:avalon:classloader" );
m_appliance = (Appliance) context.get( "urn:assembly:appliance.target" );
m_deployment = (DeploymentService) context.get( "urn:assembly:lifecycle.deployment" );
- try
- {
- m_context = (Locator) context.get( "urn:assembly:deployment.context" );
- }
- catch( ContextException ce )
- {
- m_context = null;
- }
}
//==============================================================
// Initializable
//==============================================================
- /**
- * Initialization of the lifestyle manager. The implementation verifies
- * initial state followed by establishment of a lifestyle handler based on
- * the policy declared within the profile underlying the appliance.
- *
- * @exception Exception if a invalid state is encounter
- */
- public void initialize() throws Exception
+ /**
+ * Initialization of the lifestyle manager. The implementation verifies
+ * initial state followed by establishment of a lifestyle handler based on
+ * the policy declared within the profile underlying the appliance.
+ *
+ * @exception Exception if a invalid state is encounter
+ */
+ public void initialize() throws Exception
{
if( getLogger() == null )
{
- throw new LifestyleException("logger");
+ throw new LifestyleException( "logger" );
}
if( m_appliance == null )
{
- throw new LifestyleException("context");
+ throw new LifestyleException( "context" );
}
}
@@ -181,34 +149,34 @@
//==============================================================
/**
- * Resolve a object to a value qualified by a supplied service
+ * Resolve a object to a value qualified by a supplied service
* reference.
*
* @param partition the context within the the resolution is applied
* @param ref the reference descriptor
* @return the resolved object
* @throws ContextException if an error occurs
- * @todo build a proxy that isolates the service described by the
+ * @todo build a proxy that isolates the service described by the
* ref argument
*/
public Object resolve( Object partition, String ref )
- throws LocatorException
+ throws LocatorException
{
return resolve( partition );
}
- /**
- * Activate a service provided by the appliance.
- * @param appliance the appliance to deploy
- */
- public abstract Object resolve( Object partition )
- throws LocatorException;
-
- /**
- * Release an a service or handler established by the appliance. The
- * default implementation irreversably decommissions the supplied object.
- * @param object the service to be released
- */
+ /**
+ * Activate a service provided by the appliance.
+ * @param appliance the appliance to deploy
+ */
+ public abstract Object resolve( Object partition )
+ throws LocatorException;
+
+ /**
+ * Release an a service or handler established by the appliance. The
+ * default implementation irreversably decommissions the supplied object.
+ * @param object the service to be released
+ */
public void release( Object object, Object partition )
{
if( getLogger().isDebugEnabled() )
@@ -225,49 +193,47 @@
//==============================================================
/**
- * Request for disposal of the handler.
+ * Request for disposal of the handler.
*/
public void dispose()
{
m_appliance = null;
m_classloader = null;
m_deployment = null;
- m_context = null;
}
//==============================================================
// utilities
//==============================================================
- /**
- * Return the appliance that this handler is handling.
- * @return the appliance
- */
+ /**
+ * Return the appliance that this handler is handling.
+ * @return the appliance
+ */
protected Appliance getAppliance()
{
if( m_appliance == null )
{
- throw new IllegalStateException("appliance");
+ throw new IllegalStateException( "appliance" );
}
return m_appliance;
}
- /**
- * Creation of a new intance of the class declared by the profile backing the
- * appliance assigned to this handler.
- * @return Object a new instance of the component class
- */
+ /**
+ * Creation of a new intance of the class declared by the profile backing the
+ * appliance assigned to this handler.
+ * @return Object a new instance of the component class
+ */
protected Object newInstance() throws LifestyleException
{
try
{
return m_deployment.deploy( m_appliance, m_classloader );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
- final String error =
- "Unable to create new instance for appliance: "
- + m_appliance;
+ final String error =
+ "Unable to create new instance for appliance: "
+ + m_appliance;
throw new LifestyleException( error, e );
}
}
@@ -282,7 +248,7 @@
StageDescriptor[] phases = getAppliance().getType().getStages();
for( int i = 0; i < phases.length; i++ )
{
- StageDescriptor stage = phases[ i ];
+ StageDescriptor stage = phases[i];
processExtension( stage, object, true );
}
}
@@ -294,19 +260,18 @@
protected void processReleaseStage( Object object )
{
StageDescriptor[] phases = getAppliance().getType().getStages();
- for( int i = ( phases.length - 1 ); i > -1; i-- )
+ for( int i = (phases.length - 1); i > -1; i-- )
{
- StageDescriptor stage = phases[ i ];
+ StageDescriptor stage = phases[i];
try
{
processExtension( stage, object, false );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
if( getLogger().isWarnEnabled() )
{
final String warning =
- "Ignoring release exception.";
+ "Ignoring release exception.";
getLogger().warn( warning, e );
}
}
@@ -323,21 +288,21 @@
* @exception Exception if an error occurs during stage execution
*/
private void processExtension(
- StageDescriptor stage,
- Object object,
- boolean access )
- throws LifestyleException, ContextException
+ StageDescriptor stage,
+ Object object,
+ boolean access )
+ throws LifestyleException, ContextException
{
Appliance provider = m_appliance.getExtensionProvider( stage );
if( provider == null )
{
- final String error =
- "Null provider returned from appliance: " + m_appliance
- + " stage: " + stage;
+ final String error =
+ "Null provider returned from appliance: " + m_appliance
+ + " stage: " + stage;
throw new IllegalStateException( error );
}
- if( Accessor.class.isAssignableFrom( getImplementationClass( provider ) ) )
+ if( Accessor.class.isAssignableFrom( getImplementationClass() ) )
{
Accessor extension = (Accessor) provider.resolve( this );
try
@@ -346,43 +311,40 @@
if( access )
{
extension.access( object, context );
- }
- else
+ } else
{
extension.release( object, context );
}
provider.release( extension, this );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Extension provider appliance: " + provider
- + " raised a execution exception while processing an inner stage: " + stage
- + " in appliance: " + m_appliance;
+ "Extension provider appliance: " + provider
+ + " raised a execution exception while processing an inner stage: " + stage
+ + " in appliance: " + m_appliance;
throw new LifestyleException( error, e );
}
}
}
- private Class getImplementationClass( Appliance appliance )
+ private Class getImplementationClass()
{
try
{
String classname = m_appliance.getType().getInfo().getClassname();
return m_classloader.loadClass( classname );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
- final String error =
- "Internal error while attempting to load the implementation class for an appliance: "
- + m_appliance;
+ final String error =
+ "Internal error while attempting to load the implementation class for an appliance: "
+ + m_appliance;
throw new LifestyleRuntimeException( error, e );
}
}
- /**
- * Terminate the appliance.
- */
+ /**
+ * Terminate the appliance.
+ */
public void terminate()
{
dispose();
1.2 +44 -65 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/DefaultLifestyleService.java
Index: DefaultLifestyleService.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/DefaultLifestyleService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultLifestyleService.java 13 Mar 2003 01:04:15 -0000 1.1
+++ DefaultLifestyleService.java 11 Apr 2003 20:14:22 -0000 1.2
@@ -50,28 +50,18 @@
package org.apache.avalon.assembly.lifestyle;
-import java.util.Hashtable;
-
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.assembly.appliance.Appliance;
import org.apache.avalon.assembly.appliance.ApplianceHolder;
-import org.apache.avalon.assembly.engine.Engine;
import org.apache.avalon.assembly.lifecycle.DeploymentService;
-import org.apache.avalon.assembly.lifecycle.DefaultDeploymentService;
import org.apache.avalon.assembly.locator.Contextualizable;
import org.apache.avalon.assembly.locator.DefaultLocator;
import org.apache.avalon.assembly.locator.Locator;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
/**
- * A lifestyle service provides support for the creation of a lifestyle
+ * A lifestyle service provides support for the creation of a lifestyle
* handlers.
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
@@ -84,34 +74,29 @@
//==============================================================
/**
- * The context containing the deployment service to assign
+ * The context containing the deployment service to assign
* to the lifestyle handler.
*/
private Locator m_context;
/**
- * The system context.
+ * Flag holding the initialized state of the service.
*/
- private Locator m_system;
-
- /**
- * Flag holding the initialized state of the service.
- */
private boolean m_initialized = false;
- /**
- * The supplied static configuration.
- */
+ /**
+ * The supplied static configuration.
+ */
private DeploymentService m_deployment;
//==============================================================
// Contextualizable
//==============================================================
- /**
- * Supply of supporting services to this componet by its manager.
- * This includes a deployment service.
- */
+ /**
+ * Supply of supporting services to this componet by its manager.
+ * This includes a deployment service.
+ */
public void contextualize( Locator context ) throws ContextException
{
if( context == null )
@@ -127,8 +112,8 @@
m_context = context;
- m_deployment =
- (DeploymentService) context.get( "urn:assembly:lifecycle.deployment" );
+ m_deployment =
+ (DeploymentService) context.get( "urn:assembly:lifecycle.deployment" );
}
@@ -140,11 +125,11 @@
{
if( getLogger() == null )
{
- throw new IllegalStateException("logger");
+ throw new IllegalStateException( "logger" );
}
if( m_context == null )
{
- throw new IllegalStateException("context");
+ throw new IllegalStateException( "context" );
}
m_initialized = true;
}
@@ -153,27 +138,27 @@
// LifestyleService
//==============================================================
- /**
- * Creation of a new lifestyle handler.
- * @param appliance the appliance that the handler will manage
- * @param classloader the classloader to assign to the handler
- * @param context a deployment context
- */
- public LifestyleHandler createHandler(
- Appliance appliance, ClassLoader classloader, Locator deploymentContext )
+ /**
+ * Creation of a new lifestyle handler.
+ * @param appliance the appliance that the handler will manage
+ * @param classloader the classloader to assign to the handler
+ * @param context a deployment context
+ */
+ public LifestyleHandler createHandler(
+ Appliance appliance, ClassLoader classloader, Locator deploymentContext )
{
if( !m_initialized )
{
- throw new IllegalStateException("initialization");
+ throw new IllegalStateException( "initialization" );
}
if( appliance == null )
{
- throw new NullPointerException("appliance");
+ throw new NullPointerException( "appliance" );
}
if( classloader == null )
{
- throw new NullPointerException("classloader");
+ throw new NullPointerException( "classloader" );
}
//
@@ -187,7 +172,7 @@
}
context.put( "urn:assembly:appliance.target", new ApplianceHolder( appliance ) );
context.put( "urn:avalon:classloader", classloader );
- context.put( "urn:assembly:lifecycle.deployment", m_deployment );
+ context.put( "urn:assembly:lifecycle.deployment", m_deployment );
context.makeReadOnly();
//
@@ -196,8 +181,8 @@
//
final String policy =
- appliance.getType().getInfo().getAttribute(
- "urn:avalon:lifestyle", "singleton" );
+ appliance.getType().getInfo().getAttribute(
+ "urn:avalon:lifestyle", "singleton" );
if( policy.equalsIgnoreCase( "singleton" ) )
{
@@ -208,15 +193,13 @@
singleton.contextualize( context );
singleton.initialize();
return singleton;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Internal error while attempting to establish the singleton lifestyle handler.";
+ "Internal error while attempting to establish the singleton lifestyle handler.";
throw new LifestyleRuntimeException( error, e );
}
- }
- else if( policy.equals( "transient" ) )
+ } else if( policy.equals( "transient" ) )
{
try
{
@@ -225,15 +208,13 @@
transientHandler.contextualize( context );
transientHandler.initialize();
return transientHandler;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Internal error while attempting to establish the transient lifestyle handler.";
+ "Internal error while attempting to establish the transient lifestyle handler.";
throw new LifestyleRuntimeException( error, e );
}
- }
- else if( policy.equals( "thread" ) )
+ } else if( policy.equals( "thread" ) )
{
try
{
@@ -242,19 +223,17 @@
thread.contextualize( context );
thread.initialize();
return thread;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Internal error while attempting to establish the transient lifestyle handler.";
+ "Internal error while attempting to establish the transient lifestyle handler.";
throw new LifestyleRuntimeException( error, e );
}
- }
- else
+ } else
{
- final String error =
- "Lifestyle policy argument '" + policy + "' within appliance: "
- + appliance + "' is not recognized.";
+ final String error =
+ "Lifestyle policy argument '" + policy + "' within appliance: "
+ + appliance + "' is not recognized.";
throw new LifestyleRuntimeException( error );
}
}
1.2 +2 -2 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleException.java
Index: LifestyleException.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LifestyleException.java 13 Mar 2003 01:04:15 -0000 1.1
+++ LifestyleException.java 11 Apr 2003 20:14:22 -0000 1.2
@@ -59,7 +59,7 @@
* @version $Revision$ $Date$
*/
public class LifestyleException
- extends CascadingException
+ extends CascadingException
{
/**
1.3 +4 -6 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java
Index: LifestyleHandler.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LifestyleHandler.java 10 Apr 2003 04:36:13 -0000 1.2
+++ LifestyleHandler.java 11 Apr 2003 20:14:22 -0000 1.3
@@ -50,8 +50,6 @@
package org.apache.avalon.assembly.lifestyle;
-import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
import org.apache.avalon.assembly.locator.Reclaimable;
/**
@@ -62,9 +60,9 @@
*/
public interface LifestyleHandler extends Reclaimable
{
- /**
- * Terminate the handler.
- */
+ /**
+ * Terminate the handler.
+ */
void terminate();
}
1.2 +2 -2 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleRuntimeException.java
Index: LifestyleRuntimeException.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleRuntimeException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LifestyleRuntimeException.java 13 Mar 2003 01:04:16 -0000 1.1
+++ LifestyleRuntimeException.java 11 Apr 2003 20:14:22 -0000 1.2
@@ -59,7 +59,7 @@
* @version $Revision$ $Date$
*/
public class LifestyleRuntimeException
- extends CascadingRuntimeException
+ extends CascadingRuntimeException
{
/**
1.2 +11 -13 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleService.java
Index: LifestyleService.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LifestyleService.java 13 Mar 2003 01:04:17 -0000 1.1
+++ LifestyleService.java 11 Apr 2003 20:14:22 -0000 1.2
@@ -50,13 +50,11 @@
package org.apache.avalon.assembly.lifestyle;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.context.Context;
import org.apache.avalon.assembly.appliance.Appliance;
import org.apache.avalon.assembly.locator.Locator;
/**
- * A lifestyle service provides support for the creation of a lifestyle
+ * A lifestyle service provides support for the creation of a lifestyle
* handlers.
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
@@ -64,13 +62,13 @@
*/
public interface LifestyleService
{
- /**
- * Creation of a new lifestyle handler.
- * @param appliance the appliance that the handler will manage
- * @param classloader the classloader to assign to the handler
- * @param system the logging channel for the handler
- * @param context a deployment context
- */
- LifestyleHandler createHandler(
- Appliance appliance, ClassLoader classloader, Locator context );
+ /**
+ * Creation of a new lifestyle handler.
+ * @param appliance the appliance that the handler will manage
+ * @param classloader the classloader to assign to the handler
+ * @param system the logging channel for the handler
+ * @param context a deployment context
+ */
+ LifestyleHandler createHandler(
+ Appliance appliance, ClassLoader classloader, Locator context );
}
1.2 +73 -87 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/PooledLifestyleHandler.java
Index: PooledLifestyleHandler.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/PooledLifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PooledLifestyleHandler.java 13 Mar 2003 01:04:17 -0000 1.1
+++ PooledLifestyleHandler.java 11 Apr 2003 20:14:22 -0000 1.2
@@ -1,14 +1,14 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
@@ -20,13 +20,13 @@
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software
- * itself, if and wherever such third-party acknowledgments
+ * Alternately, this acknowledgment may appear in the software
+ * itself, if and wherever such third-party acknowledgments
* normally appear.
*
- * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
+ * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -49,30 +49,25 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
+ * information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
- */
+ */
package org.apache.avalon.assembly.lifestyle;
+import org.apache.avalon.assembly.appliance.Appliance;
+import org.apache.avalon.assembly.locator.Contextualizable;
+import org.apache.avalon.assembly.locator.Locator;
+import org.apache.avalon.assembly.locator.LocatorException;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.assembly.appliance.Appliance;
-import org.apache.avalon.assembly.lifecycle.DeploymentService;
-import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.excalibur.mpool.ObjectFactory;
import org.apache.excalibur.mpool.Pool;
import org.apache.excalibur.mpool.PoolManager;
-import org.apache.excalibur.mpool.ObjectFactory;
-import org.apache.avalon.assembly.locator.Contextualizable;
-import org.apache.avalon.assembly.locator.Locator;
-import org.apache.avalon.assembly.locator.LocatorException;
/**
* Lifestyle implementation that provides suppport for the pooled
@@ -88,40 +83,34 @@
// state
//==============================================================
- /**
- * The appliance that this handler is handling.
- */
+ /**
+ * The appliance that this handler is handling.
+ */
private Appliance m_appliance;
- /**
- * The runtime context.
- */
+ /**
+ * The runtime context.
+ */
private Locator m_context;
- /**
- * The deplyment service to handle lifecycle processing of
- * component implementations established by this handler.
- */
- private DeploymentService m_deployment;
-
- /**
- * The pool manager.
- */
+ /**
+ * The pool manager.
+ */
private PoolManager m_poolManager;
- /**
- * The object pool.
- */
+ /**
+ * The object pool.
+ */
private Pool m_pool;
- /**
- * The object pool size.
- */
+ /**
+ * The object pool size.
+ */
private int m_size;
- /**
- * The class of object managed by the pool.
- */
+ /**
+ * The class of object managed by the pool.
+ */
private Class m_class;
@@ -129,10 +118,10 @@
// Configurable
//==============================================================
- /**
- * Supply of the static configuration for the deployment service.
- * @param config the static configuration
- */
+ /**
+ * Supply of the static configuration for the deployment service.
+ * @param config the static configuration
+ */
public void configure( Configuration config ) throws ConfigurationException
{
if( config == null )
@@ -146,12 +135,12 @@
// Contextualizable
//==============================================================
- /**
- * <p>Application of a runtime context to the lifestyle service.
- * The context value will be passed directly to lifestyle handlers
- * established by this service.
- * @param context the runtime context
- */
+ /**
+ * <p>Application of a runtime context to the lifestyle service.
+ * The context value will be passed directly to lifestyle handlers
+ * established by this service.
+ * @param context the runtime context
+ */
public void contextualize( Locator context ) throws ContextException
{
super.contextualize( context );
@@ -181,20 +170,20 @@
// LifestyleHandler
//==============================================================
- /**
- * Activate a service provided by the appliance.
- * @param appliance the appliance to deploy
- */
+ /**
+ * Activate a service provided by the appliance.
+ * @param appliance the appliance to deploy
+ */
//public Object access( DependencyDescriptor dependency ) throws LifestyleException
public Object resolve( Object partition ) throws LocatorException
{
return access();
}
- /**
- * Activate an extension handler provided by the appliance.
- * @param appliance the appliance to deploy
- */
+ /**
+ * Activate an extension handler provided by the appliance.
+ * @param appliance the appliance to deploy
+ */
//public Object access( StageDescriptor stage ) throws LifestyleException
//{
// return access();
@@ -215,19 +204,18 @@
Object object = m_pool.acquire();
super.processAccessStage( object );
return object;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
- final String error =
- "Pooled object creation error.";
+ final String error =
+ "Pooled object creation error.";
throw new LocatorException( error, e );
}
}
- /**
- * Release an a service or handler established by the appliance.
- * @param object the service to be released
- */
+ /**
+ * Release an a service or handler established by the appliance.
+ * @param object the service to be released
+ */
//public void release( Object object )
public void release( Object object, Object partition )
{
@@ -240,13 +228,12 @@
{
super.processReleaseStage( object );
m_pool.release( object );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
if( getLogger().isWarnEnabled() )
{
- final String warning =
- "Unexpected error occured while releasing a pooled object.";
+ final String warning =
+ "Unexpected error occured while releasing a pooled object.";
getLogger().warn( warning );
}
}
@@ -285,7 +272,7 @@
//==============================================================
/**
- * Disposal of the handler.
+ * Disposal of the handler.
*/
public void dispose()
{
@@ -293,9 +280,8 @@
{
try
{
- ((Disposable)m_pool ).dispose();
- }
- catch( Throwable e )
+ ((Disposable) m_pool).dispose();
+ } catch( Throwable e )
{
// ignore
}
1.2 +30 -41 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java
Index: SingletonLifestyleHandler.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SingletonLifestyleHandler.java 13 Mar 2003 01:04:18 -0000 1.1
+++ SingletonLifestyleHandler.java 11 Apr 2003 20:14:22 -0000 1.2
@@ -50,20 +50,10 @@
package org.apache.avalon.assembly.lifestyle;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
-import org.apache.avalon.assembly.appliance.Appliance;
-import org.apache.avalon.assembly.locator.Contextualizable;
-import org.apache.avalon.assembly.locator.Locator;
import org.apache.avalon.assembly.locator.LocatorException;
/**
- * The singleton lifestyle handler provides support for object instantiation and
+ * The singleton lifestyle handler provides support for object instantiation and
* lifecycle processing.
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
@@ -75,43 +65,43 @@
// state
//==============================================================
- /**
- * The singleton instance.
- */
+ /**
+ * The singleton instance.
+ */
private Object m_instance;
//==============================================================
// LifestyleHandler
//==============================================================
- /**
- * Activate a service provided by the appliance.
- * @param appliance the appliance to deploy
- */
+ /**
+ * Activate a service provided by the appliance.
+ * @param appliance the appliance to deploy
+ */
public Object resolve( Object partition ) throws LocatorException
{
return access();
}
- /**
- * Activate an extension handler provided by the appliance.
- * @param appliance the appliance to deploy
- */
+ /**
+ * Activate an extension handler provided by the appliance.
+ * @param appliance the appliance to deploy
+ */
//public Object access( StageDescriptor stage ) throws LifestyleException
//{
// return access();
//}
- /**
- * Activate the implementation.
- * @param appliance the appliance to deploy
- */
+ /**
+ * Activate the implementation.
+ * @param appliance the appliance to deploy
+ */
private Object access() throws LocatorException
{
if( getLogger().isDebugEnabled() )
{
final String debug =
- "access in appliance: " + getAppliance();
+ "access in appliance: " + getAppliance();
getLogger().debug( debug );
}
@@ -120,18 +110,17 @@
Object object = newInstance();
super.processAccessStage( object );
return object;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error = "Singleton object access failure.";
throw new LocatorException( error, e );
}
}
- /**
- * Release an a service or handler established by the appliance.
- * @param object the service to be released
- */
+ /**
+ * Release an a service or handler established by the appliance.
+ * @param object the service to be released
+ */
//public void release( Object object )
public void release( Object object, Object partition )
{
@@ -143,7 +132,7 @@
//==============================================================
/**
- * Request for disposal of the handler.
+ * Request for disposal of the handler.
*/
public void dispose()
{
@@ -159,11 +148,11 @@
// utilities
//==============================================================
- /**
- * Creation of a new intance of the class declared by the profile backing the
- * appliance assigned to this handler.
- * @return Object a new instance of the component class
- */
+ /**
+ * Creation of a new intance of the class declared by the profile backing the
+ * appliance assigned to this handler.
+ * @return Object a new instance of the component class
+ */
protected Object newInstance() throws LifestyleException
{
if( m_instance == null )
@@ -171,7 +160,7 @@
if( getLogger().isDebugEnabled() )
{
final String debug =
- "new instance in appliance: " + getAppliance();
+ "new instance in appliance: " + getAppliance();
getLogger().debug( debug );
}
1.2 +32 -38 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java
Index: ThreadLocalLifestyleHandler.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ThreadLocalLifestyleHandler.java 13 Mar 2003 01:04:18 -0000 1.1
+++ ThreadLocalLifestyleHandler.java 11 Apr 2003 20:14:22 -0000 1.2
@@ -1,14 +1,14 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
@@ -20,13 +20,13 @@
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software
- * itself, if and wherever such third-party acknowledgments
+ * Alternately, this acknowledgment may appear in the software
+ * itself, if and wherever such third-party acknowledgments
* normally appear.
*
- * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
+ * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -49,16 +49,12 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
+ * information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
- */
+ */
package org.apache.avalon.assembly.lifestyle;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.meta.model.Profile;
-import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
import org.apache.avalon.assembly.locator.LocatorException;
/**
@@ -71,10 +67,10 @@
private ThreadLocalComponent m_instance;
- /**
- * Activate a service provided by the appliance.
- * @param appliance the appliance to deploy
- */
+ /**
+ * Activate a service provided by the appliance.
+ * @param appliance the appliance to deploy
+ */
public Object resolve( Object partition ) throws LocatorException
{
return access();
@@ -90,9 +86,9 @@
public Object access() throws LocatorException
{
if( getLogger().isDebugEnabled() )
- {
+ {
final String message =
- "access using thread local policy on appliance: " + getAppliance();
+ "access using thread local policy on appliance: " + getAppliance();
getLogger().debug( message );
}
@@ -106,18 +102,17 @@
Object object = m_instance.get();
super.processAccessStage( object );
return object;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error = "Access stage error.";
throw new LocatorException( error, e );
}
}
- /**
- * Release an a service or handler established by the appliance.
- * @param object the service to be released
- */
+ /**
+ * Release an a service or handler established by the appliance.
+ * @param object the service to be released
+ */
public void release( Object object, Object partition )
{
if( object == null )
@@ -131,9 +126,9 @@
}
}
- /**
- * Internal utility class to hold the thread local instance.
- */
+ /**
+ * Internal utility class to hold the thread local instance.
+ */
private static final class ThreadLocalComponent extends ThreadLocal
{
private final ThreadLocalLifestyleHandler m_handler;
@@ -148,8 +143,7 @@
try
{
return m_handler.newInstance();
- }
- catch( Exception e )
+ } catch( Exception e )
{
return null;
}
1.2 +23 -32 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java
Index: TransientLifestyleHandler.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransientLifestyleHandler.java 13 Mar 2003 01:04:18 -0000 1.1
+++ TransientLifestyleHandler.java 11 Apr 2003 20:14:22 -0000 1.2
@@ -50,55 +50,47 @@
package org.apache.avalon.assembly.lifestyle;
-import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
-import org.apache.avalon.assembly.appliance.Appliance;
import org.apache.avalon.assembly.locator.LocatorException;
/**
- * The abstract lifestyle handler provides support for object instantiation and
+ * The abstract lifestyle handler provides support for object instantiation and
* lifecycle processing.
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public class TransientLifestyleHandler extends AbstractLifestyleHandler
+public class TransientLifestyleHandler extends AbstractLifestyleHandler
{
//==============================================================
// state
//==============================================================
- /**
- * The set of transient objects created by the handler.
- */
+ /**
+ * The set of transient objects created by the handler.
+ */
private List m_instances = new ArrayList();
//==============================================================
// LifestyleHandler
//==============================================================
- /**
- * Activate a service provided by the appliance.
- * @param appliance the appliance to deploy
- */
+ /**
+ * Activate a service provided by the appliance.
+ * @param appliance the appliance to deploy
+ */
public Object resolve( Object partition ) throws LocatorException
{
return access();
}
- /**
- * Activate the implementation.
- * @param appliance the appliance to deploy
- */
+ /**
+ * Activate the implementation.
+ * @param appliance the appliance to deploy
+ */
private Object access() throws LocatorException
{
try
@@ -107,22 +99,21 @@
synchronized( m_instances )
{
m_instances.add( object );
- }
+ }
super.processAccessStage( object );
return object;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Transient object establishment error.";
+ "Transient object establishment error.";
throw new LocatorException( error, e );
}
}
- /**
- * Release an a service or handler established by the appliance.
- * @param object the service to be released
- */
+ /**
+ * Release an a service or handler established by the appliance.
+ * @param object the service to be released
+ */
public void release( Object object, Object partition )
{
processReleaseStage( object );
@@ -138,7 +129,7 @@
//==============================================================
/**
- * Request for disposal of the handler.
+ * Request for disposal of the handler.
*/
public void dispose()
{
1.2 +3 -6 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/package.html
Index: package.html
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 13 Mar 2003 01:04:17 -0000 1.1
+++ package.html 11 Apr 2003 20:14:22 -0000 1.2
@@ -1,6 +1,3 @@
-
-<body>
-<p>
-The <code>lifestyle</code> package includes interfaces and classes supporting the four standard lifestyle policies - singleton, thread, pooled and transient.
-</p>
-</body>
+<p>The <code>lifestyle</code> package includes interfaces and classes
+supporting the four standard lifestyle policies - singleton, thread,
+pooled and transient.</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org