Keel 2.1RC2

org.apache.excalibur.instrument.manager
Class InstrumentableProxy

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

class InstrumentableProxy
extends AbstractLogEnabled
implements 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:

Field Summary
private  InstrumentableDescriptorLocal[] m_childInstrumentableDescriptorArray
          Optimized array of the child InstrumentableDescriptorLocals.
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  InstrumentableDescriptorLocalImpl m_descriptor
          The Descriptor for the Instrumentable.
private  InstrumentDescriptorLocal[] m_instrumentDescriptorArray
          Optimized array of the InstrumentDescriptorLocals.
private  DefaultInstrumentManager 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.
 
Fields inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
 
Constructor Summary
(package private) InstrumentableProxy(DefaultInstrumentManager 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(Configuration configuration)
          Configures the Instrumentable.
(package private)  InstrumentableDescriptorLocal[] 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)  java.lang.String getDescription()
          Gets the description of the Instrumentable.
(package private)  InstrumentableDescriptorLocal getDescriptor()
          Returns a Descriptor for the Instrumentable.
(package private)  InstrumentDescriptorLocal[] getInstrumentDescriptors()
          Returns an array of Descriptors for the Instruments in the Instrumentable.
(package private)  DefaultInstrumentManager 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)  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 loadState(Configuration state)
          Loads the state into the Instrumentable.
(package private)  Configuration saveState()
          Saves the current state into a Configuration.
(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  InstrumentableDescriptorLocal[] updateChildInstrumentableDescriptorArray()
          Updates the cached array of child InstrumentableDescriptorLocals taking synchronization into account.
private  InstrumentableProxy[] updateChildInstrumentableProxyArray()
          Updates the cached array of child InstrumentableProxies taking synchronization into account.
private  InstrumentDescriptorLocal[] updateInstrumentDescriptorArray()
          Updates the cached array of InstrumentDescriptorLocals taking synchronization into account.
private  InstrumentProxy[] updateInstrumentProxyArray()
          Updates the cached array of InstrumentProxies taking synchronization into account.
 
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 DefaultInstrumentManager 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 InstrumentableDescriptorLocalImpl 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 InstrumentableDescriptorLocal[] m_childInstrumentableDescriptorArray
Optimized array of the child InstrumentableDescriptorLocals.


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 InstrumentDescriptorLocal[] m_instrumentDescriptorArray
Optimized array of the InstrumentDescriptorLocals.


m_stateVersion

private int m_stateVersion
State Version.

Constructor Detail

InstrumentableProxy

InstrumentableProxy(DefaultInstrumentManager 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(Configuration configuration)
               throws ConfigurationException
Configures the Instrumentable. Called from the ProfilerManager's configure method. The class does not need to be configured to function correctly.

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

getInstrumentManager

DefaultInstrumentManager 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 the configuration of the Profiler and to gain access to a InstrumentableDescriptor through a ProfilerManager.

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 profiler if a configuration exists for this Instrumentable.

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

InstrumentableDescriptorLocal 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 of the Profiler 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)
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

InstrumentableDescriptorLocal[] 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 InstrumentableDescriptorLocal[] updateChildInstrumentableDescriptorArray()
Updates the cached array of child InstrumentableDescriptorLocals taking synchronization into account.

Returns:
An array of the child InstrumentableDescriptorLocals.

addInstrumentProxy

void addInstrumentProxy(InstrumentProxy instrumentProxy)
Adds a InstrumentProxy to the Instrumentable. This method will be called during the configuration phase of the Profiler if an element defining the Instrument exists, or if the Instrument registers itself with the ProfilerManager 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)
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

InstrumentDescriptorLocal[] 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 InstrumentDescriptorLocal[] updateInstrumentDescriptorArray()
Updates the cached array of InstrumentDescriptorLocals taking synchronization into account.

Returns:
An array of the InstrumentDescriptorLocals.

saveState

Configuration saveState()
Saves the current state into a Configuration.

Returns:
The state as a Configuration. Returns null if the configuration would not contain any information.

loadState

void loadState(Configuration state)
         throws ConfigurationException
Loads the state into the Instrumentable.

Parameters:
state - Configuration object to load state from.
Throws:
ConfigurationException - If there were any problems loading the state.

stateChanged

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


Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.