View Javadoc

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