|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.turbine.services.BaseInitable | +--org.apache.turbine.services.BaseService | +--org.apache.turbine.services.TurbineBaseService | +--org.apache.turbine.services.pull.TurbinePullService
This is the concrete implementation of the Turbine Pull Service.
These are tools that are placed in the context by the service These tools will be made available to all your templates. You list the tools in the following way:
tool.. = is the tool scope: global, request, session or persistent (see below for more details) is the name of the tool in the context You can configure the tools in this way: tool. . = So if you find "global", "request", "session" or "persistent" as second part, it is a configuration to put a tool into the toolbox, else it is a tool specific configuration. For example: tool.global.ui = org.apache.turbine.util.pull.UIManager tool.global.mm = org.apache.turbine.util.pull.MessageManager tool.request.link = org.apache.turbine.util.template.TemplateLink tool.request.page = org.apache.turbine.util.template.TemplatePageAttributes Then: tool.ui.skin = default configures the value of "skin" for the "ui" tool. Tools are accessible in all templates by the given to the tool. So for the above listings the UIManager would be available as $ui, the MessageManager as $mm, the TemplateLink as $link and the TemplatePageAttributes as $page. You should avoid using tool names called "global", "request", "session" or "persistent" because of clashes with the possible Scopes. Scopes: global: tool is instantiated once and that instance is available to all templates for all requests. Tool must be threadsafe. request: tool is instantiated once for each request (although the PoolService is used to recycle instances). Tool need not be threadsafe. session: tool is instantiated once for each user session, and is stored in the user's temporary hashtable. Tool should be threadsafe. persistent: tool is instantitated once for each use session, and is stored in the user's permanent hashtable. This means for a logged in user the tool will be persisted in the user's objectdata. Tool should be threadsafe and Serializable. Defaults: none
Inner Class Summary | |
private static class |
TurbinePullService.ToolData
This inner class is used in the lists below to store the tool name and class for each of request, session and persistent tools |
Field Summary | |
private static java.lang.String |
absolutePathToResourcesDirectory
The absolute path the to resources directory used by the application tools. |
private static java.lang.String |
GLOBAL_TOOL
The property tags that are used in conjunction with TurbineResources.getOrderedValues(String) to get our list of tools to instantiate (one tag for each type of tool). |
private org.apache.velocity.context.Context |
globalContext
This is the container for the global web application tools that are used in conjunction with the Turbine Pull Model. |
private java.util.List |
globalTools
The lists that store tool data (name and class) for each of the different type of tool. |
private static java.lang.String |
PERSISTENT_TOOL
|
private java.util.List |
persistentTools
|
private static boolean |
refreshToolsPerRequest
Should we refresh the application tools on a per request basis. |
private static java.lang.String |
REQUEST_TOOL
|
private java.util.List |
requestTools
|
private static java.lang.String |
resourcesDirectory
Directory where application tool resources are stored. |
private static java.lang.String |
SESSION_TOOL
|
private java.util.List |
sessionTools
|
private static java.lang.String |
TOOL_RESOURCES_DIR
Property tag for application tool resources directory |
private static java.lang.String |
TOOL_RESOURCES_DIR_DEFAULT
Default value for the application tool resources directory. |
private static java.lang.String |
TOOLS_PER_REQUEST_REFRESH
Property tag for per request tool refreshing (for obvious reasons has no effect for per-request tools) |
Fields inherited from class org.apache.turbine.services.BaseService |
configuration, name, properties, serviceBroker |
Fields inherited from class org.apache.turbine.services.BaseInitable |
initableBroker, isInitialized |
Fields inherited from interface org.apache.turbine.services.pull.PullService |
SERVICE_NAME |
Constructor Summary | |
TurbinePullService()
|
Method Summary | |
java.lang.String |
getAbsolutePathToResourcesDirectory()
Return the absolute path to the resources directory used by the application tools. |
org.apache.velocity.context.Context |
getGlobalContext()
Return the Context which contains all global tools that are to be used in conjunction with the Turbine Pull Model. |
java.lang.String |
getResourcesDirectory()
Return the resources directory. |
private java.util.List |
getTools(java.lang.String keyPrefix)
Retrieve the tool names and classes for the tools definied in the properties file with the prefix given. |
void |
init()
Called the first time the Service is used. |
private void |
initPull()
Initialize the pull system |
void |
populateContext(org.apache.velocity.context.Context context,
RunData data)
Populate the given context with all request, session and persistent scope tools (it is assumed that the context already wraps the global context, and thus already contains the global tools). |
private void |
populateWithGlobalTools(org.apache.velocity.context.Context context)
Populate the given context with the global tools |
private void |
populateWithRequestTools(org.apache.velocity.context.Context context,
RunData data)
Populate the given context with the request-scope tools |
private void |
populateWithSessionTools(java.util.List tools,
org.apache.velocity.context.Context context,
User user,
boolean usePerm)
Populate the given context with the session-scoped tools. |
void |
refreshGlobalTools()
Refresh the global tools. |
boolean |
refreshToolsPerRequest()
Should we refresh the ToolBox on a per request basis. |
void |
releaseTools(org.apache.velocity.context.Context context)
Release the request-scope tool instances in the given Context back to the pool |
private void |
releaseTools(org.apache.velocity.context.Context context,
PoolService pool,
java.util.List tools)
Release the given list of tools from the context back to the pool |
Methods inherited from class org.apache.turbine.services.TurbineBaseService |
init, init, init, shutdown |
Methods inherited from class org.apache.turbine.services.BaseService |
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker |
Methods inherited from class org.apache.turbine.services.BaseInitable |
getInit, getInitableBroker, setInit, setInitableBroker |
Methods inherited from class java.lang.Object |
|
Methods inherited from interface org.apache.turbine.services.Service |
getConfiguration, getName, getProperties, setName, setServiceBroker |
Methods inherited from interface org.apache.turbine.services.Initable |
getInit, init, setInitableBroker, shutdown |
Field Detail |
private org.apache.velocity.context.Context globalContext
private java.util.List globalTools
private java.util.List requestTools
private java.util.List sessionTools
private java.util.List persistentTools
private static final java.lang.String GLOBAL_TOOL
private static final java.lang.String REQUEST_TOOL
private static final java.lang.String SESSION_TOOL
private static final java.lang.String PERSISTENT_TOOL
private static java.lang.String resourcesDirectory
private static java.lang.String absolutePathToResourcesDirectory
private static final java.lang.String TOOL_RESOURCES_DIR
private static final java.lang.String TOOL_RESOURCES_DIR_DEFAULT
private static final java.lang.String TOOLS_PER_REQUEST_REFRESH
private static boolean refreshToolsPerRequest
Constructor Detail |
public TurbinePullService()
Method Detail |
public void init() throws InitializationException
init
in interface Initable
init
in class TurbineBaseService
org.apache.turbine.services.Initable
InitializationException,
- if initialization of this
class was not successful.private void initPull() throws java.lang.Exception
Exception,
- a generic exception.private java.util.List getTools(java.lang.String keyPrefix)
keyPrefix
- a String giving the property name prefix to look forpublic org.apache.velocity.context.Context getGlobalContext()
getGlobalContext
in interface PullService
public void populateContext(org.apache.velocity.context.Context context, RunData data)
populateContext
in interface PullService
context
- a Velocity Context to populatedata
- a RunData object for request specific dataprivate void populateWithGlobalTools(org.apache.velocity.context.Context context)
context
- a Velocity Context to populateprivate void populateWithRequestTools(org.apache.velocity.context.Context context, RunData data)
context
- a Velocity Context to populatedata
- a RunData instanceprivate void populateWithSessionTools(java.util.List tools, org.apache.velocity.context.Context context, User user, boolean usePerm)
tools
- The list of tools with which to populate the
session.context
- The context to populate.user
- The User
object whose storage to
retrieve the tool from.userPerm
- Whether to retrieve the tools from the
permanent storage (as opposed to the temporary storage).public java.lang.String getAbsolutePathToResourcesDirectory()
getAbsolutePathToResourcesDirectory
in interface PullService
public java.lang.String getResourcesDirectory()
getResourcesDirectory
in interface PullService
public void refreshGlobalTools()
refreshGlobalTools
in interface PullService
public boolean refreshToolsPerRequest()
refreshToolsPerRequest
in interface PullService
public void releaseTools(org.apache.velocity.context.Context context)
releaseTools
in interface PullService
context
- the Velocity Context to release tools fromprivate void releaseTools(org.apache.velocity.context.Context context, PoolService pool, java.util.List tools)
context
- the Context containing the toolspool
- an instance of the PoolServicetools
- a List of ToolData objects
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |