Package org.jboss.weld.event
Class ObserverMethodImpl<T,X>
- java.lang.Object
-
- org.jboss.weld.event.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 Summary
Fields Modifier and Type Field Description protected BeanManagerImplbeanManagerprotected RIBean<X>declaringBeanstatic StringID_PREFIXstatic StringID_SEPARATORprotected MethodInjectionPoint<T,? super X>observerMethodprotected javax.enterprise.event.TransactionPhasetransactionPhase
-
Constructor Summary
Constructors Modifier Constructor Description protectedObserverMethodImpl(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager)Creates an Observer which describes and encapsulates an observer method (8.5).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckRequiredTypeAnnotations(EnhancedAnnotatedParameter<?,?> eventParameter)protected StringcreateId(EnhancedAnnotatedMethod<?,?> observer, RIBean<?> declaringBean)protected StringcreateTypeId(RIBean<?> declaringBean)booleanequals(Object obj)Class<X>getBeanClass()RIBean<X>getDeclaringBean()StringgetId()Set<WeldInjectionPointAttributes<?,?>>getInjectionPoints()MethodInjectionPoint<T,? super X>getMethod()Set<WeldInjectionPointAttributes<?,?>>getNewInjectionPoints()Set<Annotation>getObservedQualifiers()TypegetObservedType()protected ObjectgetReceiver(javax.enterprise.context.spi.CreationalContext<X> creationalContext)javax.enterprise.event.ReceptiongetReception()javax.enterprise.event.TransactionPhasegetTransactionPhase()inthashCode()voidinitialize(EnhancedAnnotatedMethod<T,? super X> annotated)Completes initialization of the observer and allows derived types to override behavior.protected MethodInjectionPoint<T,? super X>initMethodInjectionPoint(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager)booleanisEventMetadataRequired()voidnotify(T event)protected voidpostNotify(T event, Object receiver)protected voidpreNotify(T event, Object receiver)Hooks allowing subclasses to perform additional logic just before and just after an event is delivered to an observer method.protected voidsendEvent(T event)Invokes the observer method immediately passing the event.protected voidsendEvent(T event, Object receiver, javax.enterprise.context.spi.CreationalContext<?> creationalContext)Note thatCreationalContext.release()is not invoked within this method.StringtoString()
-
-
-
Field Detail
-
ID_PREFIX
public static final String ID_PREFIX
-
ID_SEPARATOR
public static final String ID_SEPARATOR
- See Also:
- Constant Field Values
-
beanManager
protected final BeanManagerImpl beanManager
-
observerMethod
protected final MethodInjectionPoint<T,? super X> observerMethod
-
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 observerdeclaringBean- The observer beanmanager- The Bean manager
-
-
Method Detail
-
createId
protected String createId(EnhancedAnnotatedMethod<?,?> observer, RIBean<?> declaringBean)
-
initMethodInjectionPoint
protected MethodInjectionPoint<T,? super X> initMethodInjectionPoint(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager)
-
getInjectionPoints
public Set<WeldInjectionPointAttributes<?,?>> getInjectionPoints()
-
getNewInjectionPoints
public Set<WeldInjectionPointAttributes<?,?>> getNewInjectionPoints()
-
checkRequiredTypeAnnotations
protected void checkRequiredTypeAnnotations(EnhancedAnnotatedParameter<?,?> eventParameter)
-
getBeanClass
public Class<X> getBeanClass()
- Specified by:
getBeanClassin interfacejavax.enterprise.inject.spi.ObserverMethod<T>
-
getReception
public javax.enterprise.event.Reception getReception()
- Specified by:
getReceptionin interfacejavax.enterprise.inject.spi.ObserverMethod<T>
-
getObservedQualifiers
public Set<Annotation> getObservedQualifiers()
- Specified by:
getObservedQualifiersin interfacejavax.enterprise.inject.spi.ObserverMethod<T>
-
getObservedType
public Type getObservedType()
- Specified by:
getObservedTypein interfacejavax.enterprise.inject.spi.ObserverMethod<T>
-
getTransactionPhase
public javax.enterprise.event.TransactionPhase getTransactionPhase()
- Specified by:
getTransactionPhasein interfacejavax.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:
notifyin interfacejavax.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 thatCreationalContext.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.
-
getReceiver
protected Object getReceiver(javax.enterprise.context.spi.CreationalContext<X> creationalContext)
-
getId
public String getId()
-
isEventMetadataRequired
public boolean isEventMetadataRequired()
-
-