Package org.apache.pivot.util
Class MessageBus
- java.lang.Object
-
- org.apache.pivot.util.MessageBus
-
public final class MessageBus extends java.lang.ObjectProvides support for basic intra-application message passing.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> voidsendMessage(T message)Sends a message to subscribed topic listeners.static <T> voidsubscribe(java.lang.Class<? super T> topic, MessageBusListener<T> messageListener)Subscribes a listener to a message topic.static <T> voidunsubscribe(java.lang.Class<? super T> topic, MessageBusListener<T> messageListener)Unsubscribe a listener from a message topic.
-
-
-
Method Detail
-
subscribe
public static <T> void subscribe(java.lang.Class<? super T> topic, MessageBusListener<T> messageListener)Subscribes a listener to a message topic.- Type Parameters:
T- The type of the topic.- Parameters:
topic- The topic class to subscribe to.messageListener- The listener we want to attach.
-
unsubscribe
public static <T> void unsubscribe(java.lang.Class<? super T> topic, MessageBusListener<T> messageListener)Unsubscribe a listener from a message topic.- Type Parameters:
T- The type of the topic.- Parameters:
topic- The topic class to subscribe to.messageListener- The listener to unsubscribe.- Throws:
java.lang.IllegalArgumentException- if there are no listeners subscribed.
-
sendMessage
public static <T> void sendMessage(T message)
Sends a message to subscribed topic listeners.- Type Parameters:
T- The type of the topic.- Parameters:
message- The message to send to all subscribed listeners.
-
-