public class ViewToolManager extends ToolManager
FactoryConfiguration
or having one in the ServletContext attributes under
ServletUtils.CONFIGURATION_KEY
, as well as configuration
via a tools.xml or tools.properties file in
either the classpath or the local file system.Modifier and Type | Field and Description |
---|---|
static String |
CREATE_SESSION_PROPERTY |
static String |
DEFAULT_TOOLBOX_KEY |
static String |
PUBLISH_TOOLBOXES_PROPERTY |
protected javax.servlet.ServletContext |
servletContext |
factory, log, velocity
Constructor and Description |
---|
ViewToolManager(javax.servlet.ServletContext app)
Constructs an instance already configured to use
any configuration specified via a "org.apache.velocity.tools"
system property.
|
ViewToolManager(javax.servlet.ServletContext app,
boolean includeDefaults) |
ViewToolManager(javax.servlet.ServletContext app,
boolean autoConfig,
boolean includeDefaults) |
Modifier and Type | Method and Description |
---|---|
protected void |
addToolboxes(ToolContext context)
Add toolboxes to contex
|
void |
autoConfigure(boolean includeDefaults)
Autoconfiguration using the configuration file potentially found
in the
org.apache.velocity.tools system property. |
void |
configure(FactoryConfiguration config)
Configure the tool manager with this toolbox factory config
|
ViewToolContext |
createContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
ToolContext |
createContext(Map<String,Object> toolProps)
create new context with configured toolboxes tools,
using the provided tools properties
|
protected FactoryConfiguration |
findConfig(String path)
Find a configuration file
|
boolean |
getCreateSession() |
boolean |
getPublishToolboxes() |
protected Toolbox |
getSessionToolbox() |
Toolbox |
getSessionToolbox(javax.servlet.http.HttpSession session) |
String |
getToolboxKey() |
boolean |
hasSessionTools() |
void |
prepareContext(ViewToolContext context,
javax.servlet.http.HttpServletRequest request) |
void |
publishApplicationTools()
Publish
Scope.APPLICATION Toolbox. |
void |
publishToolboxes(javax.servlet.http.HttpServletRequest request)
Places the
Scope.REQUEST Toolbox (if any)
into the HttpServletRequest attributes using
Toolbox.KEY as the key, places the Scope.SESSION
Toolbox (if any) into the attributes of the HttpSession (if any)
then ensures that the Scope.APPLICATION Toolbox (if any)
has been placed in the ServletContext attributes. |
void |
publishToolboxes(javax.servlet.ServletRequest request)
Places the
Scope.REQUEST Toolbox (if any)
into the ServletRequest attributes using
Toolbox.KEY as the key. |
void |
setCreateSession(boolean create)
Sets whether or not a new HttpSession should be created
when there are session scoped tools to be stored in the session,
but no session has been created yet.
|
void |
setPublishToolboxes(boolean publish)
Sets whether or not the creation of a new
ViewToolContext
should make the various scoped Toolbox instances available
publically via the HttpServletRequest/HttpSession/ServletContext
attributes or simply add the Toolbox instances directly to the
context. |
void |
setToolboxKey(String key)
Sets a new attribute key to be used for publishing each
Toolbox . |
protected void |
unpublishApplicationTools()
Removes any published
Scope.APPLICATION Toolbox. |
protected void |
updateGlobalProperties()
Checks the internal
ToolboxFactory for any changes to
the createSession or publishToolboxes settings. |
configure, createContext, createToolbox, getApplicationToolbox, getLog, getRequestToolbox, getToolboxFactory, getUserCanOverwriteTools, getVelocityEngine, hasApplicationTools, hasRequestTools, hasTools, initLog, prepareContext, setToolboxFactory, setUserCanOverwriteTools, setVelocityEngine
public static final String CREATE_SESSION_PROPERTY
public static final String PUBLISH_TOOLBOXES_PROPERTY
public static final String DEFAULT_TOOLBOX_KEY
protected javax.servlet.ServletContext servletContext
public ViewToolManager(javax.servlet.ServletContext app)
app
- servlet contextpublic ViewToolManager(javax.servlet.ServletContext app, boolean includeDefaults)
public ViewToolManager(javax.servlet.ServletContext app, boolean autoConfig, boolean includeDefaults)
public void autoConfigure(boolean includeDefaults)
ToolManager
org.apache.velocity.tools
system property.autoConfigure
in class ToolManager
includeDefaults
- whether to include default toolspublic void setPublishToolboxes(boolean publish)
ViewToolContext
should make the various scoped Toolbox
instances available
publically via the HttpServletRequest/HttpSession/ServletContext
attributes or simply add the Toolbox instances directly to the
context. It is important to note that if this is set to false,
session-scoped tools will NOT be stored in the session, but instead
be recreated for each request.publish
- whether to publish the available toolboxespublishToolboxes
,
setToolboxKey(java.lang.String)
public boolean getPublishToolboxes()
public void setToolboxKey(String key)
Toolbox
.key
- toolbox keysetPublishToolboxes(boolean)
,
publishToolboxes
public String getToolboxKey()
public void setCreateSession(boolean create)
create
- whether to create a new session if neededpublishToolboxes
public boolean getCreateSession()
protected void updateGlobalProperties()
ToolboxFactory
for any changes to
the createSession or publishToolboxes settings.public void publishApplicationTools()
Scope.APPLICATION
Toolbox.protected void unpublishApplicationTools()
Scope.APPLICATION
Toolbox.public void configure(FactoryConfiguration config)
ToolManager
configure
in class ToolManager
config
- toolbox factory configprotected FactoryConfiguration findConfig(String path)
ToolManager
findConfig
in class ToolManager
path
- path to a configuration fileprotected void addToolboxes(ToolContext context)
ToolManager
addToolboxes
in class ToolManager
context
- contextpublic ToolContext createContext(Map<String,Object> toolProps)
ToolManager
createContext
in class ToolManager
toolProps
- tools propertiespublic ViewToolContext createContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public void prepareContext(ViewToolContext context, javax.servlet.http.HttpServletRequest request)
public boolean hasSessionTools()
protected Toolbox getSessionToolbox()
public Toolbox getSessionToolbox(javax.servlet.http.HttpSession session)
public void publishToolboxes(javax.servlet.ServletRequest request)
Scope.REQUEST
Toolbox
(if any)
into the ServletRequest
attributes using
Toolbox.KEY
as the key.request
- servlet requestpublic void publishToolboxes(javax.servlet.http.HttpServletRequest request)
Scope.REQUEST
Toolbox
(if any)
into the HttpServletRequest
attributes using
Toolbox.KEY
as the key, places the Scope.SESSION
Toolbox (if any) into the attributes of the HttpSession
(if any)
then ensures that the Scope.APPLICATION
Toolbox (if any)
has been placed in the ServletContext
attributes.request
- servlet requestCopyright © 2002–2021 The Apache Software Foundation. All rights reserved.