jvanzyl 01/06/14 07:44:01
Modified: src/java/org/apache/turbine/services/template
BaseTemplateEngineService.java
TurbineTemplateService.java
Log:
- updating service as per notes.
Revision Changes Path
1.7 +12 -14
jakarta-turbine/src/java/org/apache/turbine/services/template/BaseTemplateEngineService.java
Index: BaseTemplateEngineService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/template/BaseTemplateEngineService.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BaseTemplateEngineService.java 2001/04/05 13:42:39 1.6
+++ BaseTemplateEngineService.java 2001/06/14 14:44:01 1.7
@@ -57,8 +57,7 @@
import java.util.Iterator;
import java.util.Hashtable;
-import org.apache.turbine.services.TurbineBaseService;
-import org.apache.velocity.runtime.configuration.Configuration;
+import org.apache.turbine.services.BaseService;
/**
* The base implementation of Turbine {@link
@@ -66,9 +65,10 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: BaseTemplateEngineService.java,v 1.6 2001/04/05 13:42:39 rafal Exp
$
+ * @version $Id: BaseTemplateEngineService.java,v 1.7 2001/06/14 14:44:01 jvanzyl
Exp $
*/
-public abstract class BaseTemplateEngineService extends TurbineBaseService
+public abstract class BaseTemplateEngineService
+ extends BaseService
implements TemplateEngineService
{
/**
@@ -122,20 +122,18 @@
*/
protected void initConfiguration(String defaultExt)
{
- Configuration config = getConfiguration();
-
/*
* Should modify the configuration class to take defaults
* here, should have to do this.
*/
String[] fileExtensionAssociations =
- config.getStringArray(TEMPLATE_EXTENSIONS);
+ getConfiguration().getStringArray(TEMPLATE_EXTENSIONS);
if (fileExtensionAssociations == null ||
fileExtensionAssociations.length == 0)
{
fileExtensionAssociations = new String[1];
- fileExtensionAssociations[0] = config.getString(
+ fileExtensionAssociations[0] = getConfiguration().getString(
DEFAULT_TEMPLATE_EXTENSION, defaultExt);
}
@@ -146,15 +144,15 @@
* throw an exception here if these things aren't set
* up correctly.
*/
- configuration.put(DEFAULT_PAGE, config.getString(DEFAULT_PAGE));
- configuration.put(DEFAULT_SCREEN, config.getString(DEFAULT_SCREEN));
- configuration.put(DEFAULT_LAYOUT, config.getString(DEFAULT_LAYOUT));
+ configuration.put(DEFAULT_PAGE, getConfiguration().getString(DEFAULT_PAGE));
+ configuration.put(DEFAULT_SCREEN,
getConfiguration().getString(DEFAULT_SCREEN));
+ configuration.put(DEFAULT_LAYOUT,
getConfiguration().getString(DEFAULT_LAYOUT));
configuration.put(DEFAULT_NAVIGATION,
- config.getString(DEFAULT_NAVIGATION));
+ getConfiguration().getString(DEFAULT_NAVIGATION));
configuration.put(DEFAULT_ERROR_SCREEN,
- config.getString(DEFAULT_ERROR_SCREEN));
+ getConfiguration().getString(DEFAULT_ERROR_SCREEN));
configuration.put(DEFAULT_LAYOUT_TEMPLATE,
- config.getString(DEFAULT_LAYOUT_TEMPLATE));
+ getConfiguration().getString(DEFAULT_LAYOUT_TEMPLATE));
}
/**
1.45 +27 -24
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.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- TurbineTemplateService.java 2001/05/10 21:30:09 1.44
+++ TurbineTemplateService.java 2001/06/14 14:44:01 1.45
@@ -65,12 +65,14 @@
import org.apache.turbine.util.RunData;
-import org.apache.turbine.services.TurbineBaseService;
+import org.apache.turbine.services.BaseService;
import org.apache.turbine.services.InitializationException;
-import org.apache.turbine.services.resources.TurbineResources;
-import org.apache.turbine.services.servlet.TurbineServlet;
-import org.apache.velocity.runtime.configuration.Configuration;
+//!! It would be nice to remove this and make it a property
+// of the services. This service may only be usable within
+// the context of Turbine but it would be nice if this
+// service could be used outside the context of turbine.
+import org.apache.turbine.services.resources.TurbineResources;
/**
* This service provides a method for mapping templates to their
@@ -110,9 +112,10 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Ilkka Priha</a>
- * @version $Id: TurbineTemplateService.java,v 1.44 2001/05/10 21:30:09 jmcnally
Exp $
+ * @version $Id: TurbineTemplateService.java,v 1.45 2001/06/14 14:44:01 jvanzyl Exp
$
*/
-public class TurbineTemplateService extends TurbineBaseService
+public class TurbineTemplateService
+ extends BaseService
implements TemplateService
{
/**
@@ -338,6 +341,7 @@
public String getDefaultPageName(RunData data)
{
String template = data.getParameters().get("template");
+
return template != null ?
getDefaultPageName(template) : getDefaultPage();
}
@@ -437,7 +441,7 @@
{
for (int i = 0; i < templatePaths.length; i++)
{
- templatePaths[i] = TurbineServlet.getRealPath(templatePaths[i]);
+ templatePaths[i] = getRealPath(templatePaths[i]);
}
return templatePaths;
}
@@ -519,8 +523,7 @@
* @param key The module type key.
* @return The default page module name.
*/
- protected String getDefaultModuleName(String template,
- int key)
+ protected String getDefaultModuleName(String template, int key)
{
TemplateEngineService tes = getTemplateEngineService(template);
return tes != null ?
@@ -538,8 +541,7 @@
* @return The cached name.
* @exception Exception, a generic exception.
*/
- protected String getCachedName(String template,
- int key)
+ protected String getCachedName(String template, int key)
throws Exception
{
/*
@@ -720,12 +722,13 @@
/* Let the template engine service to check its existance. */
TemplateEngineService tes = getTemplateEngineService(template);
- if ((tes == null) ||
- !tes.templateExists(path.toString()))
+
+ if ((tes == null) || !tes.templateExists(path.toString()))
{
throw new Exception(
"Screen template '" + template + "' not found");
}
+
return path.substring(7);
}
@@ -887,28 +890,28 @@
private void initTemplate()
{
/*
- * Get the configuration for the template service.
- */
- Configuration config = getConfiguration();
-
- /*
* Get the default extension to use if nothing else is applicable.
*/
- defaultExtension = config.getString("default.extension",NO_FILE_EXT);
+ defaultExtension =
getConfiguration().getString("default.extension",NO_FILE_EXT);
defaultTemplate = "Default." + defaultExtension;
/*
* Check to see if we are going to be caching modules.
*/
+
+ //!! This is some nasty coupling. This may not be
+ // preventable and turbine specific but it would be
+ // nice if this system could work outside of turbine
+ // if someone so desired to use it. jvz.
useCache = TurbineResources.getBoolean("module.cache",true);
if (useCache)
{
- int screenSize = config.getInt("screen.cache.size",5);
- int screenTemplateSize = config.getInt("screen.cache.size",50);
- int layoutSize = config.getInt("layout.cache.size",5);
- int layoutTemplateSize = config.getInt("layout.cache.size",5);
- int navigationSize = config.getInt("navigation.cache.size",10);
+ int screenSize = getConfiguration().getInt("screen.cache.size",5);
+ int screenTemplateSize =
getConfiguration().getInt("screen.cache.size",50);
+ int layoutSize = getConfiguration().getInt("layout.cache.size",5);
+ int layoutTemplateSize =
getConfiguration().getInt("layout.cache.size",5);
+ int navigationSize =
getConfiguration().getInt("navigation.cache.size",10);
/*
* Create hashtables for each object type,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]