C# 클래스 NVelocity.Runtime.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: *
 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. ----------------------------------------------------------------------- 
*
상속: RuntimeConstants, RuntimeServices
파일 보기 프로젝트 열기: nats/castle-1.0.3-mono

공개 메소드들

메소드 설명
AddProperty ( String key, Object value ) : void

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 IList like the following: ["file", "classpath"]

AddVelocimacro ( String name, String macro, String argArray, String sourceTemplate ) : bool

Adds a new Velocimacro. Usually called by Macro only while parsing.

ClearProperty ( String key ) : void

Clear the values pertaining to a particular property.

CreateNewParser ( ) : Parser

Returns a JavaCC generated Parser.

Debug ( Object message ) : void

Log a debug message.

DumpVMNamespace ( String ns ) : bool

Tells the vmFactory to dump the specified namespace. This is to support clearing the VM list when in inline-VM-local-scope mode.

Error ( Object message ) : void

Log an error message.

GetApplicationAttribute ( Object key ) : Object

Return the velocity runtime configuration object.

GetBoolean ( String key, bool def ) : bool

Boolean property accessor method to hide the configuration implementation.

GetContent ( String name ) : ContentResource

Returns a static content resource from the resource manager. Uses the current value if INPUT_ENCODING as the character encoding.

GetContent ( String name, String encoding ) : ContentResource

Returns a static content resource from the resource manager.

GetInt ( String key ) : int

Int property accessor method to hide the configuration implementation.

GetInt ( String key, int defaultValue ) : int

Int property accessor method to hide the configuration implementation.

GetLoaderNameForResource ( String resourceName ) : String

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.

GetProperty ( String key ) : Object

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.

GetString ( String key ) : String

String property accessor method to hide the configuration implementation

GetString ( String key, String defaultValue ) : String

String property accessor method with default to hide the configuration implementation.

GetTemplate ( String name ) : Template

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"

GetTemplate ( String name, String encoding ) : Template

Returns a Template from the resource manager

GetVelocimacro ( String vmName, String templateName ) : Directive.Directive

Returns the appropriate VelocimacroProxy object if strVMname is a valid current Velocimacro.

Info ( Object message ) : void

Log an info message.

Init ( ) : void
Init ( ExtendedProperties p ) : void

Initialize the Velocity Runtime with a Properties object.

Init ( String configurationFile ) : void

Initialize the Velocity Runtime with the name of ExtendedProperties object.

IsVelocimacro ( String vmName, String templateName ) : bool

Checks to see if a VM exists

Parse ( TextReader reader, String templateName ) : SimpleNode

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.

Parse ( TextReader reader, String templateName, bool dumpNamespace ) : SimpleNode

Parse the input and return the root of the AST node structure.

RuntimeInstance ( ) : System
SetApplicationAttribute ( Object key, Object o ) : Object
SetProperty ( String key, Object value ) : void

Allows an external system to set a property in the Velocity Runtime.

Warn ( Object message ) : void

Log a warning message.

비공개 메소드들

메소드 설명
Log ( LogLevel level, Object message ) : void

Handle logging.

initializeDirectiveManager ( ) : void
initializeDirectives ( ) : void

This methods initializes all the directives that are used by the Velocity Runtime. The directives to be initialized are listed in the RUNTIME_DEFAULT_DIRECTIVES properties file. @throws Exception

initializeIntrospection ( ) : void

Gets the classname for the Uberspect introspection package and instantiates an instance.

initializeLogger ( ) : void

Initialize the Velocity logging system. * @throws Exception

initializeParserPool ( ) : void

Initializes the Velocity parser pool. This still needs to be implemented.

initializeProperties ( ) : void

Initialize Velocity properties, if the default properties have not been laid down first then do so. Then proceed to process any overriding properties. Laying down the default properties gives a much greater chance of having a working system.

initializeResourceManager ( ) : void
setDefaultProperties ( ) : void

Initializes the Velocity Runtime with properties file. The properties file may be in the file system proper, or the properties file may be in the classpath.

showStackTrace ( ) : bool

Added this to check and make sure that the configuration is initialized before trying to get properties from it. This occurs when there are errors during initialization and the default properties have yet to be layed down.

메소드 상세

AddProperty() 공개 메소드

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 IList like the following: ["file", "classpath"]
public AddProperty ( String key, Object value ) : void
key String key
value Object value
리턴 void

AddVelocimacro() 공개 메소드

Adds a new Velocimacro. Usually called by Macro only while parsing.
public AddVelocimacro ( String name, String macro, String argArray, String sourceTemplate ) : bool
name String Name of velocimacro
macro String String form of macro body
argArray String Array of strings, containing the #macro() arguments. the 0th is the name.
sourceTemplate String Name of template
리턴 bool

ClearProperty() 공개 메소드

Clear the values pertaining to a particular property.
public ClearProperty ( String key ) : void
key String key of property to clear
리턴 void

CreateNewParser() 공개 메소드

Returns a JavaCC generated Parser.
public CreateNewParser ( ) : Parser
리턴 NVelocity.Runtime.Parser.Parser

Debug() 공개 메소드

