}
}
}
private void validateEnabledAlternativeClasses(BeanManagerImpl beanManager, BeanDeployment deployment) {
BeansXml beansXml = deployment.getBeanDeploymentArchive().getBeansXml();
if (beansXml != null && !beansXml.getEnabledAlternativeClasses().isEmpty()) {
// prepare lookup structure
Map<String, Class<?>> loadedClasses = buildClassNameMap(beanManager.getEnabled().getAlternativeClasses());
// lookup structure for validation of alternatives
Multimap<Class<?>, Bean<?>> beansByClass = HashMultimap.create();
for (Bean<?> bean : beanManager.getAccessibleBeans()) {
if (!(bean instanceof NewBean)) {
beansByClass.put(bean.getBeanClass(), bean);
}
}
for (Metadata<String> definition : beansXml.getEnabledAlternativeClasses()) {
Class<?> enabledClass = loadedClasses.get(definition.getValue());
if (enabledClass.isAnnotation() || enabledClass.isInterface()) {
throw ValidatorLogger.LOG.alternativeBeanClassNotClass(definition);
} else {
// check that the class is a bean class of at least one alternative