in webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java [142:209]
protected ObserverMethodImpl(AbstractOwbBean<?> ownerBean, AnnotatedMethod<T> annotatedObserverMethod, AnnotatedParameter<T> annotatedObservesParameter, boolean fireEvent)
{
this.ownerBean = ownerBean;
this.annotatedObservesParameter = annotatedObservesParameter;
this.annotatedObserverMethod = annotatedObserverMethod;
observedEventType = annotatedObservesParameter.getBaseType();
Observes observes = annotatedObservesParameter.getAnnotation(Observes.class);
Class<? extends Annotation> observerAnnotation;
if (observes != null)
{
ifExist = observes.notifyObserver() == Reception.IF_EXISTS;
phase = observes.during();
observerAnnotation = Observes.class;
}
else
{
ObservesAsync observesAsync = annotatedObservesParameter.getAnnotation(ObservesAsync.class);
ifExist = observesAsync.notifyObserver() == Reception.IF_EXISTS;
phase = TransactionPhase.IN_PROGRESS;
observerAnnotation = ObservesAsync.class;
isAsync = true;
}
observedQualifiers = new HashSet<>();
for (Annotation annotation: annotatedObservesParameter.getAnnotations())
{
if (ownerBean.getWebBeansContext().getAnnotationManager().isQualifierAnnotation(annotation.annotationType()))
{
observedQualifiers.add(annotation);
}
}
// detect the Priority
Priority priorityAnn = annotatedObservesParameter.getAnnotation(Priority.class);
if (priorityAnn != null)
{
priority = priorityAnn.value();
}
OpenWebBeansEjbPlugin ejbPlugin = getWebBeansContext().getPluginLoader().getEjbPlugin();
if (ejbPlugin != null && ejbPlugin.isNewSessionBean(ownerBean.getBeanClass()))
{
view = ejbPlugin.resolveViewMethod(ownerBean , annotatedObserverMethod.getJavaMember());
}
else
{
view = annotatedObserverMethod.getJavaMember();
}
injectionPoints = new LinkedHashSet<>();
for (AnnotatedParameter<?> parameter: annotatedObserverMethod.getParameters())
{
if (!parameter.isAnnotationPresent(observerAnnotation))
{
injectionPoints.add(getWebBeansContext().getInjectionPointFactory().buildInjectionPoint(ownerBean, parameter, fireEvent));
}
}
checkObserverCondition(annotatedObservesParameter);
if (!view.isAccessible())
{
ownerBean.getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(view, true);
}
}