comparator = new DefaultClassLoaderComparator(classLoader);
}
final WebBeansContext webBeansContext = startupObject.getWebBeansContext();
final AlternativesManager alternativesManager = webBeansContext.getAlternativesManager();
final DecoratorsManager decoratorsManager = webBeansContext.getDecoratorsManager();
final InterceptorsManager interceptorsManager = webBeansContext.getInterceptorsManager();
// "manual" extension to avoid to add it through SPI mecanism
classes.addAll(asList(TRANSACTIONAL_INTERCEPTORS));
for (final Class<?> interceptor : TRANSACTIONAL_INTERCEPTORS) {
interceptorsManager.addEnabledInterceptorClass(interceptor);
}
// TODO: this shouldn't be needed with OWB 2, see org.apache.openejb.cdi.OptimizedLoaderService.loadExtensions() too
classes.add(BValInterceptor.class);
interceptorsManager.addEnabledInterceptorClass(BValInterceptor.class);
// app beans
for (final EjbJarInfo ejbJar : appInfo.ejbJars) {
final BeansInfo beans = ejbJar.beans;
if (beans == null) {
continue;
}
if (startupObject.isFromWebApp()) { // deploy only the related ejbmodule
if (!ejbJar.moduleId.equals(startupObject.getWebContext().getId())) {
continue;
}
} else if (ejbJar.webapp && !appInfo.webAppAlone) {
continue;
}
// fail fast
final StringBuilder errors = new StringBuilder("You can't define multiple times the same class in beans.xml: ");
if (addErrors(errors, "alternative classes", beans.duplicatedAlternativeClasses)
|| addErrors(errors, "alternative stereotypes", beans.duplicatedAlternativeStereotypes)
|| addErrors(errors, "decorators", beans.duplicatedDecorators)
|| addErrors(errors, "interceptors", beans.duplicatedInterceptors)) {
throw new WebBeansConfigurationException(errors.toString());
}
// no more need of errors so clear them
beans.duplicatedAlternativeStereotypes.clear();
beans.duplicatedAlternativeClasses.clear();
beans.duplicatedDecorators.clear();
beans.duplicatedInterceptors.clear();
for (final String className : beans.interceptors) {
final Class<?> clazz = load(PropertyPlaceHolderHelper.simpleValue(className), classLoader);
if (clazz != null) {
if (!interceptorsManager.isInterceptorClassEnabled(clazz)) {
interceptorsManager.addEnabledInterceptorClass(clazz);
classes.add(clazz);
} /* else { don't do it, check is done when we know the beans.xml path --> org.apache.openejb.config.DeploymentLoader.addBeansXmls
throw new WebBeansConfigurationException("Interceptor class : " + clazz.getName() + " is already defined");
}*/
} else if (shouldThrowCouldNotLoadException(startupObject)) {
throw new WebBeansConfigurationException("Could not load interceptor class: " + className);
}
}
for (final String className : beans.decorators) {
final Class<?> clazz = load(PropertyPlaceHolderHelper.simpleValue(className), classLoader);
if (clazz != null) {
if (!decoratorsManager.isDecoratorEnabled(clazz)) {
decoratorsManager.addEnabledDecorator(clazz);
classes.add(clazz);
} // same than interceptors regarding throw new WebBeansConfigurationException("Decorator class : " + clazz.getName() + " is already defined");
} else if (shouldThrowCouldNotLoadException(startupObject)) {
throw new WebBeansConfigurationException("Could not load decorator class: " + className);
}