org.xwiki.velocity.internal
Class DefaultVelocityEngine

java.lang.Object
  extended by org.xwiki.velocity.internal.DefaultVelocityEngine
All Implemented Interfaces:
org.apache.velocity.runtime.log.LogChute, VelocityEngine

@Component
@InstantiationStrategy(value=PER_LOOKUP)
public class DefaultVelocityEngine
extends java.lang.Object
implements VelocityEngine, org.apache.velocity.runtime.log.LogChute

Default implementation of the Velocity service which initializes the Velocity system using configuration values defined in the component's configuration. Note that the initialize(java.util.Properties) method has to be executed before any other method can be called.

Version:
$Id$

Field Summary
 
Fields inherited from interface org.apache.velocity.runtime.log.LogChute
DEBUG_ID, DEBUG_PREFIX, ERROR_ID, ERROR_PREFIX, INFO_ID, INFO_PREFIX, TRACE_ID, TRACE_PREFIX, WARN_ID, WARN_PREFIX
 
Constructor Summary
DefaultVelocityEngine()
           
 
Method Summary
 void clearMacroNamespace(java.lang.String templateName)
          Clear the internal Velocity Macro cache for the passed namespace.
 boolean evaluate(org.apache.velocity.context.Context context, java.io.Writer out, java.lang.String templateName, java.io.Reader source)
          Renders the input string using the context into the output writer.
 boolean evaluate(org.apache.velocity.context.Context context, java.io.Writer out, java.lang.String templateName, java.lang.String source)
          Renders the input string using the context into the output writer.
 void init(org.apache.velocity.runtime.RuntimeServices runtimeServices)
          
 void initialize(java.util.Properties overridingProperties)
          Initializes the Velocity engine by setting its configuration both from the component's configuration and from the passed properties.
 boolean isLevelEnabled(int level)
          
 void log(int level, java.lang.String message)
          
 void log(int level, java.lang.String message, java.lang.Throwable throwable)
          
 void startedUsingMacroNamespace(java.lang.String namespace)
          Notify that a rendering action is starting in the given namespace.
 void stoppedUsingMacroNamespace(java.lang.String namespace)
          Notify that a rendering action in the given namespace just finished.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultVelocityEngine

public DefaultVelocityEngine()
Method Detail

initialize

public void initialize(java.util.Properties overridingProperties)
                throws XWikiVelocityException
Initializes the Velocity engine by setting its configuration both from the component's configuration and from the passed properties. This method must be called before any other method from this class can be executed.

Specified by:
initialize in interface VelocityEngine
Parameters:
overridingProperties - the properties that will override the static properties defined in the component's configuration
Throws:
XWikiVelocityException - in case of error
See Also:
VelocityEngine.initialize(Properties)

evaluate

public boolean evaluate(org.apache.velocity.context.Context context,
                        java.io.Writer out,
                        java.lang.String templateName,
                        java.lang.String source)
                 throws XWikiVelocityException
Renders the input string using the context into the output writer.

Specified by:
evaluate in interface VelocityEngine
Parameters:
context - the Velocity context to use in rendering the input string
out - the writer in which to render the output
templateName - the string to be used as the template name for log messages in case of error
source - the input string containing the VTL to be rendered
Returns:
true if successful, false otherwise. If false, see the Velocity runtime log
Throws:
XWikiVelocityException - in case of error
See Also:
VelocityEngine.evaluate(Context, java.io.Writer, String, String)

evaluate

public boolean evaluate(org.apache.velocity.context.Context context,
                        java.io.Writer out,
                        java.lang.String templateName,
                        java.io.Reader source)
                 throws XWikiVelocityException
Renders the input string using the context into the output writer.

Specified by:
evaluate in interface VelocityEngine
Parameters:
context - the Velocity context to use in rendering the input string
out - the writer in which to render the output
templateName - the string to be used as the template name for log messages in case of error
source - the input containing the VTL to be rendered, as a Reader
Returns:
true if successful, false otherwise. If false, see the Velocity runtime log
Throws:
XWikiVelocityException - in case of error
See Also:
VelocityEngine.evaluate(Context, java.io.Writer, String, String), init(RuntimeServices)

clearMacroNamespace

public void clearMacroNamespace(java.lang.String templateName)
Clear the internal Velocity Macro cache for the passed namespace.

Specified by:
clearMacroNamespace in interface VelocityEngine
Parameters:
templateName - the namespace for which to remove all cached Velocity macros
Since:
2.4M2
See Also:
VelocityEngine.clearMacroNamespace(String)

startedUsingMacroNamespace

public void startedUsingMacroNamespace(java.lang.String namespace)
Notify that a rendering action is starting in the given namespace.

Specified by:
startedUsingMacroNamespace in interface VelocityEngine
Parameters:
namespace - the namespace being used
Since:
2.4RC1
See Also:
VelocityEngine.startedUsingMacroNamespace(String)

stoppedUsingMacroNamespace

public void stoppedUsingMacroNamespace(java.lang.String namespace)
Notify that a rendering action in the given namespace just finished.

Specified by:
stoppedUsingMacroNamespace in interface VelocityEngine
Parameters:
namespace - the namespace which was used
Since:
2.4RC1
See Also:
VelocityEngine.stoppedUsingMacroNamespace(String)

init

public void init(org.apache.velocity.runtime.RuntimeServices runtimeServices)

Specified by:
init in interface org.apache.velocity.runtime.log.LogChute
See Also:
LogChute.init(org.apache.velocity.runtime.RuntimeServices)

log

public void log(int level,
                java.lang.String message)

Specified by:
log in interface org.apache.velocity.runtime.log.LogChute
See Also:
LogChute.log(int, String)

log

public void log(int level,
                java.lang.String message,
                java.lang.Throwable throwable)

Specified by:
log in interface org.apache.velocity.runtime.log.LogChute
See Also:
LogChute.log(int, String, Throwable)

isLevelEnabled

public boolean isLevelEnabled(int level)

Specified by:
isLevelEnabled in interface org.apache.velocity.runtime.log.LogChute
See Also:
LogChute.isLevelEnabled(int)


Copyright © 2004-2011 XWiki. All Rights Reserved.