|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.tools.view.XMLToolboxManager org.apache.velocity.tools.view.servlet.ServletToolboxManager
A toolbox manager for the servlet environment.
A toolbox manager is responsible for automatically filling the Velocity context with a set of view tools. This class provides the following features:
Configuration
The toolbox manager is configured through an XML-based configuration
file. The configuration file is passed to the XMLToolboxManager.load(java.io.InputStream input)
method. The format is shown in the following example:
<?xml version="1.0"?> <toolbox> <tool> <key>link</key> <scope>request</scope> <class>org.apache.velocity.tools.view.tools.LinkTool</class> </tool> <tool> <key>date</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.DateTool</class> </tool> <data type="number"> <key>luckynumber</key> <value>1.37</value> </data> <data type="string"> <key>greeting</key> <value>Hello World!</value> </data> <xhtml>true</xhtml> </toolbox>
The recommended location for the configuration file is the WEB-INF directory of the web application.
Field Summary | |
private java.util.Map |
appTools
|
private boolean |
createSession
|
private static java.util.HashMap |
managersMap
|
private java.util.ArrayList |
requestToolInfo
|
private javax.servlet.ServletContext |
servletContext
|
private static org.apache.commons.digester.RuleSet |
servletRuleSet
|
static java.lang.String |
SESSION_TOOLS_KEY
|
private java.util.ArrayList |
sessionToolInfo
|
Fields inherited from class org.apache.velocity.tools.view.XMLToolboxManager |
|
Constructor Summary | |
private |
ServletToolboxManager(javax.servlet.ServletContext servletContext)
Use getInstance(ServletContext,String) instead to ensure there is exactly one ServletToolboxManager per xml toolbox configuration file. |
Method Summary | |
void |
addTool(ToolInfo info)
Overrides XMLToolboxManager to separate tools by scope. |
static ServletToolboxManager |
getInstance(javax.servlet.ServletContext servletContext,
java.lang.String toolboxFile)
ServletToolboxManager factory method. |
protected java.lang.Object |
getMutex(javax.servlet.http.HttpSession session)
Returns a mutex (lock object) unique to the specified session to allow for reliable synchronization on the session. |
protected org.apache.commons.digester.RuleSet |
getRuleSet()
For subclassing convienence. |
ToolboxContext |
getToolboxContext(java.lang.Object initData)
Overrides XMLToolboxManager to handle the separate scopes. |
void |
setCreateSession(boolean b)
Sets whether or not to create a new session when none exists for the current request and session-scoped tools have been defined for this toolbox. |
void |
setXhtml(java.lang.Boolean value)
Sets an application attribute to tell velocimacros and tools (especially the LinkTool) whether they should output XHTML or HTML. |
Methods inherited from class org.apache.velocity.tools.view.XMLToolboxManager |
load |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String SESSION_TOOLS_KEY
private javax.servlet.ServletContext servletContext
private java.util.Map appTools
private java.util.ArrayList sessionToolInfo
private java.util.ArrayList requestToolInfo
private boolean createSession
private static java.util.HashMap managersMap
private static org.apache.commons.digester.RuleSet servletRuleSet
Constructor Detail |
private ServletToolboxManager(javax.servlet.ServletContext servletContext)
Method Detail |
public static ServletToolboxManager getInstance(javax.servlet.ServletContext servletContext, java.lang.String toolboxFile)
public void setCreateSession(boolean b)
Sets whether or not to create a new session when none exists for the current request and session-scoped tools have been defined for this toolbox.
If true, then a call to getToolboxContext(Object)
will
create a new session if none currently exists for this request and
the toolbox has one or more session-scoped tools designed.
If false, then a call to getToolboxContext(Object) will never create a new session for the current request. This effectively means that no session-scoped tools will be added to the ToolboxContext for a request that does not have a session object.
The default value is true.
public void setXhtml(java.lang.Boolean value)
Sets an application attribute to tell velocimacros and tools (especially the LinkTool) whether they should output XHTML or HTML.
ViewContext.XHTML
protected org.apache.commons.digester.RuleSet getRuleSet()
getRuleSet
in class XMLToolboxManager
public void addTool(ToolInfo info)
addTool
in interface ToolboxManager
addTool
in class XMLToolboxManager
public ToolboxContext getToolboxContext(java.lang.Object initData)
getToolboxContext
in interface ToolboxManager
getToolboxContext
in class XMLToolboxManager
initData
- the ViewContext
for the current servlet requestprotected java.lang.Object getMutex(javax.servlet.http.HttpSession session)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |