001package org.apache.turbine.services.template;
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
022import java.util.Hashtable;
023
024/**
025 * This is the interface that all template engine services must adhere
026 * to. This includes the Velocity, WebMacro, FreeMarker, and JSP
027 * services.
028 *
029 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
030 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
031 * @version $Id$ */
032public interface TemplateEngineService
033{
034    /** Configuration key */
035    String TEMPLATE_EXTENSIONS = "template.extension";
036    /** Configuration key */
037    String DEFAULT_TEMPLATE_EXTENSION = "template.default.extension";
038    /** Configuration key */
039    String DEFAULT_PAGE = "default.page";
040    /** Configuration key */
041    String DEFAULT_SCREEN = "default.screen";
042    /** Configuration key */
043    String DEFAULT_LAYOUT = "default.layout";
044    /** Configuration key */
045    String DEFAULT_NAVIGATION = "default.navigation";
046    /** Configuration key */
047    String DEFAULT_ERROR_SCREEN = "default.error.screen";
048    /** Configuration key */
049    String DEFAULT_LAYOUT_TEMPLATE = "default.layout.template";
050    /** Configuration key */
051    String DEFAULT_SCREEN_TEMPLATE = "default.screen.template";
052    /** Configuration key */
053    String DEFAULT_NAVIGATION_TEMPLATE = "default.navigation.template";
054
055    /**
056     * Return the configuration of the template engine in
057     * the form of a Hashtable.
058     * @return the template engine service configuration map
059     */
060    Hashtable<String, Object> getTemplateEngineServiceConfiguration();
061
062    /**
063     * Initializes file extension associations and registers with the
064     * template service.
065     *
066     * @param defaultExt The default file extension association to use
067     *                   in case of properties file misconfiguration.
068     */
069    void registerConfiguration(String defaultExt);
070
071    /**
072     * Supplies the file extension to key this engine in {@link
073     * org.apache.turbine.services.template.TemplateService}'s
074     * registry with.
075     * @return the list of extensions this engine supports
076     */
077    String[] getAssociatedFileExtensions();
078
079    /**
080     * Use the specific template engine to determine whether
081     * a given template exists. This allows Turbine the TemplateService
082     * to delegate the search for a template to the template
083     * engine being used for the view. This gives us the
084     * advantage of fully utilizing the capabilities of
085     * template engine with respect to retrieving templates
086     * from arbitrary sources.
087     *
088     * @param template The name of the template to check the existence of.
089     * @return         Whether the specified template exists.
090     */
091    boolean templateExists(String template);
092}