View Javadoc

1   package org.apache.turbine.services.jsp;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.turbine.services.TurbineServices;
23  
24  import org.apache.turbine.util.RunData;
25  import org.apache.turbine.util.TurbineException;
26  
27  /***
28   * Facade class for the Jsp Service.
29   *
30   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
31   * @version $Id: TurbineJsp.java 534527 2007-05-02 16:10:59Z tv $
32   */
33  public abstract class TurbineJsp
34  {
35      /***
36       * Utility method for accessing the service
37       * implementation
38       *
39       * @return a JspService implementation instance
40       */
41      protected static JspService getService()
42      {
43          return (JspService) TurbineServices
44              .getInstance().getService(JspService.SERVICE_NAME);
45      }
46  
47      /***
48       * Adds some convenience objects to the request.  For example an instance
49       * of JspLink which can be used to generate links to other templates.
50       *
51       * @param data the turbine rundata object
52       */
53      public static void addDefaultObjects(RunData data)
54      {
55          getService().addDefaultObjects(data);
56      }
57  
58      /***
59       * executes the JSP given by templateName.
60       *
61       * @param data A RunData Object
62       * @param templateName The template to execute
63       * @param isForward whether to perform a forward or include.
64       *
65       * @throws TurbineException If a problem occured while executing the JSP
66       */
67      public static void handleRequest(RunData data, String templateName, boolean isForward)
68          throws TurbineException
69      {
70          getService().handleRequest(data, templateName, isForward);
71      }
72  
73      /***
74       * executes the JSP given by templateName.
75       *
76       * @param data A RunData Object
77       * @param templateName The template to execute
78       *
79       * @throws TurbineException If a problem occured while executing the JSP
80       */
81      public static void handleRequest(RunData data, String templateName)
82          throws TurbineException
83      {
84          getService().handleRequest(data, templateName);
85      }
86  
87      /***
88       * Returns the default buffer size of the JspService
89       *
90       * @return The default buffer size.
91       */
92      public static int getDefaultBufferSize()
93      {
94          return getService().getDefaultBufferSize();
95      }
96  
97      /***
98       * Searchs for a template in the default.template path[s] and
99       * returns the template name with a relative path which is required
100      * by <a href="http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContext.html#getRequestDispatcher(java.lang.String)">javax.servlet.RequestDispatcher</a>
101      *
102      * @param template The name of the template to search for.
103      *
104      * @return the template with a relative path
105      */
106     public static String getRelativeTemplateName(String template)
107     {
108         return getService().getRelativeTemplateName(template);
109     }
110 }