1 /*
2 * $Id: FacesContextFactory.java,v 1.19 2007/04/27 22:00:06 ofung Exp $
3 */
4
5 /*
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
7 *
8 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
9 *
10 * The contents of this file are subject to the terms of either the GNU
11 * General Public License Version 2 only ("GPL") or the Common Development
12 * and Distribution License("CDDL") (collectively, the "License"). You
13 * may not use this file except in compliance with the License. You can obtain
14 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
15 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
16 * language governing permissions and limitations under the License.
17 *
18 * When distributing the software, include this License Header Notice in each
19 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
20 * Sun designates this particular file as subject to the "Classpath" exception
21 * as provided by Sun in the GPL Version 2 section of the License file that
22 * accompanied this code. If applicable, add the following below the License
23 * Header, with the fields enclosed by brackets [] replaced by your own
24 * identifying information: "Portions Copyrighted [year]
25 * [name of copyright owner]"
26 *
27 * Contributor(s):
28 *
29 * If you wish your version of this file to be governed by only the CDDL or
30 * only the GPL Version 2, indicate your decision by adding "[Contributor]
31 * elects to include this software in this distribution under the [CDDL or GPL
32 * Version 2] license." If you don't indicate a single choice of license, a
33 * recipient has the option to distribute your version of this file under
34 * either the CDDL, the GPL Version 2 or to extend the choice of license to
35 * its licensees as provided above. However, if you add GPL Version 2 code
36 * and therefore, elected the GPL Version 2 license, then the option applies
37 * only if the new code is made subject to such option by the copyright
38 * holder.
39 */
40
41 package javax.faces.context;
42
43 import javax.faces.FacesException;
44 import javax.faces.lifecycle.Lifecycle;
45
46
47 /**
48 * <p><strong>FacesContextFactory</strong> is a factory object that creates
49 * (if needed) and returns new {@link FacesContext} instances, initialized
50 * for the processing of the specified request and response objects.
51 * Implementations may take advantage of the calls to the
52 * <code>release()</code> method of the allocated {@link FacesContext}
53 * instances to pool and recycle them, rather than creating a new instance
54 * every time.</p>
55 *
56 * <p>There must be one <code>FacesContextFactory</code> instance per web
57 * application that is utilizing JavaServer Faces. This instance can be
58 * acquired, in a portable manner, by calling:</p>
59 * <pre>
60 * FacesContextFactory factory = (FacesContextFactory)
61 * FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
62 * </pre>
63 */
64
65 public abstract class FacesContextFactory {
66
67
68 /**
69 * <p>Create (if needed) and return a {@link FacesContext} instance
70 * that is initialized for the processing of the specified request
71 * and response objects, utilizing the specified {@link Lifecycle}
72 * instance, for this web application.</p>
73 *
74 * <p>The implementation of this method must ensure that calls to the
75 * <code>getCurrentInstance()</code> method of {@link FacesContext},
76 * from the same thread that called this method, will return the same
77 * {@link FacesContext} instance until the <code>release()</code>
78 * method is called on that instance.</p>
79 *
80 * @param context In servlet environments, the
81 * <code>ServletContext</code> that is associated with this web
82 * application
83 * @param request In servlet environments, the
84 * <code>ServletRequest</code> that is to be processed
85 * @param response In servlet environments, the
86 * <code>ServletResponse</code> that is to be processed
87 * @param lifecycle The {@link Lifecycle} instance being used
88 * to process this request
89 *
90 * @throws FacesException if a {@link FacesContext} cannot be
91 * constructed for the specified parameters
92 * @throws NullPointerException if any of the parameters
93 * are <code>null</code>
94 */
95 public abstract FacesContext getFacesContext
96 (Object context, Object request,
97 Object response, Lifecycle lifecycle)
98 throws FacesException;
99
100
101 }