org.apache.commons.monitoring.listeners
Class SecondaryRepository

java.lang.Object
  extended by org.apache.commons.monitoring.impl.repositories.AbstractRepository
      extended by org.apache.commons.monitoring.listeners.SecondaryRepository
All Implemented Interfaces:
Detachable, Repository, Repository.Listener

public class SecondaryRepository
extends AbstractRepository
implements Repository.Listener, Detachable

A repository implementation that registers as a Listener to an Observable repository and maintains a set of Monitors in sync with the observed repository.

As a Detachable implementation, the SecondaryRepository can be detached from the observed repository and used to build a report for the observed period.

Author:
Nicolas De Loof

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.commons.monitoring.Repository
Repository.Listener, Repository.Observable
 
Constructor Summary
SecondaryRepository(Repository.Observable repository)
           
 
Method Summary
 void detach()
          Detach the instance from live monitoring beackbone.
 long getAttachedAt()
           
 long getDetachedAt()
           
protected  Monitor getMonitor(Monitor.Key key)
          
 boolean isDetached()
          
 void newMonitorInstance(Monitor monitor)
          A monitor has just been created.
 StopWatch start(Monitor monitor)
          Start a StopWatch to monitor execution
 
Methods inherited from class org.apache.commons.monitoring.impl.repositories.AbstractRepository
getCategories, getMonitor, getMonitor, getMonitor, getMonitors, getMonitorsFromCategory, getMonitorsFromSubSystem, getSubSystems, register, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecondaryRepository

public SecondaryRepository(Repository.Observable repository)
Method Detail

detach

public void detach()
Description copied from interface: Detachable
Detach the instance from live monitoring beackbone. Any new monitoring event will not affect datas in this component.

Specified by:
detach in interface Detachable

getMonitor

protected Monitor getMonitor(Monitor.Key key)

Overrides:
getMonitor in class AbstractRepository
See Also:
AbstractRepository.getMonitor(org.apache.commons.monitoring.Monitor.Key)

newMonitorInstance

public void newMonitorInstance(Monitor monitor)
Description copied from interface: Repository.Listener
A monitor has just been created. Can be used to add custom StatValues or to register StatValue.Listener for all monitors that declare the same category or subsystem.

Specified by:
newMonitorInstance in interface Repository.Listener
See Also:
Repository.Listener.newMonitorInstance(org.apache.commons.monitoring.Monitor)

start

public StopWatch start(Monitor monitor)
Start a StopWatch to monitor execution

Specified by:
start in interface Repository
Parameters:
monitor - the monitor associated with the process
Returns:
a running StopWatch
See Also:
Repository.start(org.apache.commons.monitoring.Monitor)

getAttachedAt

public long getAttachedAt()
Specified by:
getAttachedAt in interface Detachable
Returns:
When (as a System.currentTimeMillis() time) the SecondaryRepository started to observe the repository

getDetachedAt

public long getDetachedAt()
Specified by:
getDetachedAt in interface Detachable
Returns:
When (as a System.currentTimeMillis() time) the SecondaryRepository stopped observing the repository

isDetached

public boolean isDetached()

Specified by:
isDetached in interface Detachable
See Also:
Detachable.isDetached()


Copyright © 2008 The Apache Software Foundation. All Rights Reserved.