org.apache.velocity.runtime

Class VelocimacroFactory

public class VelocimacroFactory extends Object

VelocimacroFactory.java manages the set of VMs in a running Velocity engine.

Version: $Id: VelocimacroFactory.java,v 1.17.4.1 2004/03/03 23:22:55 geirm Exp $

Author: Geir Magnusson Jr.

Nested Class Summary
classVelocimacroFactory.Twonk
small continer class to hold the duple of a template and modification time.
Field Summary
booleanaddNewAllowed
controls if new VMs can be added.
booleanautoReloadLibrary
determines if the libraries are auto-loaded when they change
booleanblather
controls log output
MaplibModMap
map of the library Template objects used for reload determination
VectormacroLibVec
vector of the library names
booleanreplaceAllowed
determines if replacement of global VMs are allowed controlled by VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL
RuntimeServicesrsvc
runtime services for this instance
booleantemplateLocal
sets if template-local namespace in used
VelocimacroManagervmManager
VMManager : deal with namespace management and actually keeps all the VM definitions
Constructor Summary
VelocimacroFactory(RuntimeServices rs)
CTOR : requires a runtime services from now on
Method Summary
booleanaddVelocimacro(String name, String macroBody, String[] argArray, String sourceTemplate)
adds a macro to the factory.
booleancanAddVelocimacro(String name, String sourceTemplate)
determines if a given macro/namespace (name, source) combo is allowed to be added
booleandumpVMNamespace(String namespace)
tells the vmManager to dump the specified namespace
booleangetAutoload()
get the switch for automatic reloading of global library-based VMs
booleangetBlather()
get output message mode
booleangetTemplateLocalInline()
DirectivegetVelocimacro(String vmName, String sourceTemplate)
actual factory : creates a Directive that will behave correctly wrt getting the framework to dig out the correct # of args
voidinitVelocimacro()
initialize the factory - setup all permissions load all global libraries.
booleanisVelocimacro(String vm, String sourceTemplate)
Tells the world if a given directive string is a Velocimacro
voidlogVMMessageInfo(String s)
localization of the logging logic
voidlogVMMessageWarn(String s)
localization of the logging logic
booleansetAddMacroPermission(boolean arg)
sets the permission to add new macros
voidsetAutoload(boolean b)
set the switch for automatic reloading of global library-based VMs
voidsetBlather(boolean b)
set output message mode
booleansetReplacementPermission(boolean arg)
sets the permission for allowing addMacro() calls to replace existing VM's
voidsetTemplateLocalInline(boolean b)
sets permission to have VMs local in scope to their declaring template note that this is really taken care of in the VMManager class, but we need it here for gating purposes in addVM eventually, I will slide this all into the manager, maybe.

Field Detail

addNewAllowed

private boolean addNewAllowed
controls if new VMs can be added. Set by VM_PERM_ALLOW_INLINE Note the assumption that only through inline defs can this happen. additions through autoloaded VMs is allowed

autoReloadLibrary

private boolean autoReloadLibrary
determines if the libraries are auto-loaded when they change

blather

private boolean blather
controls log output

libModMap

private Map libModMap
map of the library Template objects used for reload determination

macroLibVec

private Vector macroLibVec
vector of the library names

replaceAllowed

private boolean replaceAllowed
determines if replacement of global VMs are allowed controlled by VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL

rsvc

private RuntimeServices rsvc
runtime services for this instance

templateLocal

private boolean templateLocal
sets if template-local namespace in used

vmManager

private VelocimacroManager vmManager
VMManager : deal with namespace management and actually keeps all the VM definitions

Constructor Detail

VelocimacroFactory

public VelocimacroFactory(RuntimeServices rs)
CTOR : requires a runtime services from now on

Method Detail

addVelocimacro

public boolean addVelocimacro(String name, String macroBody, String[] argArray, String sourceTemplate)
adds a macro to the factory.

canAddVelocimacro

private boolean canAddVelocimacro(String name, String sourceTemplate)
determines if a given macro/namespace (name, source) combo is allowed to be added

Parameters: name Name of VM to add sourceTemplate Source template that contains the defintion of the VM

Returns: true if it is allowed to be added, false otherwise

dumpVMNamespace

public boolean dumpVMNamespace(String namespace)
tells the vmManager to dump the specified namespace

getAutoload

private boolean getAutoload()
get the switch for automatic reloading of global library-based VMs

getBlather

private boolean getBlather()
get output message mode

getTemplateLocalInline

private boolean getTemplateLocalInline()

getVelocimacro

public Directive getVelocimacro(String vmName, String sourceTemplate)
actual factory : creates a Directive that will behave correctly wrt getting the framework to dig out the correct # of args

initVelocimacro

public void initVelocimacro()
initialize the factory - setup all permissions load all global libraries.

isVelocimacro

public boolean isVelocimacro(String vm, String sourceTemplate)
Tells the world if a given directive string is a Velocimacro

logVMMessageInfo

private void logVMMessageInfo(String s)
localization of the logging logic

logVMMessageWarn

private void logVMMessageWarn(String s)
localization of the logging logic

setAddMacroPermission

private boolean setAddMacroPermission(boolean arg)
sets the permission to add new macros

setAutoload

private void setAutoload(boolean b)
set the switch for automatic reloading of global library-based VMs

setBlather

private void setBlather(boolean b)
set output message mode

setReplacementPermission

private boolean setReplacementPermission(boolean arg)
sets the permission for allowing addMacro() calls to replace existing VM's

setTemplateLocalInline

private void setTemplateLocalInline(boolean b)
sets permission to have VMs local in scope to their declaring template note that this is really taken care of in the VMManager class, but we need it here for gating purposes in addVM eventually, I will slide this all into the manager, maybe.
Copyright B) 2002 Apache Software Foundation. All Rights Reserved.