use of com.sun.enterprise.container.common.spi.JavaEEInterceptorBuilderFactory in project Payara by payara.
the class ManagedBeanManagerImpl method loadManagedBeans.
public void loadManagedBeans(Application app) {
JCDIService jcdiService = habitat.getService(JCDIService.class);
for (BundleDescriptor bundle : app.getBundleDescriptors()) {
if (!bundleEligible(bundle)) {
continue;
}
boolean isCDIBundle = (jcdiService != null && jcdiService.isJCDIEnabled(bundle));
for (ManagedBeanDescriptor next : bundle.getManagedBeans()) {
try {
Set<String> interceptorClasses = next.getAllInterceptorClasses();
Class targetClass = bundle.getClassLoader().loadClass(next.getBeanClassName());
InterceptorInfo interceptorInfo = new InterceptorInfo();
interceptorInfo.setTargetClass(targetClass);
interceptorInfo.setInterceptorClassNames(interceptorClasses);
interceptorInfo.setAroundConstructInterceptors(next.getAroundConstructCallbackInterceptors(targetClass, getConstructor(targetClass, isCDIBundle)));
interceptorInfo.setPostConstructInterceptors(next.getCallbackInterceptors(LifecycleCallbackDescriptor.CallbackType.POST_CONSTRUCT));
interceptorInfo.setPreDestroyInterceptors(next.getCallbackInterceptors(LifecycleCallbackDescriptor.CallbackType.PRE_DESTROY));
if (next.hasAroundInvokeMethod()) {
interceptorInfo.setHasTargetClassAroundInvoke(true);
}
Map<Method, List> interceptorChains = new HashMap<Method, List>();
for (Method m : targetClass.getMethods()) {
interceptorChains.put(m, next.getAroundInvokeInterceptors(m));
}
interceptorInfo.setAroundInvokeInterceptorChains(interceptorChains);
// TODO can optimize this out for the non-JAXRS, non-application specified interceptor case
interceptorInfo.setSupportRuntimeDelegate(true);
JavaEEInterceptorBuilderFactory interceptorBuilderFactory = habitat.getService(JavaEEInterceptorBuilderFactory.class);
JavaEEInterceptorBuilder builder = interceptorBuilderFactory.createBuilder(interceptorInfo);
next.setInterceptorBuilder(builder);
compEnvManager.bindToComponentNamespace(next);
String jndiName = next.getGlobalJndiName();
ManagedBeanNamingProxy namingProxy = new ManagedBeanNamingProxy(next, habitat);
if (processType.isServer()) {
namingManager.publishObject(jndiName, namingProxy, true);
} else {
// Can't store them in server's global naming service so keep
// them in local map.
appClientManagedBeans.put(jndiName, namingProxy);
}
} catch (Exception e) {
throw new RuntimeException("Error binding ManagedBean " + next.getBeanClassName() + " with name = " + next.getName(), e);
}
}
jcdiManagedBeanInstanceMap.put(bundle, Collections.synchronizedMap(new HashMap<Object, JCDIService.JCDIInjectionContext>()));
}
}
Aggregations