//Create an annotated type
AnnotatedType<T> annotatedType = processAnnotatedEvent.getAnnotatedType();
//Fires ProcessInjectionTarget event for Java EE components instances
//That supports injections but not managed beans
GProcessInjectionTarget processInjectionTargetEvent = null;
if (webBeansContext.getWebBeansUtil().supportsJavaEeComponentInjections(clazz)) {
//Fires ProcessInjectionTarget
processInjectionTargetEvent = webBeansContext.getWebBeansUtil().fireProcessInjectionTargetEventForJavaEeComponents(clazz);
webBeansContext.getWebBeansUtil().inspectErrorStack("There are errors that are added by ProcessInjectionTarget event observers. Look at logs for further details");
//Sets custom InjectionTarget instance
if (processInjectionTargetEvent.isSet()) {
//Adding injection target
manager.putInjectionTargetWrapperForJavaEeComponents(clazz, new InjectionTargetWrapper<T>(processInjectionTargetEvent.getInjectionTarget()));
}
//Checks that not contains @Inject InjectionPoint
webBeansContext.getAnnotationManager().checkInjectionPointForInjectInjectionPoint(clazz);
}
//Check for whether this class is candidate for Managed Bean
if (webBeansContext.getManagedBeanConfigurator().isManagedBean(clazz)) {
//Check conditions
webBeansContext.getManagedBeanConfigurator().checkManagedBeanCondition(clazz);
//Temporary managed bean instance creationa
ManagedBean<T> managedBean = new ManagedBean<T>(clazz, WebBeansType.MANAGED, webBeansContext);
ManagedBeanCreatorImpl<T> managedBeanCreator = new ManagedBeanCreatorImpl<T>(managedBean);
boolean annotationTypeSet = false;
if (processAnnotatedEvent.isModifiedAnnotatedType()) {
annotationTypeSet = true;
managedBean.setAnnotatedType(annotatedType);
annotatedType = processAnnotatedEvent.getAnnotatedType();
managedBeanCreator.setAnnotatedType(annotatedType);
managedBeanCreator.setMetaDataProvider(MetaDataProvider.THIRDPARTY);
}
//If ProcessInjectionTargetEvent is not set, set it
if (processInjectionTargetEvent == null) {
// processInjectionTargetEvent = webBeansContext.getWebBeansUtil().fireProcessInjectionTargetEvent(managedBean);
processInjectionTargetEvent = webBeansContext.getWebBeansUtil().createProcessInjectionTargetEvent(managedBean);
}
//Decorator
if (WebBeansUtil.isAnnotatedTypeDecorator(annotatedType)) {
if (logger.isDebugEnabled()) {
logger.debug("Found Managed Bean Decorator with class name : [{0}]", annotatedType.getJavaClass().getName());
}
if (annotationTypeSet) {
webBeansContext.getWebBeansUtil().defineDecorator(annotatedType);
} else {
webBeansContext.getWebBeansUtil().defineDecorator(managedBeanCreator, processInjectionTargetEvent);
}
}
//Interceptor
else if (WebBeansUtil.isAnnotatedTypeInterceptor(annotatedType)) {
if (logger.isDebugEnabled()) {
logger.debug("Found Managed Bean Interceptor with class name : [{0}]", annotatedType.getJavaClass().getName());
}
if (annotationTypeSet) {
webBeansContext.getWebBeansUtil().defineInterceptor(annotatedType);
} else {
webBeansContext.getWebBeansUtil().defineInterceptor(managedBeanCreator, processInjectionTargetEvent);
}
} else {
if (webBeansContext.getBeanManagerImpl().containsCustomDecoratorClass(annotatedType.getJavaClass()) ||
webBeansContext.getBeanManagerImpl().containsCustomInterceptorClass(annotatedType.getJavaClass())) {
return false;
}
if (logger.isDebugEnabled()) {
logger.debug("Found Managed Bean with class name : [{0}]", annotatedType.getJavaClass().getName());
}
webBeansContext.getWebBeansUtil().defineManagedBean(managedBeanCreator, processInjectionTargetEvent, false);
}
if(processInjectionTargetEvent != null) {
final InjectionTarget originalInjectionTarget = processInjectionTargetEvent.getInjectionTarget();
final InjectionTarget updatedInjectionTarget = webBeansContext.getWebBeansUtil()
.fireProcessInjectionTargetEvent(processInjectionTargetEvent).getInjectionTarget();
if (updatedInjectionTarget != originalInjectionTarget) {
webBeansContext.getBeanManagerImpl().putInjectionTargetWrapper(managedBean, new InjectionTargetWrapper<T>(updatedInjectionTarget));
}