📄 facescontextloader.java
字号:
/* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package de.mindmatters.faces.spring.context.servlet;import javax.faces.FacesException;import javax.faces.FactoryFinder;import javax.faces.context.FacesContext;import javax.faces.context.FacesContextFactory;import javax.faces.lifecycle.Lifecycle;import javax.faces.lifecycle.LifecycleFactory;import javax.servlet.ServletContext;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import de.mindmatters.faces.lifecycle.LifecycleImpl;/** * Performs the actual initialization work for a {@link FacesContext} which * contains all of the per-request state information. Called by * {@link FacesContextFilter} and {@link FacesDispatcherServlet}. * * @author Andreas Kuhrwahl * @see FacesContextFilter * @see FacesDispatcherServlet */public final class FacesContextLoader { /** The Singleton instance of the FacesContextLoader. */ private static final FacesContextLoader INSTANCE = new FacesContextLoader(); /** The JSF-Spring Lifecycle needed for FacesContext creation. */ private final Lifecycle lifecycle = ((LifecycleFactory) FactoryFinder .getFactory(FactoryFinder.LIFECYCLE_FACTORY)) .getLifecycle(LifecycleImpl.JSF_SPRING_LIFECYCLE_ID); /** The {@link FacesContextFactory} for FacesContext creation. */ private final FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); /** * Constructor. */ private FacesContextLoader() { super(); } /** * @return The singleton instance of FacesContextLoader. */ public static FacesContextLoader getCurrentInstance() { return INSTANCE; } /** * Create (if needed) and return a {@link FacesContext} instance that is * initialized for the processing of the specified request and response * objects. * * @param servletContext * the <code>ServletContext</code> that is associated with this * web * @param request * the <code>ServletRequest</code> that is to be processed * @param response * the <code>ServletResponse</code> that is to be processed * @return The {@link FacesContext} instance * @throws ServletException * if a {@link FacesContext} cannot be constructed for the * specified parameters * @see FacesContextFactory#getFacesContext(Object, Object, Object, * Lifecycle) */ public FacesContext initFacesContext(final ServletContext servletContext, final ServletRequest request, final ServletResponse response) throws ServletException { try { return this.facesContextFactory.getFacesContext(servletContext, request, response, this.lifecycle); } catch (FacesException ex) { throw new ServletException(ex); } } /** * Release any resources associated with the given <code>FacesContext</code> * instance. * * @param context * the FacesContext which contains per-request state information * @see FacesContext#release() */ public void releaseFacesContext(final FacesContext context) { context.release(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -