FacesContextFactory (Java EE 5)

Java EE API


javax.faces.context Class FacesContextFactory

java.lang.Object
  extended by javax.faces.context.FacesContextFactory

public abstract class FacesContextFactory
extends Object


FacesContextFactory 是一个工厂对象,它创建(如果需要)并返回新的 FacesContext 实例,这些实例已经进行了初始化,以处理指定的请求和响应对象。实现可以调用分配的 FacesContext 实例的 release() 方法将其入池并回收,而不是每次都创建新的实例。

每个利用 JavaServer Faces 的 Web 应用程序都必须有一个 FacesContextFactory 实例。可以通过可移植的方式获取此实例,只需调用:

FacesContextFactory factory = (FacesContextFactory)
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
 
英文文档:

FacesContextFactory is a factory object that creates (if needed) and returns new FacesContext instances, initialized for the processing of the specified request and response objects. Implementations may take advantage of the calls to the release() method of the allocated FacesContext instances to pool and recycle them, rather than creating a new instance every time.

There must be one FacesContextFactory instance per web application that is utilizing JavaServer Faces. This instance can be acquired, in a portable manner, by calling:

   FacesContextFactory factory = (FacesContextFactory)
    FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
 


Constructor Summary
 
Method Summary
abstract  FacesContext
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public FacesContextFactory()
英文文档:

FacesContextFactory

public FacesContextFactory()
Method Detail

abstract public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle) throws FacesException

利用为此 Web 应用程序指定的 Lifecycle 实例创建(如果需要)并返回一个 FacesContext 实例,该实例已经进行了初始化,以处理指定的请求和响应对象。

此方法的实现必须确保,在对该实例调用 release() 方法之前,从调用此方法的线程调用 FacesContextgetCurrentInstance() 方法将返回相同的 FacesContext 实例。

context 在 servlet 环境中,与此 Web 应用程序关联的 ServletContext
request 在 servlet 环境中,将要处理的 ServletRequest
response 在 servlet 环境中,将要处理的 ServletResponse
lifecycle 用来处理此请求的 Lifecycle 实例
ThrowsFacesException: 如果无法为指定的参数构建 FacesContext
ThrowsNullPointerException: 如果有参数为 null
英文文档:

getFacesContext

public abstract FacesContext getFacesContext(Object context,
                                             Object request,
                                             Object response,
                                             Lifecycle lifecycle)
                                      throws FacesException

Create (if needed) and return a FacesContext instance that is initialized for the processing of the specified request and response objects, utilizing the specified Lifecycle instance, for this web application.

The implementation of this method must ensure that calls to the getCurrentInstance() method of FacesContext, from the same thread that called this method, will return the same FacesContext instance until the release() method is called on that instance.

Parameters:
context - In servlet environments, the ServletContext that is associated with this web application
request - In servlet environments, the ServletRequest that is to be processed
response - In servlet environments, the ServletResponse that is to be processed
lifecycle - The Lifecycle instance being used to process this request
Throws:
FacesException - if a FacesContext cannot be constructed for the specified parameters
NullPointerException - if any of the parameters are null


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!