org.apache.turbine.services.pull

## Class TurbinePullService

- java.lang.Object
- - org.apache.turbine.services.BaseInitable
  - - org.apache.turbine.services.BaseService
    - - org.apache.turbine.services.TurbineBaseService
      - - org.apache.turbine.services.pull.TurbinePullService

- All Implemented Interfaces:
    Initable, PullService, Service

      public class TurbinePullService
      extends TurbineBaseService
      implements PullService

  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.<scope>.<id> = <classname>

       <scope>      is the tool scope: global, request, session,
                    authorized or persistent (see below for more details)
       <id>         is the name of the tool in the context

       You can configure the tools in this way:
       tool.<id>.<parameter> = <value>

       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.services.pull.tools.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 <id> 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 session.  These tools do not need to be
                    threadsafe.

        authorized: tool is instantiated once for each user session once the
                    user logs in. After this, it is a normal session tool.

        persistent: tool is instantitated once for each user session once
                    the user logs in and is 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 Serializable.  These
                    tools do not need to be threadsafe.
                    persistent scope tools are deprecated in 2.3

       Defaults: none

  Version:
    $Id: TurbinePullService.java 1773378 2016-12-09 13:19:59Z tv $
  Author:
    Jason van Zyl, Sean Legassick, Henning P. Schmiedehausen, Quinton McCombs, Peter Courcoux

- - ### Field Summary

    - ### Fields inherited from class org.apache.turbine.services.BaseService

      `configuration, name, serviceBroker`

    - ### Fields inherited from class org.apache.turbine.services.BaseInitable

      `initableBroker, isInitialized`

    - ### Fields inherited from interface org.apache.turbine.services.pull.PullService

      `AUTHORIZED_TOOL, GLOBAL_TOOL, PERSISTENT_TOOL, REQUEST_TOOL, SERVICE_NAME, SESSION_TOOL, SESSION_TOOLS_ATTRIBUTE_PREFIX, TOOL_RESOURCES_DIR_DEFAULT, TOOL_RESOURCES_DIR_KEY, TOOLS_PER_REQUEST_REFRESH_DEFAULT, TOOLS_PER_REQUEST_REFRESH_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TurbinePullService()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `String` | `getResourcesDirectory()` Return the resources directory.
    `void` | `init()` Called the first time the Service is used.
    `void` | `populateContext(org.apache.velocity.context.Context context, PipelineData pipelineData)` Populate the given context with all request, session, authorized and persistent scope tools (it is assumed that the context already wraps the global context, and thus already contains the global tools).
    `void` | `populateContext(org.apache.velocity.context.Context context, RunData data)` Populate the given context with all request, session, authorized and persistent scope tools (it is assumed that the context already wraps the global context, and thus already contains the global tools).
    `void` | `releaseTools(org.apache.velocity.context.Context context)` Release the request-scope tool instances in the given Context back to the pool

    - ### Methods inherited from class org.apache.turbine.services.TurbineBaseService

      `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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### 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`

- - ### Constructor Detail

    - #### TurbinePullService

          public TurbinePullService()

  - ### Method Detail

    - #### init

          public void init()
                    throws InitializationException

      Called the first time the Service is used.
      Specified by:
        `init` in interface `Initable`
      Overrides:
        `init` in class `TurbineBaseService`
      Throws:
        `InitializationException` - if initialization of this class was not successful.

    - #### getGlobalContext

          public 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. The tools are refreshed every time the global Context is pulled.
      Specified by:
        `getGlobalContext` in interface `PullService`
      Returns:
        A Context object which contains the Global Tool instances.

    - #### populateContext

          public void populateContext(org.apache.velocity.context.Context context,
                             RunData data)

      Populate the given context with all request, session, authorized and persistent scope tools (it is assumed that the context already wraps the global context, and thus already contains the global tools).
      Specified by:
        `populateContext` in interface `PullService`
      Parameters:
        `context` - a Velocity Context to populate
        `data` - a RunData object for request specific data

    - #### populateContext

          public void populateContext(org.apache.velocity.context.Context context,
                             PipelineData pipelineData)

      Populate the given context with all request, session, authorized and persistent scope tools (it is assumed that the context already wraps the global context, and thus already contains the global tools).
      Specified by:
        `populateContext` in interface `PullService`
      Parameters:
        `context` - a Velocity Context to populate
        `pipelineData` - a PipelineData object for request specific data

    - #### getAbsolutePathToResourcesDirectory

          public String getAbsolutePathToResourcesDirectory()

      Return the absolute path to the resources directory used by the application tools.
      Specified by:
        `getAbsolutePathToResourcesDirectory` in interface `PullService`
      Returns:
        the absolute path of the resources directory

    - #### getResourcesDirectory

          public String getResourcesDirectory()

      Return the resources directory. This is relative to the web context.
      Specified by:
        `getResourcesDirectory` in interface `PullService`
      Returns:
        the relative path of the resources directory

    - #### releaseTools

          public void releaseTools(org.apache.velocity.context.Context context)

      Release the request-scope tool instances in the given Context back to the pool
      Specified by:
        `releaseTools` in interface `PullService`
      Parameters:
        `context` - the Velocity Context to release tools from

Copyright © 2000–2018 The Apache Software Foundation. All rights reserved.