public class RuntimeSingleton extends java.lang.Object implements RuntimeConstants
RuntimeSingleton.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatePath); RuntimeSingleton.setProperty(RuntimeConstants.RUNTIME_LOG, pathToVelocityLog); RuntimeSingleton.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 ----------------------------------------------------------------------- RuntimeSingleton.init() If Runtime.init() is called by itself the Runtime will initialize with a set of default values. ----------------------------------------------------------------------- RuntimeSingleton.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
Modifier and Type | Field and Description |
---|---|
private static RuntimeInstance |
ri |
COUNTER_INITIAL_VALUE, COUNTER_NAME, DEBUG_PREFIX, DEFAULT_RUNTIME_DIRECTIVES, DEFAULT_RUNTIME_PROPERTIES, ENCODING_DEFAULT, ERROR_PREFIX, ERRORMSG_END, ERRORMSG_START, FILE_RESOURCE_LOADER_CACHE, FILE_RESOURCE_LOADER_PATH, INFO_PREFIX, INPUT_ENCODING, INTERPOLATE_STRINGLITERALS, LOGSYSTEM_LOG4J_EMAIL_BUFFER_SIZE, LOGSYSTEM_LOG4J_EMAIL_FROM, LOGSYSTEM_LOG4J_EMAIL_SERVER, LOGSYSTEM_LOG4J_EMAIL_SUBJECT, LOGSYSTEM_LOG4J_EMAIL_TO, LOGSYSTEM_LOG4J_FILE_BACKUPS, LOGSYSTEM_LOG4J_FILE_SIZE, LOGSYSTEM_LOG4J_PATTERN, LOGSYSTEM_LOG4J_REMOTE_HOST, LOGSYSTEM_LOG4J_REMOTE_PORT, LOGSYSTEM_LOG4J_SYSLOGD_FACILITY, LOGSYSTEM_LOG4J_SYSLOGD_HOST, NUMBER_OF_PARSERS, OUTPUT_ENCODING, PARSE_DIRECTIVE_MAXDEPTH, PARSER_POOL_SIZE, RESOURCE_LOADER, RESOURCE_MANAGER_CACHE_CLASS, RESOURCE_MANAGER_CLASS, RESOURCE_MANAGER_LOGWHENFOUND, RUNTIME_LOG, RUNTIME_LOG_ERROR_STACKTRACE, RUNTIME_LOG_INFO_STACKTRACE, RUNTIME_LOG_LOGSYSTEM, RUNTIME_LOG_LOGSYSTEM_CLASS, RUNTIME_LOG_REFERENCE_LOG_INVALID, RUNTIME_LOG_WARN_STACKTRACE, UBERSPECT_CLASSNAME, UNKNOWN_PREFIX, VM_CONTEXT_LOCALSCOPE, VM_LIBRARY, VM_LIBRARY_AUTORELOAD, VM_MESSAGES_ON, VM_PERM_ALLOW_INLINE, VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, VM_PERM_INLINE_LOCAL, WARN_PREFIX
Constructor and Description |
---|
RuntimeSingleton() |
Modifier and Type | Method and Description |
---|---|
static void |
addProperty(java.lang.String key,
java.lang.Object value)
Add a property to the configuration.
|
static boolean |
addVelocimacro(java.lang.String name,
java.lang.String macro,
java.lang.String[] argArray,
java.lang.String sourceTemplate)
Adds a new Velocimacro.
|
static void |
clearProperty(java.lang.String key)
Clear the values pertaining to a particular
property.
|
private static Parser |
createNewParser()
Returns a JavaCC generated Parser.
|
static void |
debug(java.lang.Object message)
Log a debug message.
|
static boolean |
dumpVMNamespace(java.lang.String namespace)
tells the vmFactory to dump the specified namespace.
|
static void |
error(java.lang.Object message)
Log an error message.
|
static java.lang.Object |
getApplicationAttribute(java.lang.Object key) |
static boolean |
getBoolean(java.lang.String key,
boolean def)
Boolean property accessor method to hide the configuration implementation.
|
static org.apache.commons.collections.ExtendedProperties |
getConfiguration()
Return the velocity runtime configuration object.
|
static ContentResource |
getContent(java.lang.String name)
Returns a static content resource from the
resource manager.
|
static ContentResource |
getContent(java.lang.String name,
java.lang.String encoding)
Returns a static content resource from the
resource manager.
|
static int |
getInt(java.lang.String key)
Int property accessor method to hide the configuration implementation.
|
static int |
getInt(java.lang.String key,
int defaultValue)
Int property accessor method to hide the configuration implementation.
|
static Introspector |
getIntrospector()
Return the Introspector for this RuntimeInstance
|
static java.lang.String |
getLoaderNameForResource(java.lang.String resourceName)
Determines is a template exists, and returns name of the loader that
provides it.
|
static java.lang.Object |
getProperty(java.lang.String key)
Allows an external caller to get a property.
|
static RuntimeInstance |
getRuntimeInstance()
Deprecated.
Use getRuntimeServices() instead.
|
static RuntimeServices |
getRuntimeServices() |
static java.lang.String |
getString(java.lang.String key)
String property accessor method to hide the configuration implementation
|
static java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
String property accessor method with default to hide the
configuration implementation.
|
static Template |
getTemplate(java.lang.String name)
Returns a
Template from the resource manager. |
static Template |
getTemplate(java.lang.String name,
java.lang.String encoding)
Returns a
Template from the resource manager |
static Uberspect |
getUberspect() |
static Directive |
getVelocimacro(java.lang.String vmName,
java.lang.String templateName)
Returns the appropriate VelocimacroProxy object if strVMname
is a valid current Velocimacro.
|
static void |
info(java.lang.Object message)
Log an info message.
|
static void |
init()
This is the primary initialization method in the Velocity
Runtime.
|
static void |
init(java.util.Properties p)
Initialize the Velocity Runtime with a Properties
object.
|
static void |
init(java.lang.String configurationFile)
Initialize the Velocity Runtime with the name of
ExtendedProperties object.
|
static boolean |
isVelocimacro(java.lang.String vmName,
java.lang.String templateName)
Checks to see if a VM exists
|
static SimpleNode |
parse(java.io.Reader reader,
java.lang.String templateName)
Parse the input and return the root of
AST node structure.
|
static SimpleNode |
parse(java.io.Reader reader,
java.lang.String templateName,
boolean dumpNamespace)
Parse the input and return the root of the AST node structure.
|
static void |
setConfiguration(org.apache.commons.collections.ExtendedProperties configuration)
Allow an external system to set an ExtendedProperties
object to use.
|
static void |
setProperty(java.lang.String key,
java.lang.Object value)
Allows an external system to set a property in
the Velocity Runtime.
|
static void |
warn(java.lang.Object message)
Log a warning message.
|
private static RuntimeInstance ri
public static void init() throws java.lang.Exception
java.lang.Exception
public static RuntimeServices getRuntimeServices()
public static void setProperty(java.lang.String key, java.lang.Object value)
String
- property keyString
- property valuepublic static void setConfiguration(org.apache.commons.collections.ExtendedProperties configuration)
ExtendedProperties
- configurationpublic static void addProperty(java.lang.String key, java.lang.Object value)
String
- keyString
- valuepublic static void clearProperty(java.lang.String key)
String
- key of property to clearpublic static java.lang.Object getProperty(java.lang.String key)
key
- property to returnpublic static void init(java.util.Properties p) throws java.lang.Exception
Properties
- java.lang.Exception
public static void init(java.lang.String configurationFile) throws java.lang.Exception
Properties
- java.lang.Exception
private static Parser createNewParser()
public static SimpleNode parse(java.io.Reader reader, java.lang.String templateName) throws ParseException
InputStream
- inputstream retrieved by a resource loaderString
- name of the template being parsedParseException
public static SimpleNode parse(java.io.Reader reader, java.lang.String templateName, boolean dumpNamespace) throws ParseException
InputStream
- inputstream retrieved by a resource loaderString
- name of the template being parseddumpNamespace
- flag to dump the Velocimacro namespace for this templateParseException
public static Template getTemplate(java.lang.String name) throws ResourceNotFoundException, ParseErrorException, java.lang.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.java.lang.Exception
- if an error occurs in template initializationpublic static Template getTemplate(java.lang.String name, java.lang.String encoding) throws ResourceNotFoundException, ParseErrorException, java.lang.Exception
Template
from the resource managername
- The name of the desired template.encoding
- Character encoding of the templateResourceNotFoundException
- if template not found
from any available source.ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.java.lang.Exception
- if an error occurs in template initializationpublic static ContentResource getContent(java.lang.String name) throws ResourceNotFoundException, ParseErrorException, java.lang.Exception
name
- Name of content resource to getResourceNotFoundException
- if template not found
from any available source.ParseErrorException
java.lang.Exception
public static ContentResource getContent(java.lang.String name, java.lang.String encoding) throws ResourceNotFoundException, ParseErrorException, java.lang.Exception
name
- Name of content resource to getencoding
- Character encoding to useResourceNotFoundException
- if template not found
from any available source.ParseErrorException
java.lang.Exception
public static java.lang.String getLoaderNameForResource(java.lang.String resourceName)
resourceName
- Name of template or content resourcepublic static void warn(java.lang.Object message)
Object
- message to logpublic static void info(java.lang.Object message)
Object
- message to logpublic static void error(java.lang.Object message)
Object
- message to logpublic static void debug(java.lang.Object message)
Object
- message to logpublic static java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
String
- key property keyString
- defaultValue default value to return if key not
found in resource manager.public static Directive getVelocimacro(java.lang.String vmName, java.lang.String templateName)
String
- vmName Name of velocimacro requestedpublic static boolean addVelocimacro(java.lang.String name, java.lang.String macro, java.lang.String[] argArray, java.lang.String sourceTemplate)
String
- name Name of velocimacroString
- macro String form of macro bodyString
- argArray Array of strings, containing the
#macro() arguments. the 0th is the name.public static boolean isVelocimacro(java.lang.String vmName, java.lang.String templateName)
name
- Name of velocimacropublic static boolean dumpVMNamespace(java.lang.String namespace)
public static java.lang.String getString(java.lang.String key)
key
- property keypublic static int getInt(java.lang.String key)
String
- key property keypublic static int getInt(java.lang.String key, int defaultValue)
key
- property keyint
- default valuepublic static boolean getBoolean(java.lang.String key, boolean def)
String
- key property keyboolean
- default default value if property not foundpublic static org.apache.commons.collections.ExtendedProperties getConfiguration()
public static Introspector getIntrospector()
public static java.lang.Object getApplicationAttribute(java.lang.Object key)
public static Uberspect getUberspect()
RuntimeServices.getUberspect()
public static RuntimeInstance getRuntimeInstance()
Copyright ? 2002 Apache Software Foundation. All Rights Reserved.