1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
19
20
21
22
23
24 package javax.servlet.jsp;
25
26 import javax.servlet.Servlet;
27 import javax.servlet.ServletRequest;
28 import javax.servlet.ServletResponse;
29 import javax.servlet.jsp.PageContext;
30
31 /**
32 * <p>
33 * The JspFactory is an abstract class that defines a number of factory
34 * methods available to a JSP page at runtime for the purposes of creating
35 * instances of various interfaces and classes used to support the JSP
36 * implementation.
37 * <p>
38 * A conformant JSP Engine implementation will, during it's initialization
39 * instantiate an implementation dependent subclass of this class, and make
40 * it globally available for use by JSP implementation classes by registering
41 * the instance created with this class via the
42 * static <code> setDefaultFactory() </code> method.
43 * <p>
44 * The PageContext and the JspEngineInfo classes are the only implementation-dependent
45 * classes that can be created from the factory.
46 * <p>
47 * JspFactory objects should not be used by JSP page authors.
48 */
49
50 public abstract class JspFactory {
51
52 private static JspFactory deflt = null;
53
54 /**
55 * Sole constructor. (For invocation by subclass constructors,
56 * typically implicit.)
57 */
58 public JspFactory() {
59 }
60
61 /**
62 * <p>
63 * set the default factory for this implementation. It is illegal for
64 * any principal other than the JSP Engine runtime to call this method.
65 * </p>
66 *
67 * @param deflt The default factory implementation
68 */
69
70 public static synchronized void setDefaultFactory(JspFactory deflt) {
71 JspFactory.deflt = deflt;
72 }
73
74 /**
75 * Returns the default factory for this implementation.
76 *
77 * @return the default factory for this implementation
78 */
79
80 public static synchronized JspFactory getDefaultFactory() {
81 return deflt;
82 }
83
84 /**
85 * <p>
86 * obtains an instance of an implementation dependent
87 * javax.servlet.jsp.PageContext abstract class for the calling Servlet
88 * and currently pending request and response.
89 * </p>
90 *
91 * <p>
92 * This method is typically called early in the processing of the
93 * _jspService() method of a JSP implementation class in order to
94 * obtain a PageContext object for the request being processed.
95 * </p>
96 * <p>
97 * Invoking this method shall result in the PageContext.initialize()
98 * method being invoked. The PageContext returned is properly initialized.
99 * </p>
100 * <p>
101 * All PageContext objects obtained via this method shall be released
102 * by invoking releasePageContext().
103 * </p>
104 *
105 * @param servlet the requesting servlet
106 * @param request the current request pending on the servlet
107 * @param response the current response pending on the servlet
108 * @param errorPageURL the URL of the error page for the requesting JSP, or null
109 * @param needsSession true if the JSP participates in a session
110 * @param buffer size of buffer in bytes, PageContext.NO_BUFFER if no buffer,
111 * PageContext.DEFAULT_BUFFER if implementation default.
112 * @param autoflush should the buffer autoflush to the output stream on buffer
113 * overflow, or throw an IOException?
114 *
115 * @return the page context
116 *
117 * @see javax.servlet.jsp.PageContext
118 */
119
120 public abstract PageContext getPageContext(Servlet servlet,
121 ServletRequest request,
122 ServletResponse response,
123 String errorPageURL,
124 boolean needsSession,
125 int buffer,
126 boolean autoflush);
127
128 /**
129 * <p>
130 * called to release a previously allocated PageContext object.
131 * Results in PageContext.release() being invoked.
132 * This method should be invoked prior to returning from the _jspService() method of a JSP implementation
133 * class.
134 * </p>
135 *
136 * @param pc A PageContext previously obtained by getPageContext()
137 */
138
139 public abstract void releasePageContext(PageContext pc);
140
141 /**
142 * <p>
143 * called to get implementation-specific information on the current JSP engine.
144 * </p>
145 *
146 * @return a JspEngineInfo object describing the current JSP engine
147 */
148
149 public abstract JspEngineInfo getEngineInfo();
150 }