org.apache.webbeans.event
Class ObserverMethodImpl<T>

java.lang.Object
  extended by org.apache.webbeans.event.ObserverMethodImpl<T>
Type Parameters:
T - event type
All Implemented Interfaces:
javax.enterprise.inject.spi.ObserverMethod<T>, 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 javax.enterprise.inject.spi.ObserverMethod#notify() method is called.

Version:
$Rev: 1680185 $ $Date: 2015-05-19 08:21:53 +0200 (Tue, 19 May 2015) $

Constructor Summary
ObserverMethodImpl(AbstractOwbBean<?> bean, javax.enterprise.inject.spi.AnnotatedMethod<T> annotatedObserverMethod, javax.enterprise.inject.spi.AnnotatedParameter<T> annotatedObservesParameter)
          used if the qualifiers and event type are already known, e.g. from the XML.
 
Method Summary
protected  void checkObserverCondition(javax.enterprise.inject.spi.AnnotatedParameter<T> annotatedObservesParameter)
           
 Class<?> getBeanClass()
          Returns observer owner bean.
 Set<javax.enterprise.inject.spi.InjectionPoint> getInjectionPoints()
          Returns the InjectionPoints for the parameters of this observer method.
protected  List<org.apache.webbeans.event.ObserverMethodImpl.ObserverParams> getMethodArguments(Object event, javax.enterprise.inject.spi.EventMetadata metadata)
          Gets observer method parameters.
 Set<Annotation> getObservedQualifiers()
          
 Type getObservedType()
          
 javax.enterprise.inject.spi.AnnotatedMethod<T> getObserverMethod()
           
 javax.enterprise.event.Reception getReception()
          
 javax.enterprise.event.TransactionPhase getTransactionPhase()
           
protected  WebBeansContext getWebBeansContext()
           
protected  void invoke(Object object, Object[] args)
           
 void notify(T event)
          
 void notify(T event, javax.enterprise.inject.spi.EventMetadata metadata)
          will actually call the underlying observer method with the specified event metadata
 void setObserverMethod(javax.enterprise.inject.spi.AnnotatedMethod<T> m)
          Provides a way to set the observer method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObserverMethodImpl

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

Parameters:
bean -
annotatedObserverMethod -
Method Detail

checkObserverCondition

protected void checkObserverCondition(javax.enterprise.inject.spi.AnnotatedParameter<T> annotatedObservesParameter)

getInjectionPoints

public Set<javax.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)

Specified by:
notify in interface javax.enterprise.inject.spi.ObserverMethod<T>

notify

public void notify(T event,
                   javax.enterprise.inject.spi.EventMetadata metadata)
will actually call the underlying observer method with the specified event metadata

Specified by:
notify in interface OwbObserverMethod<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,
                                                                                               javax.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 javax.enterprise.inject.spi.ObserverMethod<T>
Returns:
the bean

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>

getReception

public javax.enterprise.event.Reception getReception()

Specified by:
getReception 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>

getObserverMethod

public javax.enterprise.inject.spi.AnnotatedMethod<T> getObserverMethod()

getWebBeansContext

protected WebBeansContext getWebBeansContext()

setObserverMethod

public void setObserverMethod(javax.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


Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.