javax.faces.context.FacesContextFactory Maven / Gradle / Ivy
Show all versions of jboss-javaee-all-8.0
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package javax.faces.context;
import javax.faces.FacesException;
import javax.faces.FacesWrapper;
import javax.faces.lifecycle.Lifecycle;
/**
* FacesContextFactory
* is a factory object that creates
* (if needed) and returns new {@link 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 {@link 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);
*
*
* Usage: extend this class and push the implementation being wrapped to the
* constructor and use {@link #getWrapped} to access the instance being wrapped.
*
*/
public abstract class FacesContextFactory implements FacesWrapper {
private FacesContextFactory wrapped;
/**
* @deprecated Use the other constructor taking the implementation being wrapped.
*/
@Deprecated
public FacesContextFactory() {
}
/**
* If this factory has been decorated,
* the implementation doing the decorating should push the implementation being wrapped to this constructor.
* The {@link #getWrapped()} will then return the implementation being wrapped.
*
* @param wrapped The implementation being wrapped.
*/
public FacesContextFactory(FacesContextFactory wrapped) {
this.wrapped = wrapped;
}
/**
* If this factory has been decorated, the
* implementation doing the decorating may override this method to provide
* access to the implementation being wrapped.
*
* @since 2.0
*/
@Override
public FacesContextFactory getWrapped() {
return wrapped;
}
/**
* Create (if needed)
* and return a {@link FacesContext} instance that is initialized
* for the processing of the specified request and response objects,
* utilizing the specified {@link Lifecycle} instance, for this web
* application.
*
* The implementation of this method must ensure that calls to the
* getCurrentInstance()
method of {@link FacesContext},
* from the same thread that called this method, will return the same
* {@link FacesContext} instance until the release()
* method is called on that instance.
* The implementation must call
* {@link ExternalContextFactory#getExternalContext} to produce the
* {@link ExternalContext} for the {@link FacesContext} instance.
* The default implementation must call
* {@link ExceptionHandlerFactory#getExceptionHandler} and make it
* so the return from that method is what gets returned from a call
* to {@link FacesContext#getExceptionHandler} on the returned
* FacesContext
instance.
*
* The default implementation must call
* {@link javax.faces.lifecycle.ClientWindowFactory#getClientWindow} and make it
* so the return from that method is what gets returned from a call
* to {@link ExternalContext#getClientWindow()} on the returned
* ExternalContext
instance.
*
* @param context In servlet environments, the
* ServletContext
that is associated with this web
* application
* @param request In servlet environments, the
* ServletRequest
that is to be processed
* @param response In servlet environments, the
* ServletResponse
that is to be processed
* @param lifecycle The {@link Lifecycle} instance being used
* to process this request
*
* @return the instance of FacesContext
.
*
* @throws FacesException if a {@link FacesContext} cannot be
* constructed for the specified parameters
* @throws NullPointerException if any of the parameters
* are null
*/
public abstract FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle) throws FacesException;
}