net.java.dev.moskito.core.stats.impl
Class IntervalRegistry

java.lang.Object
  extended by net.java.dev.moskito.core.stats.impl.IntervalRegistry

public class IntervalRegistry
extends Object

This class implements a registry singleton to hold and create Interval instances.

Author:
dvayanu

Field Summary
private static IntervalRegistry instance
          This is the instance of the singleton.
private  Map<Integer,Interval> intervalsById
          This Map holds all Intervals by their ids.
private  Map<String,Interval> intervalsByName
          This Map holds all Intervals by their names.
private  AtomicInteger nextId
          This is a Thread-safe counter to generate VM-wide uniqe ids for new Interval instances.
private  List<IntervalRegistryListener> registryListeners
          This List holds all registered IntervalRegistryListeners.
private  IUpdateTriggerService updateTriggerService
          This is a time control serive for periodic call backs.
 
Constructor Summary
private IntervalRegistry()
          The contructor.
 
Method Summary
private  Interval createInterval(String aName, int aLength)
          This method creates a new Interval with the given name and length.
static IntervalRegistry getInstance()
          This is the Singleton instance accessor method.
(package private)  Interval getInterval(int aId)
          This method retrieves an Interval with the given id.
 Interval getInterval(String aName)
          This method retrieves an Interval with the given name.
 Interval getInterval(String aName, int aLength)
          This method retrieves an Interval with the given name.
 List<Interval> getIntervals()
          This method returns a list containing all known Intervals.
private  int obtainNextUniqueId()
          This method returns the next free id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static IntervalRegistry instance
This is the instance of the singleton.


intervalsById

private Map<Integer,Interval> intervalsById
This Map holds all Intervals by their ids.


intervalsByName

private Map<String,Interval> intervalsByName
This Map holds all Intervals by their names.


nextId

private AtomicInteger nextId
This is a Thread-safe counter to generate VM-wide uniqe ids for new Interval instances.


updateTriggerService

private IUpdateTriggerService updateTriggerService
This is a time control serive for periodic call backs.


registryListeners

private List<IntervalRegistryListener> registryListeners
This List holds all registered IntervalRegistryListeners.

See Also:
IntervalRegistryListener
Constructor Detail

IntervalRegistry

private IntervalRegistry()
The contructor.

Method Detail

getInstance

public static IntervalRegistry getInstance()
This is the Singleton instance accessor method.

Returns:
the IntervalRegistry instance.

getInterval

Interval getInterval(int aId)
This method retrieves an Interval with the given id.

Parameters:
aId - the Interval id
Returns:
the found Interval
Throws:
UnknownIntervalException - if no Interval with the given id could be found

getInterval

public Interval getInterval(String aName,
                            int aLength)
This method retrieves an Interval with the given name. If no one could be found it will create a new Interval with given name and length. TODO: This method should be renamed to "getOrCreateInterval" or something like that TODO: This method MUST be synchonrized to avoid doublicate Interval instances....

Parameters:
aName - the Interval name
aLength - the length of the new Interval in seconds.
Returns:
the existing Interval or a new Interval with given name and length

getInterval

public Interval getInterval(String aName)
This method retrieves an Interval with the given name. If no one could be found it will create a new Interval with given name - the length will be a guess. TODO: This method should be renamed to "getOrCreateInterval" or something like that TODO: This method MUST be synchonrized to avoid double Interval instances....

Parameters:
aName - the Interval name
Returns:
the existing Interval or a new Interval with given name and guessed length

createInterval

private Interval createInterval(String aName,
                                int aLength)
This method creates a new Interval with the given name and length.

Parameters:
aName - the name of the new Interval
aLength - the length of the Interval in seconds
Returns:
the new Interval

obtainNextUniqueId

private int obtainNextUniqueId()
This method returns the next free id.

Returns:
the next id

getIntervals

public List<Interval> getIntervals()
This method returns a list containing all known Intervals.

Returns:
the Interval list


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