org.flexiblepower.observation
T - The type of value that will be in the published observations.public interface ObservationProvider<T>
ObservationProvider is any object that wants to publish Observations to a
ObservationConsumer. When using OSGi, there are a couple of properties that should be registered to make it
easier for consumers to find the proper providers.
org.flexiblepower.monitoring.observedBy: describes the component that does the observations.
Normally this will be the name of the component itself.
org.flexiblepower.monitoring.observationOf: describes the physical thing that it is observing.
org.flexiblepower.monitoring.type: gives the full classname of the type of value that will be
published by the provider.
org.flexiblepower.monitoring.type.X: for each attribute, the X is replaced by the name of the
attribute (as will be returned by the method and the value is the type description,
usually the classname.
org.flexiblepower.monitoring.type.X.unit: optionally describes the unit in which the attribute will
be transformed. This is only relevant for raw values, like doubles or integers.
org.flexiblepower.monitoring.type.X.optional: optionally describes if an attribute is optional. By
default the consumer may assume that all attributes are available each time, but by setting this to true it can
indicate otherwise.
| Modifier and Type | Method and Description |
|---|---|
Observation<? extends T> |
getLastObservation()
Get the last published
Observation. |
void |
subscribe(ObservationConsumer<? super T> consumer)
Binds the consumer to this provider.
|
void |
unsubscribe(ObservationConsumer<? super T> consumer)
Unbinds the consumer from this provider.
|
void subscribe(ObservationConsumer<? super T> consumer)
ObservationConsumer.consume(ObservationProvider, Observation)
method.consumer - The ObservationConsumer that will be bound to this provider.void unsubscribe(ObservationConsumer<? super T> consumer)
consumer - The ObservationConsumer that will be unbound from this provider.Observation<? extends T> getLastObservation()
Observation.