View Javadoc

    1   package org.apache.turbine.services.pull;
    2
    3
    4   /*
    5    * Licensed to the Apache Software Foundation (ASF) under one
    6    * or more contributor license agreements.  See the NOTICE file
    7    * distributed with this work for additional information
    8    * regarding copyright ownership.  The ASF licenses this file
    9    * to you under the Apache License, Version 2.0 (the
    10   * "License"); you may not use this file except in compliance
    11   * with the License.  You may obtain a copy of the License at
    12   *
    13   *   http://www.apache.org/licenses/LICENSE-2.0
    14   *
    15   * Unless required by applicable law or agreed to in writing,
    16   * software distributed under the License is distributed on an
    17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    18   * KIND, either express or implied.  See the License for the
    19   * specific language governing permissions and limitations
    20   * under the License.
    21   */
    22
    23
    24  import org.apache.turbine.pipeline.PipelineData;
    25  import org.apache.turbine.services.Service;
    26  import org.apache.turbine.util.RunData;
    27  import org.apache.velocity.context.Context;
    28
    29  /**
    30   * The Pull Service manages the creation of application
    31   * tools that are available to all templates in a
    32   * Turbine application. By using the Pull Service you
    33   * can avoid having to make Screens to populate a
    34   * context for use in a particular template. The Pull
    35   * Service creates a set of tools, as specified in
    36   * the TR.props file.
    37   *
    38   * These tools can have global scope, request scope,
    39   * authorized or session scope (i.e. stored in user temp hashmap)
    40   * or persistent scope (i.e. stored in user perm hashmap)
    41   *
    42   * The standard way of referencing these global
    43   * tools is through the toolbox handle. This handle
    44   * is typically $toolbox, but can be specified in the
    45   * TR.props file.
    46   *
    47   * So, for example, if you had a UI Manager tool
    48   * which created a set of UI attributes from a
    49   * properties file, and one of the properties
    50   * was 'bgcolor', then you could access this
    51   * UI attribute with $ui.bgcolor. The identifier
    52   * that is given to the tool, in this case 'ui', can
    53   * be specified as well.
    54   *
    55   * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    56   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    57   * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    58   * @version $Id: PullService.java 1706239 2015-10-01 13:18:35Z tv $
    59   */
    60  public interface PullService
    61          extends Service
    62  {
    63      /** The key under which this service is stored in TurbineServices. */
    64      String SERVICE_NAME = "PullService";
    65
    66      /** Property Key for the global tools */
    67      String GLOBAL_TOOL = "tool.global";
    68
    69      /** Property Key for the request tools */
    70      String REQUEST_TOOL = "tool.request";
    71
    72      /** Property Key for the session tools */
    73      String SESSION_TOOL = "tool.session";
    74
    75      /** Property Key for the authorized tools */
    76      String AUTHORIZED_TOOL = "tool.authorized";
    77
    78      /** Property Key for the persistent tools */
    79      String PERSISTENT_TOOL = "tool.persistent";
    80
    81      /** Property tag for application tool resources directory */
    82      String TOOL_RESOURCES_DIR_KEY = "tools.resources.dir";
    83
    84      /**
    85       * Default value for the application tool resources. This is relative
    86       * to the webapp root
    87       */
    88      String TOOL_RESOURCES_DIR_DEFAULT = "resources";
    89
    90      /**
    91       * Property tag for per request tool refreshing (for obvious reasons
    92       * has no effect for per-request tools)
    93       */
    94      String TOOLS_PER_REQUEST_REFRESH_KEY = "tools.per.request.refresh";
    95
    96      /** Default value for per request tool refreshing */
    97      boolean TOOLS_PER_REQUEST_REFRESH_DEFAULT = false;
    98
    99      /** prefix for key used in the session to store session scope pull tools */
    100     String SESSION_TOOLS_ATTRIBUTE_PREFIX = "turbine.sessiontools.";
    101
    102     /**
    103      * Get the context containing global tools that will be
    104      * use as part of the Turbine Pull Model.
    105      *
    106      * @return A Context object which contains the
    107      *         Global Tool instances.
    108      */
    109     Context getGlobalContext();
    110
    111     /**
    112      * Populate the given context with all request, session, authorized
    113      * and persistent scope tools (it is assumed that the context
    114      * already wraps the global context, and thus already contains
    115      * the global tools).
    116      *
    117      * @param context a Velocity Context to populate
    118      * @param pipelineData a RunData object for request specific data
    119      */
    120      void populateContext(Context context, PipelineData pipelineData);
    121
    122      /**
    123       * Populate the given context with all request, session, authorized
    124       * and persistent scope tools (it is assumed that the context
    125       * already wraps the global context, and thus already contains
    126       * the global tools).
    127       *
    128       * @param context a Velocity Context to populate
    129       * @param data a RunData object for request specific data
    130       */
    131       void populateContext(Context context, RunData data);
    132
    133     /**
    134      * Return the absolute path of the resources directory
    135      * used by application tools.
    136      *
    137      * @return A directory path in the file system or null.
    138      */
    139     String getAbsolutePathToResourcesDirectory();
    140
    141     /**
    142      * Return the resources directory. This is relative
    143      * to the webapp context.
    144      *
    145      * @return A directory path to the resources directory relative to the webapp root or null.
    146      */
    147     String getResourcesDirectory();
    148
    149     /**
    150      * Release tool instances from the given context to the
    151      * object pool
    152      *
    153      * @param context a Velocity Context to release tools from
    154      */
    155     void releaseTools(Context context);
    156 }