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:12:53 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/freemarker TurbineFreeMarkerService.java
jvanzyl 01/03/31 08:12:53
Modified: src/java/org/apache/turbine/services/freemarker
TurbineFreeMarkerService.java
Log:
- started changing the freemarker service but need to read up a bit,
it compiles but will probably not work with the revamped template
service. i'm not even sure if anyone is using this so if someone
is and they want this to conform to the TemplateEngineService interface
and register itself with the template service post init then
please give me a hand. otherwise it will take me a couple of
days to get it working. i have set up a testbed for all the template
services and i will add one for freemarker in a couple of days.
Revision Changes Path
1.14 +18 -14 jakarta-turbine/src/java/org/apache/turbine/services/freemarker/TurbineFreeMarkerService.java
Index: TurbineFreeMarkerService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/freemarker/TurbineFreeMarkerService.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TurbineFreeMarkerService.java 2001/03/06 06:12:10 1.13
+++ TurbineFreeMarkerService.java 2001/03/31 16:12:53 1.14
@@ -62,17 +62,20 @@
import javax.servlet.*;
// Turbine Stuff
-import org.apache.turbine.services.*;
-import org.apache.turbine.services.resources.*;
import org.apache.turbine.util.*;
import org.apache.turbine.util.security.*;
import org.apache.turbine.om.security.*;
+import org.apache.turbine.services.*;
+import org.apache.turbine.services.resources.*;
+import org.apache.turbine.services.servlet.TurbineServlet;
import org.apache.ecs.StringElement;
// FreeMarker Stuff
import freemarker.template.*;
+import org.apache.velocity.runtime.configuration.Configuration;
+
/*
* This is a Service that can process FreeMarker templates from within
* a Turbine Screen. Here's an example of how you might use it from a
@@ -88,7 +91,8 @@
* data.getPage().getBody().addElement(results);
*
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
- * @version $Id: TurbineFreeMarkerService.java,v 1.13 2001/03/06 06:12:10 chrise Exp $
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @version $Id: TurbineFreeMarkerService.java,v 1.14 2001/03/31 16:12:53 jvanzyl Exp $
*/
public class TurbineFreeMarkerService
extends TurbineBaseService
@@ -112,17 +116,17 @@
*
* @param config A ServletConfig.
*/
- public void init( ServletConfig config )
- throws InitializationException
+ public void init() throws InitializationException
{
try
{
- initFreeMarker(config);
+ initFreeMarker();
setInit(true);
}
catch (Exception e)
{
- throw new InitializationException("TurbineFreeMarkerService failed to initialize", e);
+ throw new InitializationException(
+ "TurbineFreeMarkerService failed to initialize", e);
}
}
@@ -299,7 +303,8 @@
}
catch(Exception e)
{
- throw new TurbineException("Error encountered processing a template: " + filename, e);
+ throw new TurbineException(
+ "Error encountered processing a template: " + filename, e);
}
finally
{
@@ -376,19 +381,18 @@
* @param config A ServletConfig.
* @exception Exception, a generic exception.
*/
- private void initFreeMarker(ServletConfig config)
- throws Exception
+ private void initFreeMarker() throws Exception
{
- Properties props = getProperties();
+ Configuration config = getConfiguration();
- path = props.getProperty("templates", "/templates");
+ path = config.getString("templates", "/templates");
// If possible, transform paths to be webapp root relative.
- path = ServletUtils.expandRelative(config, path);
+ path = TurbineServlet.getRealPath(path);
// Store the converted path in service properties for Turbine
// based providers.
- props.put("templates", path);
+ config.setProperty("templates", path);
templateCache = new FileTemplateCache(path);
templateCache.addCacheListener(this);
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org