Package org.jboss.weld.event
Class ObserverMethodImpl<T,X>
java.lang.Object
org.jboss.weld.event.ObserverMethodImpl<T,X>
- All Implemented Interfaces:
jakarta.enterprise.inject.spi.ObserverMethod<T>,jakarta.enterprise.inject.spi.Prioritized,EventMetadataAwareObserverMethod<T>
- Direct Known Subclasses:
ExtensionObserverMethodImpl
public class ObserverMethodImpl<T,X>
extends Object
implements jakarta.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.
- Author:
- David Allen, Jozef Hartinger, Marko Luksa
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BeanManagerImplstatic final Stringstatic final Stringprotected final MethodInjectionPoint<T,? super X> protected static final Set<Class<? extends Annotation>>protected jakarta.enterprise.event.TransactionPhaseFields inherited from interface jakarta.enterprise.inject.spi.ObserverMethod
DEFAULT_PRIORITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedObserverMethodImpl(EnhancedAnnotatedMethod<T, ? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager, boolean isAsync) Creates an Observer which describes and encapsulates an observer method (8.5). -
Method Summary
Modifier and TypeMethodDescriptionprotected <Y> voidcheckRequiredTypeAnnotations(EnhancedAnnotatedParameter<?, ?> eventParameter, EnhancedAnnotatedMethod<T, Y> annotated) protected StringcreateId(EnhancedAnnotatedMethod<?, ?> observer, RIBean<?> declaringBean) protected StringcreateTypeId(RIBean<?> declaringBean) booleanprotected EnhancedAnnotatedParameter<?,? super X> getEventParameter(EnhancedAnnotatedMethod<T, ? super X> observer) getId()MethodInjectionPoint<T,? super X> intprotected ObjectgetReceiver(jakarta.enterprise.context.spi.CreationalContext<X> creationalContext) jakarta.enterprise.event.Receptionjakarta.enterprise.event.TransactionPhaseinthashCode()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) booleanisAsync()booleanvoidvoidUsed as default notify method from ObserverMethodConfiguratorImpl.protected voidpostNotify(T event, Object receiver) protected voidHooks allowing subclasses to perform additional logic just before and just after an event is delivered to an observer method.voidInvokes the observer method immediately passing the event.protected voidsendEvent(T event, Object receiver, jakarta.enterprise.context.spi.CreationalContext<?> creationalContext) Note thatCreationalContext.release()is not invoked within this method.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jakarta.enterprise.inject.spi.ObserverMethod
notify
-
Field Details
-
ID_PREFIX
-
ID_SEPARATOR
- See Also:
-
SPECIAL_PARAM_MARKERS
-
beanManager
-
declaringBean
-
observerMethod
-
transactionPhase
protected jakarta.enterprise.event.TransactionPhase transactionPhase
-
-
Constructor Details
-
ObserverMethodImpl
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).- Parameters:
observer- The observerdeclaringBean- The observer beanmanager- The Bean manager
-
-
Method Details
-
getEventParameter
protected EnhancedAnnotatedParameter<?,? super X> getEventParameter(EnhancedAnnotatedMethod<T, ? super X> observer) -
createId
-
createTypeId
-
initMethodInjectionPoint
protected MethodInjectionPoint<T,? super X> initMethodInjectionPoint(EnhancedAnnotatedMethod<T, ? super X> observer, RIBean<X> declaringBean, BeanManagerImpl manager) -
getInjectionPoints
-
checkRequiredTypeAnnotations
protected <Y> void checkRequiredTypeAnnotations(EnhancedAnnotatedParameter<?, ?> eventParameter, EnhancedAnnotatedMethod<T, Y> annotated) -
getBeanClass
- Specified by:
getBeanClassin interfacejakarta.enterprise.inject.spi.ObserverMethod<T>
-
getDeclaringBean
- Specified by:
getDeclaringBeanin interfacejakarta.enterprise.inject.spi.ObserverMethod<T>
-
getReception
public jakarta.enterprise.event.Reception getReception()- Specified by:
getReceptionin interfacejakarta.enterprise.inject.spi.ObserverMethod<T>
-
getObservedQualifiers
- Specified by:
getObservedQualifiersin interfacejakarta.enterprise.inject.spi.ObserverMethod<T>
-
getObservedType
- Specified by:
getObservedTypein interfacejakarta.enterprise.inject.spi.ObserverMethod<T>
-
getTransactionPhase
public jakarta.enterprise.event.TransactionPhase getTransactionPhase()- Specified by:
getTransactionPhasein interfacejakarta.enterprise.inject.spi.ObserverMethod<T>
-
getMethod
- Returns:
- the observerMethod
-
initialize
Completes initialization of the observer and allows derived types to override behavior. -
notify
- Specified by:
notifyin interfacejakarta.enterprise.inject.spi.ObserverMethod<T>
-
notify
Used as default notify method from ObserverMethodConfiguratorImpl. This allows Weld to respectReceptionset in the configurator. -
sendEvent
Invokes the observer method immediately passing the event.- Parameters:
event- The event to notify observer with
-
sendEvent
protected void sendEvent(T event, Object receiver, jakarta.enterprise.context.spi.CreationalContext<?> creationalContext) Note thatCreationalContext.release()is not invoked within this method.- Parameters:
event-receiver-creationalContext-
-
preNotify
Hooks allowing subclasses to perform additional logic just before and just after an event is delivered to an observer method. -
postNotify
-
getReceiver
-
toString
-
getId
-
equals
-
hashCode
public int hashCode() -
getPriority
public int getPriority()- Specified by:
getPriorityin interfacejakarta.enterprise.inject.spi.ObserverMethod<T>- Specified by:
getPriorityin interfacejakarta.enterprise.inject.spi.Prioritized
-
isAsync
public boolean isAsync()- Specified by:
isAsyncin interfacejakarta.enterprise.inject.spi.ObserverMethod<T>
-
isEventMetadataRequired
public boolean isEventMetadataRequired()- Specified by:
isEventMetadataRequiredin interfaceEventMetadataAwareObserverMethod<T>- Returns:
trueifEventMetadatais required,falseotherwise
-