public class VelocityScriptEngine
extends javax.script.AbstractScriptEngine
implements javax.script.Compilable
Modifier and Type | Class and Description |
---|---|
protected static class |
VelocityScriptEngine.SingleResourceReader |
Modifier and Type | Field and Description |
---|---|
private javax.script.ScriptEngineFactory |
factory |
static java.lang.String |
VELOCITY_PROPERTIES_KEY
Key used to provide this engine with the pathname of the Velocity properties file.
|
private RuntimeInstance |
velocityEngine |
Constructor and Description |
---|
VelocityScriptEngine()
constructs a new standalone Velocity script engine
|
VelocityScriptEngine(javax.script.ScriptEngineFactory factory)
constructs a new Velocity script engine, linked to the given factory
|
Modifier and Type | Method and Description |
---|---|
javax.script.CompiledScript |
compile(java.io.Reader script)
Compile a template
|
javax.script.CompiledScript |
compile(java.lang.String script)
Compile a template
|
javax.script.Bindings |
createBindings()
creates a new Bindings to be used with this script
|
java.lang.Object |
eval(java.io.Reader reader,
javax.script.ScriptContext ctx)
Evaluate the given script.
|
java.lang.Object |
eval(java.lang.String str,
javax.script.ScriptContext ctx)
Evaluate the given script.
|
javax.script.ScriptEngineFactory |
getFactory()
get the factory used to create this script engine
|
protected static java.lang.String |
getFilename(javax.script.ScriptContext ctx) |
protected static VelocityContext |
getVelocityContext(javax.script.ScriptContext ctx) |
protected RuntimeInstance |
getVelocityEngine()
get the internal Velocity RuntimeInstance
|
protected static java.util.Properties |
getVelocityProperties(javax.script.ScriptContext ctx) |
private void |
initVelocityEngine(javax.script.ScriptContext ctx) |
public static final java.lang.String VELOCITY_PROPERTIES_KEY
private volatile javax.script.ScriptEngineFactory factory
private volatile RuntimeInstance velocityEngine
public VelocityScriptEngine(javax.script.ScriptEngineFactory factory)
factory
- public VelocityScriptEngine()
protected RuntimeInstance getVelocityEngine()
public java.lang.Object eval(java.lang.String str, javax.script.ScriptContext ctx) throws javax.script.ScriptException
eval
in interface javax.script.ScriptEngine
str
- script sourcectx
- script contextjavax.script.ScriptException
public java.lang.Object eval(java.io.Reader reader, javax.script.ScriptContext ctx) throws javax.script.ScriptException
eval
in interface javax.script.ScriptEngine
reader
- script source readerctx
- script contextjavax.script.ScriptException
public javax.script.ScriptEngineFactory getFactory()
getFactory
in interface javax.script.ScriptEngine
public javax.script.Bindings createBindings()
createBindings
in interface javax.script.ScriptEngine
private void initVelocityEngine(javax.script.ScriptContext ctx)
protected static VelocityContext getVelocityContext(javax.script.ScriptContext ctx)
protected static java.lang.String getFilename(javax.script.ScriptContext ctx)
protected static java.util.Properties getVelocityProperties(javax.script.ScriptContext ctx)
public javax.script.CompiledScript compile(java.lang.String script) throws javax.script.ScriptException
compile
in interface javax.script.Compilable
script
- template sourcejavax.script.ScriptException
public javax.script.CompiledScript compile(java.io.Reader script) throws javax.script.ScriptException
compile
in interface javax.script.Compilable
script
- template sourcejavax.script.ScriptException