com.netflix.eventbus.spi
Interface DynamicSubscriber
public interface DynamicSubscriber
Eventbus subscribers, by design, are statically tied to a particular type of object i.e. the class of the event it
is interested in. This in most cases is beneficial and easy to use, however, in some cases (typically event agnostic,
middlemen, which stores the event for later investigation), the event processing is much the same irrespective of the
type of event it receives. In such a case, it will be an overhead (even if possible) to define a subscriber for
each kind of event existing in the system.
This special subscriber is a way to achieve dynamic interests (immutable after registration) in subscribers. Although,
this subscriber can only listen to one type of event but the type is defined at runtime as opposed to compile time
in a normal subscriber.
Although, this subscriber does not mandate that the subscriber must have a subscribe method (one annotated with
Subscribe) listening to event type Object but in most of the cases, such a subscribe method will
prove to be more useful. EventBus allows specifying the subscribe method with argument Object
only for these subscribers.
Implementations must only have a single subscriber method or else the registration with eventbus will be rejected.
This limitation is imposed as we do not want to make runtime decisions on which subscribe method an event must be
directed to.
|
Method Summary |
java.lang.Class<?> |
getEventType()
Returns the event type i.e. |
getEventType
java.lang.Class<?> getEventType()
- Returns the event type i.e. the class of the event that this subscriber will be interested in.
EventBus allows specifying the subscribe method with argument Object only for
these subscribers.
The implementers of this interface must make sure that the subscribe method accepts the event class returned by
this method.
- Returns:
- The event type i.e. the class of the event that this subscriber will be interested in.