public class ObserverMethodImpl<T,X> extends java.lang.Object implements ExperimentalObserverMethod<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 java.lang.String |
ID_PREFIX |
static java.lang.String |
ID_SEPARATOR |
protected MethodInjectionPoint<T,? super X> |
observerMethod |
protected TransactionPhase |
transactionPhase |
DEFAULT_PRIORITY| Modifier | Constructor and Description |
|---|---|
protected |
ObserverMethodImpl(EnhancedAnnotatedMethod<T,? super X> observer,
RIBean<X> declaringBean,
BeanManagerImpl manager)
Creates an Observer which describes and encapsulates an observer method (8.5).
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkRequiredTypeAnnotations(EnhancedAnnotatedParameter<?,?> eventParameter) |
protected static java.lang.String |
createId(EnhancedAnnotatedMethod<?,?> observer,
RIBean<?> declaringBean) |
boolean |
equals(java.lang.Object obj) |
java.lang.Class<X> |
getBeanClass()
Obtains the class of the type that declares the observer method.
|
RIBean<X> |
getDeclaringBean() |
java.lang.String |
getId() |
java.util.Set<WeldInjectionPointAttributes<?,?>> |
getInjectionPoints() |
MethodInjectionPoint<T,? super X> |
getMethod() |
java.util.Set<WeldInjectionPointAttributes<?,?>> |
getNewInjectionPoints() |
java.util.Set<java.lang.annotation.Annotation> |
getObservedQualifiers()
Obtains the set of observed event qualifiers.
|
java.lang.reflect.Type |
getObservedType()
Obtains the observed event type.
|
int |
getPriority()
The priority of this observer method
|
protected java.lang.Object |
getReceiver(CreationalContext<X> creationalContext) |
Reception |
getReception()
Obtains the specified
Reception for the observer method. |
TransactionPhase |
getTransactionPhase()
Obtains the specified
TransactionPhase for the observer method. |
int |
hashCode() |
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) |
void |
notify(T event)
Calls the observer method, passing the given event object.
|
protected void |
postNotify(T event,
java.lang.Object receiver) |
protected void |
preNotify(T event,
java.lang.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,
java.lang.Object receiver,
CreationalContext<?> creationalContext) |
java.lang.String |
toString() |
public static final java.lang.String ID_PREFIX
public static final java.lang.String ID_SEPARATOR
protected final BeanManagerImpl beanManager
protected final MethodInjectionPoint<T,? super X> observerMethod
protected TransactionPhase transactionPhase
protected ObserverMethodImpl(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager)
observer - The observerdeclaringBean - The observer beanmanager - The Bean managerprotected static java.lang.String createId(EnhancedAnnotatedMethod<?,?> observer, RIBean<?> declaringBean)
protected MethodInjectionPoint<T,? super X> initMethodInjectionPoint(EnhancedAnnotatedMethod<T,? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager)
public java.util.Set<WeldInjectionPointAttributes<?,?>> getInjectionPoints()
public java.util.Set<WeldInjectionPointAttributes<?,?>> getNewInjectionPoints()
protected void checkRequiredTypeAnnotations(EnhancedAnnotatedParameter<?,?> eventParameter)
public java.lang.Class<X> getBeanClass()
ObserverMethodObtains the class of the type that declares the observer method.
getBeanClass in interface ObserverMethod<T>public Reception getReception()
ObserverMethodReception for the observer method. This indicates if the observer is conditional or not.getReception in interface ObserverMethod<T>Receptionpublic java.util.Set<java.lang.annotation.Annotation> getObservedQualifiers()
ObserverMethodgetObservedQualifiers in interface ObserverMethod<T>public java.lang.reflect.Type getObservedType()
ObserverMethodgetObservedType in interface ObserverMethod<T>public TransactionPhase getTransactionPhase()
ObserverMethodTransactionPhase for the observer method.getTransactionPhase in interface ObserverMethod<T>TransactionPhasepublic MethodInjectionPoint<T,? super X> getMethod()
public void initialize(EnhancedAnnotatedMethod<T,? super X> annotated)
public void notify(T event)
ObserverMethodCalls the observer method, passing the given event object.
The implementation of this method for a custom observer method is responsible for deciding whether to call
the method if the ObserverMethod.getReception() returns Reception.IF_EXISTS.
notify in interface ObserverMethod<T>event - the event objectprotected void sendEvent(T event)
event - The event to notify observer withprotected void sendEvent(T event, java.lang.Object receiver, CreationalContext<?> creationalContext)
protected void preNotify(T event, java.lang.Object receiver)
protected void postNotify(T event, java.lang.Object receiver)
protected java.lang.Object getReceiver(CreationalContext<X> creationalContext)
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getId()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int getPriority()
ExperimentalObserverMethodgetPriority in interface ExperimentalObserverMethod<T>getPriority in interface PrioritizedCopyright © 2014. All Rights Reserved.