Package it.tidalwave.messagebus
Interface MessageBus
-
- All Known Subinterfaces:
CollaborationAwareMessageBus
- All Known Implementing Classes:
SimpleMessageBus
public interface MessageBus
A simple message bus for a local publish/subscribe facility.- Author:
- Fabrizio Giudici
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
MessageBus.Listener<TOPIC>
A listener to receive notifications from aMessageBus
.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <TOPIC> void
publish(java.lang.Class<TOPIC> topic, TOPIC message)
Publishes the given message and topic.<TOPIC> void
publish(TOPIC message)
Publishes the given event.<TOPIC> void
subscribe(java.lang.Class<TOPIC> topic, MessageBus.Listener<TOPIC> listener)
Subscribes aMessageBus.Listener
to a topic.void
unsubscribe(MessageBus.Listener<?> listener)
Unsubscribes aMessageBus.Listener
.
-
-
-
Method Detail
-
publish
<TOPIC> void publish(@Nonnull TOPIC message)
Publishes the given event. The topic is the class of the event.- Type Parameters:
TOPIC
- the static type of the topic- Parameters:
message
- the event
-
publish
<TOPIC> void publish(@Nonnull java.lang.Class<TOPIC> topic, @Nonnull TOPIC 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:
TOPIC
- the static type of the topic- Parameters:
topic
- the topicmessage
- the message
-
subscribe
<TOPIC> void subscribe(@Nonnull java.lang.Class<TOPIC> topic, @Nonnull MessageBus.Listener<TOPIC> listener)
Subscribes aMessageBus.Listener
to a topic.- Type Parameters:
TOPIC
- 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
-
-