use of org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType in project HotswapAgent by HotswapProjects.
the class BeanReloadExecutor method doReloadBean.
@SuppressWarnings({ "rawtypes", "unchecked", "serial" })
private static void doReloadBean(String bdaId, Class<?> beanClass, String oldSignatureByStrategy, BeanReloadStrategy reloadStrategy) {
BeanManagerImpl beanManager = null;
BeanManager bm = CDI.current().getBeanManager();
if (bm instanceof WeldManager) {
bm = ((WeldManager) bm).unwrap();
}
if (bm instanceof BeanManagerImpl) {
beanManager = (BeanManagerImpl) bm;
}
// TODO: check if archive is excluded
Set<Bean<?>> beans = beanManager.getBeans(beanClass, new AnnotationLiteral<Any>() {
});
if (beans != null && !beans.isEmpty()) {
for (Bean<?> bean : beans) {
if (bean instanceof AbstractClassBean) {
EnhancedAnnotatedType eat = createAnnotatedTypeForExistingBeanClass(bdaId, beanClass);
if (!eat.isAbstract() || !eat.getJavaClass().isInterface()) {
// injectionTargetCannotBeCreatedForInterface
((AbstractClassBean) bean).setProducer(beanManager.getLocalInjectionTargetFactory(eat).createInjectionTarget(eat, bean, false));
if (isReinjectingContext(bean)) {
doReloadAbstractClassBean(beanManager, beanClass, (AbstractClassBean) bean, oldSignatureByStrategy, reloadStrategy);
LOGGER.debug("Bean reloaded '{}'", beanClass.getName());
continue;
}
}
LOGGER.info("Bean '{}' redefined", beanClass.getName());
} else {
LOGGER.warning("Bean '{}' reloading not supported.", beanClass.getName());
}
}
} else {
doDefineNewManagedBean(beanManager, bdaId, beanClass);
}
}
Aggregations