Class ObserverMethodImpl<T>

java.lang.Object
org.apache.webbeans.event.ObserverMethodImpl<T>
Type Parameters:
T - event type
All Implemented Interfaces:
jakarta.enterprise.inject.spi.ObserverMethod<T>, jakarta.enterprise.inject.spi.Prioritized, OwbObserverMethod<T>
Direct Known Subclasses:
ContainerEventObserverMethodImpl

public class ObserverMethodImpl<T> extends Object implements OwbObserverMethod<T>
Defines observers that are declared in observer methods.

Example:

  public class X {
      
      public void afterLoggedIn(@Observes @Current LoggedInEvent event)
      {
          .....
      }
  }
 
Above class X instance observes for the event with type LoggedInEvent and event qualifier is Current. Whenever event is fired, its jakarta.enterprise.inject.spi.ObserverMethod#notify() method is called.

Version:
$Rev$ $Date$
  • Constructor Details

    • ObserverMethodImpl

      public ObserverMethodImpl(AbstractOwbBean<?> ownerBean, jakarta.enterprise.inject.spi.AnnotatedMethod<T> annotatedObserverMethod, jakarta.enterprise.inject.spi.AnnotatedParameter<T> annotatedObservesParameter)
      used if the qualifiers and event type are already known, e.g. from the XML.
    • ObserverMethodImpl

      protected ObserverMethodImpl(AbstractOwbBean<?> ownerBean, jakarta.enterprise.inject.spi.AnnotatedMethod<T> annotatedObserverMethod, jakarta.enterprise.inject.spi.AnnotatedParameter<T> annotatedObservesParameter, boolean fireEvent)
  • Method Details

    • checkObserverCondition

      protected void checkObserverCondition(jakarta.enterprise.inject.spi.AnnotatedParameter<T> annotatedObservesParameter)
    • getOwnerBean

      public AbstractOwbBean<?> getOwnerBean()
      Specified by:
      getOwnerBean in interface OwbObserverMethod<T>
    • isAsync

      public boolean isAsync()
      Specified by:
      isAsync in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • 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
    • getInjectionPoints

      public Set<jakarta.enterprise.inject.spi.InjectionPoint> getInjectionPoints()
      Returns the InjectionPoints for the parameters of this observer method.
      Specified by:
      getInjectionPoints in interface OwbObserverMethod<T>
    • notify

      public void notify(T event)
      Deprecated.
      actually. Use the method with the EventContext instead
      Specified by:
      notify in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
    • notify

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

      protected void invoke(Object object, Object[] args) throws IllegalAccessException, InvocationTargetException
      Throws:
      IllegalAccessException
      InvocationTargetException
    • getMethodArguments

      protected List<org.apache.webbeans.event.ObserverMethodImpl.ObserverParams> getMethodArguments(Object event, jakarta.enterprise.inject.spi.EventMetadata metadata)
      Gets observer method parameters.
      Parameters:
      event - event payload
      Returns:
      observer method parameters
    • getBeanClass

      public Class<?> getBeanClass()
      Returns observer owner bean.
      Specified by:
      getBeanClass in interface jakarta.enterprise.inject.spi.ObserverMethod<T>
      Returns:
      the bean
    • 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>
    • getReception

      public jakarta.enterprise.event.Reception getReception()
      Specified by:
      getReception 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>
    • getObserverMethod

      public jakarta.enterprise.inject.spi.AnnotatedMethod<T> getObserverMethod()
    • getWebBeansContext

      protected WebBeansContext getWebBeansContext()
    • setObserverMethod

      public void setObserverMethod(jakarta.enterprise.inject.spi.AnnotatedMethod<T> m)
      Provides a way to set the observer method. This may need to be done for EJBs so that the method used will be from an interface and not the EJB class that likely can not be invoked on the EJB proxy
      Parameters:
      m - method to be invoked as the observer