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 classSubscriber 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 SubscriberExceptionContextGets the context for the given event.(package private) static SubscriberCreates aSubscriberformethodonlistener.(package private) final voiddispatchEvent(Object event) Dispatcheseventto this subscriber using the proper executor.final booleanfinal inthashCode()(package private) voidinvokeSubscriberMethod(Object event) Invokes the subscriber method.private static booleanisDeclaredThreadSafe(Method method) Checks whethermethodis thread-safe, as indicated by the presence of theAllowConcurrentEventsannotation.
-
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 aSubscriberformethodonlistener. -
dispatchEvent
Dispatcheseventto 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 whethermethodis thread-safe, as indicated by the presence of theAllowConcurrentEventsannotation.
-