Examples of RuntimeConfig


Examples of org.apache.myfaces.config.RuntimeConfig

        IMocksControl control = EasyMock.createControl();
       
        JspFactory jspFactory = control.createMock(JspFactory.class);
        initializer.setJspFactory(jspFactory);
       
        RuntimeConfig runtimeConfig = control.createMock(RuntimeConfig.class);
       
        ServletContext context = control.createMock(ServletContext.class);
        ExpressionFactory expressionFactory = control.createMock(ExpressionFactory.class);
        runtimeConfig.setExpressionFactory(expressionFactory);
        runtimeConfig.setPropertyResolverChainHead(isA(DefaultPropertyResolver.class));
        runtimeConfig.setVariableResolverChainHead(isA(VariableResolverImpl.class));
       
        expect(context.getAttribute(eq(RuntimeConfig.class.getName()))).andReturn(runtimeConfig).anyTimes();
       
        expect(context.getInitParameter(eq(FacesServlet.CONFIG_FILES_ATTR))).andReturn(null);
        expect(context.getResourceAsStream(eq("/WEB-INF/faces-config.xml"))).andReturn(null);
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

    }

    private Map getNavigationCases(FacesContext facesContext)
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);

        if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
        {
            synchronized(this)
            {
                if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
                {
                    Collection rules = runtimeConfig.getNavigationRules();
                    int rulesSize = rules.size();
                    Map cases = new HashMap(HashMapUtils.calcCapacity(rulesSize));
                    List wildcardKeys = new ArrayList();

                    for (Iterator iterator = rules.iterator(); iterator.hasNext();)
                    {
                        NavigationRule rule = (NavigationRule) iterator.next();
                        String fromViewId = rule.getFromViewId();

                        //specification 7.4.2 footnote 4 - missing fromViewId is allowed:
                        if (fromViewId == null)
                        {
                            fromViewId = ASTERISK;
                        }
                        else
                        {
                            fromViewId = fromViewId.trim();
                        }

                        List list = (List) cases.get(fromViewId);
                        if (list == null)
                        {
                            list = new ArrayList(rule.getNavigationCases());
                            cases.put(fromViewId, list);
                            if (fromViewId.endsWith(ASTERISK))
                            {
                                wildcardKeys.add(fromViewId);
                            }
                        } else {
                            list.addAll(rule.getNavigationCases());
                        }

                    }
                    Collections.sort(wildcardKeys, new KeyComparator());

                    synchronized (cases)
                    {
                        // We do not really need this sychronization at all, but this
                        // gives us the peace of mind that some good optimizing compiler
                        // will not rearrange the execution of the assignment to an
                        // earlier time, before all init code completes
                        _navigationCases = cases;
                        _wildcardKeys = wildcardKeys;

                        runtimeConfig.setNavigationRulesChanged(false);
                    }
                }
            }
        }
        return _navigationCases;
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

    @Override
    public Map<String, Set<NavigationCase>> getNavigationCases()
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);

        if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
        {
            synchronized (this)
            {
                if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
                {
                    Collection<? extends NavigationRule> rules = runtimeConfig.getNavigationRules();
                    int rulesSize = rules.size();

                    Map<String, Set<NavigationCase>> cases = new HashMap<String, Set<NavigationCase>>(
                            HashMapUtils.calcCapacity(rulesSize));

                    List<String> wildcardKeys = new ArrayList<String>();

                    for (NavigationRule rule : rules)
                    {
                        String fromViewId = rule.getFromViewId();

                        //specification 7.4.2 footnote 4 - missing fromViewId is allowed:
                        if (fromViewId == null)
                        {
                            fromViewId = ASTERISK;
                        }
                        else
                        {
                            fromViewId = fromViewId.trim();
                        }

                        Set<NavigationCase> set = cases.get(fromViewId);
                        if (set == null)
                        {
                            set = new HashSet<NavigationCase>(convertNavigationCasesToAPI(rule));
                            cases.put(fromViewId, set);
                            if (fromViewId.endsWith(ASTERISK))
                            {
                                wildcardKeys.add(fromViewId);
                            }
                        }
                        else
                        {
                            set.addAll(convertNavigationCasesToAPI(rule));
                        }
                    }

                    Collections.sort(wildcardKeys, new KeyComparator());

                    synchronized (cases)
                    {
                        // We do not really need this sychronization at all, but this
                        // gives us the peace of mind that some good optimizing compiler
                        // will not rearrange the execution of the assignment to an
                        // earlier time, before all init code completes
                        _navigationCases = cases;
                        _wildcardKeys = wildcardKeys;

                        runtimeConfig.setNavigationRulesChanged(false);
                    }
                }
            }
        }
        return _navigationCases;
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

    @Override
    public Map<String, Set<NavigationCase>> getNavigationCases()
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);

        if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
        {
            calculateNavigationCases(facesContext, runtimeConfig);
        }
        return _navigationCases;
    }
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

    @Override
    public Map<String, Set<NavigationCase>> getNavigationCases()
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);

        if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
        {
            synchronized (this)
            {
                if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
                {
                    Collection<? extends NavigationRule> rules = runtimeConfig.getNavigationRules();
                    int rulesSize = rules.size();

                    Map<String, Set<NavigationCase>> cases = new HashMap<String, Set<NavigationCase>>(
                            HashMapUtils.calcCapacity(rulesSize));

                    List<String> wildcardKeys = new ArrayList<String>();

                    for (NavigationRule rule : rules)
                    {
                        String fromViewId = rule.getFromViewId();

                        //specification 7.4.2 footnote 4 - missing fromViewId is allowed:
                        if (fromViewId == null)
                        {
                            fromViewId = ASTERISK;
                        }
                        else
                        {
                            fromViewId = fromViewId.trim();
                        }

                        Set<NavigationCase> set = cases.get(fromViewId);
                        if (set == null)
                        {
                            set = new HashSet<NavigationCase>(convertNavigationCasesToAPI(rule));
                            cases.put(fromViewId, set);
                            if (fromViewId.endsWith(ASTERISK))
                            {
                                wildcardKeys.add(fromViewId);
                            }
                        }
                        else
                        {
                            set.addAll(convertNavigationCasesToAPI(rule));
                        }
                    }

                    Collections.sort(wildcardKeys, new KeyComparator());

                    synchronized (cases)
                    {
                        // We do not really need this sychronization at all, but this
                        // gives us the peace of mind that some good optimizing compiler
                        // will not rearrange the execution of the assignment to an
                        // earlier time, before all init code completes
                        _navigationCases = cases;
                        _wildcardKeys = wildcardKeys;

                        runtimeConfig.setNavigationRulesChanged(false);
                    }
                }
            }
        }
        return _navigationCases;
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

    }

    private void loadTextFacesConfig(String file) throws SAXException,
            IOException
    {
        RuntimeConfig runtimeConfig = RuntimeConfig
                .getCurrentInstance(externalContext);

        org.apache.myfaces.config.impl.digester.elements.FacesConfig config = _digesterFacesConfigUnmarshaller
                .getFacesConfig(getClass().getResourceAsStream(file), file);

        for (NavigationRule rule : config.getNavigationRules())
        {
            runtimeConfig.addNavigationRule(rule);
        }
    }
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

     * @param facesContext
     */
    private void _createEagerBeans(FacesContext facesContext)
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
        List<ManagedBean> eagerBeans = new ArrayList<ManagedBean>();
       
        // check all registered managed-beans
        for (ManagedBean bean : runtimeConfig.getManagedBeans().values())
        {
            String eager = bean.getEager();
            if (eager != null && "true".equals(eager))
            {
                // eager beans are only allowed for application scope
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

     * @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);
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

        // create and configure our ApplicationImpl instance
        FactoryFinder.setFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
                MockViewDeclarationLanguageFactory.class.getName());
        FactoryFinder.setFactory(FactoryFinder.FACELET_CACHE_FACTORY,
                FaceletCacheFactoryImpl.class.getName());
        RuntimeConfig runtimeConfig = new RuntimeConfig();
        _testApplication = new TestApplicationWrapper(new ApplicationImpl(runtimeConfig));
        facesContext.setApplication(_testApplication);
    }
View Full Code Here

Examples of org.apache.myfaces.config.RuntimeConfig

            }
            JspApplicationContext appCtx = jspFactory.getJspApplicationContext(servletContext);

            appCtx.addELContextListener(new FacesELContextListener());

            RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
            runtimeConfig.setExpressionFactory(appCtx.getExpressionFactory());

            ApplicationImpl.setInitializingRuntimeConfig(runtimeConfig);

            // And configure everything
            new FacesConfigurator(externalContext).configure();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.