}
@SuppressWarnings("unchecked")
public <X> Set<ObserverMethod<?>> defineObserverMethods(AbstractInjectionTargetBean<X> bean,AnnotatedType<X> annotatedType)
{
WebBeansContext webBeansContext = bean.getWebBeansContext();
Set<ObserverMethod<?>> definedObservers = new HashSet<ObserverMethod<?>>();
Set<AnnotatedMethod<? super X>> annotatedMethods = annotatedType.getMethods();
for (AnnotatedMethod<? super X> annotatedMethod : annotatedMethods)
{
AnnotatedMethod<X> annt = (AnnotatedMethod<X>)annotatedMethod;
List<AnnotatedParameter<X>> parameters = annt.getParameters();
boolean found = false;
for(AnnotatedParameter<X> parameter : parameters)
{
if(parameter.isAnnotationPresent(Observes.class))
{
found = true;
break;
}
}
if(found)
{
checkObserverMethodConditions(annotatedMethod, annotatedMethod.getDeclaringType().getJavaClass());
if(bean.getScope().equals(Dependent.class))
{
//Check Reception
AnnotationUtil.getAnnotatedMethodFirstParameterWithAnnotation(annotatedMethod, Observes.class);
Observes observes = AnnotationUtil.getAnnotatedMethodFirstParameterAnnotation(annotatedMethod, Observes.class);
Reception reception = observes.notifyObserver();
if(reception.equals(Reception.IF_EXISTS))
{
throw new WebBeansConfigurationException("Dependent Bean : " + bean + " can not define observer method with @Receiver = IF_EXIST");
}
}
//Add method
bean.addObservableMethod(annotatedMethod.getJavaMember());
//Add injection point data
addMethodInjectionPointMetaData(bean, annotatedMethod);
//Looking for ObserverMethod
ObserverMethod<?> definedObserver = webBeansContext.getBeanManagerImpl().getNotificationManager().getObservableMethodForAnnotatedMethod(annotatedMethod, bean);
if(definedObserver != null)
{
definedObservers.add(definedObserver);
}
}