1 package org.apache.turbine.services.template;
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 java.util.Hashtable;
23
24 /**
25 * This is the interface that all template engine services must adhere
26 * to. This includes the Velocity, WebMacro, FreeMarker, and JSP
27 * services.
28 *
29 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
30 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
31 * @version $Id: TemplateEngineService.java 1706239 2015-10-01 13:18:35Z tv $ */
32 public interface TemplateEngineService
33 {
34 /** Configuration key */
35 String TEMPLATE_EXTENSIONS = "template.extension";
36 /** Configuration key */
37 String DEFAULT_TEMPLATE_EXTENSION = "template.default.extension";
38 /** Configuration key */
39 String DEFAULT_PAGE = "default.page";
40 /** Configuration key */
41 String DEFAULT_SCREEN = "default.screen";
42 /** Configuration key */
43 String DEFAULT_LAYOUT = "default.layout";
44 /** Configuration key */
45 String DEFAULT_NAVIGATION = "default.navigation";
46 /** Configuration key */
47 String DEFAULT_ERROR_SCREEN = "default.error.screen";
48 /** Configuration key */
49 String DEFAULT_LAYOUT_TEMPLATE = "default.layout.template";
50 /** Configuration key */
51 String DEFAULT_SCREEN_TEMPLATE = "default.screen.template";
52 /** Configuration key */
53 String DEFAULT_NAVIGATION_TEMPLATE = "default.navigation.template";
54
55 /**
56 * Return the configuration of the template engine in
57 * the form of a Hashtable.
58 * @return the template engine service configuration map
59 */
60 Hashtable<String, Object> getTemplateEngineServiceConfiguration();
61
62 /**
63 * Initializes file extension associations and registers with the
64 * template service.
65 *
66 * @param defaultExt The default file extension association to use
67 * in case of properties file misconfiguration.
68 */
69 void registerConfiguration(String defaultExt);
70
71 /**
72 * Supplies the file extension to key this engine in {@link
73 * org.apache.turbine.services.template.TemplateService}'s
74 * registry with.
75 * @return the list of extensions this engine supports
76 */
77 String[] getAssociatedFileExtensions();
78
79 /**
80 * Use the specific template engine to determine whether
81 * a given template exists. This allows Turbine the TemplateService
82 * to delegate the search for a template to the template
83 * engine being used for the view. This gives us the
84 * advantage of fully utilizing the capabilities of
85 * template engine with respect to retrieving templates
86 * from arbitrary sources.
87 *
88 * @param template The name of the template to check the existence of.
89 * @return Whether the specified template exists.
90 */
91 boolean templateExists(String template);
92 }