Source Code Cross Referenced for TurbineVelocity.java in  » Project-Management » turbine » org » apache » turbine » services » velocity » 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 » Project Management » turbine » org.apache.turbine.services.velocity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.services.velocity;
002:
003:        /*
004:         * Copyright 2001-2005 The Apache Software Foundation.
005:         *
006:         * Licensed under the Apache License, Version 2.0 (the "License")
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         *
010:         *     http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        import java.io.OutputStream;
020:        import java.io.Writer;
021:
022:        import org.apache.turbine.services.TurbineServices;
023:        import org.apache.turbine.util.RunData;
024:
025:        import org.apache.velocity.context.Context;
026:
027:        /**
028:         * This is a simple static accessor to common Velocity tasks such as
029:         * getting an instance of a context as well as handling a request for
030:         * processing a template.
031:         * <pre>
032:         * Context context = TurbineVelocity.getContext(data);
033:         * context.put("message", "Hello from Turbine!");
034:         * String results = TurbineVelocity.handleRequest(context, "helloWorld.vm");
035:         * data.getPage().getBody().addElement(results);
036:         * </pre>
037:         *
038:         * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
039:         * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
040:         * @author <a href="mailto:jvanzyl@periapt.com.com">Jason van Zyl</a>
041:         * @version $Id: TurbineVelocity.java 264148 2005-08-29 14:21:04Z henning $
042:         */
043:        public abstract class TurbineVelocity {
044:            /**
045:             * Utility method for accessing the service
046:             * implementation
047:             *
048:             * @return a VelocityService implementation instance
049:             */
050:            public static VelocityService getService() {
051:                return (VelocityService) TurbineServices.getInstance()
052:                        .getService(VelocityService.SERVICE_NAME);
053:            }
054:
055:            /**
056:             * This allows you to pass in a context and a path to a template
057:             * file and then grabs an instance of the velocity service and
058:             * processes the template and returns the results as a String
059:             * object.
060:             *
061:             * @param context A Context.
062:             * @param template The path for the template files.
063:             * @return A String.
064:             * @exception Exception a generic exception.
065:             */
066:            public static String handleRequest(Context context, String template)
067:                    throws Exception {
068:                return getService().handleRequest(context, template);
069:            }
070:
071:            /**
072:             * Process the request and fill in the template with the values
073:             * you set in the Context.
074:             *
075:             * @param context A Context.
076:             * @param template A String with the filename of the template.
077:             * @param out A OutputStream where we will write the process template as
078:             * a String.
079:             * @exception Exception a generic exception.
080:             */
081:            public static void handleRequest(Context context, String template,
082:                    OutputStream out) throws Exception {
083:                getService().handleRequest(context, template, out);
084:            }
085:
086:            /**
087:             * Process the request and fill in the template with the values
088:             * you set in the Context.
089:             *
090:             * @param context A Context.
091:             * @param template A String with the filename of the template.
092:             * @param writer A Writer where we will write the process template as
093:             * a String.
094:             * @exception Exception a generic exception.
095:             */
096:            public static void handleRequest(Context context, String template,
097:                    Writer writer) throws Exception {
098:                getService().handleRequest(context, template, writer);
099:            }
100:
101:            /**
102:             * This returns a Context that you can pass into handleRequest
103:             * once you have populated it with information that the template
104:             * will know about.
105:             *
106:             * @param data A Turbine RunData.
107:             * @return A Context.
108:             */
109:            public static Context getContext(RunData data) {
110:                return getService().getContext(data);
111:            }
112:
113:            /**
114:             * This method returns a blank Context object, which
115:             * also contains the global context object. Do not use
116:             * this method if you need an empty context object! Use
117:             * getNewContext for this.
118:             *
119:             * @return A WebContext.
120:             */
121:            public static Context getContext() {
122:                return getService().getContext();
123:            }
124:
125:            /**
126:             * This method returns a new, empty Context object.
127:             *
128:             * @return A WebContext.
129:             */
130:            public static Context getNewContext() {
131:                return getService().getNewContext();
132:            }
133:
134:            /**
135:             * Performs post-request actions (releases context
136:             * tools back to the object pool).
137:             *
138:             * @param context a Velocity Context
139:             */
140:            public static void requestFinished(Context context) {
141:                getService().requestFinished(context);
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.