public class InstrumentProxy
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.excalibur.instrument.InstrumentProxy, org.apache.avalon.framework.configuration.Configurable
The type of a Instrument can not be determined at configuration time. It is resolved when the Instrumentable actually registers the Instrument.
| Modifier and Type | Field and Description |
|---|---|
private boolean |
m_configured
Configured flag.
|
private java.lang.String |
m_description
The description of the Instrumente.
|
private org.apache.excalibur.instrument.manager.InstrumentDescriptor |
m_descriptor
The Descriptor for the Instrument.
|
private InstrumentableProxy |
m_instrumentableProxy
The InstrumentableProxy which owns the InstrumentProxy.
|
private int |
m_lastValue
The most recent value set if this is a value instrument.
|
private org.apache.excalibur.instrument.manager.InstrumentListener[] |
m_listeners
Array of registered Counter/ValueInstrumentListeners.
|
private java.lang.String |
m_name
The name used to identify a Instrument.
|
private boolean |
m_registered
Registered flag.
|
private InstrumentSample[] |
m_sampleArray
Optimized array of the InstrumentSamples.
|
private org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor[] |
m_sampleDescriptorArray
Optimized array of the InstrumentSampleDescriptors.
|
private java.util.HashMap |
m_samples
Map of the maintained InstrumentSamples.
|
private int |
m_stateVersion
State Version.
|
private int |
m_type
Type of the Instrument
|
private org.apache.avalon.framework.logger.Logger |
m_valueLogger
Child logger to use for logging of new values.
|
| Constructor and Description |
|---|
InstrumentProxy(InstrumentableProxy instrumentableProxy,
java.lang.String name,
java.lang.String description)
Creates a new InstrumentProxy.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addCounterInstrumentListener(org.apache.excalibur.instrument.manager.CounterInstrumentListener listener)
Adds a CounterInstrumentListener to the list of listeners which will
receive updates of the value of the Instrument.
|
private void |
addInstrumentListener(org.apache.excalibur.instrument.manager.InstrumentListener listener)
Common code to add a listener to the list of listeners which will
receive updates of the value of the Instrument.
|
private void |
addInstrumentSample(InstrumentSample instrumentSample)
Add a InstrumentSample to the Instrument.
|
(package private) void |
addValueInstrumentListener(org.apache.excalibur.instrument.manager.ValueInstrumentListener listener)
Adds a ValueInstrumentListener to the list of listeners which will
receive updates of the value of the Instrument.
|
void |
configure(org.apache.avalon.framework.configuration.Configuration configuration)
Configures the Instrument.
|
(package private) InstrumentSample |
createInstrumentSample(java.lang.String sampleDescription,
long sampleInterval,
int sampleSize,
long sampleLease,
int sampleType)
Returns an InstrumentSampleDescriptor based on its name.
|
void |
enableLogging(org.apache.avalon.framework.logger.Logger logger) |
(package private) java.lang.String |
getDescription()
Gets the description of the Instrument.
|
(package private) org.apache.excalibur.instrument.manager.InstrumentDescriptor |
getDescriptor()
Returns a Descriptor for the Instrument.
|
(package private) InstrumentableProxy |
getInstrumentableProxy()
Returns the InstrumentableProxy which owns the InstrumentProxy.
|
(package private) InstrumentSample |
getInstrumentSample(java.lang.String instrumentSampleName)
Returns a InstrumentSample based on its name.
|
(package private) org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor[] |
getInstrumentSampleDescriptors()
Returns an array of Descriptors for the InstrumentSamples in the
Instrument.
|
(package private) InstrumentSample[] |
getInstrumentSamples()
Returns an array of the InstrumentSamples in the Instrument.
|
(package private) java.lang.String |
getName()
Gets the name for the Instrument.
|
(package private) int |
getStateVersion()
Returns the stateVersion of the instrument.
|
(package private) int |
getType()
Returns the type of the Instrument.
|
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.
|
(package private) boolean |
isConfigured()
Returns true if the Instrument was configured in the instrumentables
section of the configuration.
|
(package private) boolean |
isRegistered()
Returns true if the Instrument was registered with the Instrument
Manager.
|
(package private) InstrumentSample |
loadSampleState(org.apache.avalon.framework.configuration.Configuration state)
Loads the state of an Instrument Sample.
|
(package private) void |
removeCounterInstrumentListener(org.apache.excalibur.instrument.manager.CounterInstrumentListener listener)
Removes a InstrumentListener from the list of listeners which will
receive events.
|
private void |
removeInstrumentListener(org.apache.excalibur.instrument.manager.InstrumentListener listener)
Common code to remove a listener from the list of listeners which will
receive updates of the value of the Instrument.
|
(package private) void |
removeInstrumentSample(InstrumentSample instrumentSample)
Removes an InstrumentSample from the Instrument.
|
(package private) void |
removeValueInstrumentListener(org.apache.excalibur.instrument.manager.ValueInstrumentListener listener)
Removes a InstrumentListener from the list of listeners which will
receive events.
|
(package private) void |
setDescription(java.lang.String description)
Sets the description for the Instrument.
|
(package private) void |
setRegistered()
Called by the InstrumentManager whenever an Instrument assigned to
this proxy is registered.
|
(package private) void |
setType(int type)
Set the type of the Instrument.
|
void |
setValue(int value)
Sets the current value of the Instrument.
|
protected void |
stateChanged()
Called whenever the state of the instrument is changed.
|
private InstrumentSample[] |
updateInstrumentSampleArray()
Updates the cached array of InstrumentSamples taking synchronization into
account.
|
private org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor[] |
updateInstrumentSampleDescriptorArray()
Updates the cached array of InstrumentSampleDescriptors taking
synchronization into account.
|
(package private) void |
writeState(java.io.PrintWriter out)
Writes the current state to a PrintWriter as XML.
|
private InstrumentableProxy m_instrumentableProxy
private boolean m_configured
private boolean m_registered
private java.lang.String m_name
private java.lang.String m_description
private org.apache.excalibur.instrument.manager.InstrumentDescriptor m_descriptor
private int m_type
private org.apache.excalibur.instrument.manager.InstrumentListener[] m_listeners
private java.util.HashMap m_samples
private InstrumentSample[] m_sampleArray
private org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor[] m_sampleDescriptorArray
private org.apache.avalon.framework.logger.Logger m_valueLogger
private int m_lastValue
private int m_stateVersion
InstrumentProxy(InstrumentableProxy instrumentableProxy, java.lang.String name, java.lang.String description)
instrumentableProxy - The InstrumentableProxy which owns the
InstrumentProxy.name - The name used to identify a Instrumentable.description - The description of the the Instrumentable.public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
enableLogging in interface org.apache.avalon.framework.logger.LogEnabledenableLogging in class org.apache.avalon.framework.logger.AbstractLogEnabledpublic void configure(org.apache.avalon.framework.configuration.Configuration configuration)
throws org.apache.avalon.framework.configuration.ConfigurationException
configure in interface org.apache.avalon.framework.configuration.Configurableconfiguration - Instrument configuration element from the
InstrumentManager's configuration.org.apache.avalon.framework.configuration.ConfigurationException - If there are any configuration problems.public boolean isActive()
isActive in interface org.apache.excalibur.instrument.InstrumentProxypublic void increment(int count)
increment in interface org.apache.excalibur.instrument.InstrumentProxycount - A positive integer to increment the counter by.public void setValue(int value)
setValue in interface org.apache.excalibur.instrument.InstrumentProxyvalue - The new value for the Instrument.InstrumentableProxy getInstrumentableProxy()
boolean isConfigured()
boolean isRegistered()
void setRegistered()
java.lang.String getName()
void setDescription(java.lang.String description)
description - The description of the Instrument.java.lang.String getDescription()
org.apache.excalibur.instrument.manager.InstrumentDescriptor getDescriptor()
void setType(int type)
type - Type of the Instrument.int getType()
void addCounterInstrumentListener(org.apache.excalibur.instrument.manager.CounterInstrumentListener listener)
listener - CounterInstrumentListener which will start receiving
updates.java.lang.IllegalStateException - If the Instrument's type is not
InstrumentManager.INSTRUMENT_TYPE_COUNTER.void removeCounterInstrumentListener(org.apache.excalibur.instrument.manager.CounterInstrumentListener listener)
listener - InstrumentListener which will stop receiving events.java.lang.IllegalStateException - If the Instrument's type is not
InstrumentManager.INSTRUMENT_TYPE_COUNTER.void addValueInstrumentListener(org.apache.excalibur.instrument.manager.ValueInstrumentListener listener)
listener - ValueInstrumentListener which will start receiving
updates.java.lang.IllegalStateException - If the Instrument's type is not
InstrumentManager.INSTRUMENT_TYPE_VALUE.void removeValueInstrumentListener(org.apache.excalibur.instrument.manager.ValueInstrumentListener listener)
listener - InstrumentListener which will stop receiving events.java.lang.IllegalStateException - If the Instrument's type is not
InstrumentManager.INSTRUMENT_TYPE_VALUE.private void addInstrumentSample(InstrumentSample instrumentSample)
InstrumentSample - InstrumentSample to be added.void removeInstrumentSample(InstrumentSample instrumentSample)
InstrumentSample - InstrumentSample to be removed.InstrumentSample getInstrumentSample(java.lang.String instrumentSampleName)
instrumentSampleName - Name of the InstrumentSample being requested.InstrumentSample[] getInstrumentSamples()
InstrumentSample createInstrumentSample(java.lang.String sampleDescription, long sampleInterval, int sampleSize, long sampleLease, int sampleType)
sampleDescription - Description to assign to the new Sample.sampleInterval - Sample interval to use in the new Sample.sampleLease - Requested lease time for the new Sample in
milliseconds. The InstrumentManager may grant a
lease which is shorter or longer than the requested
period.sampleType - Type of sample to request. Must be one of the
following: DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER,
DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MINIMUM,
DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MAXIMUM,
DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MEAN.NoSuchInstrumentSampleException - If the specified InstrumentSample
does not exist.org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor[] getInstrumentSampleDescriptors()
int getStateVersion()
private void addInstrumentListener(org.apache.excalibur.instrument.manager.InstrumentListener listener)
listener - InstrumentListener which will start receiving
updates.private void removeInstrumentListener(org.apache.excalibur.instrument.manager.InstrumentListener listener)
listener - InstrumentListener which will stop receiving
updates.private InstrumentSample[] updateInstrumentSampleArray()
private org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor[] updateInstrumentSampleDescriptorArray()
void writeState(java.io.PrintWriter out)
out - The PrintWriter to which the state should be written.InstrumentSample loadSampleState(org.apache.avalon.framework.configuration.Configuration state) throws org.apache.avalon.framework.configuration.ConfigurationException
state - Configuration object to load state from.org.apache.avalon.framework.configuration.ConfigurationException - If there were any problems loading the
state.protected void stateChanged()
public static java.lang.String getTypeName(int type)
type - Type whose name is wanted.