org.apache.avalon.framework.container
Class ContainerUtil

java.lang.Object
  extended byorg.apache.avalon.framework.container.ContainerUtil

public final class ContainerUtil
extends java.lang.Object

Utility class that makes it easier to transfer a component throught it's lifecycle stages.

Version:
$Id: ContainerUtil.java 30977 2004-07-30 08:57:54Z niclas $
Author:
Avalon Development Team

Method Summary
static void compose(java.lang.Object object, ComponentManager componentManager)
          Deprecated. compose() is no longer the preferred method via which components will be supplied with Components. Please Use service() from Composable instead.
static void configure(java.lang.Object object, Configuration configuration)
          Configure specified object if it implements the Configurable interface.
static void contextualize(java.lang.Object object, Context context)
          Supply specified object with a Context object if it implements the Contextualizable interface.
static void dispose(java.lang.Object object)
          Dispose specified object if it implements the Disposable interface.
static void enableLogging(java.lang.Object object, Logger logger)
          Supply specified object with Logger if it implements the LogEnabled interface.
static void execute(java.lang.Object object)
          Execute the specified object if it implements the Executable interface.
static void initialize(java.lang.Object object)
          Initialize specified object if it implements the Initializable interface.
static void parameterize(java.lang.Object object, Parameters parameters)
          Parameterize specified object if it implements the Parameterizable interface.
static void service(java.lang.Object object, ServiceManager serviceManager)
          Supply specified object with ServiceManager if it implements the Serviceable interface.
static void shutdown(java.lang.Object object)
          Run specified object through shutdown lifecycle stages (Stop and Dispose).
static void start(java.lang.Object object)
          Start specified object if it implements the Startable interface.
static void stop(java.lang.Object object)
          Stop specified object if it implements the Startable interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

shutdown

public static void shutdown(java.lang.Object object)
                     throws java.lang.Exception
Run specified object through shutdown lifecycle stages (Stop and Dispose).

Parameters:
object - the object to shutdown
Throws:
java.lang.Exception - if there is a problem stoppping object

enableLogging

public static void enableLogging(java.lang.Object object,
                                 Logger logger)
Supply specified object with Logger if it implements the LogEnabled interface.

Parameters:
object - the object to Start
logger - the logger to enable component with. May be null in which case the specified object must not implement LogEnabled.
Throws:
java.lang.IllegalArgumentException - if the object is LogEnabled but Logger is null

contextualize

public static void contextualize(java.lang.Object object,
                                 Context context)
                          throws ContextException
Supply specified object with a Context object if it implements the Contextualizable interface.

Parameters:
object - the object to contextualize
context - the context object to use for object. May be null in which case the specified object must not implement Contextualizable.
Throws:
ContextException - if there is a problem contextualizing object
java.lang.IllegalArgumentException - if the object is Contextualizable but context is null

service

public static void service(java.lang.Object object,
                           ServiceManager serviceManager)
                    throws ServiceException
Supply specified object with ServiceManager if it implements the Serviceable interface.

Parameters:
object - the object to service
serviceManager - the serviceManager object to use for object. May be null in which case the specified object must not implement Serviceable.
Throws:
ServiceException - if there is a problem servicing object
java.lang.IllegalArgumentException - if the object is Servicable but ServiceManager is null

compose

public static void compose(java.lang.Object object,
                           ComponentManager componentManager)
                    throws ComponentException
Deprecated. compose() is no longer the preferred method via which components will be supplied with Components. Please Use service() from Composable instead.

Supply specified object with ComponentManager if it implements the Composable interface.

Parameters:
object - the object to compose
componentManager - the ComponentManager object to use for object. May be null in which case the specified object must not implement Composable.
Throws:
ComponentException - if there is a problem composing object
java.lang.IllegalArgumentException - if the object is Composable but ComponentManager is null

configure

public static void configure(java.lang.Object object,
                             Configuration configuration)
                      throws ConfigurationException
Configure specified object if it implements the Configurable interface.

Parameters:
object - the object to Start
configuration - the configuration object to use during configuration. May be null in which case the specified object must not implement Configurable
Throws:
ConfigurationException - if there is a problem Configuring object, or the object is Configurable but Configuration is null
java.lang.IllegalArgumentException - if the object is Configurable but Configuration is null

parameterize

public static void parameterize(java.lang.Object object,
                                Parameters parameters)
                         throws ParameterException
Parameterize specified object if it implements the Parameterizable interface.

Parameters:
object - the object to Parameterize.
parameters - the parameters object to use during Parameterization. May be null in which case the specified object must not implement Parameterizable.
Throws:
ParameterException - if there is a problem Parameterizing object
java.lang.IllegalArgumentException - if the object is Parameterizable but parameters is null

initialize

public static void initialize(java.lang.Object object)
                       throws java.lang.Exception
Initialize specified object if it implements the Initializable interface.

Parameters:
object - the object to Initialize
Throws:
java.lang.Exception - if there is a problem Initializing object

start

public static void start(java.lang.Object object)
                  throws java.lang.Exception
Start specified object if it implements the Startable interface.

Parameters:
object - the object to Start
Throws:
java.lang.Exception - if there is a problem Starting object

execute

public static void execute(java.lang.Object object)
                    throws java.lang.Exception
Execute the specified object if it implements the Executable interface.

Parameters:
object - the object to execute
Throws:
java.lang.Exception - if there is a problem executing object

stop

public static void stop(java.lang.Object object)
                 throws java.lang.Exception
Stop specified object if it implements the Startable interface.

Parameters:
object - the object to stop
Throws:
java.lang.Exception - if there is a problem stoppping object

dispose

public static void dispose(java.lang.Object object)
Dispose specified object if it implements the Disposable interface.

Parameters:
object - the object to dispose


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.