|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.runtime.Runtime
public class Runtime
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:
Runtime.setProperty(Runtime.FILE_RESOURCE_LOADER_PATH, templatePath); Runtime.setProperty(Runtime.RUNTIME_LOG, pathToVelocityLog); Runtime.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 ----------------------------------------------------------------------- Runtime.init() If Runtime.init() is called by itself the Runtime will initialize with a set of default values. ----------------------------------------------------------------------- Runtime.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. -----------------------------------------------------------------------
RuntimeInstance
,
RuntimeSingleton
Field Summary |
---|
Constructor Summary | |
---|---|
Runtime()
Deprecated. |
Method Summary | |
---|---|
static void |
addProperty(String key,
Object value)
Deprecated. Add a property to the configuration. |
static boolean |
addVelocimacro(String name,
String macro,
String[] argArray,
String sourceTemplate)
Deprecated. Just like the whole class.... |
static void |
clearProperty(String key)
Deprecated. Clear the values pertaining to a particular property. |
static void |
debug(Object message)
Deprecated. Log a debug message. |
static boolean |
dumpVMNamespace(String namespace)
Deprecated. tells the vmFactory to dump the specified namespace. |
static void |
error(Object message)
Deprecated. Log an error message. |
static boolean |
getBoolean(String key,
boolean def)
Deprecated. Boolean property accessor method to hide the configuration implementation. |
static ExtendedProperties |
getConfiguration()
Deprecated. Return the velocity runtime configuration object. |
static ContentResource |
getContent(String name)
Deprecated. Returns a static content resource from the resource manager. |
static ContentResource |
getContent(String name,
String encoding)
Deprecated. Returns a static content resource from the resource manager. |
static int |
getInt(String key)
Deprecated. Int property accessor method to hide the configuration implementation. |
static int |
getInt(String key,
int defaultValue)
Deprecated. Int property accessor method to hide the configuration implementation. |
static String |
getLoaderNameForResource(String resourceName)
Deprecated. Determines is a template exists, and returns name of the loader that provides it. |
static Object |
getProperty(String key)
Deprecated. Allows an external caller to get a property. |
static String |
getString(String key)
Deprecated. String property accessor method to hide the configuration implementation |
static String |
getString(String key,
String defaultValue)
Deprecated. String property accessor method with default to hide the configuration implementation. |
static Template |
getTemplate(String name)
Deprecated. Returns a Template from the resource manager. |
static Template |
getTemplate(String name,
String encoding)
Deprecated. Returns a Template from the resource manager |
static Directive |
getVelocimacro(String vmName,
String templateName)
Deprecated. Returns the appropriate VelocimacroProxy object if strVMname is a valid current Velocimacro. |
static void |
info(Object message)
Deprecated. Log an info message. |
static void |
init()
Deprecated. This is the primary initialization method in the Velocity Runtime. |
static void |
init(Properties p)
Deprecated. Initialize the Velocity Runtime with a Properties object. |
static void |
init(String configurationFile)
Deprecated. Initialize the Velocity Runtime with the name of ExtendedProperties object. |
static boolean |
isVelocimacro(String vmName,
String templateName)
Deprecated. Checks to see if a VM exists |
static SimpleNode |
parse(Reader reader,
String templateName)
Deprecated. Parse the input and return the root of AST node structure. |
static SimpleNode |
parse(Reader reader,
String templateName,
boolean dumpNamespace)
Deprecated. Parse the input and return the root of the AST node structure. |
static void |
setConfiguration(ExtendedProperties configuration)
Deprecated. Allow an external system to set an ExtendedProperties object to use. |
static void |
setProperty(String key,
Object value)
Deprecated. Allows an external system to set a property in the Velocity Runtime. |
static void |
warn(Object message)
Deprecated. Log a warning message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Runtime()
Method Detail |
---|
public static void init() throws Exception
Exception
- When init fails for any reason.public static void setProperty(String key, Object value)
key
- The property key.value
- The property value.public static void setConfiguration(ExtendedProperties configuration)
configuration
- A configuration object.public static void addProperty(String key, Object value)
key
- A property key.value
- The property value.public static void clearProperty(String key)
key
- Name of the property to clear.public static Object getProperty(String key)
key
- property to return
public static void init(Properties p) throws Exception
p
- The properties used for initializiation.
Exception
- When a problem occurs during init.public static void init(String configurationFile) throws Exception
configurationFile
- The name of a properties file.
Exception
- When a problem occurs during init.public static SimpleNode parse(Reader reader, String templateName) throws ParseException
reader
- A reader returning the template input stream.templateName
- name of the template being parsed
ParseException
- When the input stream is not parsable.public static SimpleNode parse(Reader reader, String templateName, boolean dumpNamespace) throws ParseException
reader
- A reader returning the template input stream.templateName
- name of the template being parseddumpNamespace
- flag to dump the Velocimacro namespace for this template.
ParseException
- When the input stream is not parsable.parse(Reader, String)
public static 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"
name
- 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 static Template getTemplate(String name, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception
Template
from the resource manager
name
- 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 initializationpublic static ContentResource getContent(String name) throws ResourceNotFoundException, ParseErrorException, Exception
name
- Name of content resource to get
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 initializationpublic static ContentResource getContent(String name, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception
name
- Name of content resource to getencoding
- Character encoding to use
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 initializationpublic static String getLoaderNameForResource(String resourceName)
resourceName
- Name of template or content resource
public static void warn(Object message)
message
- message to logpublic static void info(Object message)
message
- message to logpublic static void error(Object message)
message
- message to logpublic static void debug(Object message)
message
- message to logpublic static String getString(String key, String defaultValue)
key
- A property key.defaultValue
- default value to return if key not
found in resource manager.
public static Directive getVelocimacro(String vmName, String templateName)
vmName
- Name of velocimacro requestedtemplateName
- The template from which the macro is requested.
public static boolean addVelocimacro(String name, String macro, String[] argArray, String sourceTemplate)
name
- Name of a new velocimacro.macro
- String form of the macro body.argArray
- Array of strings, containing the
#macro() arguments. the 0th argument is the name.sourceTemplate
- The template from which the macro is requested.
public static boolean isVelocimacro(String vmName, String templateName)
vmName
- The name of velocimacro.templateName
- The template from which the macro is requested.
public static boolean dumpVMNamespace(String namespace)
namespace
- The namespace to dump.
public static String getString(String key)
key
- property key
public static int getInt(String key)
key
- A property key.
public static int getInt(String key, int defaultValue)
key
- property keydefaultValue
- default value
public static boolean getBoolean(String key, boolean def)
key
- property keydef
- default default value if property not found
public static ExtendedProperties getConfiguration()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |