org.apache.excalibur.instrument.manager.impl
Class InstrumentableProxy

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.excalibur.instrument.manager.impl.InstrumentableProxy
All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled

 class InstrumentableProxy
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.avalon.framework.configuration.Configurable

A InstrumentableProxy makes it easy for the InstrumentManager to manage Instrumentables and their Instruments.

Not Synchronized.

Since:
4.1
Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:25 $
Author:
Avalon Development Team

Field Summary
private  org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] m_childInstrumentableDescriptorArray
          Optimized array of the child InstrumentableDescriptors.
private  java.util.HashMap m_childInstrumentableProxies
          Map of the Child InstrumentableProxies owned by this InstrumentableProxy.
private  InstrumentableProxy[] m_childInstrumentableProxyArray
          Optimized array of the child InstrumentableProxies.
private  boolean m_configured
          Configured flag.
private  java.lang.String m_description
          The description of the Instrumentable.
private  InstrumentableDescriptorImpl m_descriptor
          The Descriptor for the Instrumentable.
private  org.apache.excalibur.instrument.manager.InstrumentDescriptor[] m_instrumentDescriptorArray
          Optimized array of the InstrumentDescriptors.
private  DefaultInstrumentManagerImpl m_instrumentManager
          InstrumentManager which owns the proxy.
private  java.util.HashMap m_instrumentProxies
          Map of the InstrumentProxies owned by this InstrumentableProxy.
private  InstrumentProxy[] m_instrumentProxyArray
          Optimized array of the InstrumentProxies.
private  java.lang.String m_name
          The name used to identify a Instrumentable.
private  InstrumentableProxy m_parentInstrumentableProxy
          The parent Instrumentable proxy or null if this is a top level Instrumentable.
private  boolean m_registered
          Registered flag.
private  int m_stateVersion
          State Version.
 
Constructor Summary
InstrumentableProxy(DefaultInstrumentManagerImpl instrumentManager, InstrumentableProxy parentInstrumentableProxy, java.lang.String name, java.lang.String description)
          Creates a new InstrumentableProxy.
 
Method Summary
(package private)  void addChildInstrumentableProxy(InstrumentableProxy childInstrumentableProxy)
          Adds a child InstrumentableProxy to the Instrumentable.
(package private)  void addInstrumentProxy(InstrumentProxy instrumentProxy)
          Adds a InstrumentProxy to the Instrumentable.
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures the Instrumentable.
(package private)  org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] getChildInstrumentableDescriptors()
          Returns an array of Descriptors for the child Instrumentables in this Instrumentable.
(package private)  InstrumentableProxy[] getChildInstrumentableProxies()
          Returns an array of Proxies to the child Instrumentables in this Instrumentable.
(package private)  InstrumentableProxy getChildInstrumentableProxy(java.lang.String childInstrumentableName)
          Returns a child InstrumentableProxy based on its name or the name of any of its children.
(package private)  InstrumentableProxy getChildInstrumentableProxy(java.lang.String childInstrumentableName, boolean create)
           
(package private)  java.lang.String getDescription()
          Gets the description of the Instrumentable.
(package private)  org.apache.excalibur.instrument.manager.InstrumentableDescriptor getDescriptor()
          Returns a Descriptor for the Instrumentable.
(package private)  org.apache.excalibur.instrument.manager.InstrumentDescriptor[] getInstrumentDescriptors()
          Returns an array of Descriptors for the Instruments in the Instrumentable.
(package private)  DefaultInstrumentManagerImpl getInstrumentManager()
          Returns instrumentManager which owns the proxy.
(package private)  InstrumentProxy[] getInstrumentProxies()
          Returns an array of Proxies to the Instruments in the Instrumentable.
(package private)  InstrumentProxy getInstrumentProxy(java.lang.String instrumentName)
          Returns a InstrumentProxy based on its name or the name of any of its children.
(package private)  InstrumentProxy getInstrumentProxy(java.lang.String instrumentName, boolean create)
           
(package private)  java.lang.String getName()
          Gets the name for the Instrumentable.
(package private)  InstrumentableProxy getParentInstrumentableProxy()
          Returns the parent InstrumentableProxy or null if this is a top level proxy.
(package private)  int getStateVersion()
          Returns the stateVersion of the instrumentable.
(package private)  boolean isConfigured()
          Returns true if the instrumentable was configured in the instrumentables section of the configuration.
(package private)  boolean isRegistered()
          Returns true if the Instrumentable was registered with the Instrument Manager.
(package private)  void setDescription(java.lang.String description)
          Sets the description for the instrumentable object.
