Search in sources :

Example 1 with JavaEEInterceptorBuilderFactory

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>()));
    }
}
Also used : JCDIService(com.sun.enterprise.container.common.spi.JCDIService) HashMap(java.util.HashMap) InterceptorInfo(com.sun.enterprise.container.common.spi.util.InterceptorInfo) ManagedBeanDescriptor(com.sun.enterprise.deployment.ManagedBeanDescriptor) Method(java.lang.reflect.Method) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) JavaEEInterceptorBuilderFactory(com.sun.enterprise.container.common.spi.JavaEEInterceptorBuilderFactory) JavaEEInterceptorBuilder(com.sun.enterprise.container.common.spi.JavaEEInterceptorBuilder) List(java.util.List)

Aggregations

JCDIService (com.sun.enterprise.container.common.spi.JCDIService)1 JavaEEInterceptorBuilder (com.sun.enterprise.container.common.spi.JavaEEInterceptorBuilder)1 JavaEEInterceptorBuilderFactory (com.sun.enterprise.container.common.spi.JavaEEInterceptorBuilderFactory)1 InterceptorInfo (com.sun.enterprise.container.common.spi.util.InterceptorInfo)1 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)1 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)1 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 List (java.util.List)1