org.apache.avalon.fortress.util
Class LifecycleExtensionManager

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.avalon.fortress.util.LifecycleExtensionManager
All Implemented Interfaces:
LogEnabled

public final class LifecycleExtensionManager
extends AbstractLogEnabled

LifecycleExtensionManager class. This class manages a list of extensions objects that are executed on components during the various stages of their lifecycles.

It provides methods for adding extension objects to the system, and a method for executing them on a particular component object. The current context is also passed in to the extension objects to facilitate the communication of any global values.

Extensions are stored internally in a list. This guarentees that the order in which they are executed matches the order in which they are inserted.

Version:
CVS $Revision: 1.12 $ $Date: 2004/02/28 15:16:26 $
Author:
Avalon Development Team

Field Summary
protected static int ACCESS
           
protected static int CREATE
           
protected static int DESTROY
           
protected static int RELEASE
           
static java.lang.String ROLE
           
 
Constructor Summary
LifecycleExtensionManager()
           
 
Method Summary
 int accessorExtensionsCount()
          Find out the total number of accessor extensions registered with this manager
 java.util.Iterator accessorExtensionsIterator()
          Obtain an iterator.
 void addAccessorExtension(Accessor extension)
          Adds an accessor extension to the manager
 void addCreatorExtension(Creator extension)
          Adds a creator extension to the manager
protected  void checkWriteable()
          Utility method to check if LifecycleExtensionsManager is writeable and if not throw exception.
 void clearAccessorExtensions()
          Clears all accessor extensions registered with this manager
 void clearCreatorExtensions()
          Clears all creator extensions registered with this manager
 int creatorExtensionsCount()
          Find out the total number of creator extensions registered with this manager
 java.util.Iterator creatorExtensionsIterator()
          Obtain an iterator.
 void executeAccessExtensions(java.lang.Object component, Context context)
          executeAccessExtensions method, executes all access level extensions on the given component.
 void executeCreationExtensions(java.lang.Object component, Context context)
          executeCreationExtensions method, executes all creation level extensions on the given component.
 void executeDestructionExtensions(java.lang.Object component, Context context)
          executeDestructionExtensions method, executes all destruction level extensions on the given component.
protected  void executeExtensions(java.lang.Object[] extensions, java.lang.Object component, Context context, int type)
          executeExtensions method, executes a given array of lifecycle interfaces on a given component.
 void executeReleaseExtensions(java.lang.Object component, Context context)
          executeReleaseExtensions method, executes all release level extensions on the given component.
 Accessor getAccessorExtension(int index)
          Obtain the particular accessor extension at the given index
 Creator getCreatorExtension(int index)
          Obtain the particular creator extension at the given index
 void insertAccessorExtension(int position, Accessor extension)
          Inserts an accessor extension at a given index in the manager
 void insertCreatorExtension(int position, Creator extension)
          Inserts a creator extension at a given index in the manager
 void makeReadOnly()
          Make the extension manager read only (immutable).
 Accessor removeAccessorExtension(int position)
          Removes a particular accessor extension from the manager
 Creator removeCreatorExtension(int position)
          Removes a particular creator extension from the manager
 LifecycleExtensionManager writeableCopy()
          Create a copy; it will be writeable even if the original was not.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROLE

public static final java.lang.String ROLE

ACCESS

protected static final int ACCESS
See Also:
Constant Field Values

RELEASE

protected static final int RELEASE
See Also:
Constant Field Values

CREATE

protected static final int CREATE
See Also:
Constant Field Values

DESTROY

protected static final int DESTROY
See Also:
Constant Field Values
Constructor Detail

LifecycleExtensionManager

public LifecycleExtensionManager()
Method Detail

makeReadOnly

public void makeReadOnly()
Make the extension manager read only (immutable).


writeableCopy

public LifecycleExtensionManager writeableCopy()
Create a copy; it will be writeable even if the original was not.


executeAccessExtensions

public void executeAccessExtensions(java.lang.Object component,
                                    Context context)
                             throws java.lang.Exception
