You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2002/12/20 01:17:24 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/velocity TurbineVelocityService.java
henning 2002/12/19 16:17:24
Modified: src/java/org/apache/turbine/services/velocity
TurbineVelocityService.java
Log:
Start up Velocity by initializing the SimpleLog4j logging system and
accessing the velocity logging facility. Which ends up in the velocity.log
like before.
Revision Changes Path
1.10 +34 -31 jakarta-turbine-2/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java
Index: TurbineVelocityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TurbineVelocityService.java 14 Aug 2002 16:44:09 -0000 1.9
+++ TurbineVelocityService.java 20 Dec 2002 00:17:24 -0000 1.10
@@ -59,25 +59,40 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
+
import java.util.Iterator;
import java.util.Vector;
+
import javax.servlet.ServletConfig;
+
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationConverter;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.turbine.Turbine;
+import org.apache.turbine.TurbineConstants;
+
import org.apache.turbine.services.InitializationException;
+
import org.apache.turbine.services.pull.TurbinePull;
+
import org.apache.turbine.services.servlet.TurbineServlet;
+
import org.apache.turbine.services.template.BaseTemplateEngineService;
-import org.apache.turbine.util.Log;
+
import org.apache.turbine.util.RunData;
-import org.apache.turbine.util.StringUtils;
import org.apache.turbine.util.TurbineConfig;
import org.apache.turbine.util.TurbineException;
+
import org.apache.velocity.VelocityContext;
+
import org.apache.velocity.app.Velocity;
+
import org.apache.velocity.context.Context;
+import org.apache.velocity.runtime.log.SimpleLog4JLogSystem;
/**
* This is a Service that can process Velocity templates from within a
@@ -96,9 +111,11 @@
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @author <a href="mailto:sean@informage.ent">Sean Legassick</a>
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
-public class TurbineVelocityService extends BaseTemplateEngineService
+public class TurbineVelocityService
+ extends BaseTemplateEngineService
implements VelocityService
{
/**
@@ -122,6 +139,9 @@
*/
private static final String ABSOLUTE_PREFIX = "file://";
+ /** Logging */
+ private static Log log = LogFactory.getLog(TurbineVelocityService.class);
+
/**
* The context used to the store the context
* containing the global application tools.
@@ -162,7 +182,8 @@
*
* @throws InitializationException Something went wrong when starting up.
*/
- public void init(ServletConfig config) throws InitializationException
+ public void init(ServletConfig config)
+ throws InitializationException
{
try
{
@@ -529,7 +550,7 @@
throws TurbineException
{
String err = "Error rendering Velocity template: " + filename;
- Log.error(err + ": " + e.getMessage());
+ log.error(err + ": " + e.getMessage());
throw new TurbineException(err, e);
}
@@ -539,36 +560,18 @@
*
* @exception InitializationException For any errors during initialization.
*/
- private void initVelocity() throws InitializationException
+ private void initVelocity()
+ throws InitializationException
{
/*
* Get the configuration for this service.
*/
Configuration configuration = getConfiguration();
- /*
- * Now we have to perform a couple of path translations
- * for our log file and template paths.
- */
- String path = Turbine.getRealPath
- (configuration.getString(Velocity.RUNTIME_LOG, null));
-
- if (StringUtils.isValid(path))
- {
- configuration.setProperty(Velocity.RUNTIME_LOG, path);
- }
- else
- {
- String msg = VelocityService.SERVICE_NAME + " runtime log file " +
- "is misconfigured: '" + path + "' is not a valid log file";
-
- if (TurbineServlet.getServletConfig() instanceof TurbineConfig)
- {
- msg += ": TurbineConfig users must use a path relative to " +
- "web application root";
- }
- throw new Error(msg);
- }
+ configuration.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
+ SimpleLog4JLogSystem.class.getName());
+ configuration.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM + ".log4j.category",
+ "velocity");
/*
* Get all the template paths where the velocity runtime should search
@@ -605,7 +608,7 @@
for (Iterator j = paths.iterator(); j.hasNext();)
{
- path = (String) j.next();
+ String path = (String) j.next();
if (path.startsWith(JAR_PREFIX + "file"))
{
/*
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>