1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * Portions Copyright Apache Software Foundation.
7 *
8 * The contents of this file are subject to the terms of either the GNU
9 * General Public License Version 2 only ("GPL") or the Common Development
10 * and Distribution License("CDDL") (collectively, the "License"). You
11 * may not use this file except in compliance with the License. You can obtain
12 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
13 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
14 * language governing permissions and limitations under the License.
15 *
16 * When distributing the software, include this License Header Notice in each
17 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
18 * Sun designates this particular file as subject to the "Classpath" exception
19 * as provided by Sun in the GPL Version 2 section of the License file that
20 * accompanied this code. If applicable, add the following below the License
21 * Header, with the fields enclosed by brackets [] replaced by your own
22 * identifying information: "Portions Copyrighted [year]
23 * [name of copyright owner]"
24 *
25 * Contributor(s):
26 *
27 * If you wish your version of this file to be governed by only the CDDL or
28 * only the GPL Version 2, indicate your decision by adding "[Contributor]
29 * elects to include this software in this distribution under the [CDDL or GPL
30 * Version 2] license." If you don't indicate a single choice of license, a
31 * recipient has the option to distribute your version of this file under
32 * either the CDDL, the GPL Version 2 or to extend the choice of license to
33 * its licensees as provided above. However, if you add GPL Version 2 code
34 * and therefore, elected the GPL Version 2 license, then the option applies
35 * only if the new code is made subject to such option by the copyright
36 * holder.
37 */
38
39 package javax.servlet.jsp;
40
41 import javax.servlet.Servlet;
42 import javax.servlet.ServletRequest;
43 import javax.servlet.ServletResponse;
44 import javax.servlet.jsp.PageContext;
45
46 /**
47 * <p>
48 * The JspFactory is an abstract class that defines a number of factory
49 * methods available to a JSP page at runtime for the purposes of creating
50 * instances of various interfaces and classes used to support the JSP
51 * implementation.
52 * <p>
53 * A conformant JSP Engine implementation will, during it's initialization
54 * instantiate an implementation dependent subclass of this class, and make
55 * it globally available for use by JSP implementation classes by registering
56 * the instance created with this class via the
57 * static <code> setDefaultFactory() </code> method.
58 * <p>
59 * The PageContext and the JspEngineInfo classes are the only implementation-dependent
60 * classes that can be created from the factory.
61 * <p>
62 * JspFactory objects should not be used by JSP page authors.
63 */
64
65 public abstract class JspFactory {
66
67 private static JspFactory deflt = null;
68
69 /**
70 * Sole constructor. (For invocation by subclass constructors,
71 * typically implicit.)
72 */
73 public JspFactory() {
74 }
75
76 /**
77 * <p>
78 * set the default factory for this implementation. It is illegal for
79 * any principal other than the JSP Engine runtime to call this method.
80 * </p>
81 *
82 * @param deflt The default factory implementation
83 */
84
85 public static synchronized void setDefaultFactory(JspFactory deflt) {
86 JspFactory.deflt = deflt;
87 }
88
89 /**
90 * Returns the default factory for this implementation.
91 *
92 * @return the default factory for this implementation
93 */
94
95 public static synchronized JspFactory getDefaultFactory() {
96 return deflt;
97 }
98
99 /**
100 * <p>
101 * obtains an instance of an implementation dependent
102 * javax.servlet.jsp.PageContext abstract class for the calling Servlet
103 * and currently pending request and response.
104 * </p>
105 *
106 * <p>
107 * This method is typically called early in the processing of the
108 * _jspService() method of a JSP implementation class in order to
109 * obtain a PageContext object for the request being processed.
110 * </p>
111 * <p>
112 * Invoking this method shall result in the PageContext.initialize()
113 * method being invoked. The PageContext returned is properly initialized.
114 * </p>
115 * <p>
116 * All PageContext objects obtained via this method shall be released
117 * by invoking releasePageContext().
118 * </p>
119 *
120 * @param servlet the requesting servlet
121 * @param request the current request pending on the servlet
122 * @param response the current response pending on the servlet
123 * @param errorPageURL the URL of the error page for the requesting JSP, or null
124 * @param needsSession true if the JSP participates in a session
125 * @param buffer size of buffer in bytes, PageContext.NO_BUFFER if no buffer,
126 * PageContext.DEFAULT_BUFFER if implementation default.
127 * @param autoflush should the buffer autoflush to the output stream on buffer
128 * overflow, or throw an IOException?
129 *
130 * @return the page context
131 *
132 * @see javax.servlet.jsp.PageContext
133 */
134
135 public abstract PageContext getPageContext(Servlet servlet,
136 ServletRequest request,
137 ServletResponse response,
138 String errorPageURL,
139 boolean needsSession,
140 int buffer,
141 boolean autoflush);
142
143 /**
144 * <p>
145 * called to release a previously allocated PageContext object.
146 * Results in PageContext.release() being invoked.
147 * This method should be invoked prior to returning from the _jspService() method of a JSP implementation
148 * class.
149 * </p>
150 *
151 * @param pc A PageContext previously obtained by getPageContext()
152 */
153
154 public abstract void releasePageContext(PageContext pc);
155
156 /**
157 * <p>
158 * called to get implementation-specific information on the current JSP engine.
159 * </p>
160 *
161 * @return a JspEngineInfo object describing the current JSP engine
162 */
163
164 public abstract JspEngineInfo getEngineInfo();
165 }