executeAccessExtensions method, executes all access level extensions on the given component.

Parameters:
component - a Component instance
context - a Context instance
Throws:
java.lang.Exception - if an error occurs

executeReleaseExtensions

public void executeReleaseExtensions(java.lang.Object component,
                                     Context context)
                              throws java.lang.Exception
executeReleaseExtensions method, executes all release level extensions on the given component.

Parameters:
component - a Component instance
context - a Context instance
Throws:
java.lang.Exception - if an error occurs

executeCreationExtensions

public void executeCreationExtensions(java.lang.Object component,
                                      Context context)
                               throws java.lang.Exception
executeCreationExtensions method, executes all creation level extensions on the given component.

Parameters:
component - a Component instance
context - a Context instance
Throws:
java.lang.Exception - if an error occurs

executeDestructionExtensions

public void executeDestructionExtensions(java.lang.Object component,
                                         Context context)
                                  throws java.lang.Exception
executeDestructionExtensions method, executes all destruction level extensions on the given component.

Parameters:
component - a Component instance
context - a Context instance
Throws:
java.lang.Exception - if an error occurs

addAccessorExtension

public void addAccessorExtension(Accessor extension)
Adds an accessor extension to the manager

Parameters:
extension - a Accessor instance

addCreatorExtension

public void addCreatorExtension(Creator extension)
Adds a creator extension to the manager

Parameters:
extension - a Creator instance

insertAccessorExtension

public void insertAccessorExtension(int position,
                                    Accessor extension)
Inserts an accessor extension at a given index in the manager

Parameters:
position - an int index value
extension - a Accessor instance

insertCreatorExtension

public void insertCreatorExtension(int position,
                                   Creator extension)
Inserts a creator extension at a given index in the manager

Parameters:
position - an int index value
extension - a Creator instance

removeAccessorExtension

public Accessor removeAccessorExtension(int position)
Removes a particular accessor extension from the manager

Parameters:
position - an int index value
Returns:
a Accessor instance

removeCreatorExtension

public Creator removeCreatorExtension(int position)
Removes a particular creator extension from the manager

Parameters:
position - an int index value
Returns:
a Creator instance

accessorExtensionsIterator

public java.util.Iterator accessorExtensionsIterator()
Obtain an iterator.

Returns:
an Iterator instance

creatorExtensionsIterator

public java.util.Iterator creatorExtensionsIterator()
Obtain an iterator.

Returns:
an Iterator instance

accessorExtensionsCount

public int accessorExtensionsCount()
Find out the total number of accessor extensions registered with this manager

Returns:
an int value

creatorExtensionsCount

public int creatorExtensionsCount()
Find out the total number of creator extensions registered with this manager

Returns:
an int value

getAccessorExtension

public Accessor getAccessorExtension(int index)
Obtain the particular accessor extension at the given index

Parameters:
index - an int index value
Returns:
a Accessor instance

getCreatorExtension

public Creator getCreatorExtension(int index)
Obtain the particular creator extension at the given index

Parameters:
index - an int index value
Returns:
a Creator instance

clearAccessorExtensions

public void clearAccessorExtensions()
Clears all accessor extensions registered with this manager


clearCreatorExtensions

public void clearCreatorExtensions()
Clears all creator extensions registered with this manager


executeExtensions

protected void executeExtensions(java.lang.Object[] extensions,
                                 java.lang.Object component,
                                 Context context,
                                 int type)
                          throws java.lang.Exception
executeExtensions method, executes a given array of lifecycle interfaces on a given component.

Parameters:
component - a Component instance
context - a Context instance
type - a constant, referencing which phase the extensions array adheres to
Throws:
java.lang.Exception - if an error occurs

checkWriteable

protected final void checkWriteable()
                             throws java.lang.IllegalStateException
Utility method to check if LifecycleExtensionsManager is writeable and if not throw exception.

Throws:
java.lang.IllegalStateException - if context is read only


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