Package it.tidalwave.messagebus
Interface MessageBus
-
- All Known Implementing Classes:
SimpleMessageBus
public interface MessageBusA simple message bus for a local publish/subscribe facility.- Author:
- Fabrizio Giudici
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceMessageBus.Listener<T>A listener to receive notifications from aMessageBus.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> voidpublish(java.lang.Class<T> topic, T message)Publishes the given message and topic.<T> voidpublish(T message)Publishes the given event.<T> voidsubscribe(java.lang.Class<T> topic, MessageBus.Listener<T> listener)Subscribes aMessageBus.Listenerto a topic.voidunsubscribe(MessageBus.Listener<?> listener)Unsubscribes aMessageBus.Listener.
-
-
-
Method Detail
-
publish
<T> void publish(@Nonnull T message)Publishes the given event. The topic is the class of the event.- Type Parameters:
T- the static type of the topic- Parameters:
message- the event
-
publish
<T> void publish(@Nonnull java.lang.Class<T> topic, @Nonnull T message)Publishes the given message and topic. Passing an explicit topic can be useful when dealing with a hierarchy of events (so, perhaps a subclass is passed but the topic is the root of the hierarchy).- Type Parameters:
T- the static type of the topic- Parameters:
topic- the topicmessage- the message
-
subscribe
<T> void subscribe(@Nonnull java.lang.Class<T> topic, @Nonnull MessageBus.Listener<T> listener)Subscribes aMessageBus.Listenerto a topic.- Type Parameters:
T- the static type of the topic- Parameters:
topic- the topiclistener- the listener
-
unsubscribe
void unsubscribe(@Nonnull MessageBus.Listener<?> listener)Unsubscribes aMessageBus.Listener.- Parameters:
listener- the listener
-
-