final Data data = (Data) deploymentInfo.getContainerData();
try {
Context ctx = deploymentInfo.getJndiEnc();
// Create bean instance
InjectionProcessor injectionProcessor = new InjectionProcessor(beanClass, deploymentInfo.getInjections(), null, null, unwrap(ctx));
try {
if (SessionBean.class.isAssignableFrom(beanClass) || beanClass.getMethod("setSessionContext", SessionContext.class) != null) {
callContext.setCurrentOperation(Operation.INJECTION);
injectionProcessor.setProperty("sessionContext", data.sessionContext);
}
} catch (NoSuchMethodException ignored) {
// bean doesn't have a setSessionContext method, so we don't need to inject one
}
Object bean = injectionProcessor.createInstance();
HashMap<String, Object> interceptorInstances = new HashMap<String, Object>();
// Add the stats interceptor instance and other already created interceptor instances
for (InterceptorInstance interceptorInstance : deploymentInfo.getSystemInterceptors()) {
Class clazz = interceptorInstance.getData().getInterceptorClass();
interceptorInstances.put(clazz.getName(), interceptorInstance.getInterceptor());
}
for (InterceptorData interceptorData : deploymentInfo.getInstanceScopedInterceptors()) {
if (interceptorData.getInterceptorClass().equals(beanClass)) {
continue;
}
Class clazz = interceptorData.getInterceptorClass();
InjectionProcessor interceptorInjector = new InjectionProcessor(clazz, deploymentInfo.getInjections(), unwrap(ctx));
try {
Object interceptorInstance = interceptorInjector.createInstance();
interceptorInstances.put(clazz.getName(), interceptorInstance);
} catch (ConstructionException e) {
throw new Exception("Failed to create interceptor: " + clazz.getName(), e);
}
}