}
}
}
private void ensureWebBeansContext(final AppContext appContext) {
WebBeansContext webBeansContext = appContext.get(WebBeansContext.class);
if (webBeansContext == null) {
webBeansContext = appContext.getWebBeansContext();
}
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(TransactionService.class, new OpenEJBTransactionService());
services.put(ScannerService.class, new CdiScanner());
services.put(ELAdaptor.class, new CustomELAdapter(appContext));
services.put(LoaderService.class, new OptimizedLoaderService());
final Properties properties = new Properties();
properties.setProperty(org.apache.webbeans.spi.SecurityService.class.getName(), ManagedSecurityService.class.getName());
webBeansContext = new WebBeansContext(services, properties);
webBeansContext.registerService(ContextsService.class, new CdiAppContextsService(webBeansContext, true));
webBeansContext.registerService(ResourceInjectionService.class, new CdiResourceInjectionService(webBeansContext));
appContext.setCdiEnabled(false);
OpenEJBTransactionService.class.cast(services.get(TransactionService.class)).setWebBeansContext(webBeansContext);
}