org.javasimon
Class EnabledManager

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

public final class EnabledManager
extends Object
implements Manager

Implements fully functional Manager in the enabled state. Does not support enable()/disable() - for this use SwitchingManager.

Author:
Richard "Virgo" Richter

Field Summary
private  Map<String,AbstractSimon> allSimons
           
private  CompositeCallback callback
           
private  ManagerConfiguration configuration
           
private  UnknownSimon rootSimon
           
 
Fields inherited from interface org.javasimon.Manager
HIERARCHY_DELIMITER, ROOT_SIMON_NAME
 
Constructor Summary
EnabledManager()
          Creates new enabled manager.
 
Method Summary
private  void addToHierarchy(AbstractSimon simon, String name)
           
 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.
private  AbstractSimon createOrReplaceUnknownSimon(String name, Class<? extends AbstractSimon> simonClass)
           
 void destroySimon(String name)
          Removes Simon from the Manager.
 void disable()
          Throws UnsupportedOperationException.
 void enable()
          Throws UnsupportedOperationException.
 Counter getCounter(String name)
          Returns existing Counter or creates new if necessary.
private  Simon getOrCreateSimon(String name, Class<? extends AbstractSimon> simonClass)
           
 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.
private  AbstractSimon instantiateSimon(String name, Class<? extends AbstractSimon> simonClass)
           
 boolean isEnabled()
          Returns true.
 void message(String message)
          Method propagates message to manager's Callback.
private  AbstractSimon newSimon(String name, Class<? extends AbstractSimon> simonClass)
           
private  AbstractSimon replaceUnknownSimon(AbstractSimon simon, Class<? extends AbstractSimon> simonClass)
           
 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

allSimons

private final Map<String,AbstractSimon> allSimons

rootSimon

private UnknownSimon rootSimon

callback

private CompositeCallback callback

configuration

private ManagerConfiguration configuration
Constructor Detail

EnabledManager

public EnabledManager()
Creates new enabled manager.

Method Detail

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

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

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

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

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

getOrCreateSimon

private Simon getOrCreateSimon(String name,
                               Class<? extends AbstractSimon> simonClass)

createOrReplaceUnknownSimon

private AbstractSimon createOrReplaceUnknownSimon(String name,
                                                  Class<? extends AbstractSimon> simonClass)

replaceUnknownSimon

private AbstractSimon replaceUnknownSimon(AbstractSimon simon,
                                          Class<? extends AbstractSimon> simonClass)

newSimon

private AbstractSimon newSimon(String name,
                               Class<? extends AbstractSimon> simonClass)

instantiateSimon

private AbstractSimon instantiateSimon(String name,
                                       Class<? extends AbstractSimon> simonClass)

addToHierarchy

private void addToHierarchy(AbstractSimon simon,
                            String name)

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()
Throws UnsupportedOperationException.

Specified by:
enable in interface Manager

disable

public void disable()
Throws UnsupportedOperationException.

Specified by:
disable in interface Manager

isEnabled

public boolean isEnabled()
Returns true.

Specified by:
isEnabled in interface Manager
Returns:
true

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.