org.javasimon
Class SwitchingManager

java.lang.Object
  extended by org.javasimon.SwitchingManager
All Implemented Interfaces:
Manager

public final class SwitchingManager
extends Object
implements Manager

Manager implementation that supports enable() and disable() and switches between backing EnabledManager and DisabledManager accordingly.

Author:
Richard "Virgo" Richter

Field Summary
private  Manager disabled
           
private  Manager enabled
           
private  Manager manager
           
 
Fields inherited from interface org.javasimon.Manager
HIERARCHY_DELIMITER, ROOT_SIMON_NAME
 
Constructor Summary
SwitchingManager()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enabled

private Manager enabled

disabled

private Manager disabled

manager

private Manager manager
Constructor Detail

SwitchingManager

public SwitchingManager()
Method Detail

getRootSimon

public Simon getRootSimon()
Description copied from interface: Manager
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.

Specified by:
getRootSimon in interface Manager
Returns:
root Simon

getSimon

public Simon getSimon(String name)
Description copied from interface: Manager
Returns Simon by its name if it exists.

Specified by:
getSimon in interface Manager
Parameters:
name - name of the Simon
Returns:
Simon object

getCounter

public Counter getCounter(String name)
Description copied from interface: Manager
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.

Specified by:
getCounter in interface Manager
Parameters:
name - name of the Counter
Returns:
counter object

getStopwatch

public Stopwatch getStopwatch(String name)
Description copied from interface: Manager
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.

Specified by:
getStopwatch in interface Manager
Parameters:
name - name of the Stopwatch
Returns:
stopwatch object

getSimonNames

public Collection<String> getSimonNames()
Description copied from interface: Manager
Returns unmodifiable collection containing names of all existing Simons. Collection is not ordered.

Specified by:
getSimonNames in interface Manager
Returns:
collection of all Simon names

getSimons

public Collection<Simon> getSimons(SimonPattern pattern)
Description copied from interface: Manager
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.

Specified by:
getSimons in interface Manager
Parameters:
pattern - Simon name pattern (see SimonPattern
Returns:
collection of all Simons matching the pattern
See Also:
to find out more about possible patterns

destroySimon

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

Specified by:
destroySimon in interface Manager
Parameters:
name - name of the Simon

clear

public void clear()
Description copied from interface: Manager
Clears the whole manager and starts again with a single newly created Root Simon.

Specified by:
clear in interface Manager

callback

public CompositeCallback callback()
Description copied from interface: Manager
Accesses default composite callback of this manager. Default callback can't be removed or replaced, only other callbacks can be added or removed.

Specified by:
callback in interface Manager
Returns:
Simon callback

configuration

public ManagerConfiguration configuration()
Description copied from interface: Manager
Accesses configuration of this manager.

Specified by:
configuration in interface Manager
Returns:
configuration of this manager

enable

public void enable()
Enables the Simon Manager. Enabled manager provides real Simons.

Specified by:
enable in interface Manager

disable

public void disable()
Disables the Simon Manager. Disabled manager provides null Simons that actually do nothing.

Specified by:
disable in interface Manager

isEnabled

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

Specified by:
isEnabled in interface Manager
Returns:
true if the API is enabled

message

public void message(String message)
Description copied from interface: Manager
Method propagates message to manager's Callback. This allows user to report any message if they implement Callback.onManagerMessage(String).

Specified by:
message in interface Manager
Parameters:
message - message text

warning

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

Specified by:
warning in interface Manager
Parameters:
warning - arbitrary warning message
cause - exception causing this warning


Copyright © 2013. All Rights Reserved.