public void execute(FacesContext facesContext) throws FacesException { //refresh all configuration information if according web-xml parameter is set. WebXml.update(facesContext.getExternalContext()); new FacesConfigurator(facesContext.getExternalContext()).update(); PhaseListenerManager phaseListenerMgr = new PhaseListenerManager(this, facesContext, getPhaseListeners()); for(int executorIndex = 0;executorIndex < lifecycleExecutors.length;executorIndex++) { if(executePhase(facesContext, lifecycleExecutors[executorIndex], phaseListenerMgr)) { return; } } }
public void update() { long refreshPeriod = (MyfacesConfig.getCurrentInstance(_externalContext).getConfigRefreshPeriod())*1000; if (refreshPeriod > 0){ long ttl = lastUpdate + refreshPeriod; if ((System.currentTimeMillis() > ttl) && (getLastModifiedTime() > ttl)) { try { purgeConfiguration(); } catch (NoSuchMethodException e) { log.error("Configuration objects do not support clean-up. Update aborted"); return; } catch (IllegalAccessException e) { log.fatal("Error during configuration clean-up" + e.getMessage()); } catch (InvocationTargetException e) { log.fatal("Error during configuration clean-up" + e.getMessage()); } configure(); } } }
public void configure() throws FacesException { // get FacesConfigurationMerger SPI implementation FacesConfigurationMerger facesConfigurationMerger = FacesConfigurationMergerFactory .getFacesConfigurationMergerFactory(_externalContext).getFacesConfigurationMerger(_externalContext); // get all faces-config data, merge it and set it as Dispenser setDispenser(facesConfigurationMerger.getFacesConfigData(_externalContext)); configureFactories(); configureApplication(); configureRenderKits(); //Now we can configure annotations //getAnnotationConfigurator().configure( // ((ApplicationFactory) FactoryFinder.getFactory( // FactoryFinder.APPLICATION_FACTORY)).getApplication(), // getDispenser(), metadataComplete); configureRuntimeConfig(); configureLifecycle(); handleSerialFactory(); configureManagedBeanDestroyer(); configureFlowHandler(); configureProtectedViews(); // record the time of update lastUpdate = System.currentTimeMillis(); }
private long getLastModifiedTime() { long lastModified = 0; long resModified; resModified = getResourceLastModified(DEFAULT_FACES_CONFIG); if (resModified > lastModified) lastModified = resModified; for (String systemId : getConfigFilesList()) { resModified = getResourceLastModified(systemId); if (resModified > lastModified) { lastModified = resModified; } } return lastModified; }
private void configureFactories() { FacesConfigDispenser dispenser = getDispenser(); setFactories(FactoryFinder.APPLICATION_FACTORY, dispenser.getApplicationFactoryIterator(), DEFAULT_APPLICATION_FACTORY); setFactories(FactoryFinder.FACES_CONTEXT_FACTORY, dispenser.getFacesContextFactoryIterator(), DEFAULT_FACES_CONTEXT_FACTORY); setFactories(FactoryFinder.LIFECYCLE_FACTORY, dispenser.getLifecycleFactoryIterator(), DEFAULT_LIFECYCLE_FACTORY); setFactories(FactoryFinder.RENDER_KIT_FACTORY, dispenser.getRenderKitFactoryIterator(), DEFAULT_RENDER_KIT_FACTORY); }
/** * Configures this JSF application. It's required that every * FacesInitializer (i.e. every subclass) calls this method during * initialization. * * @param servletContext the current ServletContext * @param externalContext the current ExternalContext * @param expressionFactory the ExpressionFactory to use * @return the current runtime configuration */ protected RuntimeConfig buildConfiguration(ServletContext servletContext, ExternalContext externalContext, ExpressionFactory expressionFactory) { RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext); runtimeConfig.setExpressionFactory(expressionFactory); // And configure everything new FacesConfigurator(externalContext).configure(); validateFacesConfig(servletContext, externalContext); return runtimeConfig; }
if ((System.currentTimeMillis() > ttl) && (getLastModifiedTime() > ttl)) purged = purgeConfiguration(); configure(); FacesContext facesContext = getFacesContext(); Application application = facesContext.getApplication();
FacesConfigData dispenser = getDispenser(); application.setActionListener(ClassUtils.buildApplicationObject(ActionListener.class, dispenser.getActionListenerIterator(), null)); application.subscribeToEvent( (Class<? extends SystemEvent>)eventClass , (Class<?>)ClassUtils.classForName((systemEventListener.getSourceClass() != null) ? systemEventListener.getSourceClass(): getDefaultSourcClassForSystemEvent(eventClass) ), //Application.class??? (javax.faces.event.SystemEventListener)ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass())); } catch (ClassNotFoundException e) { RuntimeConfig runtimeConfig = getRuntimeConfig();
private void configureRuntimeConfig() { RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext); FacesConfigDispenser dispenser = getDispenser(); for (Iterator iterator = dispenser.getManagedBeans(); iterator.hasNext();) { ManagedBean bean = (ManagedBean) iterator.next(); if (log.isWarnEnabled() && runtimeConfig.getManagedBean(bean.getManagedBeanName()) != null) log.warn("More than one managed bean w/ the name of '" + bean.getManagedBeanName() + "' - only keeping the last "); runtimeConfig.addManagedBean(bean.getManagedBeanName(), bean); } removePurgedBeansFromSessionAndApplication(runtimeConfig); for (Iterator iterator = dispenser.getNavigationRules(); iterator.hasNext();) { NavigationRule rule = (NavigationRule) iterator.next(); runtimeConfig.addNavigationRule(rule); } for (Iterator<ResourceBundle> iter = dispenser.getResourceBundles(); iter.hasNext();) { runtimeConfig.addResourceBundle(iter.next()); } for (Iterator<String> iter = dispenser.getElResolvers(); iter.hasNext();) { runtimeConfig.addFacesConfigElResolver((ELResolver) ClassUtils.newInstance(iter.next(), ELResolver.class)); } }
private void configureLifecycle() { // create the lifecycle used by the app LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder .getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle lifecycle = lifecycleFactory.getLifecycle(getLifecycleId()); // add phase listeners for (Iterator iterator = getDispenser().getLifecyclePhaseListeners(); iterator.hasNext();) { String listenerClassName = (String) iterator.next(); try { lifecycle.addPhaseListener((PhaseListener) ClassUtils.newInstance(listenerClassName)); } catch (ClassCastException e) { log.error("Class " + listenerClassName + " does not implement PhaseListener"); } } }
private void feedContextSpecifiedConfig() throws IOException, SAXException { List configFilesList = getConfigFilesList(); for (int i = 0; i < configFilesList.size(); i++) { String systemId = (String) configFilesList.get(i); InputStream stream = _externalContext.getResourceAsStream(systemId); if (stream == null) { log.error("Faces config resource " + systemId + " not found"); continue; } if (log.isInfoEnabled()) log.info("Reading config " + systemId); getDispenser().feed(getUnmarshaller().getFacesConfig(stream, systemId)); stream.close(); } }
FacesConfigData dispenser = getDispenser(); ActionListener actionListener = ClassUtils.buildApplicationObject(ActionListener.class, dispenser.getActionListenerIterator(), null); _callInjectAndPostConstruct(actionListener); application.setActionListener(actionListener); _callInjectAndPostConstruct(navigationHandler); dispenser.getStateManagerIterator(), application.getStateManager()); _callInjectAndPostConstruct(stateManager); application.setStateManager(stateManager); dispenser.getResourceHandlerIterator(), application.getResourceHandler()); _callInjectAndPostConstruct(resourceHandler); application.setResourceHandler(resourceHandler); RuntimeConfig runtimeConfig = getRuntimeConfig(); _callInjectAndPostConstruct(listener); runtimeConfig.addInjectedObject(listener); if (systemEventListener.getSourceClass() != null && systemEventListener.getSourceClass().length() > 0) FactoryFinder.getFactory(FactoryFinder.FLOW_HANDLER_FACTORY); FlowHandler flowHandler = flowHandlerFactory.createFlowHandler( getFacesContext()); application.setFlowHandler(flowHandler);
FacesConfigDispenser dispenser = getDispenser(); application.setActionListener((ActionListener) getApplicationObject(ActionListener.class, dispenser .getActionListenerIterator(), null)); application.setNavigationHandler((NavigationHandler) getApplicationObject(NavigationHandler.class, dispenser .getNavigationHandlerIterator(), application.getNavigationHandler())); application.setStateManager((StateManager) getApplicationObject(StateManager.class, dispenser .getStateManagerIterator(), application.getStateManager())); List<Locale> locales = new ArrayList<Locale>(); application.setViewHandler((ViewHandler) getApplicationObject(ViewHandler.class, dispenser .getViewHandlerIterator(), application.getViewHandler())); RuntimeConfig runtimeConfig = getRuntimeConfig(); runtimeConfig.setPropertyResolverChainHead((PropertyResolver) getApplicationObject(PropertyResolver.class, dispenser .getPropertyResolverIterator(), new DefaultPropertyResolver())); runtimeConfig.setVariableResolverChainHead((VariableResolver) getApplicationObject(VariableResolver.class, dispenser .getVariableResolverIterator(), new VariableResolverImpl()));
private void configureRuntimeConfig() FacesConfigData dispenser = getDispenser(); List<String> knownNamespaces = new ArrayList<String>(); removePurgedBeansFromSessionAndApplication(runtimeConfig); try Object creationMetaData = getInjectionProvider().inject(elResolver); getInjectionProvider().postConstruct(elResolver, creationMetaData);
private void configureFlowHandler() FacesContext facesContext = getFacesContext(); Application application = getApplication(); FacesConfigData dispenser = getDispenser(); FacesConfigurator.enableDefaultWindowMode(facesContext); if (!isEmptyString(flowDefinition.getInitializer())) if (!isEmptyString(flowDefinition.getFinalizer())) if (!isEmptyString(methodCall.getMethod())) facesContext.getELContext(), methodCall.getMethod(), null, NO_PARAMETER_TYPES)); if (!isEmptyString(methodCall.getDefaultOutcome())) !isEmptyString(flowSwitch.getDefaultOutcome().getFromOutcome())) if (!isEmptyString(navCase.getIf())) !isEmptyString(flowReturn.getNavigationCase().getFromOutcome()))
.getFactory(FactoryFinder.RENDER_KIT_FACTORY); FacesConfigDispenser dispenser = getDispenser(); for (Iterator iterator = dispenser.getRenderKitIds(); iterator.hasNext();)
/** * This method fixes MYFACES-208 */ private void feedClassloaderConfigurations() { try { Iterator it = ClassUtils.getResources(FACES_CONFIG_RESOURCE, this); while (it.hasNext()) { URL url = (URL) it.next(); InputStream stream = openStreamWithoutCache(url); String systemId = url.toExternalForm(); if (log.isInfoEnabled()) log.info("Reading config " + systemId); getDispenser().feed(getUnmarshaller().getFacesConfig(stream, systemId)); stream.close(); } } catch (Throwable e) { throw new FacesException(e); } }
private void feedWebAppConfig() throws IOException, SAXException { // web application config InputStream stream = _externalContext.getResourceAsStream(DEFAULT_FACES_CONFIG); if (stream != null) { if (log.isInfoEnabled()) log.info("Reading config /WEB-INF/faces-config.xml"); getDispenser().feed(getUnmarshaller().getFacesConfig(stream, DEFAULT_FACES_CONFIG)); stream.close(); } }
for (String listenerClassName : getDispenser().getLifecyclePhaseListeners()) ClassUtils.newInstance(listenerClassName, PhaseListener.class); Object creationMetaData = getInjectionProvider().inject(listener); getInjectionProvider().postConstruct(listener, creationMetaData); lifecycle.addPhaseListener(listener); FacesContext facesContext = getFacesContext(); if (facesContext.isProjectStage(ProjectStage.Development) && MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isDebugPhaseListenerEnabled())