Type[] types = this.observerMethod.getGenericParameterTypes();
Annotation[][] annots = this.observerMethod.getParameterAnnotations();
List<ObserverParams> list = new ArrayList<ObserverParams>();
BeanManagerImpl manager = BeanManagerImpl.getManager();
ObserverParams param = null;
if (types.length > 0)
{
int i = 0;
for (Type type : types)
{
Annotation[] annot = annots[i];
boolean observesAnnotation = false;
if (annot.length == 0)
{
annot = new Annotation[1];
annot[0] = new DefaultLiteral();
}
else
{
for (Annotation observersAnnot : annot)
{
if (observersAnnot.annotationType().equals(Observes.class))
{
param = new ObserverParams();
param.instance = event;
list.add(param);
observesAnnotation = true;
break;
}
}
}
if (!observesAnnotation)
{
//Get parameter annotations
Annotation[] bindingTypes = AnnotationUtil.getQualifierAnnotations(annot);
//Annotated parameter
AnnotatedParameter<T> annotatedParameter = annotatedMethod.getParameters().get(i);
//Creating injection point
InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(this.bean, type, this.observerMethod, annotatedParameter, bindingTypes);
//Injected Bean
Bean<Object> injectedBean = (Bean<Object>)InjectionResolver.getInstance().getInjectionPointBean(point);
//Set for @Inject InjectionPoint
if(WebBeansUtil.isDependent(injectedBean))
{
if(!InjectionPoint.class.isAssignableFrom(ClassUtil.getClass(point.getType())))
{
InjectionPointBean.local.set(point);
}
}
CreationalContext<Object> creational = manager.createCreationalContext(injectedBean);
Object instance = manager.getInstance(injectedBean, creational);
param = new ObserverParams();
param.isBean = true;
param.creational = creational;
param.instance = instance;