class Subscriber
extends java.lang.Object
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.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Subscriber.SynchronizedSubscriber
Subscriber that synchronizes invocations of a method to ensure that only one thread may enter
the method at a time.
|
Modifier and Type | Field and Description |
---|---|
private EventBus |
bus
The event bus this subscriber belongs to.
|
private java.util.concurrent.Executor |
executor
Executor to use for dispatching events to this subscriber.
|
private java.lang.reflect.Method |
method
Subscriber method.
|
(package private) java.lang.Object |
target
The object with the subscriber method.
|
Modifier | Constructor and Description |
---|---|
private |
Subscriber(EventBus bus,
java.lang.Object target,
java.lang.reflect.Method method) |
Modifier and Type | Method and Description |
---|---|
private SubscriberExceptionContext |
context(java.lang.Object event)
Gets the context for the given event.
|
(package private) static Subscriber |
create(EventBus bus,
java.lang.Object listener,
java.lang.reflect.Method method)
Creates a
Subscriber for method on listener . |
(package private) void |
dispatchEvent(java.lang.Object event)
Dispatches
event to this subscriber using the proper executor. |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
(package private) void |
invokeSubscriberMethod(java.lang.Object event)
Invokes the subscriber method.
|
private static boolean |
isDeclaredThreadSafe(java.lang.reflect.Method method)
Checks whether
method is thread-safe, as indicated by the presence of the
AllowConcurrentEvents annotation. |
private EventBus bus
final java.lang.Object target
private final java.lang.reflect.Method method
private final java.util.concurrent.Executor executor
private Subscriber(EventBus bus, java.lang.Object target, java.lang.reflect.Method method)
static Subscriber create(EventBus bus, java.lang.Object listener, java.lang.reflect.Method method)
Subscriber
for method
on listener
.final void dispatchEvent(java.lang.Object event)
event
to this subscriber using the proper executor.void invokeSubscriberMethod(java.lang.Object event) throws java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
private SubscriberExceptionContext context(java.lang.Object event)
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(@Nullable java.lang.Object obj)
equals
in class java.lang.Object
private static boolean isDeclaredThreadSafe(java.lang.reflect.Method method)
method
is thread-safe, as indicated by the presence of the
AllowConcurrentEvents
annotation.