org.perf4j.helpers
Class StatisticsExposingMBean

java.lang.Object
  extended by org.perf4j.helpers.StatisticsExposingMBean
All Implemented Interfaces:
javax.management.DynamicMBean

public class StatisticsExposingMBean
extends java.lang.Object
implements javax.management.DynamicMBean

This class provides a wrapper around GroupedTimingStatistics data so that this performance information can be exposed through JMX.

Author:
Alex Devine

Field Summary
protected  java.util.regex.Pattern attributeNamePattern
          Pattern used to parse requested attribute names into the tag name and the statistic name
protected  GroupedTimingStatistics currentTimingStatistics
          The current underlying timing statistics whose values are exposed as MBean attributes.
static java.lang.String DEFAULT_MBEAN_NAME
          Logging classes use this as the default ObjectName of this MBean when registering it with an MBeanServer.
protected  javax.management.MBeanInfo managementInterface
          This MBeanInfo exposes this MBean's management interface to the MBeanServer.
 
Constructor Summary
StatisticsExposingMBean(java.util.Collection<java.lang.String> tagsToExpose)
          Creates a new StatisticsExposingMBean whose management interface exposes performance attributes for the tags specified.
 
Method Summary
protected  javax.management.MBeanInfo createMBeanInfoFromTagNames(java.util.Collection<java.lang.String> tagNames)
          Helper method creates an MBeanInfo object that contains 6 read only attributes for each tag name, each attribute representing a different statistic.
 java.lang.Object getAttribute(java.lang.String attribute)
           
 javax.management.AttributeList getAttributes(java.lang.String[] attributeNames)
           
 javax.management.MBeanInfo getMBeanInfo()
           
protected  java.util.Map<java.lang.String,StatsValueRetriever> getStatsValueRetrievers()
          Overridable helper method gets the Map of statistic name to StatsValueRetriever.
 java.lang.Object invoke(java.lang.String s, java.lang.Object[] objects, java.lang.String[] strings)
           
 void setAttribute(javax.management.Attribute attribute)
           
 javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
           
 void updateCurrentTimingStatistics(GroupedTimingStatistics currentTimingStatistics)
          This method should be called to update the underlying timing statistics, which will correspondingly change the values of the exposed attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MBEAN_NAME

public static final java.lang.String DEFAULT_MBEAN_NAME
Logging classes use this as the default ObjectName of this MBean when registering it with an MBeanServer.

See Also:
Constant Field Values

managementInterface

protected javax.management.MBeanInfo managementInterface
This MBeanInfo exposes this MBean's management interface to the MBeanServer.


currentTimingStatistics

protected GroupedTimingStatistics currentTimingStatistics
The current underlying timing statistics whose values are exposed as MBean attributes.


attributeNamePattern

protected java.util.regex.Pattern attributeNamePattern
Pattern used to parse requested attribute names into the tag name and the statistic name

Constructor Detail

StatisticsExposingMBean

public StatisticsExposingMBean(java.util.Collection<java.lang.String> tagsToExpose)
Creates a new StatisticsExposingMBean whose management interface exposes performance attributes for the tags specified.

Parameters:
tagsToExpose - The names of the tags whose statistics should exposed. For each tag specified there will be 6 attributes whose getters are exposed: tagNameMean, tagNameStdDev, tagNameMin, tagNameMax, and tagNameCount and tagNameTPS
Method Detail

updateCurrentTimingStatistics

public void updateCurrentTimingStatistics(GroupedTimingStatistics currentTimingStatistics)
This method should be called to update the underlying timing statistics, which will correspondingly change the values of the exposed attributes.

Parameters:
currentTimingStatistics - The TimingStatistics to set, may not be null

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException,
                                     javax.management.ReflectionException
Specified by:
getAttribute in interface javax.management.DynamicMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException

setAttribute

public void setAttribute(javax.management.Attribute attribute)
                  throws javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.MBeanException,
                         javax.management.ReflectionException
Specified by:
setAttribute in interface javax.management.DynamicMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.InvalidAttributeValueException
javax.management.MBeanException
javax.management.ReflectionException

getAttributes

public javax.management.AttributeList getAttributes(java.lang.String[] attributeNames)
Specified by:
getAttributes in interface javax.management.DynamicMBean

setAttributes

public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
Specified by:
setAttributes in interface javax.management.DynamicMBean

invoke

public java.lang.Object invoke(java.lang.String s,
                               java.lang.Object[] objects,
                               java.lang.String[] strings)
                        throws javax.management.MBeanException,
                               javax.management.ReflectionException
Specified by:
invoke in interface javax.management.DynamicMBean
Throws:
javax.management.MBeanException
javax.management.ReflectionException

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo()
Specified by:
getMBeanInfo in interface javax.management.DynamicMBean

getStatsValueRetrievers

protected java.util.Map<java.lang.String,StatsValueRetriever> getStatsValueRetrievers()
Overridable helper method gets the Map of statistic name to StatsValueRetriever.

Returns:
The StatsValueRetriever Map.

createMBeanInfoFromTagNames

protected javax.management.MBeanInfo createMBeanInfoFromTagNames(java.util.Collection<java.lang.String> tagNames)
Helper method creates an MBeanInfo object that contains 6 read only attributes for each tag name, each attribute representing a different statistic.

Parameters:
tagNames - The name of the tags whose statistics should be exposed as MBeanAttributes.
Returns:
The MBeanInfo that represents the management interface for this MBean.


Copyright © 2008 perf4j.org. All Rights Reserved.