001: package org.apache.turbine.services.jsp;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.apache.turbine.services.TurbineServices;
023:
024: import org.apache.turbine.util.RunData;
025: import org.apache.turbine.util.TurbineException;
026:
027: /**
028: * Facade class for the Jsp Service.
029: *
030: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
031: * @version $Id: TurbineJsp.java 534527 2007-05-02 16:10:59Z tv $
032: */
033: public abstract class TurbineJsp {
034: /**
035: * Utility method for accessing the service
036: * implementation
037: *
038: * @return a JspService implementation instance
039: */
040: protected static JspService getService() {
041: return (JspService) TurbineServices.getInstance().getService(
042: JspService.SERVICE_NAME);
043: }
044:
045: /**
046: * Adds some convenience objects to the request. For example an instance
047: * of JspLink which can be used to generate links to other templates.
048: *
049: * @param data the turbine rundata object
050: */
051: public static void addDefaultObjects(RunData data) {
052: getService().addDefaultObjects(data);
053: }
054:
055: /**
056: * executes the JSP given by templateName.
057: *
058: * @param data A RunData Object
059: * @param templateName The template to execute
060: * @param isForward whether to perform a forward or include.
061: *
062: * @throws TurbineException If a problem occured while executing the JSP
063: */
064: public static void handleRequest(RunData data, String templateName,
065: boolean isForward) throws TurbineException {
066: getService().handleRequest(data, templateName, isForward);
067: }
068:
069: /**
070: * executes the JSP given by templateName.
071: *
072: * @param data A RunData Object
073: * @param templateName The template to execute
074: *
075: * @throws TurbineException If a problem occured while executing the JSP
076: */
077: public static void handleRequest(RunData data, String templateName)
078: throws TurbineException {
079: getService().handleRequest(data, templateName);
080: }
081:
082: /**
083: * Returns the default buffer size of the JspService
084: *
085: * @return The default buffer size.
086: */
087: public static int getDefaultBufferSize() {
088: return getService().getDefaultBufferSize();
089: }
090:
091: /**
092: * Searchs for a template in the default.template path[s] and
093: * returns the template name with a relative path which is required
094: * by <a href="http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContext.html#getRequestDispatcher(java.lang.String)">javax.servlet.RequestDispatcher</a>
095: *
096: * @param template The name of the template to search for.
097: *
098: * @return the template with a relative path
099: */
100: public static String getRelativeTemplateName(String template) {
101: return getService().getRelativeTemplateName(template);
102: }
103: }
|