Class Subscriber

java.lang.Object
com.google.common.eventbus.Subscriber
Direct Known Subclasses:
Subscriber.SynchronizedSubscriber

class Subscriber extends Object
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.

  • Field Details

    • bus

      private EventBus bus
      The event bus this subscriber belongs to.
    • target

      final Object target
      The object with the subscriber method.
    • method

      private final Method method
      Subscriber method.
    • executor

      private final Executor executor
      Executor to use for dispatching events to this subscriber.
  • Constructor Details

  • Method Details

    • create

      static Subscriber create(EventBus bus, Object listener, Method method)
      Creates a Subscriber for method on listener.
    • dispatchEvent

      final void dispatchEvent(Object event)
      Dispatches event to this subscriber using the proper executor.
    • invokeSubscriberMethod

      void invokeSubscriberMethod(Object event) throws InvocationTargetException
      Invokes the subscriber method. This method can be overridden to make the invocation synchronized.
      Throws:
      InvocationTargetException
    • context

      private SubscriberExceptionContext context(Object event)
      Gets the context for the given event.
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(@CheckForNull Object obj)
      Overrides:
      equals in class Object
    • isDeclaredThreadSafe

      private static boolean isDeclaredThreadSafe(Method method)
      Checks whether method is thread-safe, as indicated by the presence of the AllowConcurrentEvents annotation.