Source Code Cross Referenced for JspEngineContext.java in  » Portal » Open-Portal » com » sun » portal » providers » jsp » jasper3 » jasper » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.providers.jsp.jasper3.jasper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Apache Software License, Version 1.1
003:         *
004:         * Copyright (c) 1999 The Apache Software Foundation.  All rights 
005:         * reserved.
006:         *
007:         * Redistribution and use in source and binary forms, with or without
008:         * modification, are permitted provided that the following conditions
009:         * are met:
010:         *
011:         * 1. Redistributions of source code must retain the above copyright
012:         *    notice, this list of conditions and the following disclaimer. 
013:         *
014:         * 2. Redistributions in binary form must reproduce the above copyright
015:         *    notice, this list of conditions and the following disclaimer in
016:         *    the documentation and/or other materials provided with the
017:         *    distribution.
018:         *
019:         * 3. The end-user documentation included with the redistribution, if
020:         *    any, must include the following acknowlegement:  
021:         *       "This product includes software developed by the 
022:         *        Apache Software Foundation (http://www.apache.org/)."
023:         *    Alternately, this acknowlegement may appear in the software itself,
024:         *    if and wherever such third-party acknowlegements normally appear.
025:         *
026:         * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
027:         *    Foundation" must not be used to endorse or promote products derived
028:         *    from this software without prior written permission. For written 
029:         *    permission, please contact apache@apache.org.
030:         *
031:         * 5. Products derived from this software may not be called "Apache"
032:         *    nor may "Apache" appear in their names without prior written
033:         *    permission of the Apache Group.
034:         *
035:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
036:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046:         * SUCH DAMAGE.
047:         * ====================================================================
048:         *
049:         * This software consists of voluntary contributions made by many
050:         * individuals on behalf of the Apache Software Foundation.  For more
051:         * information on the Apache Software Foundation, please see
052:         * <http://www.apache.org/>.
053:         *
054:         */
055:
056:        package com.sun.portal.providers.jsp.jasper3.jasper;
057:
058:        import javax.servlet.ServletContext;
059:        import javax.servlet.http.HttpServletRequest;
060:        import javax.servlet.http.HttpServletResponse;
061:        import java.io.IOException;
062:        import java.util.logging.Level;
063:
064:        import com.sun.portal.providers.jsp.jasper3.jasper.compiler.JspReader;
065:        import com.sun.portal.providers.jsp.jasper3.jasper.compiler.ServletWriter; //import com.sun.portal.providers.jsp.jasper3.jasper.runtime.JspLoader;
066:        import com.sun.portal.providers.jsp.jasper3.jasper.servlet.JasperLoader;
067:        import com.sun.portal.providers.jsp.jasper3.jasper.compiler.TagLibraries;
068:
069:        import com.sun.portal.providers.jsp.jasper3.jasper.compiler.Compiler;
070:        import com.sun.portal.providers.jsp.jasper3.jasper.compiler.JspCompiler;
071:        import com.sun.portal.providers.jsp.jasper3.jasper.compiler.SunJavaCompiler;
072:        import com.sun.portal.providers.jsp.jasper3.jasper.compiler.JavaCompiler;
073:
074:        import com.sun.portal.log.common.PortalLogger;
075:
076:        /**
077:         * A place holder for various things that are used through out the JSP
078:         * engine. This is a per-request/per-context data structure. Some of
079:         * the instance variables are set at different points.
080:         *
081:         * JspLoader creates this object and passes this off to the "compiler"
082:         * subsystem, which then initializes the rest of the variables. 
083:         *
084:         * @author Anil K. Vijendran
085:         * @author Harish Prabandham
086:         */
087:        public class JspEngineContext implements  JspCompilationContext {
088:            JspReader reader;
089:            ServletWriter writer;
090:            ServletContext context;
091:            JasperLoader loader;
092:            String classpath; // for compiling JSPs.
093:            boolean isErrPage;
094:            String jspFile;
095:            String servletClassName;
096:            String servletPackageName;
097:            String servletJavaFileName;
098:            String contentType;
099:            Options options;
100:            HttpServletRequest req;
101:            HttpServletResponse res;
102:
103:            private java.util.logging.Logger logger = PortalLogger
104:                    .getLogger(JspEngineContext.class);
105:
106:            public JspEngineContext(JasperLoader loader, String classpath,
107:                    ServletContext context, String jspFile, boolean isErrPage,
108:                    Options options, HttpServletRequest req,
109:                    HttpServletResponse res) {
110:                this .loader = loader;
111:                this .classpath = classpath;
112:                this .context = context;
113:                this .jspFile = jspFile;
114:                this .isErrPage = isErrPage;
115:                this .options = options;
116:                this .req = req;
117:                this .res = res;
118:            }
119:
120:            /**
121:             * Get the http request we are servicing now...
122:             */
123:            public HttpServletRequest getRequest() {
124:                return req;
125:            }
126:
127:            /**
128:             * Get the http response we are using now...
129:             */
130:            public HttpServletResponse getResponse() {
131:                return res;
132:            }
133:
134:            /**
135:             * The classpath that is passed off to the Java compiler. 
136:             */
137:            public String getClassPath() {
138:                return loader.getClassPath() + classpath;
139:            }
140:
141:            /**
142:             * Get the input reader for the JSP text. 
143:             */
144:            public JspReader getReader() {
145:                return reader;
146:            }
147:
148:            /**
149:             * Where is the servlet being generated?
150:             */
151:            public ServletWriter getWriter() {
152:                return writer;
153:            }
154:
155:            /**
156:             * Get the ServletContext for the JSP we're processing now. 
157:             */
158:            public ServletContext getServletContext() {
159:                return context;
160:            }
161:
162:            /**
163:             * What class loader to use for loading classes while compiling
164:             * this JSP? I don't think this is used right now -- akv. 
165:             */
166:            public ClassLoader getClassLoader() {
167:                return loader;
168:            }
169:
170:            public void addJar(String jar) throws IOException {
171:                loader.addJar(jar);
172:            }
173:
174:            /**
175:             * Are we processing something that has been declared as an
176:             * errorpage? 
177:             */
178:            public boolean isErrorPage() {
179:                return isErrPage;
180:            }
181:
182:            /**
183:             * What is the scratch directory we are generating code into?
184:             * FIXME: In some places this is called scratchDir and in some
185:             * other places it is called outputDir.
186:             */
187:            public String getOutputDir() {
188:                return options.getScratchDir().toString();
189:            }
190:
191:            /**
192:             * Path of the JSP URI. Note that this is not a file name. This is
193:             * the context rooted URI of the JSP file. 
194:             */
195:            public String getJspFile() {
196:                return jspFile;
197:            }
198:
199:            /**
200:             * Just the class name (does not include package name) of the
201:             * generated class. 
202:             */
203:            public String getServletClassName() {
204:                return servletClassName;
205:            }
206:
207:            /**
208:             * The package name into which the servlet class is generated. 
209:             */
210:            public String getServletPackageName() {
211:                return servletPackageName;
212:            }
213:
214:            /**
215:             * Utility method to get the full class name from the package and
216:             * class name. 
217:             */
218:            public final String getFullClassName() {
219:                if (servletPackageName == null)
220:                    return servletClassName;
221:                return servletPackageName + "." + servletClassName;
222:            }
223:
224:            /**
225:             * Full path name of the Java file into which the servlet is being
226:             * generated. 
227:             */
228:            public String getServletJavaFileName() {
229:                return servletJavaFileName;
230:            }
231:
232:            /**
233:             * Are we keeping generated code around?
234:             */
235:            public boolean keepGenerated() {
236:                return options.getKeepGenerated();
237:            }
238:
239:            /**
240:             * What's the content type of this JSP? Content type includes
241:             * content type and encoding. 
242:             */
243:            public String getContentType() {
244:                return contentType;
245:            }
246:
247:            /**
248:             * Get hold of the Options object for this context. 
249:             */
250:            public Options getOptions() {
251:                return options;
252:            }
253:
254:            public void setContentType(String contentType) {
255:                this .contentType = contentType;
256:            }
257:
258:            public void setReader(JspReader reader) {
259:                this .reader = reader;
260:            }
261:
262:            public void setWriter(ServletWriter writer) {
263:                this .writer = writer;
264:            }
265:
266:            public void setServletClassName(String servletClassName) {
267:                this .servletClassName = servletClassName;
268:            }
269:
270:            public void setServletPackageName(String servletPackageName) {
271:                this .servletPackageName = servletPackageName;
272:            }
273:
274:            public void setServletJavaFileName(String servletJavaFileName) {
275:                this .servletJavaFileName = servletJavaFileName;
276:            }
277:
278:            public void setErrorPage(boolean isErrPage) {
279:                this .isErrPage = isErrPage;
280:            }
281:
282:            /**
283:             * Create a "Compiler" object based on some init param data. If	
284:             * jspCompilerPlugin is not specified or is not available, the 
285:             * SunJavaCompiler is used.
286:             */
287:            public Compiler createCompiler() throws JasperException {
288:                String compilerPath = options.getJspCompilerPath();
289:                Class jspCompilerPlugin = options.getJspCompilerPlugin();
290:                JavaCompiler javac;
291:
292:                if (jspCompilerPlugin != null) {
293:                    try {
294:                        javac = (JavaCompiler) jspCompilerPlugin.newInstance();
295:                    } catch (Exception ex) {
296:                        logger.log(Level.FINEST, "PSDT_CSPPJJJ0013",
297:                                new Object[] { jspCompilerPlugin.getName() });
298:                        javac = new SunJavaCompiler();
299:                    }
300:                } else {
301:                    javac = new SunJavaCompiler();
302:                }
303:
304:                if (compilerPath != null)
305:                    javac.setCompilerPath(compilerPath);
306:
307:                Compiler jspCompiler = new JspCompiler(this );
308:                jspCompiler.setJavaCompiler(javac);
309:
310:                return jspCompiler;
311:            }
312:
313:            /** 
314:             * Get the full value of a URI relative to this compilations context
315:             */
316:            public String resolveRelativeUri(String uri) {
317:                if (uri.charAt(0) == '/') {
318:                    return uri;
319:                } else {
320:                    String actURI = req.getServletPath();
321:                    String baseURI = actURI.substring(0, actURI
322:                            .lastIndexOf('/'));
323:                    return baseURI + '/' + uri;
324:                }
325:            }
326:
327:            /**
328:             * Gets a resource as a stream, relative to the meanings of this
329:             * context's implementation.
330:             *@returns a null if the resource cannot be found or represented 
331:             *         as an InputStream.
332:             */
333:            public java.io.InputStream getResourceAsStream(String res) {
334:                return context.getResourceAsStream(res);
335:            }
336:
337:            /** 
338:             * Gets the actual path of a URI relative to the context of
339:             * the compilation.
340:             */
341:            public String getRealPath(String path) {
342:                if (context != null) {
343:                    return context.getRealPath(path);
344:                } else {
345:                    return path;
346:                }
347:            }
348:
349:        }
w_w__w___.__j_a__va__2__s.___c___o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.