com.mtgi.analytics.jmx
Class StatisticsMBeanEventPersisterImpl

java.lang.Object
  extended by com.mtgi.analytics.jmx.StatisticsMBeanEventPersisterImpl
All Implemented Interfaces:
BehaviorEventPersister, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

public class StatisticsMBeanEventPersisterImpl
extends java.lang.Object
implements BehaviorEventPersister, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

An event persister which aggregates statistics for each type of event in memory, exposing those statistics as MBeans.

Configuration is very similar to that of the Spring Framework class MBeanExporter. BehaviorEvent MBeans are named (and thus grouped for aggregation) by an implementation of ObjectNamingStrategy; EventTypeNamingStrategy is used by default. Each MBean is backed by an instance of StatisticsMBean, which is converted into a ModelMBean by an instance of MBeanInfoAssembler; MetadataMBeanInfoAssembler is used by default. Statistics mbeans are registered in an instance of MBeanServer; JmxUtils.locateMBeanServer() is used to choose the default platform MBean server if none is specified.


Constructor Summary
StatisticsMBeanEventPersisterImpl()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
protected  StatisticsMBean getStatistics(BehaviorEvent event)
          Retrieve an aggregator for the given behavior event.
 void persist(java.util.Queue<BehaviorEvent> events)
          Store the given completed events, assigning unique identifiers to each and persisting all instances to the database.
 void setAssembler(org.springframework.jmx.export.assembler.MBeanInfoAssembler assembler)
           
 void setNamingStrategy(org.springframework.jmx.export.naming.ObjectNamingStrategy namingStrategy)
           
 void setServer(javax.management.MBeanServer server)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatisticsMBeanEventPersisterImpl

public StatisticsMBeanEventPersisterImpl()
Method Detail

setNamingStrategy

public void setNamingStrategy(org.springframework.jmx.export.naming.ObjectNamingStrategy namingStrategy)

setAssembler

public void setAssembler(org.springframework.jmx.export.assembler.MBeanInfoAssembler assembler)

setServer

public void setServer(javax.management.MBeanServer server)

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

persist

public void persist(java.util.Queue<BehaviorEvent> events)
Description copied from interface: BehaviorEventPersister

Store the given completed events, assigning unique identifiers to each and persisting all instances to the database. Some of the events may already have identifiers assigned; in this case, that identifer should be respected and a new one not assigned.

Persisters must support the persisting of child events before their parents, since this is generally the natural order in which events are completed.

Some members of the given collection may have parent events that are not in the collection itself. These parent events should not be persisted, though they must be assigned IDs.

Specified by:
persist in interface BehaviorEventPersister

getStatistics

protected StatisticsMBean getStatistics(BehaviorEvent event)
                                 throws javax.management.RuntimeOperationsException,
                                        javax.management.modelmbean.InvalidTargetObjectTypeException,
                                        javax.management.JMException
Retrieve an aggregator for the given behavior event. If no aggregator yet exists for the given event type, one is created and registered with the MBean server prior to being returned.

Returns:
the StatisticsMBean used to track aggregate data for event, never null
Throws:
javax.management.RuntimeOperationsException
javax.management.modelmbean.InvalidTargetObjectTypeException
javax.management.JMException