com.commsen.stopwatch
Interface StopwatchEngine

All Known Implementing Classes:
DefaultStopwatchEngine, MemoryStopwatchEngine

public interface StopwatchEngine

Interface describes the basic functionality a Stopwatch engine should support. All classes implementing this interface are considered Stopwatch engines. Stopwatch can be configured to use given engine by :

Author:
Milen Dyankov

Method Summary
 long begin(java.lang.String group, java.lang.String label)
          Method called when mensuration is started.
 void end(long id)
          Method called when mensuration is stopped.
 java.util.Properties getProperties()
          Returns engine properties.
 StopwatchStorage getStorage()
          Allows clients to get reference to the stopwatch's storage.
 java.lang.String getStorageClass()
          Method called to obtain the current storage class
 void pause()
          Called when Stopwatch is disabled or for any other reason it will not use this engine for some time.
 void resume()
          Called when Stopwatch is enabled and before attepting to use paused engine.
 void setDebugEnabled(boolean debugEnabled)
          Instructs engine to disable/enable debug information.
 void setPersistenceMode(int persistenceMode)
          Method called to instruct engine in what mode persistence manager should work in.
 void setProperties(java.util.Properties properties)
          Called by Stopwatch to set engine properties .
 void setStorage(StopwatchStorage storage)
          Method called to instruct engine to use user defined storage
 void skip(long id)
          Method called when mensuration with id id is to be skipped.
 void start()
          Method called by Stopwatch when initilializing Stopwatch engine.
 void stop()
          Called when Stopwatch's engine is changed or for any other reason Stopwatch will no longer use this engine.
 

Method Detail

start

void start()
Method called by Stopwatch when initilializing Stopwatch engine.


pause

void pause()
Called when Stopwatch is disabled or for any other reason it will not use this engine for some time. This gives engine a chance to force-close all pending measurments, invalidate caches, close database connections, etc.


resume

void resume()
Called when Stopwatch is enabled and before attepting to use paused engine. This gives engine a chance to re-initialize caches, open database connections, etc.


stop

void stop()
Called when Stopwatch's engine is changed or for any other reason Stopwatch will no longer use this engine. This gives engine a chance to free all used resources.


begin

long begin(java.lang.String group,
           java.lang.String label)
Method called when mensuration is started.

Parameters:
group - the name of the group this measurment should be placed in
label - how this measurment should be labeled
Returns:
Unique ID representing current measurment.

end

void end(long id)
Method called when mensuration is stopped. It is possible to call this method multiple times with the same id, however the engine should process only the first call.

Parameters:
id - Unique ID representing the actual measurment that need to be stopped.

skip

void skip(long id)
Method called when mensuration with id id is to be skipped. It is possible to call this method multiple times with the same id, however the engine should process only the first call.

Parameters:
id - Unique ID representing the actual measurment that need to be stopped.

setStorage

void setStorage(StopwatchStorage storage)
Method called to instruct engine to use user defined storage

Parameters:
storage - the storage to be used by this engine

setPersistenceMode

void setPersistenceMode(int persistenceMode)
Method called to instruct engine in what mode persistence manager should work in.

Parameters:
persistenceMode - the mode persistence manager should work in.
See Also:
StorageManager.NORMAL_MODE, StorageManager.THREAD_MODE, StorageManager.DELAYED_MODE

getStorageClass

java.lang.String getStorageClass()
Method called to obtain the current storage class

Returns:
the class name of the current storage

getStorage

StopwatchStorage getStorage()
Allows clients to get reference to the stopwatch's storage. Storage is normaly used by clients to generate reports.

Returns:
reference to the storage

setDebugEnabled

void setDebugEnabled(boolean debugEnabled)
Instructs engine to disable/enable debug information. The reason for this exist is to be able to minimize the performance impact Stopwatch may have on the measured application. Generating debug info consumes additional CPU units, which may become a problem if Stopwatch is heavily used. Setting this to false (it is false by default) should cause no debug info being generated even when log4j's level is set to DEBUG.

Parameters:
debugEnabled - should debug information be generated

setProperties

void setProperties(java.util.Properties properties)
Called by Stopwatch to set engine properties .

Parameters:
properties - the properties

getProperties

java.util.Properties getProperties()
Returns engine properties.

Returns:
engine properties


Copyright © 2006-2008 Commsen International. All Rights Reserved.