001 /*
002 * Copyright 2004 The Apache Software Foundation
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package javax.servlet.jsp;
017
018 import javax.servlet.Servlet;
019 import javax.servlet.ServletRequest;
020 import javax.servlet.ServletResponse;
021 import javax.servlet.jsp.PageContext;
022
023 /**
024 * <p>
025 * The JspFactory is an abstract class that defines a number of factory
026 * methods available to a JSP page at runtime for the purposes of creating
027 * instances of various interfaces and classes used to support the JSP
028 * implementation.
029 * <p>
030 * A conformant JSP Engine implementation will, during it's initialization
031 * instantiate an implementation dependent subclass of this class, and make
032 * it globally available for use by JSP implementation classes by registering
033 * the instance created with this class via the
034 * static <code> setDefaultFactory() </code> method.
035 * <p>
036 * The PageContext and the JspEngineInfo classes are the only implementation-dependent
037 * classes that can be created from the factory.
038 * <p>
039 * JspFactory objects should not be used by JSP page authors.
040 */
041
042 public abstract class JspFactory {
043
044 private static JspFactory deflt = null;
045
046 /**
047 * Sole constructor. (For invocation by subclass constructors,
048 * typically implicit.)
049 */
050 public JspFactory() {
051 }
052
053 /**
054 * <p>
055 * set the default factory for this implementation. It is illegal for
056 * any principal other than the JSP Engine runtime to call this method.
057 * </p>
058 *
059 * @param deflt The default factory implementation
060 */
061
062 public static synchronized void setDefaultFactory(JspFactory deflt) {
063 JspFactory.deflt = deflt;
064 }
065
066 /**
067 * Returns the default factory for this implementation.
068 *
069 * @return the default factory for this implementation
070 */
071
072 public static synchronized JspFactory getDefaultFactory() {
073 return deflt;
074 }
075
076 /**
077 * <p>
078 * obtains an instance of an implementation dependent
079 * javax.servlet.jsp.PageContext abstract class for the calling Servlet
080 * and currently pending request and response.
081 * </p>
082 *
083 * <p>
084 * This method is typically called early in the processing of the
085 * _jspService() method of a JSP implementation class in order to
086 * obtain a PageContext object for the request being processed.
087 * </p>
088 * <p>
089 * Invoking this method shall result in the PageContext.initialize()
090 * method being invoked. The PageContext returned is properly initialized.
091 * </p>
092 * <p>
093 * All PageContext objects obtained via this method shall be released
094 * by invoking releasePageContext().
095 * </p>
096 *
097 * @param servlet the requesting servlet
098 * @param request the current request pending on the servlet
099 * @param response the current response pending on the servlet
100 * @param errorPageURL the URL of the error page for the requesting JSP, or null
101 * @param needsSession true if the JSP participates in a session
102 * @param buffer size of buffer in bytes, PageContext.NO_BUFFER if no buffer,
103 * PageContext.DEFAULT_BUFFER if implementation default.
104 * @param autoflush should the buffer autoflush to the output stream on buffer
105 * overflow, or throw an IOException?
106 *
107 * @return the page context
108 *
109 * @see javax.servlet.jsp.PageContext
110 */
111
112 public abstract PageContext getPageContext(Servlet servlet,
113 ServletRequest request, ServletResponse response,
114 String errorPageURL, boolean needsSession, int buffer,
115 boolean autoflush);
116
117 /**
118 * <p>
119 * called to release a previously allocated PageContext object.
120 * Results in PageContext.release() being invoked.
121 * This method should be invoked prior to returning from the _jspService() method of a JSP implementation
122 * class.
123 * </p>
124 *
125 * @param pc A PageContext previously obtained by getPageContext()
126 */
127
128 public abstract void releasePageContext(PageContext pc);
129
130 /**
131 * <p>
132 * called to get implementation-specific information on the current JSP engine.
133 * </p>
134 *
135 * @return a JspEngineInfo object describing the current JSP engine
136 */
137
138 public abstract JspEngineInfo getEngineInfo();
139 }
|