org.javasimon
Interface Manager

All Known Implementing Classes:
DisabledManager, EnabledManager, SwitchingManager

public interface Manager

Manager provides access to Simons and manages them in a tree structure. Any number of Managers can be created. There is also one special Manager (called "default manager") that is accessible via convenient static utility class SimonManager.

Three different implementations exist:

Author:
Richard "Virgo" Richter

Field Summary
static String HIERARCHY_DELIMITER
          Hierarchy delimiter in Simon name.
static String ROOT_SIMON_NAME
          Name of the root Simon.
 
Method Summary
 CompositeCallback callback()
          Accesses default composite callback of this manager.
 void clear()
          Clears the whole manager and starts again with a single newly created Root Simon.
 ManagerConfiguration configuration()
          Accesses configuration of this manager.
 void destroySimon(String name)
          Removes Simon from the Manager.
 void disable()
          Disables the Simon Manager.
 void enable()
          Enables the Simon Manager.
 Counter getCounter(String name)
          Returns existing Counter or creates new if necessary.
 Simon getRootSimon()
          Returns root Simon.
 Simon getSimon(String name)
          Returns Simon by its name if it exists.
 Collection<String> getSimonNames()
          Returns unmodifiable collection containing names of all existing Simons.
 Collection<Simon> getSimons(SimonPattern pattern)
          Returns collection containing all existing Simons matching the pattern (can be null).
 Stopwatch getStopwatch(String name)
          Returns existing Stopwatch or creates new if necessary.
 boolean isEnabled()
          Returns true if the Java Simon API is enabled.
 void message(String message)
          Method propagates message to manager's Callback.
 void warning(String warning, Exception cause)
          Method propagates warning to manager's Callback.
 

Field Detail

ROOT_SIMON_NAME

static final String ROOT_SIMON_NAME
Name of the root Simon.

See Also:
Constant Field Values

HIERARCHY_DELIMITER

static final String HIERARCHY_DELIMITER
Hierarchy delimiter in Simon name.

See Also:
Constant Field Values
Method Detail

getRootSimon

Simon getRootSimon()
Returns root Simon. Type of the Simon is unknown at the start but it can be replaced by the real Simon later. Specific get method with root Simon name constant can be used in that case.

Returns:
root Simon

getSimon

Simon getSimon(String name)
Returns Simon by its name if it exists.

Parameters:
name - name of the Simon
Returns:
Simon object

getCounter

Counter getCounter(String name)
Returns existing Counter or creates new if necessary. "Anonymous" Counter can be obtained if null name is specified - then it is not added to the Simon hierarchy.

Parameters:
name - name of the Counter
Returns:
counter object

getStopwatch

Stopwatch getStopwatch(String name)
Returns existing Stopwatch or creates new if necessary. "Anonymous" Stopwatch can be obtained if null name is specified - then it is not added to the Simon hierarchy.

Parameters:
name - name of the Stopwatch
Returns:
stopwatch object

getSimonNames

Collection<String> getSimonNames()
Returns unmodifiable collection containing names of all existing Simons. Collection is not ordered.

Returns:
collection of all Simon names
Since:
3.1

getSimons

Collection<Simon> getSimons(SimonPattern pattern)
Returns collection containing all existing Simons matching the pattern (can be null). Collection is unmodifiable if null pattern is provided and all Simons are returned, otherwise new collection with matching Simons is returned.

Parameters:
pattern - Simon name pattern (see SimonPattern
Returns:
collection of all Simons matching the pattern
Since:
3.2
See Also:
to find out more about possible patterns

destroySimon

void destroySimon(String name)
Removes Simon from the Manager. If Simon has some children it will be replaced by UnknownSimon.

Parameters:
name - name of the Simon

clear

void clear()
Clears the whole manager and starts again with a single newly created Root Simon.


callback

CompositeCallback callback()
Accesses default composite callback of this manager. Default callback can't be removed or replaced, only other callbacks can be added or removed.

Returns:
Simon callback

configuration

ManagerConfiguration configuration()
Accesses configuration of this manager.

Returns:
configuration of this manager

enable

void enable()
Enables the Simon Manager. Enabled manager provides real Simons. Only SwitchingManager supports this operation.


disable

void disable()
Disables the Simon Manager. Disabled manager provides null Simons that actually do nothing. Only SwitchingManager supports this operation.


isEnabled

boolean isEnabled()
Returns true if the Java Simon API is enabled.

Returns:
true if the API is enabled

message

void message(String message)
Method propagates message to manager's Callback. This allows user to report any message if they implement Callback.onManagerMessage(String).

Parameters:
message - message text

warning

void warning(String warning,
             Exception cause)
Method propagates warning to manager's Callback. This allows user to report any warning and/or exception if they implement Callback.onManagerWarning(String, Exception).

Parameters:
warning - arbitrary warning message
cause - exception causing this warning


Copyright © 2013. All Rights Reserved.