org.apache.cocoon.components
Class LifecycleHelper

java.lang.Object
  |
  +--org.apache.cocoon.components.LifecycleHelper

public class LifecycleHelper
extends java.lang.Object

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

To be moved to Avalon ?

Version:
CVS $Id: LifecycleHelper.java,v 1.1 2002/03/04 18:16:45 sylvain Exp $
Author:
Sylvain Wallez

Constructor Summary
LifecycleHelper(org.apache.log.Logger logger, org.apache.avalon.framework.context.Context context, org.apache.avalon.framework.component.ComponentManager componentManager, org.apache.avalon.excalibur.component.RoleManager roles, org.apache.avalon.excalibur.logger.LogKitManager logkit, org.apache.avalon.framework.configuration.Configuration configuration)
          Construct a new LifecycleHelper that can be used repeatedly to setup several components.
 
Method Summary
static void decommission(java.lang.Object component)
          Decomission a component, by stopping (if it's Startable) and disposing (if it's Disposable) a component.
static void dispose(java.lang.Object component)
          Dispose a component if it's Disposable.
 java.lang.Object setupComponent(java.lang.Object component)
          Setup a component, including initialization and start.
 java.lang.Object setupComponent(java.lang.Object component, boolean initializeAndStart)
          Setup a component, and optionnaly initializes (if it's Initializable) and starts it (if it's Startable).
static java.lang.Object setupComponent(java.lang.Object component, org.apache.log.Logger logger, org.apache.avalon.framework.context.Context context, org.apache.avalon.framework.component.ComponentManager componentManager, org.apache.avalon.excalibur.component.RoleManager roles, org.apache.avalon.excalibur.logger.LogKitManager logkit, org.apache.avalon.framework.configuration.Configuration configuration)
          Static equivalent to setupComponent(Object), to be used when there's only one component to setup.
static java.lang.Object setupComponent(java.lang.Object component, org.apache.log.Logger logger, org.apache.avalon.framework.context.Context context, org.apache.avalon.framework.component.ComponentManager componentManager, org.apache.avalon.excalibur.component.RoleManager roles, org.apache.avalon.excalibur.logger.LogKitManager logkit, org.apache.avalon.framework.configuration.Configuration configuration, boolean initializeAndStart)
          Static equivalent to setupComponent(Object, boolean), to be used when there's only one component to setup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleHelper

public LifecycleHelper(org.apache.log.Logger logger,
                       org.apache.avalon.framework.context.Context context,
                       org.apache.avalon.framework.component.ComponentManager componentManager,
                       org.apache.avalon.excalibur.component.RoleManager roles,
                       org.apache.avalon.excalibur.logger.LogKitManager logkit,
                       org.apache.avalon.framework.configuration.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 Loggables, unless there is a LogKitManager and the configuration specifies a logger name.
context - the Context to pass to Contexutalizables.
componentManager - the component manager to pass to Composables.
roles - the RoleManager to pass to DefaultComponentSelectors.
configuration - the Configuration object to pass to new instances.
Method Detail

setupComponent

public java.lang.Object setupComponent(java.lang.Object component)
                                throws java.lang.Exception
Setup a component, including initialization and start.
Parameters:
component - the component to setup.
Returns:
the component passed in, to allow function chaining.
Throws:
java.lang.Exception - if something went wrong.

setupComponent

public java.lang.Object setupComponent(java.lang.Object component,
                                       boolean initializeAndStart)
                                throws java.lang.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:
java.lang.Exception - if something went wrong.

setupComponent

public static java.lang.Object setupComponent(java.lang.Object component,
                                              org.apache.log.Logger logger,
                                              org.apache.avalon.framework.context.Context context,
                                              org.apache.avalon.framework.component.ComponentManager componentManager,
                                              org.apache.avalon.excalibur.component.RoleManager roles,
                                              org.apache.avalon.excalibur.logger.LogKitManager logkit,
                                              org.apache.avalon.framework.configuration.Configuration configuration)
                                       throws java.lang.Exception
Static equivalent to setupComponent(Object), to be used when there's only one component to setup.

setupComponent

public static java.lang.Object setupComponent(java.lang.Object component,
                                              org.apache.log.Logger logger,
                                              org.apache.avalon.framework.context.Context context,
                                              org.apache.avalon.framework.component.ComponentManager componentManager,
                                              org.apache.avalon.excalibur.component.RoleManager roles,
                                              org.apache.avalon.excalibur.logger.LogKitManager logkit,
                                              org.apache.avalon.framework.configuration.Configuration configuration,
                                              boolean initializeAndStart)
                                       throws java.lang.Exception
Static equivalent to setupComponent(Object, boolean), to be used when there's only one component to setup.

decommission

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

dispose

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


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.