org.jmonit.features
Class LocalStopwatch

java.lang.Object
  extended by org.jmonit.Probe
      extended by org.jmonit.Stopwatch
          extended by org.jmonit.features.LocalStopwatch
All Implemented Interfaces:
Plugin<Stopwatch>

public class LocalStopwatch
extends Stopwatch
implements Plugin<Stopwatch>

Author:
Nicolas De Loof

Field Summary
static Factory<Stopwatch> FACTORY
           
 
Constructor Summary
LocalStopwatch()
           
 
Method Summary
 void cancel()
          Cancel monitoring.
 long getElapsedTime()
           
 Stopwatch getFeature()
          A feature is identified by the class it exposes to the monitored application.
 boolean isPaused()
           
 boolean isStarted()
           
 boolean isStoped()
           
 void pause()
          Temporary stop the Stopwatch.
 void resume()
          Resume the Stopwatch after a pause.
 void setMonitor(Monitor monitor)
          Set the monitor this plugin extends.
 void setMonitoringEventBus(MonitoringEventBus bus)
          Set the event bus used to dispatch monitoring events between the monitor and it's features.
 void start()
          Start monitoring the process.
 long stop()
          Stop monitoring the process.
 long stop(boolean canceled)
          Convenience method to stop or cancel a Stopwatch depending on success of monitored operation
 
Methods inherited from class org.jmonit.Stopwatch
finalize, fireMonitoringEvent, nanotime, start
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY

public static final Factory<Stopwatch> FACTORY
Constructor Detail

LocalStopwatch

public LocalStopwatch()
Method Detail

cancel

public void cancel()
Description copied from class: Stopwatch
Cancel monitoring. Elapsed time will not be computed and will not be published to the monitor.

In some circumstances you want to monitor time elapsed from early stage of computation, and discover latter if the computed data is relevant. For example, monitoring a messaging system, but beeing interested only by some types of messages. In such case, a Stopwatch can be started early and canceled when the application is able to determine it's relevancy.

In any way, the probe will still report thread concurrency even if canceled.

Overrides:
cancel in class Stopwatch

getElapsedTime

public long getElapsedTime()
Overrides:
getElapsedTime in class Stopwatch
Returns:
Elapsed time (in nanoseconds) for the monitored process

isPaused

public boolean isPaused()
Overrides:
isPaused in class Stopwatch
Returns:
true if the Stopwatch has been paused

isStarted

public boolean isStarted()
Overrides:
isStarted in class Stopwatch
Returns:
true if the Stopwatch has been started

isStoped

public boolean isStoped()
Overrides:
isStoped in class Stopwatch
Returns:
true if the Stopwatch has been stopped

pause

public void pause()
Description copied from class: Stopwatch
Temporary stop the Stopwatch. Elapsed time calculation will not include time spent in paused mode.

Overrides:
pause in class Stopwatch

resume

public void resume()
Description copied from class: Stopwatch
Resume the Stopwatch after a pause.

Overrides:
resume in class Stopwatch

start

public void start()
Description copied from class: Stopwatch
Start monitoring the process.

Overrides:
start in class Stopwatch

stop

public long stop()
Description copied from class: Stopwatch
Stop monitoring the process. A Stopwatch created with Stopwatch.start(Monitor) cannot be re-used after stopped has been called.

Overrides:
stop in class Stopwatch

stop

public long stop(boolean canceled)
Description copied from class: Stopwatch
Convenience method to stop or cancel a Stopwatch depending on success of monitored operation

Overrides:
stop in class Stopwatch
Returns:
time elapsed since the probe has been started

getFeature

public Stopwatch getFeature()
A feature is identified by the class it exposes to the monitored application.

Specified by:
getFeature in interface Plugin<Stopwatch>
Returns:
the public API of this feature
See Also:
Plugin.getFeature()

setMonitoringEventBus

public void setMonitoringEventBus(MonitoringEventBus bus)
Set the event bus used to dispatch monitoring events between the monitor and it's features.

Specified by:
setMonitoringEventBus in interface Plugin<Stopwatch>
Parameters:
bus - the event bus
See Also:
Plugin.setMonitoringEventBus(org.jmonit.events.MonitoringEventBus)

setMonitor

public void setMonitor(Monitor monitor)
Set the monitor this plugin extends. Can be used for direct acces to other features.

Specified by:
setMonitor in interface Plugin<Stopwatch>
Parameters:
monitor - the extended monitor
See Also:
Plugin.setMonitor(org.jmonit.Monitor)


Copyright © 2007 Nicolas De Loof. All Rights Reserved.