Package com.google.common.eventbus
Class Subscriber
java.lang.Object
com.google.common.eventbus.Subscriber
- Direct Known Subclasses:
Subscriber.SynchronizedSubscriber
A subscriber method on a specific object, plus the executor that should be used for dispatching
events to it.
Two subscribers are equivalent when they refer to the same method on the same object (not class). This property is used to ensure that no subscriber method is registered more than once.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
Subscriber that synchronizes invocations of a method to ensure that only one thread may enter the method at a time. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate SubscriberExceptionContext
Gets the context for the given event.(package private) static Subscriber
Creates aSubscriber
formethod
onlistener
.(package private) final void
dispatchEvent
(Object event) Dispatchesevent
to this subscriber using the proper executor.final boolean
final int
hashCode()
(package private) void
invokeSubscriberMethod
(Object event) Invokes the subscriber method.private static boolean
isDeclaredThreadSafe
(Method method) Checks whethermethod
is thread-safe, as indicated by the presence of theAllowConcurrentEvents
annotation.
-
Field Details
-
bus
The event bus this subscriber belongs to. -
target
The object with the subscriber method. -
method
Subscriber method. -
executor
Executor to use for dispatching events to this subscriber.
-
-
Constructor Details
-
Subscriber
-
-
Method Details
-
create
Creates aSubscriber
formethod
onlistener
. -
dispatchEvent
Dispatchesevent
to this subscriber using the proper executor. -
invokeSubscriberMethod
Invokes the subscriber method. This method can be overridden to make the invocation synchronized.- Throws:
InvocationTargetException
-
context
Gets the context for the given event. -
hashCode
public final int hashCode() -
equals
-
isDeclaredThreadSafe
Checks whethermethod
is thread-safe, as indicated by the presence of theAllowConcurrentEvents
annotation.
-