brooklyn.management
Interface SubscriptionManager


public interface SubscriptionManager

The management interface for subscriptions. Different implementations will handle entities subscribing and unsubscribing to SensorEvents and their delivery.

See Also:
SubscriptionContext

Method Summary
 Set<SubscriptionHandle> getSubscriptionsForEntitySensor(Entity source, Sensor<?> sensor)
          Return the subscriptions on a given source-sensor pair
 Set<SubscriptionHandle> getSubscriptionsForSubscriber(Object subscriber)
          Return the subscriptions requested by a given subscriber
<T> void
publish(SensorEvent<T> event)
          Deliver a SensorEvent to all subscribed listeners.
<T> SubscriptionHandle
subscribe(Entity producer, Sensor<T> sensor, SensorEventListener<? super T> listener)
           
<T> SubscriptionHandle
subscribe(Map<String,Object> flags, Entity producer, Sensor<T> sensor, SensorEventListener<? super T> listener)
          Subscribe to Sensor data changes and events on a given Entity, supplying the SensorEventListener to invoke when they occur.
<T> SubscriptionHandle
subscribeToChildren(Entity parent, Sensor<T> sensor, SensorEventListener<? super T> listener)
           
<T> SubscriptionHandle
subscribeToChildren(Map<String,Object> flags, Entity parent, Sensor<T> sensor, SensorEventListener<? super T> listener)
          Subscribe to Sensor data changes and events on all children of a given Entity, supplying the SensorEventListener to invoke when they occur.
<T> SubscriptionHandle
subscribeToMembers(Group parent, Sensor<T> sensor, SensorEventListener<? super T> listener)
           
<T> SubscriptionHandle
subscribeToMembers(Map<String,Object> flags, Group parent, Sensor<T> sensor, SensorEventListener<? super T> listener)
          Subscribe to Sensor data changes and events on all members of a given Group, supplying the SensorEventListener to invoke when they occur.
 boolean unsubscribe(SubscriptionHandle subscriptionId)
          Unsubscribe the given subscription id.
 

Method Detail

subscribe

<T> SubscriptionHandle subscribe(Map<String,Object> flags,
                                 Entity producer,
                                 Sensor<T> sensor,
                                 SensorEventListener<? super T> listener)
Subscribe to Sensor data changes and events on a given Entity, supplying the SensorEventListener to invoke when they occur. The method returns an id which can be used to unsubscribe(SubscriptionHandle) later.

The listener callback is in-order single-threaded and synchronized on this object. The flags parameters can include the following:

Parameters:
flags - optional parameters to be associated with the subscription
producer - entity to listen to, or null to listen to all entities
sensor - sensor channel of events to listen to, or null for all sensors from the given producer(s)
listener - callback to invoke when an event occurs
Returns:
an id for this subscription
See Also:
unsubscribe(SubscriptionHandle)

subscribe

<T> SubscriptionHandle subscribe(Entity producer,
                                 Sensor<T> sensor,
                                 SensorEventListener<? super T> listener)
See Also:
subscribe(Map, Entity, Sensor, SensorEventListener)

subscribeToChildren

<T> SubscriptionHandle subscribeToChildren(Map<String,Object> flags,
                                           Entity parent,
                                           Sensor<T> sensor,
                                           SensorEventListener<? super T> listener)
Subscribe to Sensor data changes and events on all children of a given Entity, supplying the SensorEventListener to invoke when they occur. The subscriptions will be created recursively for all children, and the same listener callback will be invoked for each sensor datum. The semantics are otherwise identical to the subscribe(Map, Entity, Sensor, SensorEventListener) method.

See Also:
subscribe(Map, Entity, Sensor, SensorEventListener)

subscribeToChildren

<T> SubscriptionHandle subscribeToChildren(Entity parent,
                                           Sensor<T> sensor,
                                           SensorEventListener<? super T> listener)
See Also:
subscribeToChildren(Map, Entity, Sensor, SensorEventListener)

subscribeToMembers

<T> SubscriptionHandle subscribeToMembers(Map<String,Object> flags,
                                          Group parent,
                                          Sensor<T> sensor,
                                          SensorEventListener<? super T> listener)
Subscribe to Sensor data changes and events on all members of a given Group, supplying the SensorEventListener to invoke when they occur. The subscriptions will be created recursively for all children, and the same listener callback will be invoked for each sensor datum. The semantics are otherwise identical to the subscribe(Map, Entity, Sensor, SensorEventListener) method.

See Also:
subscribe(Map, Entity, Sensor, SensorEventListener)

subscribeToMembers

<T> SubscriptionHandle subscribeToMembers(Group parent,
                                          Sensor<T> sensor,
                                          SensorEventListener<? super T> listener)
See Also:
#subscribeToChildren(Map, Group, Sensor, SensorEventListener)

unsubscribe

boolean unsubscribe(SubscriptionHandle subscriptionId)
Unsubscribe the given subscription id.

Returns:
true if such a subscription was present (and it will now be removed)
See Also:
subscribe(Map, Entity, Sensor, SensorEventListener)

publish

<T> void publish(SensorEvent<T> event)
Deliver a SensorEvent to all subscribed listeners.


getSubscriptionsForSubscriber

Set<SubscriptionHandle> getSubscriptionsForSubscriber(Object subscriber)
Return the subscriptions requested by a given subscriber


getSubscriptionsForEntitySensor

Set<SubscriptionHandle> getSubscriptionsForEntitySensor(Entity source,
                                                        Sensor<?> sensor)
Return the subscriptions on a given source-sensor pair



Copyright © 2013. All Rights Reserved.