1 package org.apache.turbine.services.template; 2 3 18 19 import java.util.Hashtable ; 20 21 import org.apache.commons.configuration.Configuration; 22 23 import org.apache.turbine.services.TurbineBaseService; 24 25 33 public abstract class BaseTemplateEngineService 34 extends TurbineBaseService 35 implements TemplateEngineService 36 { 37 48 private Hashtable configuration = new Hashtable (); 49 50 53 public void registerConfiguration(String defaultExt) 54 { 55 initConfiguration(defaultExt); 56 TurbineTemplate.registerTemplateEngineService(this); 57 } 58 59 62 public Hashtable getTemplateEngineServiceConfiguration() 63 { 64 return configuration; 65 } 66 67 70 public String [] getAssociatedFileExtensions() 71 { 72 return (String []) configuration.get(TEMPLATE_EXTENSIONS); 73 } 74 75 88 protected void initConfiguration(String defaultExt) 89 { 90 Configuration config = getConfiguration(); 91 92 String [] fileExtensionAssociations = 97 config.getStringArray(TEMPLATE_EXTENSIONS); 98 99 if (fileExtensionAssociations == null || 100 fileExtensionAssociations.length == 0) 101 { 102 fileExtensionAssociations = new String [1]; 103 fileExtensionAssociations[0] = config.getString( 104 DEFAULT_TEMPLATE_EXTENSION, defaultExt); 105 } 106 107 configuration.put(TEMPLATE_EXTENSIONS, fileExtensionAssociations); 108 109 114 115 String [] copyParams = { 116 DEFAULT_PAGE, 117 DEFAULT_SCREEN, 118 DEFAULT_LAYOUT, 119 DEFAULT_NAVIGATION, 120 DEFAULT_ERROR_SCREEN, 121 DEFAULT_LAYOUT_TEMPLATE, 122 DEFAULT_SCREEN_TEMPLATE 123 }; 124 125 for (int i = 0; i < copyParams.length; i++) 126 { 127 configuration.put(copyParams[i], config.getString(copyParams[i], "")); 128 } 129 } 130 131 134 public abstract boolean templateExists(String template); 135 } 136 | Popular Tags |