(package private)  void setRegistered()
          Called by the InstrumentManager whenever an Instrumentable assigned to this proxy is registered.
protected  void stateChanged()
          Called whenever the state of the instrumentable is changed.
private  org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] updateChildInstrumentableDescriptorArray()
          Updates the cached array of child InstrumentableDescriptors taking synchronization into account.
private  InstrumentableProxy[] updateChildInstrumentableProxyArray()
          Updates the cached array of child InstrumentableProxies taking synchronization into account.
private  org.apache.excalibur.instrument.manager.InstrumentDescriptor[] updateInstrumentDescriptorArray()
          Updates the cached array of InstrumentDescriptors taking synchronization into account.
private  InstrumentProxy[] updateInstrumentProxyArray()
          Updates the cached array of InstrumentProxies taking synchronization into account.
(package private)  void writeState(java.io.PrintWriter out)
          Writes the current state to a PrintWriter as XML.
 
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

m_instrumentManager

private DefaultInstrumentManagerImpl m_instrumentManager
InstrumentManager which owns the proxy.


m_parentInstrumentableProxy

private InstrumentableProxy m_parentInstrumentableProxy
The parent Instrumentable proxy or null if this is a top level Instrumentable.


m_configured

private boolean m_configured
Configured flag.


m_registered

private boolean m_registered
Registered flag.


m_name

private java.lang.String m_name
The name used to identify a Instrumentable.


m_description

private java.lang.String m_description
The description of the Instrumentable.


m_descriptor

private InstrumentableDescriptorImpl m_descriptor
The Descriptor for the Instrumentable.


m_childInstrumentableProxies

private java.util.HashMap m_childInstrumentableProxies
Map of the Child InstrumentableProxies owned by this InstrumentableProxy.


m_childInstrumentableProxyArray

private InstrumentableProxy[] m_childInstrumentableProxyArray
Optimized array of the child InstrumentableProxies.


m_childInstrumentableDescriptorArray

private org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] m_childInstrumentableDescriptorArray
Optimized array of the child InstrumentableDescriptors.


m_instrumentProxies

private java.util.HashMap m_instrumentProxies
Map of the InstrumentProxies owned by this InstrumentableProxy.


m_instrumentProxyArray

private InstrumentProxy[] m_instrumentProxyArray
Optimized array of the InstrumentProxies.


m_instrumentDescriptorArray

private org.apache.excalibur.instrument.manager.InstrumentDescriptor[] m_instrumentDescriptorArray
Optimized array of the InstrumentDescriptors.


m_stateVersion

private int m_stateVersion
State Version.

Constructor Detail

InstrumentableProxy

InstrumentableProxy(DefaultInstrumentManagerImpl instrumentManager,
                    InstrumentableProxy parentInstrumentableProxy,
                    java.lang.String name,
                    java.lang.String description)
Creates a new InstrumentableProxy.

Parameters:
instrumentManager - InstrumentManager which owns the proxy.
parentInstrumentableProxy - The parent Instrumentable proxy or null if this is a top level Instrumentable.
name - The name used to identify a Instrumentable.
description - The description of the the Instrumentable.
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Configures the Instrumentable. Called from the InstrumentManager's configure method. The class does not need to be configured to function correctly.

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Parameters:
configuration - Instrumentable configuration element from the InstrumentManager's configuration.
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - If there are any configuration problems.

getInstrumentManager

DefaultInstrumentManagerImpl getInstrumentManager()
Returns instrumentManager which owns the proxy.

Returns:
InstrumentManager which owns the proxy.

getParentInstrumentableProxy

InstrumentableProxy getParentInstrumentableProxy()
Returns the parent InstrumentableProxy or null if this is a top level proxy.

Returns:
The parent InstrumentableProxy or null.

isConfigured

boolean isConfigured()
Returns true if the instrumentable was configured in the instrumentables section of the configuration.

Returns:
True if configured.

isRegistered

boolean isRegistered()
Returns true if the Instrumentable was registered with the Instrument Manager.

Returns:
True if registered.

setRegistered

void setRegistered()
Called by the InstrumentManager whenever an Instrumentable assigned to this proxy is registered.


getName

java.lang.String getName()
Gets the name for the Instrumentable. The Instrumentable Name is used to uniquely identify the Instrumentable during its configuration and to gain access to a InstrumentableDescriptor through an InstrumentManager.

Returns:
The name used to identify a Instrumentable.

setDescription

void setDescription(java.lang.String description)
Sets the description for the instrumentable object. This description will be set during the configuration of the Instrumentable if a configuration exists.

Parameters:
description - The description of the Instrumentable.

getDescription

