public class ObserverMethodImpl<T,X> extends Object implements javax.enterprise.inject.spi.ObserverMethod<T>, EventMetadataAwareObserverMethod<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.
| Modifier and Type | Field and Description |
|---|---|
protected BeanManagerImpl |
beanManager |
protected RIBean<X> |
declaringBean |
static String |
ID_PREFIX |
static String |
ID_SEPARATOR |
protected MethodInjectionPoint<T,? super X> |
observerMethod |
protected static Set<Class<? extends Annotation>> |
SPECIAL_PARAM_MARKERS |
protected javax.enterprise.event.TransactionPhase |
transactionPhase |
| Modifier | Constructor and Description |
|---|---|
protected |
ObserverMethodImpl(EnhancedAnnotatedMethod<T,? super X> observer,
RIBean<X> declaringBean,
BeanManagerImpl manager,
boolean isAsync)
Creates an Observer which describes and encapsulates an observer method (8.5).
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
createId(EnhancedAnnotatedMethod<?,?> observer,
RIBean<?> declaringBean) |
protected String |
createTypeId(RIBean<?> declaringBean) |
boolean |
equals(Object obj) |
Class<X> |
getBeanClass() |
RIBean<X> |
getDeclaringBean() |
protected EnhancedAnnotatedParameter<?,? super X> |
getEventParameter(EnhancedAnnotatedMethod<T,? super X> observer) |
String |
getId() |
Set<WeldInjectionPointAttributes<?,?>> |
getInjectionPoints() |
MethodInjectionPoint<T,? super X> |
getMethod() |
Set<Annotation> |
getObservedQualifiers() |
Type |
getObservedType() |
int |
getPriority() |
protected Object |
getReceiver(javax.enterprise.context.spi.CreationalContext<X> creationalContext) |
javax.enterprise.event.Reception |
getReception() |
javax.enterprise.event.TransactionPhase |
getTransactionPhase() |
int |
hashCode() |
protected void |
checkRequiredTypeAnnotations(EnhancedAnnotatedParameter<?,?> eventParameter) |
void |
initialize(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) |
boolean |
isAsync() |
boolean |
isEventMetadataRequired() |
void |
notify(T event) |
protected void |
postNotify(T event,
Object receiver) |
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.
|
protected void |
sendEvent(T event)
Invokes the observer method immediately passing the event.
|
protected void |
sendEvent(T event,
Object receiver,
javax.enterprise.context.spi.CreationalContext<?> creationalContext)
Note that
CreationalContext.release() is not invoked within this method. |
String |
toString() |
public static final String ID_PREFIX
public static final String ID_SEPARATOR
protected static final Set<Class<? extends Annotation>> SPECIAL_PARAM_MARKERS
protected final BeanManagerImpl beanManager
protected final MethodInjectionPoint<T,? super X> observerMethod
protected javax.enterprise.event.TransactionPhase transactionPhase
protected ObserverMethodImpl(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager, boolean isAsync)
observer - The observerdeclaringBean - The observer beanmanager - The Bean managerprotected EnhancedAnnotatedParameter<?,? super X> getEventParameter(EnhancedAnnotatedMethod<T,? super X> observer)
protected String createId(EnhancedAnnotatedMethod<?,?> observer, RIBean<?> declaringBean)
protected MethodInjectionPoint<T,? super X> initMethodInjectionPoint(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager)
public Set<WeldInjectionPointAttributes<?,?>> getInjectionPoints()
protected void checkRequiredTypeAnnotations(EnhancedAnnotatedParameter<?,?> eventParameter)
public Class<X> getBeanClass()
getBeanClass in interface javax.enterprise.inject.spi.ObserverMethod<T>public javax.enterprise.event.Reception getReception()
getReception in interface javax.enterprise.inject.spi.ObserverMethod<T>public Set<Annotation> getObservedQualifiers()
getObservedQualifiers in interface javax.enterprise.inject.spi.ObserverMethod<T>public Type getObservedType()
getObservedType in interface javax.enterprise.inject.spi.ObserverMethod<T>public javax.enterprise.event.TransactionPhase getTransactionPhase()
getTransactionPhase in interface javax.enterprise.inject.spi.ObserverMethod<T>public MethodInjectionPoint<T,? super X> getMethod()
public void initialize(EnhancedAnnotatedMethod<T,? super X> annotated)
public void notify(T event)
notify in interface javax.enterprise.inject.spi.ObserverMethod<T>protected void sendEvent(T event)
event - The event to notify observer withprotected void sendEvent(T event, Object receiver, javax.enterprise.context.spi.CreationalContext<?> creationalContext)
CreationalContext.release() is not invoked within this method.event - receiver - creationalContext - protected void preNotify(T event, Object receiver)
protected Object getReceiver(javax.enterprise.context.spi.CreationalContext<X> creationalContext)
public String getId()
public int getPriority()
getPriority in interface javax.enterprise.inject.spi.ObserverMethod<T>getPriority in interface javax.enterprise.inject.spi.Prioritizedpublic boolean isAsync()
isAsync in interface javax.enterprise.inject.spi.ObserverMethod<T>public boolean isEventMetadataRequired()
isEventMetadataRequired in interface EventMetadataAwareObserverMethod<T>true if EventMetadata is required, false otherwiseCopyright © 2017. All rights reserved.