scannerService.scan();
private String getBDABeansXMLPath(Class<?> injectionPointBeanClass) { if (injectionPointBeanClass == null) { return null; } ScannerService scannerService = webBeansContext.getScannerService(); BDABeansXmlScanner beansXMLScanner = scannerService.getBDABeansXmlScanner(); return beansXMLScanner.getBeansXml(injectionPointBeanClass); }
/** * Create AnnotatedTypes from the ClassPath via the ScannerService */ private Map<BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesFromClassPath(ScannerService scanner) { logger.fine("Creating AnnotatedTypes from class files has started."); Set<Class<?>> foundClasses = new HashSet<>(100); Map<BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesPerBda = new HashMap<>(); if (scanner instanceof BdaScannerService) { Map<BeanArchiveInformation, Set<Class<?>>> beanClassesPerBda = ((BdaScannerService) scanner).getBeanClassesPerBda(); for (Map.Entry<BeanArchiveInformation, Set<Class<?>>> bdaEntry : beanClassesPerBda.entrySet()) { List<AnnotatedType<?>> annotatedTypes = annotatedTypesFromBdaClassPath(bdaEntry.getValue(), foundClasses); annotatedTypesPerBda.put(bdaEntry.getKey(), annotatedTypes); } // also add the rest of the class es to the default bda // we also need this initialised in case annotatedTypes get added manually at a later step annotatedTypesPerBda.put(defaultBeanArchiveInformation, annotatedTypesFromBdaClassPath(scanner.getBeanClasses(), foundClasses)); } else { // this path is only for backward compat to older ScannerService implementations Set<Class<?>> classIndex = scanner.getBeanClasses(); List<AnnotatedType<?>> annotatedTypes = annotatedTypesFromBdaClassPath(classIndex, foundClasses); annotatedTypesPerBda.put(defaultBeanArchiveInformation, annotatedTypes); } return annotatedTypesPerBda; }
private void configureDecorators(URL bdaLocation, List<String> decorators) { Set<Class> decoratorsInFile = new HashSet<>(); for (String decorator : decorators) { Class<?> clazz = ClassUtil.getClassFromName(decorator); if (clazz == null) { throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Decorator class : " + decorator + " not found"); } else { if ((scannerService.isBDABeansXmlScanningEnabled() && !scannerService.getBDABeansXmlScanner().addDecorator(clazz, bdaLocation.toExternalForm())) || decoratorsInFile.contains(clazz)) { throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Decorator class : " + decorator + " is already defined"); } decoratorsManager.addEnabledDecorator(clazz); decoratorsInFile.add(clazz); } } }
@Override protected void beforeStartApplication(Object startupObject) { this.scannerService.init(startupObject); }
/** * Discovers and deploys alternatives, interceptors and decorators from XML. * * @param scanner discovery scanner * * @throws WebBeansDeploymentException if a problem occurs */ protected void deployFromXML(ScannerService scanner) throws WebBeansDeploymentException { logger.fine("Deploying configurations from XML files has started."); Set<URL> bdaLocations = scanner.getBeanXmls(); Iterator<URL> it = bdaLocations.iterator(); while (it.hasNext()) { URL url = it.next(); logger.fine("OpenWebBeans BeansDeployer configuring: " + url.toExternalForm()); BeanArchiveInformation beanArchiveInformation = beanArchiveService.getBeanArchiveInformation(url); configureDecorators(url, beanArchiveInformation.getDecorators()); configureInterceptors(url, beanArchiveInformation.getInterceptors()); configureAlternatives(url, beanArchiveInformation.getAlternativeClasses(), false); configureAlternatives(url, beanArchiveInformation.getAlternativeStereotypes(), true); configureAllowProxying(url, beanArchiveInformation.getAllowProxyingClasses()); } logger.fine("Deploying configurations from XML has ended successfully."); }
if (scannerService.isBDABeansXmlScanningEnabled())
scanner.release(); webBeansContext.getAnnotatedElementFactory().clear(); webBeansContext.getNotificationManager().clearCaches();
boolean isBDAScanningEnabled = scannerService.isBDABeansXmlScanningEnabled(); if ((!isBDAScanningEnabled && interceptorsManager.isInterceptorClassEnabled(clazz)) || (isBDAScanningEnabled && !scannerService.getBDABeansXmlScanner().addInterceptor(clazz, bdaLocation.toExternalForm())))
this.scannerService.scan();
this.scannerService.scan();