You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/03/31 18:02:30 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/template TemplateService.java TurbineTemplate.java TurbineTemplateService.java
jvanzyl 01/03/31 08:02:30
Modified: src/java/org/apache/turbine/services/template
TemplateService.java TurbineTemplate.java
TurbineTemplateService.java
Log:
- removing template path management from this service as it is
now handle by the individual template engines. this will eventually
allow multiple template engines to run at the same time each
engine managing their own set of template paths.
Revision Changes Path
1.6 +5 -1 jakarta-turbine/src/java/org/apache/turbine/services/template/TemplateService.java
Index: TemplateService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/template/TemplateService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TemplateService.java 2001/03/06 06:12:50 1.5
+++ TemplateService.java 2001/03/31 16:02:29 1.6
@@ -65,7 +65,7 @@
* properties file.
*
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
- * @version $Id: TemplateService.java,v 1.5 2001/03/06 06:12:50 chrise Exp $
+ * @version $Id: TemplateService.java,v 1.6 2001/03/31 16:02:29 jvanzyl Exp $
*/
public interface TemplateService
extends Service
@@ -146,4 +146,8 @@
*/
public String getDefaultLayoutTemplate();
+ public String[] translateTemplatePaths(String[] templatePaths);
+ public boolean templateExists(String template, String[] templatePaths);
+ public void registerTemplateEngineService(TemplateEngineService service);
+
}
1.5 +16 -1 jakarta-turbine/src/java/org/apache/turbine/services/template/TurbineTemplate.java
Index: TurbineTemplate.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/template/TurbineTemplate.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TurbineTemplate.java 2001/03/06 06:12:51 1.4
+++ TurbineTemplate.java 2001/03/31 16:02:29 1.5
@@ -62,7 +62,7 @@
* getting a Screen that is associated with a screen template.
*
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
- * @version $Id: TurbineTemplate.java,v 1.4 2001/03/06 06:12:51 chrise Exp $
+ * @version $Id: TurbineTemplate.java,v 1.5 2001/03/31 16:02:29 jvanzyl Exp $
*/
public abstract class TurbineTemplate
{
@@ -171,5 +171,20 @@
public static final String getDefaultLayoutTemplate()
{
return getService().getDefaultLayoutTemplate();
+ }
+
+ public static final void registerTemplateEngineService(TemplateEngineService service)
+ {
+ getService().registerTemplateEngineService(service);
+ }
+
+ public static final String[] translateTemplatePaths(String[] templatePaths)
+ {
+ return getService().translateTemplatePaths(templatePaths);
+ }
+
+ public static final boolean templateExists(String template, String[] templatePaths)
+ {
+ return getService().templateExists(template, templatePaths);
}
}
1.22 +31 -59 jakarta-turbine/src/java/org/apache/turbine/services/template/TurbineTemplateService.java
Index: TurbineTemplateService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/template/TurbineTemplateService.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- TurbineTemplateService.java 2001/03/30 17:04:01 1.21
+++ TurbineTemplateService.java 2001/03/31 16:02:30 1.22
@@ -110,10 +110,10 @@
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @version $Id: TurbineTemplateService.java,v 1.21 2001/03/30 17:04:01 jvanzyl Exp $
+ * @version $Id: TurbineTemplateService.java,v 1.22 2001/03/31 16:02:30 jvanzyl Exp $
*/
public class TurbineTemplateService extends TurbineBaseService
- implements TemplateService, TemplateEngineService
+ implements TemplateService
{
/**
* The hashtable used to cache Screen names.
@@ -161,11 +161,6 @@
private String defaultScreen;
/**
- * All the paths for the file base template searching.
- */
- private String[] templateRoot;
-
- /**
* The template engine that will be used to test whether
* a given template exists. You will notice that this
* service implements the TemplateEngineService: this
@@ -210,45 +205,6 @@
*/
Configuration config = getConfiguration();
- /**
- * Get the name of the template service that will
- * be searching for the templates.
- */
- String templateServiceName = config.getString("template.service.name");
-
- /**
- * Get the instance of the service that will be searching
- * for the templates. If we haven't been given a valid
- * template service for performing the template search
- * then this service will take care it, though it will
- * be limited to finding templates in the file system.
- */
- if (templateServiceName != null)
- {
- templateEngineService = (TemplateEngineService)
- TurbineServices.getInstance().getService(templateServiceName);
- }
- else
- {
- templateEngineService = this;
- }
-
- /*
- * Get the template paths listed in the TR.props for the
- * template service this is required for non-Velocity
- * template engines.
- */
- templateRoot = config.getStringArray("template.path");
-
- /*
- * Now translate our template paths to the
- * webapp context.
- */
- for (int i = 0; i < templateRoot.length; i++)
- {
- templateRoot[i] = TurbineServlet.getRealPath(templateRoot[i]);
- }
-
/*
* Check to see if we are going to be caching modules.
*/
@@ -294,6 +250,24 @@
defaultLayoutTemplate = defaultLayoutTemplate + "." + extension;
}
}
+
+ /**
+ * Take a set of template paths and translate them
+ * to the webapp space. This can be used by all
+ * template engine service implementations.
+ *
+ * @param String[] array of template paths to translate
+ * @return String[] array of translated template paths
+ */
+ public String[] translateTemplatePaths(String[] templatePaths)
+ {
+ for (int i = 0; i < templatePaths.length; i++)
+ {
+ templatePaths[i] = TurbineServlet.getRealPath(templatePaths[i]);
+ }
+
+ return templatePaths;
+ }
/**
* Adds the object into the hashtable.
@@ -565,14 +539,7 @@
return holder;
}
- /**
- * Use the companion template engine service to
- * determine whether a template exists.
- *
- * @param String template to search for
- * @return boolean
- */
- public boolean templateExists(String template)
+ public boolean templateExists(String template, String[] templatePaths)
{
/*
* Make sure the template exists and determine the correct
@@ -582,14 +549,14 @@
String allPaths = "";
String pathSep = System.getProperty("path.separator");
- for (int i = 0; i < templateRoot.length; i++)
+ for (int i = 0; i < templatePaths.length; i++)
{
- if (new File(templateRoot[i], template).exists())
+ if (new File(templatePaths[i], template).exists())
{
- pathRoot = templateRoot[i];
+ pathRoot = templatePaths[i];
break;
}
- allPaths += pathSep + templateRoot[i];
+ allPaths += pathSep + templatePaths[i];
}
if (pathRoot == null)
{
@@ -597,7 +564,7 @@
}
return true;
- }
+ }
/**
* Parse the template name out to a package path to locate the
@@ -778,4 +745,9 @@
}
return defaultNavigation;
}
+
+ public void registerTemplateEngineService(TemplateEngineService service)
+ {
+ templateEngineService = service;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org