1 package org.apache.fulcrum.template; 2 3 56 57 import java.io.OutputStream ; 58 import java.io.Writer ; 59 import java.util.Hashtable ; 60 61 import org.apache.fulcrum.BaseService; 62 import org.apache.fulcrum.ServiceException; 63 64 72 public abstract class BaseTemplateEngineService 73 extends BaseService 74 implements TemplateEngineService 75 { 76 87 private Hashtable configuration = new Hashtable (); 88 89 92 public void registerConfiguration(String defaultExt) 93 { 94 initConfiguration(defaultExt); 95 TurbineTemplate.registerTemplateEngineService(this); 96 } 97 98 101 public Hashtable getTemplateEngineServiceConfiguration() 102 { 103 return configuration; 104 } 105 106 109 public String [] getAssociatedFileExtensions() 110 { 111 return (String []) configuration.get(TEMPLATE_EXTENSIONS); 112 } 113 114 125 protected void initConfiguration(String defaultExt) 126 { 127 131 String [] fileExtensionAssociations = 132 getConfiguration().getStringArray(TEMPLATE_EXTENSIONS); 133 134 if (fileExtensionAssociations == null || 135 fileExtensionAssociations.length == 0) 136 { 137 fileExtensionAssociations = new String [1]; 138 fileExtensionAssociations[0] = getConfiguration().getString( 139 DEFAULT_TEMPLATE_EXTENSION, defaultExt); 140 } 141 142 configuration.put(TEMPLATE_EXTENSIONS, fileExtensionAssociations); 143 144 configuration.put(DEFAULT_PAGE_TEMPLATE, 145 getConfiguration().getString(DEFAULT_PAGE_TEMPLATE)); 146 147 configuration.put(DEFAULT_LAYOUT_TEMPLATE, 148 getConfiguration().getString(DEFAULT_LAYOUT_TEMPLATE)); 149 150 } 151 152 155 public abstract boolean templateExists(String template); 156 157 public abstract String handleRequest(TemplateContext context, 158 String template) 159 throws ServiceException; 160 161 public abstract void handleRequest(TemplateContext context, 162 String template, OutputStream os) 163 throws ServiceException; 164 165 168 public abstract void handleRequest(TemplateContext context, 169 String template, Writer writer) 170 throws ServiceException; 171 } 172 | Popular Tags |