public Map<Class<? extends Annotation>, Set<Class<?>>> call() throws Exception { Timer t = Timer.getInstance(); if (t != null) { t.startTiming(); } // We are executing on a different thread. facesContext.callSetCurrentInstance(); Set<URI> scanUris = null; com.sun.faces.spi.AnnotationScanner annotationScanner = metadataGetter.getAnnotationScanner(); // This is where we discover what kind of InjectionProvider // we have. if (provider instanceof DelegatingAnnotationProvider && null != annotationScanner) { // This InjectionProvider is capable of annotation scanning *and* // injection. ((DelegatingAnnotationProvider) provider) .setAnnotationScanner(annotationScanner, metadataGetter.getJarNames()); scanUris = Collections.emptySet(); } else { // This InjectionProvider is capable of annotation scanning only scanUris = metadataGetter.getAnnotationScanURIs(); } // AnnotationScanner scanner = new AnnotationScanner(sc); Map<Class<? extends Annotation>, Set<Class<?>>> annotatedClasses = provider.getAnnotatedClasses(scanUris); if (t != null) { t.stopTiming(); t.logResult("Configuration annotation scan complete."); } return annotatedClasses; }
/** * This method bootstraps JSF based on the parsed configuration resources. * * @param sc the <code>ServletContext</code> for the application that requires initialization */ public void initialize(ServletContext sc) { if (!hasBeenInitialized(sc)) { initializedContexts.add(sc); ExecutorService executor = null; try { WebConfiguration webConfig = WebConfiguration.getInstance(sc); boolean validating = webConfig.isOptionEnabled(ValidateFacesConfigFiles); if (useThreads(sc)) { executor = createExecutorService(); } DocumentInfo[] facesDocuments = getConfigDocuments(sc, getFacesConfigResourceProviders(), executor, validating); FacesConfigInfo webInfFacesConfigInfo = new FacesConfigInfo(facesDocuments[facesDocuments.length - 1]); facesDocuments = sortDocuments(facesDocuments, webInfFacesConfigInfo); InitFacesContext context = (InitFacesContext) FacesContext.getCurrentInstance(); InjectionProvider containerConnector = InjectionProviderFactory.createInstance(context.getExternalContext()); context.getAttributes().put(INJECTION_PROVIDER_KEY, containerConnector); boolean isFaceletsDisabled = isFaceletsDisabled(webConfig, webInfFacesConfigInfo); if (!webInfFacesConfigInfo.isWebInfFacesConfig() || !webInfFacesConfigInfo.isMetadataComplete()) { // execute the Task responsible for finding annotation classes ProvideMetadataToAnnotationScanTask taskMetadata = new ProvideMetadataToAnnotationScanTask(facesDocuments, containerConnector); Future<Map<Class<? extends Annotation>, Set<Class<?>>>> annotationScan; if (executor != null) { annotationScan = executor.submit(new AnnotationScanTask(sc, context, taskMetadata)); pushTaskToContext(sc, annotationScan); } else { annotationScan = new FutureTask<Map<Class<? extends Annotation>, Set<Class<?>>>>( new AnnotationScanTask(sc, context, taskMetadata)); ((FutureTask) annotationScan).run(); } pushTaskToContext(sc, annotationScan); } // see if the app is running in a HA enabled env if (containerConnector instanceof HighAvailabilityEnabler) { ((HighAvailabilityEnabler) containerConnector).enableHighAvailability(sc); } // process the ordered documents FACES_CONFIG_PROCESSOR_CHAIN.process(sc, facesDocuments); if (!isFaceletsDisabled) { FACELET_TAGLIB_CONFIG_PROCESSOR_CHAIN.process( sc, getConfigDocuments(sc, getFaceletConfigResourceProviders(), executor, validating)); } publishPostConfigEvent(); } catch (Exception e) { // clear out any configured factories releaseFactories(); Throwable t = e; if (!(e instanceof ConfigurationException)) { t = new ConfigurationException("CONFIGURATION FAILED! " + t.getMessage(), t); } throw (ConfigurationException) t; } finally { if (executor != null) { executor.shutdown(); } sc.removeAttribute(ANNOTATIONS_SCAN_TASK_KEY); } } }