Home » velocity-1.5 » org.apache » velocity » runtime » [javadoc | source]
org.apache.velocity.runtime
public interface: RuntimeServices [javadoc | source]

All Implemented Interfaces:
    RuntimeLogger

All Known Implementing Classes:
    RuntimeInstance

Interface for internal runtime services that are needed by the various components w/in Velocity. This was taken from the old Runtime singleton, and anything not necessary was removed. Currently implemented by RuntimeInstance.
Method from org.apache.velocity.runtime.RuntimeServices Summary:
addProperty,   addVelocimacro,   clearProperty,   createNewParser,   dumpVMNamespace,   getApplicationAttribute,   getApplicationEventCartridge,   getBoolean,   getConfiguration,   getContent,   getContent,   getInt,   getInt,   getIntrospector,   getLoaderNameForResource,   getLog,   getProperty,   getString,   getString,   getTemplate,   getTemplate,   getUberspect,   getVelocimacro,   init,   init,   init,   isInitialized,   isVelocimacro,   parse,   parse,   setApplicationAttribute,   setConfiguration,   setProperty
Method from org.apache.velocity.runtime.RuntimeServices Detail:
 public  void addProperty(String key,
    Object value)
    Add a property to the configuration. If it already exists then the value stated here will be added to the configuration entry. For example, if resource.loader = file is already present in the configuration and you addProperty("resource.loader", "classpath") Then you will end up with a Vector like the following: ["file", "classpath"]
 public boolean addVelocimacro(String name,
    String macro,
    String[] argArray,
    String sourceTemplate)
    Adds a new Velocimacro. Usually called by Macro only while parsing.
 public  void clearProperty(String key)
    Clear the values pertaining to a particular property.
 public Parser createNewParser()
    Create a new parser instance.
 public boolean dumpVMNamespace(String namespace)
    tells the vmFactory to dump the specified namespace. This is to support clearing the VM list when in inline-VM-local-scope mode
 public Object getApplicationAttribute(Object key)
    Return the specified application attribute.
 public EventCartridge getApplicationEventCartridge()
    Returns the event handlers for the application.
 public boolean getBoolean(String key,
    boolean def)
    Boolean property accessor method to hide the configuration implementation.
 public ExtendedProperties getConfiguration()
    Return the velocity runtime configuration object.
 public ContentResource getContent(String name) throws Exception, ResourceNotFoundException, ParseErrorException
    Returns a static content resource from the resource manager. Uses the current value if INPUT_ENCODING as the character encoding.
 public ContentResource getContent(String name,
    String encoding) throws Exception, ResourceNotFoundException, ParseErrorException
    Returns a static content resource from the resource manager.
 public int getInt(String key)
    Int property accessor method to hide the configuration implementation.
 public int getInt(String key,
    int defaultValue)
    Int property accessor method to hide the configuration implementation.
 public Introspector getIntrospector()
    Returns the configured method introspection/reflection implementation.
 public String getLoaderNameForResource(String resourceName)
    Determines is a template exists, and returns name of the loader that provides it. This is a slightly less hokey way to support the Velocity.templateExists() utility method, which was broken when per-template encoding was introduced. We can revisit this.
 public Log getLog()
    Returns a convenient Log instance that wraps the current LogChute.
 public Object getProperty(String key)
    Allows an external caller to get a property. The calling routine is required to know the type, as this routine will return an Object, as that is what properties can be.
 public String getString(String key)
    String property accessor method to hide the configuration implementation
 public String getString(String key,
    String defaultValue)
    String property accessor method with default to hide the configuration implementation.
 public Template getTemplate(String name) throws Exception, ResourceNotFoundException, ParseErrorException
    Returns a 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"
 public Template getTemplate(String name,
    String encoding) throws Exception, ResourceNotFoundException, ParseErrorException
    Returns a Template from the resource manager
 public Uberspect getUberspect()
    Returns the configured class introspection/reflection implemenation.
 public Directive getVelocimacro(String vmName,
    String templateName)
    Returns the appropriate VelocimacroProxy object if strVMname is a valid current Velocimacro.
 public  void init() throws Exception
    This is the primary initialization method in the Velocity Runtime. The systems that are setup/initialized here are as follows:
    • Logging System
    • ResourceManager
    • Parser Pool
    • Global Cache
    • Static Content Include System
    • Velocimacro System
 public  void init(Properties p) throws Exception
    Initialize the Velocity Runtime with a Properties object.
 public  void init(String configurationFile) throws Exception
    Initialize the Velocity Runtime with the name of ExtendedProperties object.
 public boolean isInitialized()
    Returns true if the RuntimeInstance has been successfully initialized.
 public boolean isVelocimacro(String vmName,
    String templateName)
    Checks to see if a VM exists
 public SimpleNode parse(Reader reader,
    String templateName) throws ParseException
    Parse the input and return the root of AST node structure.

    In the event that it runs out of parsers in the pool, it will create and let them be GC'd dynamically, logging that it has to do that. This is considered an exceptional condition. It is expected that the user will set the PARSER_POOL_SIZE property appropriately for their application. We will revisit this.
 public SimpleNode parse(Reader reader,
    String templateName,
    boolean dumpNamespace) throws ParseException
    Parse the input and return the root of the AST node structure.
 public Object setApplicationAttribute(Object key,
    Object value)
    Set the specified application attribute.
 public  void setConfiguration(ExtendedProperties configuration)
    Allow an external system to set an ExtendedProperties object to use. This is useful where the external system also uses the ExtendedProperties class and the velocity configuration is a subset of parent application's configuration. This is the case with Turbine.
 public  void setProperty(String key,
    Object value)
    Allows an external system to set a property in the Velocity Runtime.