Examples of InitFacesContext


Examples of com.sun.faces.config.InitFacesContext

            WebConfiguration config = WebConfiguration.getInstance(event.getServletContext());
            if (config.isOptionEnabled(WebConfiguration.BooleanWebContextInitParameter.EnableAgressiveSessionDirtying)) {
                syncSessionScopedBeans(request);
            }
        } catch (Throwable t) {
            FacesContext context = new InitFacesContext(event.getServletContext());
            ExceptionQueuedEventContext eventContext =
                    new ExceptionQueuedEventContext(context, t);
            context.getApplication().publishEvent(context,
                    ExceptionQueuedEvent.class, eventContext);
            context.getExceptionHandler().handle();
        }
        finally {
            ApplicationAssociate.setCurrentInstance(null);
        }
    }
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext


    public void onStartup(Set<Class<?>> classes, ServletContext servletContext)
        throws ServletException {

        InitFacesContext initFacesContext = new InitFacesContext(servletContext);

        if (shouldCheckMappings(classes, servletContext)) {


            Map<String,? extends ServletRegistration> existing = servletContext.getServletRegistrations();
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext

            WebConfiguration config = WebConfiguration.getInstance(event.getServletContext());
            if (config.isOptionEnabled(WebConfiguration.BooleanWebContextInitParameter.EnableAgressiveSessionDirtying)) {
                syncSessionScopedBeans(request);
            }
        } catch (Throwable t) {
            FacesContext context = new InitFacesContext(event.getServletContext());
            ExceptionQueuedEventContext eventContext =
                    new ExceptionQueuedEventContext(context, t);
            context.getApplication().publishEvent(context,
                    ExceptionQueuedEvent.class, eventContext);
            context.getExceptionHandler().handle();
        }
        finally {
            ApplicationAssociate.setCurrentInstance(null);
        }
    }
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext

        Timer timer = Timer.getInstance();
        if (timer != null) {
            timer.startTiming();
        }

        InitFacesContext initContext = new InitFacesContext(context);

        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.log(Level.FINE,
                    MessageFormat.format(
                            "ConfigureListener.contextInitialized({0})",
                            getServletContextIdentifier(context)));
        }

        webConfig = WebConfiguration.getInstance(context);
        ConfigManager configManager = ConfigManager.getInstance();

        if (configManager.hasBeenInitialized(context)) {
            return;
        }

        // Check to see if the FacesServlet is present in the
        // web.xml.   If it is, perform faces configuration as normal,
        // otherwise, simply return.
        Object mappingsAdded = context.getAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED);
        if (mappingsAdded != null) {
            context.removeAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED);
        }

        WebXmlProcessor webXmlProcessor = new WebXmlProcessor(context);
        if (mappingsAdded == null) {
            if (!webXmlProcessor.isFacesServletPresent()) {
                if (!webConfig.isOptionEnabled(ForceLoadFacesConfigFiles)) {
                    if (LOGGER.isLoggable(Level.FINE)) {
                        LOGGER.log(Level.FINE,
                                "No FacesServlet found in deployment descriptor - bypassing configuration");
                    }
                    WebConfiguration.clear(context);
                    return;
                }
            } else {
                if (LOGGER.isLoggable(Level.FINE)) {
                    LOGGER.log(Level.FINE,
                            "FacesServlet found in deployment descriptor - processing configuration.");
                }
            }
        }


        // bootstrap of faces required
        webAppListener = new WebappLifecycleListener(context);
        webAppListener.contextInitialized(sce);
        ReflectionUtils.initCache(Thread.currentThread().getContextClassLoader());
        Throwable caughtThrowable = null;

        try {

            if (LOGGER.isLoggable(Level.INFO)) {
                LOGGER.log(Level.INFO,
                        "jsf.config.listener.version",
                        getServletContextIdentifier(context));
            }

            // see if we need to disable our TLValidator
            Util.setHtmlTLVActive(
                    webConfig.isOptionEnabled(EnableHtmlTagLibraryValidator));

            if (webConfig.isOptionEnabled(VerifyFacesConfigObjects)) {
                if (LOGGER.isLoggable(Level.WARNING)) {
                    LOGGER.warning("jsf.config.verifyobjects.development_only");
                }
                // if we're verifying, force bean validation to occur at startup as well
                webConfig.overrideContextInitParameter(EnableLazyBeanValidation, false);
                Verifier.setCurrentInstance(new Verifier());
            }
            initScripting();
            configManager.initialize(context);
            if (shouldInitConfigMonitoring()) {
                initConfigMonitoring(context);
            }

            // Step 7, verify that all the configured factories are available
            // and optionall that configured objects can be created.
            Verifier v = Verifier.getCurrentInstance();
            if (v != null && !v.isApplicationValid()) {
                if (LOGGER.isLoggable(Level.SEVERE)) {
                    LOGGER.severe("jsf.config.verifyobjects.failures_detected");
                    StringBuilder sb = new StringBuilder(128);
                    for (String m : v.getMessages()) {
                        sb.append(m).append('\n');
                    }
                    LOGGER.severe(sb.toString());
                }
            }
            registerELResolverAndListenerWithJsp(context, false);
            ELContext elctx = new ELContextImpl(initContext.getApplication().getELResolver());
            elctx.putContext(FacesContext.class, initContext);
            initContext.setELContext(elctx);
            ApplicationAssociate associate =
                    ApplicationAssociate.getInstance(context);
            if (associate != null) {
                associate.setContextName(getServletContextIdentifier(context));
                BeanManager manager = associate.getBeanManager();
                List<String> eagerBeans = manager.getEagerBeanNames();
                if (!eagerBeans.isEmpty()) {
                    for (String name : eagerBeans) {
                        manager.create(name, initContext);
                    }
                }
                boolean isErrorPagePresent = webXmlProcessor.isErrorPagePresent();
                associate.setErrorPagePresent(isErrorPagePresent);
                context.setAttribute(RIConstants.ERROR_PAGE_PRESENT_KEY_NAME,
                        isErrorPagePresent);

            }
            Application app = initContext.getApplication();
            app.subscribeToEvent(PostConstructViewMapEvent.class,
                    UIViewRoot.class,
                    webAppListener);
            app.subscribeToEvent(PreDestroyViewMapEvent.class,
                    UIViewRoot.class,
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext

    }


    public void contextDestroyed(ServletContextEvent sce) {
        ServletContext context = sce.getServletContext();
        InitFacesContext initContext = null;
        try {
            initContext = getInitFacesContext(context);
            if (null == initContext) {
                initContext = new InitFacesContext(context);
            }

            if (webAppListener != null) {
                webAppListener.contextDestroyed(sce);
                webAppListener = null;
            }
            if (webResourcePool != null) {
                webResourcePool.shutdownNow();
            }
            if (!ConfigManager.getInstance().hasBeenInitialized(context)) {
                return;
            }
            GroovyHelper helper = GroovyHelper.getCurrentInstance(context);
            if (helper != null) {
                helper.setClassLoader();
            }
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE,
                           "ConfigureListener.contextDestroyed({0})",
                           context.getServletContextName());
            }


            ELContext elctx = new ELContextImpl(initContext.getApplication().getELResolver());
            elctx.putContext(FacesContext.class, initContext);
            initContext.setELContext(elctx);
            Application app = initContext.getApplication();
            app.publishEvent(initContext,
                    PreDestroyApplicationEvent.class,
                    Application.class,
                    app);
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext

            // 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().destroy(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) {
                Boolean errorPagePresent = (Boolean) sc.getAttribute(RIConstants.ERROR_PAGE_PRESENT_KEY_NAME);
                if (null != errorPagePresent) {
                    associate.setErrorPagePresent(errorPagePresent);
                    associate.setContextName(getServletContextIdentifier(sc));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            initContext.release();
        }

        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.log(Level.INFO,
                    "Reload complete.",
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext


    private InitFacesContext getInitFacesContext(ServletContext context) {
        Map initContextServletContext = InitFacesContext.getInitContextServletContextMap();
        Set entries = initContextServletContext.entrySet();
        InitFacesContext initContext = null;
        for (Iterator iterator1 = entries.iterator(); iterator1.hasNext();) {
            Map.Entry entry1 = (Map.Entry)iterator1.next();
            Object initContextKey = entry1.getKey();
            Object value1 = entry1.getValue();
            if (context == value1) {
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext

            WebConfiguration config = WebConfiguration.getInstance(event.getServletContext());
            if (config.isOptionEnabled(WebConfiguration.BooleanWebContextInitParameter.EnableAgressiveSessionDirtying)) {
                syncSessionScopedBeans(request);
            }
        } catch (Throwable t) {
            FacesContext context = new InitFacesContext(event.getServletContext());
            ExceptionQueuedEventContext eventContext =
                    new ExceptionQueuedEventContext(context, t);
            context.getApplication().publishEvent(context,
                    ExceptionQueuedEvent.class, eventContext);
            context.getExceptionHandler().handle();
        }
        finally {
            ApplicationAssociate.setCurrentInstance(null);
        }
    }
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext


    private InitFacesContext getInitFacesContext(ServletContext context) {
        Map initContextServletContext = InitFacesContext.getInitContextServletContextMap();
        Set entries = initContextServletContext.entrySet();
        InitFacesContext initContext = null;
        for (Iterator iterator1 = entries.iterator(); iterator1.hasNext();) {
            Map.Entry entry1 = (Map.Entry)iterator1.next();
            Object initContextKey = entry1.getKey();
            Object value1 = entry1.getValue();
            if (context == value1) {
View Full Code Here

Examples of com.sun.faces.config.InitFacesContext

        Timer timer = Timer.getInstance();
        if (timer != null) {
            timer.startTiming();
        }

        InitFacesContext initContext = new InitFacesContext(context);

        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.log(Level.FINE,
                    MessageFormat.format(
                            "ConfigureListener.contextInitialized({0})",
                            getServletContextIdentifier(context)));
        }

        webConfig = WebConfiguration.getInstance(context);
        ConfigManager configManager = ConfigManager.getInstance();

        if (configManager.hasBeenInitialized(context)) {
            return;
        }

        // Check to see if the FacesServlet is present in the
        // web.xml.   If it is, perform faces configuration as normal,
        // otherwise, simply return.
        Object mappingsAdded = context.getAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED);
        if (mappingsAdded != null) {
            context.removeAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED);
        }

        WebXmlProcessor webXmlProcessor = new WebXmlProcessor(context);
        if (mappingsAdded == null) {
            if (!webXmlProcessor.isFacesServletPresent()) {
                if (!webConfig.isOptionEnabled(ForceLoadFacesConfigFiles)) {
                    if (LOGGER.isLoggable(Level.FINE)) {
                        LOGGER.log(Level.FINE,
                                "No FacesServlet found in deployment descriptor - bypassing configuration");
                    }
                    WebConfiguration.clear(context);
                    return;
                }
            } else {
                if (LOGGER.isLoggable(Level.FINE)) {
                    LOGGER.log(Level.FINE,
                            "FacesServlet found in deployment descriptor - processing configuration.");
                }
            }
        }


        // bootstrap of faces required
        webAppListener = new WebappLifecycleListener(context);
        webAppListener.contextInitialized(sce);
        ReflectionUtils.initCache(Thread.currentThread().getContextClassLoader());
        Throwable caughtThrowable = null;

        try {

            if (LOGGER.isLoggable(Level.INFO)) {
                LOGGER.log(Level.INFO,
                        "jsf.config.listener.version",
                        getServletContextIdentifier(context));
            }

            // see if we need to disable our TLValidator
            Util.setHtmlTLVActive(
                    webConfig.isOptionEnabled(EnableHtmlTagLibraryValidator));

            if (webConfig.isOptionEnabled(VerifyFacesConfigObjects)) {
                if (LOGGER.isLoggable(Level.WARNING)) {
                    LOGGER.warning("jsf.config.verifyobjects.development_only");
                }
                // if we're verifying, force bean validation to occur at startup as well
                webConfig.overrideContextInitParameter(EnableLazyBeanValidation, false);
                Verifier.setCurrentInstance(new Verifier());
            }
            initScripting();
            configManager.initialize(context);
            if (shouldInitConfigMonitoring()) {
                initConfigMonitoring(context);
            }

            // Step 7, verify that all the configured factories are available
            // and optionall that configured objects can be created.
            Verifier v = Verifier.getCurrentInstance();
            if (v != null && !v.isApplicationValid()) {
                if (LOGGER.isLoggable(Level.SEVERE)) {
                    LOGGER.severe("jsf.config.verifyobjects.failures_detected");
                    StringBuilder sb = new StringBuilder(128);
                    for (String m : v.getMessages()) {
                        sb.append(m).append('\n');
                    }
                    LOGGER.severe(sb.toString());
                }
            }
            registerELResolverAndListenerWithJsp(context, false);
            ELContext elctx = new ELContextImpl(initContext.getApplication().getELResolver());
            elctx.putContext(FacesContext.class, initContext);
            initContext.setELContext(elctx);
            ApplicationAssociate associate =
                    ApplicationAssociate.getInstance(context);
            if (associate != null) {
                associate.setContextName(getServletContextIdentifier(context));
                BeanManager manager = associate.getBeanManager();
                List<String> eagerBeans = manager.getEagerBeanNames();
                if (!eagerBeans.isEmpty()) {
                    for (String name : eagerBeans) {
                        manager.create(name, initContext);
                    }
                }
                boolean isErrorPagePresent = webXmlProcessor.isErrorPagePresent();
                associate.setErrorPagePresent(isErrorPagePresent);
                context.setAttribute(RIConstants.ERROR_PAGE_PRESENT_KEY_NAME,
                        isErrorPagePresent);

            }
            Application app = initContext.getApplication();
            app.subscribeToEvent(PostConstructViewMapEvent.class,
                    UIViewRoot.class,
                    webAppListener);
            app.subscribeToEvent(PreDestroyViewMapEvent.class,
                    UIViewRoot.class,
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.