public class MonitorableRegistry
extends java.lang.Object
Monitorable
is associated with a particular
MonitorableRegistry, and informs the registry of its own details via a
callback to register(Monitorable)
when the Monitorable is created.
the MonitorableRegistryListener interface can be used for clients interested in state changes
to be made aware of when new Monitorables are added, such as objects that wish
to serialize state to external stores. (ie... A PCPmmvWriter.. say..)Modifier and Type | Field and Description |
---|---|
static MonitorableRegistry |
DEFAULT_REGISTRY
A single central registry which can be used by non-Registry-aware
Monitorables.
|
private java.util.Map<java.lang.String,Monitorable<?>> |
monitorables
This is a TreeMap so that the Monitorables are maintained in alphabetical
order for convenience.
|
private static java.util.concurrent.ConcurrentMap<java.lang.String,MonitorableRegistry> |
NAMED_INSTANCES |
private java.util.List<MonitorableRegistryListener> |
registryListeners |
Constructor and Description |
---|
MonitorableRegistry() |
Modifier and Type | Method and Description |
---|---|
void |
addRegistryListener(MonitorableRegistryListener monitorableRegistryListener) |
static void |
clearDefaultRegistry() |
(package private) boolean |
containsMetric(java.lang.String name) |
(package private) Monitorable<?> |
getMetric(java.lang.String name) |
java.util.Collection<Monitorable<?>> |
getMonitorables() |
static MonitorableRegistry |
getNamedInstance(java.lang.String name)
Retrieves or creates a centrally-accessible named instance, identified
uniquely by the provided String.
|
private void |
notifyListenersOfNewMonitorable(Monitorable<?> monitorable) |
<T> void |
register(Monitorable<T> monitorable)
Informs this MonitorableRegistry of a new
Monitorable ; that
Monitorable will be added to the registry, assuming no Monitorable with
the same name has previously been registered. |
<T> T |
registerOrReuse(Monitorable<T> monitorable)
Registers the monitorable if it does not already exist, but otherwise returns an already registered
Monitorable with the same name, Semantics and UNnit definition.
|
void |
removeRegistryListener(MonitorableRegistryListener listener) |
private static final java.util.concurrent.ConcurrentMap<java.lang.String,MonitorableRegistry> NAMED_INSTANCES
public static MonitorableRegistry DEFAULT_REGISTRY
MonitorableRegistry
should be used instead.private final java.util.Map<java.lang.String,Monitorable<?>> monitorables
private final java.util.List<MonitorableRegistryListener> registryListeners
public <T> void register(Monitorable<T> monitorable)
Monitorable
; that
Monitorable will be added to the registry, assuming no Monitorable with
the same name has previously been registered.java.lang.UnsupportedOperationException
- if the name of the provided monitorable has already been
registeredpublic <T> T registerOrReuse(Monitorable<T> monitorable)
private void notifyListenersOfNewMonitorable(Monitorable<?> monitorable)
public java.util.Collection<Monitorable<?>> getMonitorables()
public static void clearDefaultRegistry()
public static MonitorableRegistry getNamedInstance(java.lang.String name)
DEFAULT_REGISTRY
) and having to pass a MonitorableRegistry down
to the very depths of your class hierarchy. This is especially useful
when instrumenting third-party code which cannot easily get access to a
given MonitorableRegistry from a non-static context.name
- public void addRegistryListener(MonitorableRegistryListener monitorableRegistryListener)
public void removeRegistryListener(MonitorableRegistryListener listener)
boolean containsMetric(java.lang.String name)
Monitorable<?> getMetric(java.lang.String name)