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:
ObserverMethod<T>, OwbObserverMethod<T>

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: 1524636 $ $Date: 2013-09-19 09:11:18 +0200 (Thu, 19 Sep 2013) $

Constructor Summary
ObserverMethodImpl(AbstractOwbBean<?> bean, AnnotatedMethod<T> annotatedObserverMethod, boolean ifExist, Annotation[] qualifiers, Type observedEventType)
          used if the qualifiers and event type are already known, e.g. from the XML.
 
Method Summary
 Class<?> getBeanClass()
          Returns observer owner bean.
protected  List<org.apache.webbeans.event.ObserverMethodImpl.ObserverParams> getMethodArguments(Object event, EventMetadata metadata)
          Gets observer method parameters.
 Set<Annotation> getObservedQualifiers()
          
 Type getObservedType()
          
 AnnotatedMethod<T> getObserverMethod()
           
 Reception getReception()
          
 TransactionPhase getTransactionPhase()
           
protected  WebBeansContext getWebBeansContext()
           
 void notify(T event)
          
 void notify(T event, EventMetadata metadata)
          will actually call the underlying observer method with the specified event metadata
 void setObserverMethod(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,
                          AnnotatedMethod<T> annotatedObserverMethod,
                          boolean ifExist,
                          Annotation[] qualifiers,
                          Type observedEventType)
used if the qualifiers and event type are already known, e.g. from the XML.

Parameters:
bean -
annotatedObserverMethod -
ifExist -
qualifiers -
observedEventType -
Method Detail

notify

public void notify(T event)

Specified by:
notify in interface ObserverMethod<T>

notify

public void notify(T event,
                   EventMetadata metadata)
will actually call the underlying observer method with the specified event metadata

Specified by:
notify in interface OwbObserverMethod<T>

getMethodArguments

protected List<org.apache.webbeans.event.ObserverMethodImpl.ObserverParams> getMethodArguments(Object event,
                                                                                               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 ObserverMethod<T>
Returns:
the bean

getObservedQualifiers

public Set<Annotation> getObservedQualifiers()

Specified by:
getObservedQualifiers in interface ObserverMethod<T>

getObservedType

public Type getObservedType()

Specified by:
getObservedType in interface ObserverMethod<T>

getReception

public Reception getReception()

Specified by:
getReception in interface ObserverMethod<T>

getTransactionPhase

public TransactionPhase getTransactionPhase()
Specified by:
getTransactionPhase in interface ObserverMethod<T>

getObserverMethod

public AnnotatedMethod<T> getObserverMethod()

getWebBeansContext

protected WebBeansContext getWebBeansContext()

setObserverMethod

public void setObserverMethod(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–2014 The Apache Software Foundation. All rights reserved.