Class ObserverMethodImpl<T,X>

java.lang.Object
org.jboss.weld.event.ObserverMethodImpl<T,X>
All Implemented Interfaces:
jakarta.enterprise.inject.spi.ObserverMethod<T>, jakarta.enterprise.inject.spi.Prioritized, EventMetadataAwareObserverMethod<T>
Direct Known Subclasses:
ExtensionObserverMethodImpl

public class ObserverMethodImpl<T,X> extends Object implements jakarta.enterprise.inject.spi.ObserverMethod<T>, EventMetadataAwareObserverMethod<T>

Reference implementation for the ObserverMethod interface, which represents an observer method. Each observer method has an event type which is the class of the event object being observed, and event binding types that are annotations applied to the event parameter to narrow the event notifications delivered.

Author:
David Allen, Jozef Hartinger, Marko Luksa
  • Field Details

    • ID_PREFIX

      public static final String ID_PREFIX
    • ID_SEPARATOR

      public static final String ID_SEPARATOR
      See Also:
    • SPECIAL_PARAM_MARKERS

      protected static final Set<Class<? extends Annotation>> SPECIAL_PARAM_MARKERS
    • beanManager

      protected final BeanManagerImpl beanManager
    • declaringBean

      protected final RIBean<X> declaringBean
    • observerMethod

      protected final MethodInjectionPoint<T,? super X> observerMethod
    • transactionPhase

      protected jakarta.enterprise.event.TransactionPhase transactionPhase
  • Constructor Details

    • ObserverMethodImpl

      protected ObserverMethodImpl(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager, boolean isAsync)
      Creates an Observer which describes and encapsulates an observer method (8.5).
      Parameters:
      observer - The observer
      declaringBean - The observer bean
      manager - The Bean manager
  • Method Details

    • getEventParameter

      protected EnhancedAnnotatedParameter<?,? super X> getEventParameter(EnhancedAnnotatedMethod<T,? super X> observer)
    • createId

      protected String createId(EnhancedAnnotatedMethod<?,?> observer, RIBean<?> declaringBean)
    • createTypeId

      protected String createTypeId(RIBean<?> declaringBean)
    • initMethodInjectionPoint

      protected MethodInjectionPoint<T,? super X> initMethodInjectionPoint(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager)
    • getInjectionPoints

      public Set<WeldInjectionPointAttributes<?,?>> getInjectionPoints()
    • checkRequiredTypeAnnotations

      protected <Y> void checkRequiredTypeAnnotations(EnhancedAnnotatedParameter<?,?> eventParameter, EnhancedAnnotatedMethod<T,Y> annotated)
    • getBeanClass

      public Class<X> getBeanClass()
      Specified by:
      getBeanClass in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • getDeclaringBean

      public RIBean<X> getDeclaringBean()
      Specified by:
      getDeclaringBean in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • getReception

      public jakarta.enterprise.event.Reception getReception()
      Specified by:
      getReception in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • getObservedQualifiers

      public Set<Annotation> getObservedQualifiers()
      Specified by:
      getObservedQualifiers in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • getObservedType

      public Type getObservedType()
      Specified by:
      getObservedType in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • getTransactionPhase

      public jakarta.enterprise.event.TransactionPhase getTransactionPhase()
      Specified by:
      getTransactionPhase in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • getMethod

      public MethodInjectionPoint<T,? super X> getMethod()
      Returns:
      the observerMethod
    • initialize

      public void initialize(EnhancedAnnotatedMethod<T,? super X> annotated)
      Completes initialization of the observer and allows derived types to override behavior.
    • notify

      public void notify(T event)
      Specified by:
      notify in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • notify

      public void notify(T event, jakarta.enterprise.event.Reception reception)
      Used as default notify method from ObserverMethodConfiguratorImpl. This allows Weld to respect Reception set in the configurator.
    • sendEvent

      public void sendEvent(T event, jakarta.enterprise.event.Reception reception)
      Invokes the observer method immediately passing the event.
      Parameters:
      event - The event to notify observer with
    • sendEvent

      protected void sendEvent(T event, Object receiver, jakarta.enterprise.context.spi.CreationalContext<?> creationalContext)
      Note that CreationalContext.release() is not invoked within this method.
      Parameters:
      event -
      receiver -
      creationalContext -
    • preNotify

      protected void preNotify(T event, Object receiver)
      Hooks allowing subclasses to perform additional logic just before and just after an event is delivered to an observer method.
    • postNotify

      protected void postNotify(T event, Object receiver)
    • getReceiver

      protected Object getReceiver(jakarta.enterprise.context.spi.CreationalContext<X> creationalContext)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getId

      public String getId()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
      Specified by:
      getPriority in interface jakarta.enterprise.inject.spi.Prioritized
    • isAsync

      public boolean isAsync()
      Specified by:
      isAsync in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • isEventMetadataRequired

      public boolean isEventMetadataRequired()
      Specified by:
      isEventMetadataRequired in interface EventMetadataAwareObserverMethod<T>
      Returns:
      true if EventMetadata is required, false otherwise