private void addClasses(final Collection<String> list, final ClassLoader loader) { for (final String s : list) { final Class<?> load = load(s, loader); if (load != null) { classes.add(load); } } } private BeanArchiveService.BeanArchiveInformation handleBda(final StartupObject startupObject, final ClassLoader classLoader,final ClassLoaderComparator comparator,
private void addContainerCdiClasses(final ClassLoader loader, final AppInfo app) { if (!"true".equalsIgnoreCase(app.properties.getProperty("CdiContainer", "true"))) { return; } addContainerClasses(app.properties, loader, "BVal"); /* useless since MyFaces uses Extension to register beans if (ejbJar.webapp && "true".equalsIgnoreCase(app.properties.getProperty("Jsf.MyFaces", "true"))) { addContainerClasses(app.properties, loader, "MyFaces"); } */ }
public void cdiToContainerSetup(final @Observes WebBeansContextCreated webBeansContextCreated) throws Exception { final WebBeansContext context = webBeansContextCreated.getContext(); context.getOpenWebBeansConfiguration().setProperty(AlertCDIBridge.class.getName() + ".accepted", accepted.isEmpty() ? "*" : Join.join(",", accepted)); CdiScanner.class.cast(context.getScannerService()).getBeanClasses().add(DefaultObserver.class); }
cdiScanner.setContext(webBeansContext); cdiScanner.init(startupObject); } else { cdiScanner = new CdiScanner(); cdiScanner.setContext(webBeansContext); cdiScanner.init(startupObject); for (final Class<?> clazz : cdiScanner.getStartupClasses()) { if (ejbs.contains(clazz)) { continue;
if (addErrors(errors, "alternative classes", beans.duplicatedAlternativeClasses) || addErrors(errors, "alternative stereotypes", beans.duplicatedAlternativeStereotypes) || addErrors(errors, "decorators", beans.duplicatedDecorators) || addErrors(errors, "interceptors", beans.duplicatedInterceptors)) { throw new WebBeansConfigurationException(errors.toString()); final Class<?> clazz = load(PropertyPlaceHolderHelper.simpleValue(className), classLoader); } else if (shouldThrowCouldNotLoadException(startupObject)) { throw new WebBeansConfigurationException("Could not load interceptor class: " + className); final Class<?> clazz = load(PropertyPlaceHolderHelper.simpleValue(className), classLoader); if (clazz != null) { if (!decoratorsManager.isDecoratorEnabled(clazz)) { } else if (shouldThrowCouldNotLoadException(startupObject)) { throw new WebBeansConfigurationException("Could not load decorator class: " + className); final Class<?> clazz = load(PropertyPlaceHolderHelper.simpleValue(className), classLoader); if (clazz != null) { alternativesManager.addStereoTypeAlternative(clazz, null, null); classes.add(clazz); } else if (shouldThrowCouldNotLoadException(startupObject)) { throw new WebBeansConfigurationException("Could not load alternativeStereotype class: " + className); final Class<?> clazz = load(PropertyPlaceHolderHelper.simpleValue(className), classLoader); if (clazz != null) { alternativesManager.addClazzAlternative(clazz, null, null); classes.add(clazz);
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); } }
service.init(startupObject); } else { new CdiScanner().init(startupObject);
addClasses(information.getAlternativeClasses(), classLoader); addClasses(information.getDecorators(), classLoader); addClasses(information.getInterceptors(), classLoader); addClasses(information.getAlternativeStereotypes(), classLoader); final Class clazz = load(name, classLoader); if (clazz == null) { continue; if (isBean(clazz)) { classes.add(clazz); if (beans.startupClasses.contains(name)) {
infoByBda.put(bda, handleBda(startupObject, classLoader, comparator, beans, scl, filterByClassLoader, beanArchiveService, openejb, bda)); handleBda(startupObject, classLoader, comparator, beans, scl, filterByClassLoader, beanArchiveService, openejb, bda); classes.add(load(name, classLoader)); cdi = true; break; for (final BeansInfo.BDAInfo bda : beans.noDescriptorBdas) { if (bda.managedClasses.contains(name)) { classes.add(load(name, classLoader)); break;
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());
services.put(ScannerService.class, new CdiScanner()); WebBeansContext webBeansContext = new WebBeansContext(services, properties);
private void process(final ClassLoader classLoader, final Iterator<String> it, final StartupObject startupObject, final ClassLoaderComparator comparator, final ClassLoader scl, final boolean filterByClassLoader) { final String className = it.next(); final Class clazz = load(className, classLoader); if (clazz == null) { return; } final boolean isNotEarWebApp = startupObject.getWebContext() == null; final ClassLoader cl = clazz.getClassLoader(); // 1. this classloader is the good one // 2. the classloader is the appclassloader one and we are in the ear parent // 3. it is a container class so if it is here it is designed // // main case it tries to filter is ear one ie lib classes shouldn't be in webapp classes // but embedded other cases should still work if (!filterByClassLoader || comparator.isSame(cl) || ((cl.equals(scl) || cl == containerLoader) && isNotEarWebApp)) { classes.add(clazz); } else { it.remove(); } }
services.put(ScannerService.class, new CdiScanner());
services.put(TransactionService.class, new OpenEJBTransactionService()); services.put(ELAdaptor.class, new CustomELAdapter(appContext)); services.put(ScannerService.class, new CdiScanner()); final LoaderService loaderService = SystemInstance.get().getComponent(LoaderService.class); if (loaderService == null && !properties.containsKey(LoaderService.class.getName())) {