com.stuffthathappens.classbus
Class SyncDeliveryStrategy

java.lang.Object
  extended by com.stuffthathappens.classbus.SyncDeliveryStrategy
All Implemented Interfaces:
DeliveryStrategy

public class SyncDeliveryStrategy
extends java.lang.Object
implements DeliveryStrategy

Synchronous event delivery. Sends events on the same thread as the code invoking EventService.publish(String, Object).

Author:
Eric M. Burke

Constructor Summary
SyncDeliveryStrategy()
           
 
Method Summary
<T> void
publishTo(java.lang.Iterable<EventSubscriber<T>> subscribers, T event, DeliveryCompleteCallback<T> callback)
          Iterate over the given collection of subscribers, calling EventSubscriber.onEvent(Object) on each subscriber.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncDeliveryStrategy

public SyncDeliveryStrategy()
Method Detail

publishTo

public <T> void publishTo(java.lang.Iterable<EventSubscriber<T>> subscribers,
                          T event,
                          DeliveryCompleteCallback<T> callback)
Description copied from interface: DeliveryStrategy
Iterate over the given collection of subscribers, calling EventSubscriber.onEvent(Object) on each subscriber. This may spawn a new thread, depending on the implementation.

The callback is optional. If null, it is ignored.

Specified by:
publishTo in interface DeliveryStrategy
Parameters:
subscribers - the subscribers to notify.
event - the object to send.
callback - an optional callback to notify upon completion.
See Also:
EventSubscriber.onEvent(Object)