    001    package org.apache.turbine.services.template;
    002
    003
    004    /*
    005     * Licensed to the Apache Software Foundation (ASF) under one
    006     * or more contributor license agreements.  See the NOTICE file
    007     * distributed with this work for additional information
    008     * regarding copyright ownership.  The ASF licenses this file
    009     * to you under the Apache License, Version 2.0 (the
    010     * "License"); you may not use this file except in compliance
    011     * with the License.  You may obtain a copy of the License at
    012     *
    013     *   http://www.apache.org/licenses/LICENSE-2.0
    014     *
    015     * Unless required by applicable law or agreed to in writing,
    016     * software distributed under the License is distributed on an
    017     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    018     * KIND, either express or implied.  See the License for the
    019     * specific language governing permissions and limitations
    020     * under the License.
    021     */
    022
    023
    024    import java.util.Hashtable;
    025
    026    /**
    027     * This is the interface that all template engine services must adhere
    028     * to. This includes the Velocity, WebMacro, FreeMarker, and JSP
    029     * services.
    030     *
    031     * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    032     * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
    033     * @version $Id: TemplateEngineService.java 1078552 2011-03-06 19:58:46Z tv $ */
    034    public interface TemplateEngineService
    035    {
    036        static final String TEMPLATE_EXTENSIONS = "template.extension";
    037        static final String DEFAULT_TEMPLATE_EXTENSION = "template.default.extension";
    038        static final String DEFAULT_PAGE = "default.page";
    039        static final String DEFAULT_SCREEN = "default.screen";
    040        static final String DEFAULT_LAYOUT = "default.layout";
    041        static final String DEFAULT_NAVIGATION = "default.navigation";
    042        static final String DEFAULT_ERROR_SCREEN = "default.error.screen";
    043        static final String DEFAULT_LAYOUT_TEMPLATE = "default.layout.template";
    044        static final String DEFAULT_SCREEN_TEMPLATE = "default.screen.template";
    045        static final String DEFAULT_NAVIGATION_TEMPLATE = "default.navigation.template";
    046
    047        /**
    048         * Return the configuration of the template engine in
    049         * the form of a Hashtable.
    050         */
    051        Hashtable<String, Object> getTemplateEngineServiceConfiguration();
    052
    053        /**
    054         * Initializes file extension associations and registers with the
    055         * template service.
    056         *
    057         * @param defaultExt The default file extension association to use
    058         *                   in case of properties file misconfiguration.
    059         */
    060        void registerConfiguration(String defaultExt);
    061
    062        /**
    063         * Supplies the file extension to key this engine in {@link
    064         * org.apache.turbine.services.template.TemplateService}'s
    065         * registry with.
    066         */
    067        String[] getAssociatedFileExtensions();
    068
    069        /**
    070         * Use the specific template engine to determine whether
    071         * a given template exists. This allows Turbine the TemplateService
    072         * to delegate the search for a template to the template
    073         * engine being used for the view. This gives us the
    074         * advantage of fully utilizing the capabilities of
    075         * template engine with respect to retrieving templates
    076         * from arbitrary sources.
    077         *
    078         * @param template The name of the template to check the existance of.
    079         * @return         Whether the specified template exists.
    080         */
    081        boolean templateExists(String template);
    082    }