Package net.engio.mbassy.subscription
Class Subscription
java.lang.Object
net.engio.mbassy.subscription.Subscription
A subscription is a thread-safe container that manages exactly one message handler of all registered
message listeners of the same class, i.e. all subscribed instances (excluding subclasses) of a SingleMessageHandler.class
will be referenced in the subscription created for SingleMessageHandler.class.
There will be as many unique subscription objects per message listener class as there are message handlers
defined in the message listeners class hierarchy.
The subscription provides functionality for message publication by means of delegation to the respective
message dispatcher.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
A handle exposes specific functionality of a subscription to be used by clients. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SubscriptionContext
private final IMessageDispatcher
private final UUID
protected final Collection
<Object> private final CopyOnWriteArrayList
<Runnable> static final Comparator
<Subscription> -
Constructor Summary
ConstructorsConstructorDescriptionSubscription
(SubscriptionContext context, IMessageDispatcher dispatcher, Collection<Object> listeners) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check whether this subscription manages a message handler of the given listener class.boolean
Check whether this subscriptions manages the given listener instance.Class[]
int
boolean
handlesMessageType
(Class<?> messageType) Check whether this subscription manages a specific message type.void
publish
(MessagePublication publication, Object message) int
size()
void
boolean
unsubscribe
(Object existingListener)
-
Field Details
-
id
-
listeners
-
dispatcher
-
context
-
onSubscription
-
SubscriptionByPriorityDesc
-
-
Constructor Details
-
Subscription
Subscription(SubscriptionContext context, IMessageDispatcher dispatcher, Collection<Object> listeners)
-
-
Method Details
-
belongsTo
Check whether this subscription manages a message handler of the given listener class. -
contains
Check whether this subscriptions manages the given listener instance. -
handlesMessageType
Check whether this subscription manages a specific message type. -
getHandledMessageTypes
-
publish
-
getPriority
public int getPriority() -
subscribe
-
unsubscribe
-
size
public int size() -
getHandle
-