net.java.dev.moskito.core.dynamic
Class OnDemandStatsProducer

java.lang.Object
  extended by net.java.dev.moskito.core.dynamic.OnDemandStatsProducer
All Implemented Interfaces:
Inspectable, IStatsProducer
Direct Known Subclasses:
EntryCountLimitedOnDemandStatsProducer

public class OnDemandStatsProducer
extends Object
implements IStatsProducer, Inspectable

This producer is used when the different method producing stats aren't known at compile time (or you don't want to use them). It is used by the InvocationProxy to add methods dynamically as they being called, but also by the filters, like RequestURIFilter dynamically adding a stat for each new uri.

Author:
dvayanu

Field Summary
private  List<IStats> _cachedStatsList
          A cached stat list for faster access.
private  String category
          The variable where the category of this producer, given as parameter upon creation, is stored.
private  CreationInfo creationInfo
          CreationInfo object initialized on startup.
private  IOnDemandStatsFactory factory
          The factory for stat creation.
private  IStats linkToDefaultStats
          A fast access variable for default (cumulated) stats.
private static org.apache.log4j.Logger log
           
private  String producerId
          The variable where the producerId of this producer, given as parameter upon creation, is stored.
private  Map<String,IStats> stats
          A map where all stat and their ids (strings) are being stored.
private  String subsystem
          The variable where the subsystem of this producer, given as parameter upon creation, is stored.
 
Constructor Summary
OnDemandStatsProducer(String aProducerId, String aCategory, String aSubsystem, IOnDemandStatsFactory aStatsFactory)
          Creates a new OnDemandStatsProducer instance.
 
Method Summary
protected  List<IStats> getCachedStatsList()
           
 String getCategory()
          Returns the category of this producer.
 CreationInfo getCreationInfo()
           
 IStats getDefaultStats()
           
 String getProducerId()
          Returns the meaningful id of this producer.
protected  String getProducerNameExtension()
           
 List<IStats> getStats()
          Returns the list of all stats.
 IStats getStats(String name)
           
 String getSubsystem()
          Returns the subsystem the current producer is located in.
protected  boolean limitForNewEntriesReached()
          The getStats method checked whether the limit is reached before creating a new stat object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log

factory

private IOnDemandStatsFactory factory
The factory for stat creation.


_cachedStatsList

private List<IStats> _cachedStatsList
A cached stat list for faster access.


stats

private Map<String,IStats> stats
A map where all stat and their ids (strings) are being stored.


linkToDefaultStats

private IStats linkToDefaultStats
A fast access variable for default (cumulated) stats.


category

private String category
The variable where the category of this producer, given as parameter upon creation, is stored.


producerId

private String producerId
The variable where the producerId of this producer, given as parameter upon creation, is stored.


subsystem

private String subsystem
The variable where the subsystem of this producer, given as parameter upon creation, is stored.


creationInfo

private CreationInfo creationInfo
CreationInfo object initialized on startup.

Constructor Detail

OnDemandStatsProducer

public OnDemandStatsProducer(String aProducerId,
                             String aCategory,
                             String aSubsystem,
                             IOnDemandStatsFactory aStatsFactory)
Creates a new OnDemandStatsProducer instance.

Parameters:
aProducerId - a producer id
aCategory - a category
aSubsystem - a subsystem
aStatsFactory - a factory for IStat object creation.
Method Detail

getStats

public IStats getStats(String name)
                throws OnDemandStatsProducerException
Throws:
OnDemandStatsProducerException

getCategory

public String getCategory()
Description copied from interface: IStatsProducer
Returns the category of this producer. A typical categorie is something like servlet, action, service or dao. The categories are used to group different StatsProducer to get overview over a certain layer in the application, i.e. show me all actions.

Specified by:
getCategory in interface IStatsProducer
Returns:
the id of the category the producer belongs to.

getProducerId

public String getProducerId()
Description copied from interface: IStatsProducer
Returns the meaningful id of this producer. This should be something like a class or interface name.

Specified by:
getProducerId in interface IStatsProducer
Returns:
a string which provides unique identification of this producer, i.e. the class name or a readable form of it.

getStats

public List<IStats> getStats()
Description copied from interface: IStatsProducer
Returns the list of all stats.

Specified by:
getStats in interface IStatsProducer
Returns:
all stats this producer produces / generates.

getSubsystem

public String getSubsystem()
Description copied from interface: IStatsProducer
Returns the subsystem the current producer is located in. Moskito referrs to your application as "the system". If you want to filter some parts of your system separately you should use the getSubsystem() method to separate them. Possible subsystems are: usermanagement, messaging... whatever. The getCategory() method should separate parts of the application horizontally, whether the getSubsystem() method should provide vertical separation.

Specified by:
getSubsystem in interface IStatsProducer
Returns:
the id of the subsystem the producer belongs to.

getDefaultStats

public IStats getDefaultStats()

toString

public String toString()
Overrides:
toString in class Object

limitForNewEntriesReached

protected boolean limitForNewEntriesReached()
The getStats method checked whether the limit is reached before creating a new stat object. Overwrite this function and return true if you want to limit the number of possible stored stats. Not limiting the stats can result in memory leak if someone can influence the stat names from the outside. Therefore MoskitoFilters are using EntryCountLimitedOnDemandStatsProducer instead.

Returns:
false

getProducerNameExtension

protected String getProducerNameExtension()

getCachedStatsList

protected List<IStats> getCachedStatsList()

getCreationInfo

public CreationInfo getCreationInfo()
Specified by:
getCreationInfo in interface Inspectable


Copyright © 2006 MoSKito Project Team. All Rights Reserved.
MoSKito, the open source java monitoring framework