/** * <p>This method will store the argument * <code>factoryName/implName</code> mapping in such a way that * {@link #getFactory} will find this mapping when searching for a * match.</p> * <p/> * <p>This method has no effect if <code>getFactory()</code> has * already been called looking for a factory for this * <code>factoryName</code>.</p> * <p/> * <p>This method can be used by implementations to store a factory * mapping while parsing the Faces configuration file</p> * * @throws IllegalArgumentException if <code>factoryName</code> does not * identify a standard JavaServer Faces factory name * @throws NullPointerException if <code>factoryname</code> * is null */ public static void setFactory(String factoryName, String implName) { FactoryFinderInstance manager = FACTORIES_CACHE.getApplicationFactoryManager(); manager.addFactory(factoryName, implName); }
FactoryFinderInstance() { lock = new ReentrantReadWriteLock(true); factories = new HashMap<>(); savedFactoryNames = new HashMap<>(); for (String name : FACTORY_NAMES) { factories.put(name, new ArrayList(4)); // NOPMD } copyInjectionProviderFromFacesContext(); servletContextFinder = new ServletContextFacesContextFactory(); }
Object getFallbackFactory(FactoryFinderInstance brokenFactoryManager, String factoryName) { ClassLoader classLoader = getContextClassLoader2(); for (Map.Entry<FactoryFinderCacheKey, FactoryFinderInstance> cur : factoryFinderMap.entrySet()) { if (cur.getKey().getClassLoader().equals(classLoader) && !cur.getValue().equals(brokenFactoryManager)) { Object factory = cur.getValue().getFactory(factoryName); if (factory != null) { return factory; } } } return null; }
result = getImplGivenPreviousImpl(classLoader, factoryName, curImplClass, null); List<String> fromServices = getImplNameFromServices(classLoader, factoryName); if (fromServices != null) { for (String name : fromServices) { result = getImplGivenPreviousImpl(classLoader, factoryName, name, for (len = (implementations.size() - 1); 0 <= len; len--) { curImplClass = (String) implementations.remove(len); result = getImplGivenPreviousImpl(classLoader, factoryName, curImplClass, result);
void releaseFactories() { InjectionProvider provider = getInjectionProvider(); if (provider != null) { lock.writeLock().lock(); try { for (Entry<String, Object> entry : factories.entrySet()) { Object curFactory = entry.getValue(); // If the current entry is not the injectionProvider itself // and the current entry has a non-null value // and the value is not a string... if (!INJECTION_PROVIDER_KEY.equals(entry.getKey()) && curFactory != null && !(curFactory instanceof String)) { try { provider.invokePreDestroy(curFactory); } catch (Exception ex) { logPreDestroyFail(entry.getValue(), ex); } } } } finally { factories.clear(); lock.writeLock().unlock(); } } else { LOGGER.log(SEVERE, "Unable to call @PreDestroy annotated methods because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?"); } }
@SuppressWarnings("unchecked") Object getFactory(String factoryName) { validateFactoryName(factoryName); Object factory = getImplementationInstance(getContextClassLoader2(), factoryName, (List<String>) factoryOrList); logNoFactory(factoryName); notNullFactory(factoryName, factory);
Object getFactory(String factoryName) { validateFactoryName(factoryName); if (factoryName.equals(ServletContextFacesContextFactory.SERVLET_CONTEXT_FINDER_NAME)) { return servletContextFinder; ClassLoader cl = getClassLoader(); Object factory = getImplementationInstance(cl, factoryName, (List) factoryOrList); if (factory == null) { ResourceBundle rb = LOGGER.getResourceBundle();
(null != (factoryClass = getFactoryClass(factoryName)))) { try { clazz = Class.forName(implName, false, classLoader); InjectionProvider provider = getInjectionProvider(); if (null != provider) { try {
Class<?> factoryClass = getFactoryClass(factoryName); injectImplementation(factoryImplClassName, factoryImplementation);
void removeApplicationFactoryManager() { ClassLoader cl = getClassLoader(); FactoryFinderInstance fm = this.getApplicationFactoryManager(cl, false); if (null != fm) { fm.clearInjectionProvider(); } FacesContext facesContext = servletContextFacesContextFactory.getFacesContextWithoutServletContextLookup(); boolean isSpecialInitializationCase = detectSpecialInitializationCase(facesContext); FactoryManagerCacheKey key = new FactoryManagerCacheKey(facesContext, cl, applicationMap); applicationMap.remove(key); if (isSpecialInitializationCase) { logNullFacesContext.set(false); logNonNullFacesContext.set(false); } }
void releaseFactories() { InjectionProvider provider = getInjectionProvider(); if (null != provider) { lock.writeLock().lock();
FactoryFinderInstance newResult; if (null != toCopy) { newResult = new FactoryFinderInstance(toCopy); } else { newResult = new FactoryFinderInstance();
@SuppressWarnings("unchecked") Object getFactory(String factoryName) { validateFactoryName(factoryName); Object factory = getImplementationInstance(getContextClassLoader2(), factoryName, (List<String>) factoryOrList); logNoFactory(factoryName); notNullFactory(factoryName, factory);
result = getImplGivenPreviousImpl(classLoader, factoryName, curImplClass, null); List<String> fromServices = getImplNameFromServices(classLoader, factoryName); if (fromServices != null) { for (String name : fromServices) { result = getImplGivenPreviousImpl(classLoader, factoryName, name, for (len = (implementations.size() - 1); 0 <= len; len--) { curImplClass = (String) implementations.remove(len); result = getImplGivenPreviousImpl(classLoader, factoryName, curImplClass, result);
Object getFactory(String factoryName) { validateFactoryName(factoryName); if (factoryName.equals(ServletContextFacesContextFactory.SERVLET_CONTEXT_FINDER_NAME)) { return servletContextFinder; ClassLoader cl = getClassLoader(); Object factory = getImplementationInstance(cl, factoryName, (List) factoryOrList); if (factory == null) { ResourceBundle rb = LOGGER.getResourceBundle();
(null != (factoryClass = getFactoryClass(factoryName)))) { try { clazz = Class.forName(implName, false, classLoader); InjectionProvider provider = getInjectionProvider(); if (null != provider) { try {
void releaseFactories() { InjectionProvider provider = getInjectionProvider(); if (provider != null) { lock.writeLock().lock(); try { for (Entry<String, Object> entry : factories.entrySet()) { Object curFactory = entry.getValue(); // If the current entry is not the injectionProvider itself // and the current entry has a non-null value // and the value is not a string... if (!INJECTION_PROVIDER_KEY.equals(entry.getKey()) && curFactory != null && !(curFactory instanceof String)) { try { provider.invokePreDestroy(curFactory); } catch (Exception ex) { logPreDestroyFail(entry.getValue(), ex); } } } } finally { factories.clear(); lock.writeLock().unlock(); } } else { LOGGER.log(SEVERE, "Unable to call @PreDestroy annotated methods because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?"); } }
Class<?> factoryClass = getFactoryClass(factoryName); injectImplementation(factoryImplClassName, factoryImplementation);
void removeApplicationFactoryManager() { ClassLoader cl = getClassLoader(); FactoryFinderInstance fm = this.getApplicationFactoryManager(cl, false); if (null != fm) { fm.clearInjectionProvider(); } FacesContext facesContext = servletContextFacesContextFactory.getFacesContextWithoutServletContextLookup(); boolean isSpecialInitializationCase = detectSpecialInitializationCase(facesContext); FactoryManagerCacheKey key = new FactoryManagerCacheKey(facesContext, cl, applicationMap); applicationMap.remove(key); if (isSpecialInitializationCase) { logNullFacesContext.set(false); logNonNullFacesContext.set(false); } }
void releaseFactories() { InjectionProvider provider = getInjectionProvider(); if (null != provider) { lock.writeLock().lock();