java.lang.String getDescription()
Gets the description of the Instrumentable.

Returns:
The description of the Instrumentable.

getDescriptor

org.apache.excalibur.instrument.manager.InstrumentableDescriptor getDescriptor()
Returns a Descriptor for the Instrumentable.

Returns:
A Descriptor for the Instrumentable.

addChildInstrumentableProxy

void addChildInstrumentableProxy(InstrumentableProxy childInstrumentableProxy)
Adds a child InstrumentableProxy to the Instrumentable. This method will be called during the configuration phase if an element defining the child Instrumentable exists, or if the Instrumentable registers itself with the InstrumentManager as it is running.

This method should never be called for child Instrumentables which have already been added.

Parameters:
childInstrumentableProxy - Child InstrumentableProxy to be added.

getChildInstrumentableProxy

InstrumentableProxy getChildInstrumentableProxy(java.lang.String childInstrumentableName,
                                                boolean create)

getChildInstrumentableProxy

InstrumentableProxy getChildInstrumentableProxy(java.lang.String childInstrumentableName)
Returns a child InstrumentableProxy based on its name or the name of any of its children.

Parameters:
childInstrumentableName - Name of the child Instrumentable being requested.
Returns:
The requested child InstrumentableProxy or null if does not exist.

getChildInstrumentableProxies

InstrumentableProxy[] getChildInstrumentableProxies()
Returns an array of Proxies to the child Instrumentables in this Instrumentable.

Returns:
An array of Proxies to the child Instrumentables in this Instrumentable.

getChildInstrumentableDescriptors

org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] getChildInstrumentableDescriptors()
Returns an array of Descriptors for the child Instrumentables in this Instrumentable.

Returns:
An array of Descriptors for the child Instrumentables in this Instrumentable.

updateChildInstrumentableProxyArray

private InstrumentableProxy[] updateChildInstrumentableProxyArray()
Updates the cached array of child InstrumentableProxies taking synchronization into account.

Returns:
An array of the child InstrumentableProxies.

updateChildInstrumentableDescriptorArray

private org.apache.excalibur.instrument.manager.InstrumentableDescriptor[] updateChildInstrumentableDescriptorArray()
Updates the cached array of child InstrumentableDescriptors taking synchronization into account.

Returns:
An array of the child InstrumentableDescriptors.

addInstrumentProxy

void addInstrumentProxy(InstrumentProxy instrumentProxy)
Adds a InstrumentProxy to the Instrumentable. This method will be called during the configuration phase if an element defining the Instrument exists, or if the Instrument registers itself with the InstrumentManager as it is running.

This method should never be called for Instruments which have already been added.

Parameters:
instrumentProxy - InstrumentProxy to be added.

getInstrumentProxy

InstrumentProxy getInstrumentProxy(java.lang.String instrumentName,
                                   boolean create)

getInstrumentProxy

InstrumentProxy getInstrumentProxy(java.lang.String instrumentName)
Returns a InstrumentProxy based on its name or the name of any of its children.

Parameters:
instrumentName - Name of the Instrument being requested.
Returns:
The requested InstrumentProxy or null if does not exist.

getInstrumentProxies

InstrumentProxy[] getInstrumentProxies()
Returns an array of Proxies to the Instruments in the Instrumentable.

Returns:
An array of Proxies to the Instruments in the Instrumentable.

getInstrumentDescriptors

org.apache.excalibur.instrument.manager.InstrumentDescriptor[] getInstrumentDescriptors()
Returns an array of Descriptors for the Instruments in the Instrumentable.

Returns:
An array of Descriptors for the Instruments in the Instrumentable.

getStateVersion

int getStateVersion()
Returns the stateVersion of the instrumentable. The state version will be incremented each time any of the configuration of the instrumentable or any of its children is modified. Clients can use this value to tell whether or not anything has changed without having to do an exhaustive comparison.

Returns:
The state version of the instrumentable.

updateInstrumentProxyArray

private InstrumentProxy[] updateInstrumentProxyArray()
Updates the cached array of InstrumentProxies taking synchronization into account.

Returns:
An array of the InstrumentProxies.

updateInstrumentDescriptorArray

private org.apache.excalibur.instrument.manager.InstrumentDescriptor[] updateInstrumentDescriptorArray()
Updates the cached array of InstrumentDescriptors taking synchronization into account.

Returns:
An array of the InstrumentDescriptors.

writeState

void writeState(java.io.PrintWriter out)
Writes the current state to a PrintWriter as XML.

Parameters:
out - The PrintWriter to which the state should be written.

stateChanged

protected void stateChanged()
Called whenever the state of the instrumentable is changed.