StartupObject startupObject = (StartupObject) object;
AppInfo appInfo = startupObject.getAppInfo();
ClassLoader classLoader = startupObject.getAppContext().getClassLoader();
WebBeansContext webBeansContext = startupObject.getAppContext().getWebBeansContext();
final AlternativesManager alternativesManager = webBeansContext.getAlternativesManager();
final DecoratorsManager decoratorsManager = webBeansContext.getDecoratorsManager();
final InterceptorsManager interceptorsManager = webBeansContext.getInterceptorsManager();
final HashSet<String> ejbClasses = new HashSet<String>();
for (EjbJarInfo ejbJar : appInfo.ejbJars) {
for (EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
ejbClasses.add(bean.ejbClass);
}
}
final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
for (EjbJarInfo ejbJar : appInfo.ejbJars) {
final BeansInfo beans = ejbJar.beans;
if (beans == null) continue;
for (String className : beans.interceptors) {
Class<?> clazz = load(className, classLoader);
if (clazz != null) {
// TODO: Move check to validation phase
if (AnnotationUtil.hasAnnotation(clazz.getDeclaredAnnotations(), Interceptor.class) && !annotationManager.hasInterceptorBindingMetaAnnotation(
clazz.getDeclaredAnnotations())) {
throw new WebBeansConfigurationException("Interceptor class : " + clazz.getName() + " must have at least one @InterceptorBindingType");
}
if (interceptorsManager.isInterceptorEnabled(clazz)) {
throw new WebBeansConfigurationException("Interceptor class : " + clazz.getName() + " is already defined");
}
interceptorsManager.addNewInterceptor(clazz);
classes.add(clazz);
} else {
throw new WebBeansConfigurationException("Could not load interceptor class: " + className);
}
}
for (String className : beans.decorators) {
Class<?> clazz = load(className, classLoader);
if (clazz != null) {
if (decoratorsManager.isDecoratorEnabled(clazz)) {
throw new WebBeansConfigurationException("Decorator class : " + clazz.getName() + " is already defined");
}
decoratorsManager.addNewDecorator(clazz);
classes.add(clazz);
} else {
throw new WebBeansConfigurationException("Could not load decorator class: " + className);
}
}
for (String className : beans.alternativeStereotypes) {
Class<?> clazz = load(className, classLoader);
if (clazz != null) {
alternativesManager.addStereoTypeAlternative(clazz, null, null);
classes.add(clazz);
} else {
throw new WebBeansConfigurationException("Could not load alternativeStereotype class: " + className);
}
}
for (String className : beans.alternativeClasses) {
Class<?> clazz = load(className, classLoader);
if (clazz != null) {
alternativesManager.addClazzAlternative(clazz, null, null);
classes.add(clazz);
} else {
throw new WebBeansConfigurationException("Could not load alternative class: " + className);
}
}