Examples of ApplicationAssociate


Examples of com.sun.faces.application.ApplicationAssociate

                                   session.getId());
                    }
                    session.invalidate();
                }
            }
            ApplicationAssociate associate = ApplicationAssociate.getInstance(sc);
            if (associate != null) {
                BeanManager manager = associate.getBeanManager();
                for (Map.Entry<String,BeanBuilder> entry : manager.getRegisteredBeans().entrySet()) {
                    String name = entry.getKey();
                    BeanBuilder bean = entry.getValue();
                    if (bean.getScope() == ELUtils.Scope.APPLICATION) {
                        if (LOGGER.isLoggable(Level.INFO)) {
                            LOGGER.log(Level.INFO,
                                       "Removing application scoped managed bean: {0}",
                                       name);
                        }
                        sc.removeAttribute(name);
                    }

                }
            }
            // Release any allocated application resources
            FactoryFinder.releaseFactories();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            FacesContext initContext = new InitFacesContext(sc);
            ApplicationAssociate
                  .clearInstance(initContext.getExternalContext());
            ApplicationAssociate.setCurrentInstance(null);
            // Release the initialization mark on this web application
            ConfigManager.getInstance().destory(sc);
            initContext.release();
            ReflectionUtils.clearCache(Thread.currentThread().getContextClassLoader());
            WebConfiguration.clear(sc);
        }

        // bring the application back up, avoid re-registration of certain JSP
        // artifacts.  No verification will be performed either to make this
        // light weight.

        // init a new WebAppLifecycleListener so that the cached ApplicationAssociate
        // is removed.
        webAppListener = new WebappLifecycleListener(sc);

        FacesContext initContext = new InitFacesContext(sc);
        ReflectionUtils
              .initCache(Thread.currentThread().getContextClassLoader());

        try {
            ConfigManager configManager = ConfigManager.getInstance();
            configManager.initialize(sc);


            registerELResolverAndListenerWithJsp(sc, true);
            ApplicationAssociate associate =
                  ApplicationAssociate.getInstance(sc);
            if (associate != null) {
                associate.setContextName(getServletContextIdentifier(sc));
            }
            RenderKitUtils.loadSunJsfJs(initContext.getExternalContext());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

           
            // register an empty resolver for now. It will be populated after the
            // first request is serviced.
            FacesCompositeELResolver compositeELResolverForJsp =
                    new ChainTypeCompositeELResolver(FacesCompositeELResolver.ELResolverChainType.JSP);
            ApplicationAssociate associate =
                     ApplicationAssociate.getInstance(context);
            if (associate != null) {
                associate.setFacesELResolverForJsp(compositeELResolverForJsp);
            }
                   
            // get JspApplicationContext.
            JspApplicationContext jspAppContext = JspFactory.getDefaultFactory()
                    .getJspApplicationContext(context);
   
            // cache the ExpressionFactory instance in ApplicationAssociate
            if (associate != null) {
                associate.setExpressionFactory(jspAppContext.getExpressionFactory());
            }
   
            // register compositeELResolver with JSP
            try {
                jspAppContext.addELResolver(compositeELResolverForJsp);
View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

            return false;
        }
        try {
            ExpressionFactory factory = (ExpressionFactory)
                  Util.loadClass(elFactoryType, this).newInstance();
            ApplicationAssociate associate =
                 ApplicationAssociate.getInstance(sc);
            if (associate != null) {
                associate.setExpressionFactory(factory);
            }
            return true;
        } catch (Exception e) {
            if (LOGGER.isLoggable(Level.SEVERE)) {
                LOGGER.severe(MessageFormat.format("Unable to instantiate ExpressionFactory ''{0}''",
View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

     */
    public void destroyBeans(FacesContext facesContext, Map<String, Object> viewMap) {
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.log(Level.FINEST, "Destroying @ViewScoped beans from view map: {0}", viewMap);
        }
        ApplicationAssociate applicationAssociate = ApplicationAssociate.getInstance(facesContext.getExternalContext());
        if (applicationAssociate != null) {
            destroyBeans(applicationAssociate, viewMap);
        }
    }
View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

        HttpSession session = hse.getSession();
        Map<String, Object> activeViewMaps = (Map<String, Object>) session.getAttribute(ACTIVE_VIEW_MAPS);
        if (activeViewMaps != null) {
            Iterator<Object> activeViewMapsIterator = activeViewMaps.values().iterator();
            ApplicationAssociate applicationAssociate = ApplicationAssociate.getInstance(hse.getSession().getServletContext());
            while (activeViewMapsIterator.hasNext()) {
                Map<String, Object> viewMap = (Map<String, Object>) activeViewMapsIterator.next();
                destroyBeans(applicationAssociate, viewMap);
            }
View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

                                           List<Node> navigationCases,
                                           NavigationHandler navHandler,
                                           ServletContext sc) {

        if (navigationCases != null && !navigationCases.isEmpty()) {
            ApplicationAssociate associate =
                 ApplicationAssociate.getInstance(sc);

            for (Node navigationCase : navigationCases) {
                if (navigationCase.getNodeType() != Node.ELEMENT_NODE) {
                    continue;
                }
                NodeList children = navigationCase.getChildNodes();
                String outcome = null;
                String action = null;
                String condition = null;
                String toViewId = null;
                Map<String,List<String>> parameters = null;
                boolean redirect = false;
                boolean includeViewParams = false;
                for (int i = 0, size = children.getLength(); i < size; i++) {
                    Node n = children.item(i);
                    if (n.getNodeType() == Node.ELEMENT_NODE) {
                        if (FROM_OUTCOME.equals(n.getLocalName())) {
                            outcome = getNodeText(n);
                        } else if (FROM_ACTION.equals(n.getLocalName())) {
                            action = getNodeText(n);
                        } else if (IF.equals(n.getLocalName())) {
                            String expression = getNodeText(n);
                            if (SharedUtils.isExpression(expression) && !SharedUtils.isMixedExpression(expression)) {
                                condition = expression;
                            }
                            else {
                                if (LOGGER.isLoggable(Level.WARNING)) {
                                    LOGGER.log(Level.WARNING,
                                               "jsf.config.navigation.if_invalid_expression",
                                               new String[] { expression, fromViewId });
                                }
                            }
                        } else if (TO_VIEW_ID.equals(n.getLocalName())) {
                            String toViewIdString = getNodeText(n);
                            if (toViewIdString.charAt(0) != '/' && toViewIdString.charAt(0) != '#') {
                                if (LOGGER.isLoggable(Level.WARNING)) {
                                    LOGGER.log(Level.WARNING,
                                               "jsf.config.navigation.to_view_id_leading_slash",
                                               new String[] { toViewIdString,
                                                              fromViewId });
                                }
                                toViewId = '/' + toViewIdString;
                            } else {
                                toViewId = toViewIdString;
                            }
                        } else if (REDIRECT.equals(n.getLocalName())) {
                            parameters = processParameters(n.getChildNodes());
                            includeViewParams = isIncludeViewParams(n);
                            redirect = true;
                        }
                    }
                }

                NavigationCase cnc =
                     new NavigationCase(fromViewId,
                                        action,
                                        outcome,
                                        condition,
                                        toViewId,
                                        parameters,
                                        redirect,
                                        includeViewParams);
                if (LOGGER.isLoggable(Level.FINE)) {
                    LOGGER.log(Level.FINE,
                               MessageFormat.format("Adding NavigationCase: {0}",
                                                    cnc.toString()));
                }

                // if the top-level NavigationHandler is an instance of
                // ConfigurableNavigationHandler, add the NavigationCases to
                // that instance as well as adding them to the application associate.
                // We have to add them to the ApplicationAssociate in the case
                // where the top-level NavigationHandler may be custom and delegates
                // to the default NavigationHandler implementation.  In 1.2, they
                // could be guaranteed that the default implementation had all
                // defined navigation mappings.
                if (navHandler instanceof ConfigurableNavigationHandler) {
                    ConfigurableNavigationHandler cnav = (ConfigurableNavigationHandler) navHandler;
                    Set<NavigationCase> cases = cnav.getNavigationCases().get(fromViewId);
                    if (cases == null) {
                        cases = new LinkedHashSet<NavigationCase>();
                        cnav.getNavigationCases().put(fromViewId, cases);
                    }
                    cases.add(cnc);
                }
                associate.addNavigationCase(cnc);
               
            }


        }
View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

     */
    public static StateContext getStateContext(FacesContext ctx) {

        StateContext stateCtx = (StateContext) ctx.getAttributes().get(KEY);
        if (stateCtx == null) {
            ApplicationAssociate associate = ApplicationAssociate.getCurrentInstance();
            ApplicationStateInfo info = associate.getApplicationStateInfo();
            stateCtx = new StateContext(info);
            ctx.getAttributes().put(KEY, stateCtx);
        }
        return stateCtx;

View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

     * @see ConfigProcessor#process(javax.servlet.ServletContext,com.sun.faces.config.DocumentInfo[])
     */
    public void process(ServletContext sc, DocumentInfo[] documentInfos)
    throws Exception {

        ApplicationAssociate associate =
              ApplicationAssociate.getInstance(FacesContext.getCurrentInstance().getExternalContext());
        assert (associate != null);
        Compiler compiler = associate.getCompiler();

        for (int i = 0, length = documentInfos.length; i < length; i++) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE,
                           MessageFormat.format(
View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

     * @see com.sun.faces.application.annotation.ConfigAnnotationHandler#push(javax.faces.context.FacesContext)
     */
    public void push(FacesContext ctx) {

        if (managedBeans != null) {
            ApplicationAssociate associate =
                  ApplicationAssociate.getInstance(ctx.getExternalContext());
            if (associate != null) {
                BeanManager manager = associate.getBeanManager();
                for (Map.Entry<Class<?>,Annotation> entry : managedBeans.entrySet()) {
                    process(manager, entry.getKey(), entry.getValue());
                }
            }
        }
View Full Code Here

Examples of com.sun.faces.application.ApplicationAssociate

        FacesContext fc = FacesContext.getCurrentInstance();
        if (fc.getPartialViewContext().isAjaxRequest()) {
            return new AjaxExceptionHandlerImpl(new ExceptionHandlerImpl(Boolean.TRUE));
        }
        ApplicationAssociate associate = getAssociate(fc);
        return new ExceptionHandlerImpl(((associate != null) ? associate.isErrorPagePresent() : Boolean.TRUE));

    }
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.