|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.velocity.runtime.RuntimeInstance
public class RuntimeInstance
This is the Runtime system for Velocity. It is the single access point for all functionality in Velocity. It adheres to the mediator pattern and is the only structure that developers need to be familiar with in order to get Velocity to perform. The Runtime will also cooperate with external systems like Turbine. Runtime properties can set and then the Runtime is initialized. Turbine, for example, knows where the templates are to be loaded from, and where the Velocity log file should be placed. So in the case of Velocity cooperating with Turbine the code might look something like the following:
ri.setProperty(Runtime.FILE_RESOURCE_LOADER_PATH, templatePath);
ri.setProperty(Runtime.RUNTIME_LOG, pathToVelocityLog);
ri.init();
----------------------------------------------------------------------- N O T E S O N R U N T I M E I N I T I A L I Z A T I O N ----------------------------------------------------------------------- init() If init() is called by itself the RuntimeInstance will initialize with a set of default values. ----------------------------------------------------------------------- init(String/Properties) In this case the default velocity properties are layed down first to provide a solid base, then any properties provided in the given properties object will override the corresponding default property. -----------------------------------------------------------------------
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
RuntimeInstance()
|
|
| Method Summary | |
|---|---|
void |
addProperty(String key,
Object value)
Add a property to the configuration. |
boolean |
addVelocimacro(String name,
String macro,
String[] argArray,
String sourceTemplate,
int line,
int column)
Adds a new Velocimacro. |
void |
clearProperty(String key)
Clear the values pertaining to a particular property. |
Parser |
createNewParser()
Returns a JavaCC generated Parser. |
boolean |
dumpVMNamespace(String namespace)
tells the vmFactory to dump the specified namespace. |
Object |
getApplicationAttribute(Object key)
Gets the application attribute for the given key |
boolean |
getBoolean(String key,
boolean def)
Boolean property accessor method to hide the configuration implementation. |
org.apache.commons.collections.ExtendedProperties |
getConfiguration()
Return the velocity runtime configuration object. |
ContentResource |
getContent(String name)
Returns a static content resource from the resource manager. |
ContentResource |
getContent(String name,
String encoding)
Returns a static content resource from the resource manager. |
int |
getInt(String key)
Int property accessor method to hide the configuration implementation. |
int |
getInt(String key,
int defaultValue)
Int property accessor method to hide the configuration implementation. |
Introspector |
getIntrospector()
Return the Introspector for this instance |
String |
getLoaderNameForResource(String resourceName)
Determines is a template exists, and returns name of the loader that provides it. |
Object |
getProperty(String key)
Allows an external caller to get a property. |
String |
getString(String key)
String property accessor method to hide the configuration implementation |
String |
getString(String key,
String defaultValue)
String property accessor method with default to hide the configuration implementation. |
Template |
getTemplate(String name)
Returns a Template from the resource manager. |
Template |
getTemplate(String name,
String encoding)
Returns a Template from the resource manager |
Uberspect |
getUberspect()
Returns the configured class introspection/reflection implemenation. |
Directive |
getVelocimacro(String vmName,
String templateName)
Returns the appropriate VelocimacroProxy object if strVMname is a valid current Velocimacro. |
void |
init()
|
void |
init(Properties p)
Initialize the Velocity Runtime with a Properties object. |
void |
init(String configurationFile)
Initialize the Velocity Runtime with the name of ExtendedProperties object. |
boolean |
isVelocimacro(String vmName,
String templateName)
Checks to see if a VM exists |
SimpleNode |
parse(Reader reader,
String templateName)
Parse the input and return the root of AST node structure. |
SimpleNode |
parse(Reader reader,
String templateName,
boolean dumpNamespace)
Parse the input and return the root of the AST node structure. |
Object |
setApplicationAttribute(Object key,
Object o)
Sets the application attribute for the given key |
void |
setConfiguration(org.apache.commons.collections.ExtendedProperties configuration)
Allow an external system to set an ExtendedProperties object to use. |
void |
setProperty(String key,
Object value)
Allows an external system to set a property in the Velocity Runtime. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RuntimeInstance()
| Method Detail |
|---|
public void init()
throws Exception
init in interface RuntimeServicesException
public void setProperty(String key,
Object value)
setProperty in interface RuntimeServiceskey - property keyvalue - property valuepublic void setConfiguration(org.apache.commons.collections.ExtendedProperties configuration)
setConfiguration in interface RuntimeServicesconfiguration -
public void addProperty(String key,
Object value)
addProperty in interface RuntimeServiceskey - value - public void clearProperty(String key)
clearProperty in interface RuntimeServiceskey - of property to clearpublic Object getProperty(String key)
getProperty in interface RuntimeServiceskey - property to return
public void init(Properties p)
throws Exception
init in interface RuntimeServicesp -
Exception
public void init(String configurationFile)
throws Exception
init in interface RuntimeServicesconfigurationFile -
Exceptionpublic Parser createNewParser()
public SimpleNode parse(Reader reader,
String templateName)
throws ParseException
parse in interface RuntimeServicesreader - Reader retrieved by a resource loadertemplateName - name of the template being parsed
ParseException
public SimpleNode parse(Reader reader,
String templateName,
boolean dumpNamespace)
throws ParseException
parse in interface RuntimeServicesreader - Reader retrieved by a resource loadertemplateName - name of the template being parseddumpNamespace - flag to dump the Velocimacro namespace for this template
ParseException
public Template getTemplate(String name)
throws ResourceNotFoundException,
ParseErrorException,
Exception
Template from the resource manager.
This method assumes that the character encoding of the
template is set by the input.encoding
property. The default is "ISO-8859-1"
getTemplate in interface RuntimeServicesname - The file name of the desired template.
ResourceNotFoundException - if template not found
from any available source.
ParseErrorException - if template cannot be parsed due
to syntax (or other) error.
Exception - if an error occurs in template initialization
public Template getTemplate(String name,
String encoding)
throws ResourceNotFoundException,
ParseErrorException,
Exception
Template from the resource manager
getTemplate in interface RuntimeServicesname - The name of the desired template.encoding - Character encoding of the template
ResourceNotFoundException - if template not found
from any available source.
ParseErrorException - if template cannot be parsed due
to syntax (or other) error.
Exception - if an error occurs in template initialization
public ContentResource getContent(String name)
throws ResourceNotFoundException,
ParseErrorException,
Exception
getContent in interface RuntimeServicesname - Name of content resource to get
ResourceNotFoundException - if template not found
from any available source.
ParseErrorException
Exception
public ContentResource getContent(String name,
String encoding)
throws ResourceNotFoundException,
ParseErrorException,
Exception
getContent in interface RuntimeServicesname - Name of content resource to getencoding - Character encoding to use
ResourceNotFoundException - if template not found
from any available source.
ParseErrorException
Exceptionpublic String getLoaderNameForResource(String resourceName)
getLoaderNameForResource in interface RuntimeServicesresourceName - Name of template or content resource
public String getString(String key,
String defaultValue)
getString in interface RuntimeServiceskey - property keydefaultValue - default value to return if key not
found in resource manager.
public Directive getVelocimacro(String vmName,
String templateName)
getVelocimacro in interface RuntimeServicesvmName - Name of velocimacro requestedtemplateName -
public boolean addVelocimacro(String name,
String macro,
String[] argArray,
String sourceTemplate,
int line,
int column)
addVelocimacro in interface RuntimeServicesname - Name of velocimacromacro - String form of macro bodyargArray - Array of strings, containing the
#macro() arguments. the 0th is the name.sourceTemplate - line - the line, where the macro startscolumn - the column, where the macro starts
public boolean isVelocimacro(String vmName,
String templateName)
isVelocimacro in interface RuntimeServicesvmName - Name of the Velocimacro.templateName -
public boolean dumpVMNamespace(String namespace)
dumpVMNamespace in interface RuntimeServicespublic String getString(String key)
getString in interface RuntimeServiceskey - property key
public int getInt(String key)
getInt in interface RuntimeServiceskey - Property key
public int getInt(String key,
int defaultValue)
getInt in interface RuntimeServiceskey - property keydefaultValue - default value
public boolean getBoolean(String key,
boolean def)
getBoolean in interface RuntimeServiceskey - property keydef - default value if property not found
public org.apache.commons.collections.ExtendedProperties getConfiguration()
getConfiguration in interface RuntimeServicespublic Introspector getIntrospector()
getIntrospector in interface RuntimeServicespublic Object getApplicationAttribute(Object key)
getApplicationAttribute in interface RuntimeServiceskey -
null if not available
public Object setApplicationAttribute(Object key,
Object o)
key - o -
public Uberspect getUberspect()
RuntimeServices
getUberspect in interface RuntimeServices
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||