Search in sources :

Example 1 with OpenEJBJndiService

use of org.apache.openejb.cdi.OpenEJBJndiService in project tomee by apache.

the class Assembler method ensureWebBeansContext.

private void ensureWebBeansContext(final AppContext appContext) {
    WebBeansContext webBeansContext = appContext.get(WebBeansContext.class);
    if (webBeansContext == null) {
        webBeansContext = appContext.getWebBeansContext();
    } else {
        if (null == appContext.getWebBeansContext()) {
            appContext.setWebBeansContext(webBeansContext);
        }
        return;
    }
    if (webBeansContext == null) {
        final Map<Class<?>, Object> services = new HashMap<Class<?>, Object>();
        services.put(JNDIService.class, new OpenEJBJndiService());
        services.put(AppContext.class, appContext);
        services.put(ScannerService.class, new CdiScanner());
        services.put(BeanArchiveService.class, new OpenEJBBeanInfoService());
        services.put(ELAdaptor.class, new CustomELAdapter(appContext));
        services.put(LoaderService.class, new OptimizedLoaderService(appContext.getProperties()));
        final Properties properties = new Properties();
        properties.setProperty(org.apache.webbeans.spi.SecurityService.class.getName(), ManagedSecurityService.class.getName());
        properties.setProperty(ContextsService.class.getName(), CdiAppContextsService.class.getName());
        properties.setProperty(ResourceInjectionService.class.getName(), CdiResourceInjectionService.class.getName());
        properties.setProperty(TransactionService.class.getName(), OpenEJBTransactionService.class.getName());
        webBeansContext = new WebBeansContext(services, properties);
        appContext.setCdiEnabled(false);
        appContext.set(WebBeansContext.class, webBeansContext);
        appContext.setWebBeansContext(webBeansContext);
    }
}
Also used : ContextsService(org.apache.webbeans.spi.ContextsService) CdiAppContextsService(org.apache.openejb.cdi.CdiAppContextsService) OpenEJBJndiService(org.apache.openejb.cdi.OpenEJBJndiService) TransactionService(org.apache.webbeans.spi.TransactionService) OpenEJBTransactionService(org.apache.openejb.cdi.OpenEJBTransactionService) HashMap(java.util.HashMap) CdiAppContextsService(org.apache.openejb.cdi.CdiAppContextsService) ManagedSecurityService(org.apache.openejb.cdi.ManagedSecurityService) OpenEJBTransactionService(org.apache.openejb.cdi.OpenEJBTransactionService) SuperProperties(org.apache.openejb.util.SuperProperties) Properties(java.util.Properties) CdiResourceInjectionService(org.apache.openejb.cdi.CdiResourceInjectionService) ResourceInjectionService(org.apache.webbeans.spi.ResourceInjectionService) WebBeansContext(org.apache.webbeans.config.WebBeansContext) CustomELAdapter(org.apache.openejb.cdi.CustomELAdapter) OptimizedLoaderService(org.apache.openejb.cdi.OptimizedLoaderService) ManagedSecurityService(org.apache.openejb.cdi.ManagedSecurityService) SecurityService(org.apache.openejb.spi.SecurityService) CdiScanner(org.apache.openejb.cdi.CdiScanner) OpenEJBBeanInfoService(org.apache.openejb.cdi.OpenEJBBeanInfoService) CdiResourceInjectionService(org.apache.openejb.cdi.CdiResourceInjectionService)

Aggregations

HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 CdiAppContextsService (org.apache.openejb.cdi.CdiAppContextsService)1 CdiResourceInjectionService (org.apache.openejb.cdi.CdiResourceInjectionService)1 CdiScanner (org.apache.openejb.cdi.CdiScanner)1 CustomELAdapter (org.apache.openejb.cdi.CustomELAdapter)1 ManagedSecurityService (org.apache.openejb.cdi.ManagedSecurityService)1 OpenEJBBeanInfoService (org.apache.openejb.cdi.OpenEJBBeanInfoService)1 OpenEJBJndiService (org.apache.openejb.cdi.OpenEJBJndiService)1 OpenEJBTransactionService (org.apache.openejb.cdi.OpenEJBTransactionService)1 OptimizedLoaderService (org.apache.openejb.cdi.OptimizedLoaderService)1 SecurityService (org.apache.openejb.spi.SecurityService)1 SuperProperties (org.apache.openejb.util.SuperProperties)1 WebBeansContext (org.apache.webbeans.config.WebBeansContext)1 ContextsService (org.apache.webbeans.spi.ContextsService)1 ResourceInjectionService (org.apache.webbeans.spi.ResourceInjectionService)1 TransactionService (org.apache.webbeans.spi.TransactionService)1