if (module == null)
throw new DeploymentUnitProcessingException("Manged bean annotation processing requires a module.");
final ClassLoader classLoader = module.getClassLoader();
final ManagedBeanConfigurations managedBeanConfigurations = new ManagedBeanConfigurations();
context.putAttachment(ManagedBeanConfigurations.ATTACHMENT_KEY, managedBeanConfigurations);
for (AnnotationTarget target : targets) {
if (!(target instanceof ClassInfo)) {
throw new DeploymentUnitProcessingException("The ManagedBean annotation is only allowed at the class level: " + target);
}
final ClassInfo classInfo = ClassInfo.class.cast(target);
final String beanClassName = classInfo.name().toString();
final Class<?> beanClass;
try {
beanClass = classLoader.loadClass(beanClassName);
} catch (ClassNotFoundException e) {
throw new DeploymentUnitProcessingException("Failed to load managed bean class: " + beanClassName);
}
// Get the managed bean name from the annotation
final ManagedBean managedBeanAnnotation = beanClass.getAnnotation(ManagedBean.class);
final String beanName = managedBeanAnnotation.value().isEmpty() ? beanClassName : managedBeanAnnotation.value();
final ManagedBeanConfiguration managedBeanConfiguration = new ManagedBeanConfiguration(beanName, beanClass);
processLifecycleMethods(managedBeanConfiguration, beanClass, index);
final Map<DotName, List<AnnotationTarget>> classAnnotations = classInfo.annotations();
managedBeanConfiguration.setResourceConfigurations(processResources(classAnnotations, beanClass));
managedBeanConfiguration.setInterceptorConfigurations(processInterceptors(index, classAnnotations, beanClass));
managedBeanConfigurations.add(managedBeanConfiguration);
}
}