org.apache.cocoon.components
Class LifecycleHelper

java.lang.Object
  extended byorg.apache.cocoon.components.LifecycleHelper

public class LifecycleHelper
extends Object

Utility class for setting up Avalon components. Similar to Excalibur's DefaultComponentFactory, but on existing objects.

Version:
CVS $Id: LifecycleHelper.java 160568 2005-04-08 17:33:05Z sylvain $
Author:
Sylvain Wallez

Constructor Summary
LifecycleHelper(Logger logger, Context context, ServiceManager serviceManager, Configuration configuration)
          Construct a new LifecycleHelper that can be used repeatedly to setup several components.
 
Method Summary
static void decommission(Object component)
          Decomission a component, by stopping (if it's Startable) and disposing (if it's Disposable) a component.
static void dispose(Object component)
          Dispose a component if it's Disposable.
 Object setupComponent(Object component)
          Setup a component, including initialization and start.
 Object setupComponent(Object component, boolean initializeAndStart)
          Setup a component, and optionnaly initializes (if it's Initializable) and starts it (if it's Startable).
static Object setupComponent(Object component, Logger logger, Context context, ServiceManager serviceManager, Configuration configuration)
          Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger.
static Object setupComponent(Object component, Logger logger, Context context, ServiceManager serviceManager, Configuration configuration, boolean initializeAndStart)
          Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleHelper

public LifecycleHelper(Logger logger,
                       Context context,
                       ServiceManager serviceManager,
                       Configuration configuration)
Construct a new LifecycleHelper that can be used repeatedly to setup several components.

Note : if a parameter is null, the corresponding method isn't called (e.g. if configuration is null, configure() isn't called).

Parameters:
logger - the Logger to pass to LogEnableds, unless there is a LogKitManager and the configuration specifies a logger name.
context - the Context to pass to Contexutalizables.
serviceManager - the service manager to pass to Serviceables.
configuration - the Configuration object to pass to new instances.
Method Detail

setupComponent

public Object setupComponent(Object component)
                      throws Exception
Setup a component, including initialization and start.

Parameters:
component - the component to setup.
Returns:
the component passed in, to allow function chaining.
Throws:
Exception - if something went wrong.

setupComponent

public Object setupComponent(Object component,
                             boolean initializeAndStart)
                      throws Exception
Setup a component, and optionnaly initializes (if it's Initializable) and starts it (if it's Startable).

Parameters:
component - the component to setup.
initializeAndStart - if true, intialize() and start() will be called.
Returns:
the component passed in, to allow function chaining.
Throws:
Exception - if something went wrong.

setupComponent

public static Object setupComponent(Object component,
                                    Logger logger,
                                    Context context,
                                    ServiceManager serviceManager,
                                    Configuration configuration)
                             throws Exception
Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger.

Throws:
Exception

setupComponent

public static Object setupComponent(Object component,
                                    Logger logger,
                                    Context context,
                                    ServiceManager serviceManager,
                                    Configuration configuration,
                                    boolean initializeAndStart)
                             throws Exception
Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger.

Throws:
Exception

decommission

public static final void decommission(Object component)
                               throws Exception
Decomission a component, by stopping (if it's Startable) and disposing (if it's Disposable) a component.

Throws:
Exception

dispose

public static final void dispose(Object component)
Dispose a component if it's Disposable. Otherwhise, do nothing.



Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.