Class ObserverMethodImpl<T,​X>

  • All Implemented Interfaces:
    javax.enterprise.inject.spi.ObserverMethod<T>
    Direct Known Subclasses:
    ExtensionObserverMethodImpl

    public class ObserverMethodImpl<T,​X>
    extends Object
    implements javax.enterprise.inject.spi.ObserverMethod<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 Detail

      • ID_PREFIX

        public static final String ID_PREFIX
      • declaringBean

        protected final RIBean<X> declaringBean
      • transactionPhase

        protected javax.enterprise.event.TransactionPhase transactionPhase
    • Constructor Detail

      • ObserverMethodImpl

        protected ObserverMethodImpl​(EnhancedAnnotatedMethod<T,​? super X> observer,
                                     RIBean<X> declaringBean,
                                     BeanManagerImpl manager)
        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 Detail

      • createTypeId

        protected String createTypeId​(RIBean<?> declaringBean)
      • checkRequiredTypeAnnotations

        protected void checkRequiredTypeAnnotations​(EnhancedAnnotatedParameter<?,​?> eventParameter)
      • getBeanClass

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

        public RIBean<X> getDeclaringBean()
      • getReception

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

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

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

        public javax.enterprise.event.TransactionPhase getTransactionPhase()
        Specified by:
        getTransactionPhase in interface javax.enterprise.inject.spi.ObserverMethod<T>
      • 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 javax.enterprise.inject.spi.ObserverMethod<T>
      • sendEvent

        protected void sendEvent​(T event)
        Invokes the observer method immediately passing the event.
        Parameters:
        event - The event to notify observer with
      • sendEvent

        protected void sendEvent​(T event,
                                 Object receiver,
                                 javax.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​(javax.enterprise.context.spi.CreationalContext<X> creationalContext)
      • getId

        public String getId()
      • hashCode

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

        public boolean isEventMetadataRequired()