public void releaseCurrentInstance() { removeInitContextEntryForCurrentThread(); setCurrentInstance(null); }
public InitFacesContext(ServletContext sc) { ec = new ServletContextAdapter(sc); sc.setAttribute(INIT_FACES_CONTEXT_ATTR_NAME, this); InitFacesContext.cleanupInitMaps(sc); getThreadInitContextMap().put(Thread.currentThread(), this); getInitContextServletContextMap().put(this, sc); }
public void releaseCurrentInstance() { Map <Thread, InitFacesContext>threadInitContext = InitFacesContext.getThreadInitContextMap(); threadInitContext.remove(Thread.currentThread()); setCurrentInstance(null); }
public InitFacesContext(ServletContext servletContext) { servletContextAdapter = new ServletContextAdapter(servletContext); servletContext.setAttribute(INIT_FACES_CONTEXT_ATTR_NAME, this); InitFacesContext.cleanupInitMaps(servletContext); addServletContextEntryForInitContext(servletContext); addInitContextEntryForCurrentThread(); }
initContext = getInitFacesContext(context); if (initContext == null) { initContext = new InitFacesContext(context); } else { InitFacesContext.getThreadInitContextMap().put(Thread.currentThread(), initContext); ELContext elContext = new ELContextImpl(initContext.getApplication().getELResolver()); elContext.putContext(FacesContext.class, initContext); ExpressionFactory exFactory = ELUtils.getDefaultExpressionFactory(initContext); initContext.setELContext(elContext); Application application = initContext.getApplication(); ReflectionUtils.clearCache(Thread.currentThread().getContextClassLoader()); WebConfiguration.clear(context); InitFacesContext.cleanupInitMaps(context);
InitFacesContext initContext = new InitFacesContext(context); configManager.destroy(context, initContext); ConfigManager.removeInstance(context); InitFacesContext.cleanupInitMaps(context); ELContext elContext = new ELContextImpl(initContext.getApplication().getELResolver()); elContext.putContext(FacesContext.class, initContext); ExpressionFactory exFactory = getDefaultExpressionFactory(associate, initContext); initContext.setELContext(elContext); initContext.releaseCurrentInstance();
@Override public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException { Set<Class<?>> annotatedClasses = new HashSet<Class<?>>(); if (classes != null) { annotatedClasses.addAll(classes); } servletContext.setAttribute(ANNOTATED_CLASSES, annotatedClasses); boolean appHasSomeJsfContent = appMayHaveSomeJsfContent(classes, servletContext); boolean appHasFacesServlet = getExistingFacesServletRegistration(servletContext) != null; if (appHasSomeJsfContent || appHasFacesServlet) { InitFacesContext initFacesContext = new InitFacesContext(servletContext); try { if (appHasSomeJsfContent) { // Only look at mapping concerns if there is JSF content handleMappingConcerns(servletContext); } // Other concerns also handled if there is an existing Faces Servlet mapping handleWebSocketConcerns(servletContext); } finally { // Bug 20458755: The InitFacesContext was not being cleaned up, resulting in // a partially constructed FacesContext being made available // to other code that re-uses this Thread at init time. initFacesContext.releaseCurrentInstance(); initFacesContext.release(); } } }
InitFacesContext initContext = new InitFacesContext(context); configManager.destroy(context); ConfigManager.removeInstance(context); InitFacesContext.cleanupInitMaps(context); return; ApplicationAssociate associate = ApplicationAssociate.getInstance(context); ELContext elctx = new ELContextImpl(initContext.getApplication().getELResolver()); elctx.putContext(FacesContext.class, initContext); ExpressionFactory exFactory = ELUtils.getDefaultExpressionFactory(associate, initContext); elctx.putContext(ExpressionFactory.class, exFactory); initContext.setELContext(elctx); if (associate != null) { associate.setContextName(getServletContextIdentifier(context)); initContext.removeInitContextEntryForCurrentThread();
InjectionProvider containerConnector = InjectionProviderFactory.createInstance(facesContext.getExternalContext()); facesContext.getAttributes().put(INJECTION_PROVIDER_KEY, containerConnector); if (currentThreadId != parentThreadId) { Thread.currentThread().setContextClassLoader(parentContextClassLoader); initFacesContext = InitFacesContext.getInstance(servletContext); if (parentWebContext != null) { threadContext.propagateWebContextToChild(parentWebContext);
e.printStackTrace(); } finally { FacesContext initContext = new InitFacesContext(servletContext); ApplicationAssociate.clearInstance(initContext.getExternalContext()); ApplicationAssociate.setCurrentInstance(null); InitFacesContext initContext = new InitFacesContext(servletContext); ReflectionUtils.initCache(Thread.currentThread().getContextClassLoader()); e.printStackTrace(); } finally { initContext.release();
Map<InitFacesContext, ServletContext> facesContext2ServletContext = getInitContextServletContextMap(); Map<Thread, InitFacesContext> thread2FacesContext = getThreadInitContextMap();
/** * Publishes a {@link javax.faces.event.PostConstructApplicationEvent} event for the current * {@link Application} instance. */ void publishPostConfigEvent() { FacesContext ctx = FacesContext.getCurrentInstance(); Application app = ctx.getApplication(); if (null == ((InitFacesContext) ctx).getELContext()) { ELContext elContext = new ELContextImpl(app.getELResolver()); elContext.putContext(FacesContext.class, ctx); ExpressionFactory exFactory = ELUtils.getDefaultExpressionFactory(ctx); if (null != exFactory) { elContext.putContext(ExpressionFactory.class, exFactory); } UIViewRoot root = ctx.getViewRoot(); if (null != root) { elContext.setLocale(root.getLocale()); } ELContextListener[] listeners = app.getELContextListeners(); if (listeners.length > 0) { ELContextEvent event = new ELContextEvent(elContext); for (ELContextListener listener : listeners) { listener.contextCreated(event); } } ((InitFacesContext) ctx).setELContext(elContext); } app.publishEvent(ctx, PostConstructApplicationEvent.class, Application.class, app); }
FacesContext initContext = new InitFacesContext(context); ApplicationAssociate .clearInstance(initContext.getExternalContext());
public void addServletContextEntryForInitContext(ServletContext servletContext) { getInitContextServletContextMap().put(this, servletContext); }
public void release() { setCurrentInstance(orig); }
void removeInitContextEntryForCurrentThread() { Map <Thread, InitFacesContext>threadInitContext = InitFacesContext.getThreadInitContextMap(); Thread currentThread = Thread.currentThread(); if (threadInitContext.containsKey(currentThread)) { threadInitContext.remove(currentThread); } }
InjectionProviderFactory.createInstance(context.getExternalContext()); context.getAttributes().put(INJECTION_PROVIDER_KEY, containerConnector);
@Override public boolean isProjectStage(ProjectStage stage) { if (stage == null) { throw new NullPointerException(); } return stage.equals(getApplication().getProjectStage()); }
initContext = getInitFacesContext(context); if (initContext == null) { initContext = new InitFacesContext(context); } else { InitFacesContext.getThreadInitContextMap().put(Thread.currentThread(), initContext); ELContext elContext = new ELContextImpl(initContext.getApplication().getELResolver()); elContext.putContext(FacesContext.class, initContext); ExpressionFactory exFactory = ELUtils.getDefaultExpressionFactory(initContext); initContext.setELContext(elContext); Application application = initContext.getApplication(); ReflectionUtils.clearCache(Thread.currentThread().getContextClassLoader()); WebConfiguration.clear(context); InitFacesContext.cleanupInitMaps(context);
InitFacesContext initContext = new InitFacesContext(context); configManager.destroy(context, initContext); ConfigManager.removeInstance(context); InitFacesContext.cleanupInitMaps(context); ELContext elContext = new ELContextImpl(initContext.getApplication().getELResolver()); elContext.putContext(FacesContext.class, initContext); ExpressionFactory exFactory = getDefaultExpressionFactory(associate, initContext); initContext.setELContext(elContext); initContext.releaseCurrentInstance();