Log a debug message.
public Debug ( Object message ) : void
message Object message to log
리턴 void

DumpVMNamespace() 공개 메소드

Tells the vmFactory to dump the specified namespace. This is to support clearing the VM list when in inline-VM-local-scope mode.
public DumpVMNamespace ( String ns ) : bool
ns String
리턴 bool

Error() 공개 메소드

Log an error message.
public Error ( Object message ) : void
message Object message to log
리턴 void

GetApplicationAttribute() 공개 메소드

Return the velocity runtime configuration object.
public GetApplicationAttribute ( Object key ) : Object
key Object
리턴 Object

GetBoolean() 공개 메소드

Boolean property accessor method to hide the configuration implementation.
public GetBoolean ( String key, bool def ) : bool
key String property key
def bool default value if property not found
리턴 bool

GetContent() 공개 메소드

Returns a static content resource from the resource manager. Uses the current value if INPUT_ENCODING as the character encoding.
/// if template not found from any available source. ///
public GetContent ( String name ) : ContentResource
name String Name of content resource to get
리턴 NVelocity.Runtime.Resource.ContentResource

GetContent() 공개 메소드

Returns a static content resource from the resource manager.
/// if template not found from any available source. ///
public GetContent ( String name, String encoding ) : ContentResource
name String Name of content resource to get
encoding String Character encoding to use
리턴 NVelocity.Runtime.Resource.ContentResource

GetInt() 공개 메소드

Int property accessor method to hide the configuration implementation.
public GetInt ( String key ) : int
key String property key
리턴 int

GetInt() 공개 메소드

Int property accessor method to hide the configuration implementation.
public GetInt ( String key, int defaultValue ) : int
key String property key
defaultValue int default value
리턴 int

GetLoaderNameForResource() 공개 메소드

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 GetLoaderNameForResource ( String resourceName ) : String
resourceName String Name of template or content resource
리턴 String

GetProperty() 공개 메소드

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 GetProperty ( String key ) : Object
key String property to return
리턴 Object

GetString() 공개 메소드

String property accessor method to hide the configuration implementation
public GetString ( String key ) : String
key String property key
리턴 String

GetString() 공개 메소드

String property accessor method with default to hide the configuration implementation.
public GetString ( String key, String defaultValue ) : String
key String key property key
defaultValue String default value to return if key not found in resource manager.
리턴 String

GetTemplate() 공개 메소드

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"
/// if template not found from any available source /// /// if template cannot be parsed due to syntax (or other) error. /// /// if an error occurs in template initialization ///
public GetTemplate ( String name ) : Template
name String The file name of the desired template. ///
리턴 NVelocity.Template

GetTemplate() 공개 메소드

Returns a Template from the resource manager
/// if template not found from any available source. /// /// if template cannot be parsed due to syntax (or other) error. /// /// if an error occurs in template initialization ///
public GetTemplate ( String name, String encoding ) : Template
name String The name of the desired template.
encoding String Character encoding of the template
리턴 NVelocity.Template

GetVelocimacro() 공개 메소드

Returns the appropriate VelocimacroProxy object if strVMname is a valid current Velocimacro.
public GetVelocimacro ( String vmName, String templateName ) : Directive.Directive
vmName String Name of velocimacro requested
templateName String Name of template
리턴 Directive.Directive

Info() 공개 메소드

Log an info message.
public Info ( Object message ) : void
message Object message to log
리턴 void

Init() 공개 메소드

public Init ( ) : void
리턴 void

Init() 공개 메소드

Initialize the Velocity Runtime with a Properties object.
public Init ( ExtendedProperties p ) : void
p Commons.Collections.ExtendedProperties Properties
리턴 void

Init() 공개 메소드

Initialize the Velocity Runtime with the name of ExtendedProperties object.
public Init ( String configurationFile ) : void
configurationFile String Properties
리턴 void

IsVelocimacro() 공개 메소드

Checks to see if a VM exists
public IsVelocimacro ( String vmName, String templateName ) : bool
vmName String Name of velocimacro
templateName String Name of template
리턴 bool

Parse() 공개 메소드

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 Parse ( TextReader reader, String templateName ) : SimpleNode
reader System.IO.TextReader inputstream retrieved by a resource loader
templateName String name of the template being parsed
리턴 SimpleNode

Parse() 공개 메소드

Parse the input and return the root of the AST node structure.
public Parse ( TextReader reader, String templateName, bool dumpNamespace ) : SimpleNode
reader System.IO.TextReader inputstream retrieved by a resource loader
templateName String name of the template being parsed
dumpNamespace bool flag to dump the Velocimacro namespace for this template
리턴 SimpleNode

RuntimeInstance() 공개 메소드

public RuntimeInstance ( ) : System
리턴 System

SetApplicationAttribute() 공개 메소드

public SetApplicationAttribute ( Object key, Object o ) : Object
key Object
o Object
리턴 Object

SetProperty() 공개 메소드

Allows an external system to set a property in the Velocity Runtime.
public SetProperty ( String key, Object value ) : void
key String property key
value Object property value
리턴 void

Warn() 공개 메소드

Log a warning message.
public Warn ( Object message ) : void
message Object message to log
리턴 void