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

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

public class InstrumentProxy
extends AbstractLogEnabled
implements InstrumentProxy, Configurable

Instrumentables which do not implement ThreadSafe may have multiple instances created by the ComponentLocator. Each of these Instruments will share a common key and are instrumented as a group. The InstrumentProxy is used make it easy for the InstrumentManager to control groups of Instruments as one.

The type of a Instrument can not be determined at configuration time. It is resolved when the Instrumentable actually registers the Instrument.

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

Method Summary
 void configure(Configuration configuration)
          Configures the Instrument.
 void enableLogging(Logger logger)
          Set the components logger.
static java.lang.String getTypeName(int type)
          Returns the name of a Instrument type.
 void increment(int count)
          Increments the Instrument by a specified count.
 boolean isActive()
          Used by classes being instrumented so that they can avoid unnecessary code when the data from a Instrument is not being used.
 void setValue(int value)
          Sets the current value of the Instrument.
protected  void stateChanged()
          Called whenever the state of the instrument is changed.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

enableLogging

public void enableLogging(Logger logger)
Description copied from class: AbstractLogEnabled
Set the components logger.

Specified by:
enableLogging in interface LogEnabled
Overrides:
enableLogging in class AbstractLogEnabled
Parameters:
logger - the logger

configure

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

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

isActive

public boolean isActive()
Used by classes being instrumented so that they can avoid unnecessary code when the data from a Instrument is not being used.

Specified by:
isActive in interface InstrumentProxy
Returns:
True if listeners are registered with the Instrument.

increment

public void increment(int count)
Increments the Instrument by a specified count. This method should be optimized to be extremely light weight when there are no registered CounterInstrumentListeners.

Specified by:
increment in interface InstrumentProxy
Parameters:
count - A positive integer to increment the counter by.

setValue

public void setValue(int value)
Sets the current value of the Instrument. This method is optimized to be extremely light weight when there are no registered ValueInstrumentListeners.

Specified by:
setValue in interface InstrumentProxy
Parameters:
value - The new value for the Instrument.

stateChanged

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


getTypeName

public static java.lang.String getTypeName(int type)
Returns the name of a Instrument type.

Parameters:
type - Type whose name is wanted.
Returns:
The name of a Instrument type.


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