001: package org.apache.turbine.services.pull;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.apache.turbine.services.Service;
023: import org.apache.turbine.util.RunData;
024: import org.apache.velocity.context.Context;
025:
026: /**
027: * The Pull Service manages the creation of application
028: * tools that are available to all templates in a
029: * Turbine application. By using the Pull Service you
030: * can avoid having to make Screens to populate a
031: * context for use in a particular template. The Pull
032: * Service creates a set of tools, as specified in
033: * the TR.props file.
034: *
035: * These tools can have global scope, request scope,
036: * authorized or session scope (i.e. stored in user temp hashmap)
037: * or persistent scope (i.e. stored in user perm hashmap)
038: *
039: * The standard way of referencing these global
040: * tools is through the toolbox handle. This handle
041: * is typically $toolbox, but can be specified in the
042: * TR.props file.
043: *
044: * So, for example, if you had a UI Manager tool
045: * which created a set of UI attributes from a
046: * properties file, and one of the properties
047: * was 'bgcolor', then you could access this
048: * UI attribute with $ui.bgcolor. The identifier
049: * that is given to the tool, in this case 'ui', can
050: * be specified as well.
051: *
052: * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
053: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
054: * @version $Id: PullService.java 534527 2007-05-02 16:10:59Z tv $
055: */
056: public interface PullService extends Service {
057: /** The key under which this service is stored in TurbineServices. */
058: String SERVICE_NAME = "PullService";
059:
060: /** Property Key for the global tools */
061: String GLOBAL_TOOL = "tool.global";
062:
063: /** Property Key for the request tools */
064: String REQUEST_TOOL = "tool.request";
065:
066: /** Property Key for the session tools */
067: String SESSION_TOOL = "tool.session";
068:
069: /** Property Key for the authorized tools */
070: String AUTHORIZED_TOOL = "tool.authorized";
071:
072: /** Property Key for the persistent tools */
073: String PERSISTENT_TOOL = "tool.persistent";
074:
075: /** Property tag for application tool resources directory */
076: String TOOL_RESOURCES_DIR_KEY = "tools.resources.dir";
077:
078: /**
079: * Default value for the application tool resources. This is relative
080: * to the webapp root
081: */
082: String TOOL_RESOURCES_DIR_DEFAULT = "resources";
083:
084: /**
085: * Property tag for per request tool refreshing (for obvious reasons
086: * has no effect for per-request tools)
087: */
088: String TOOLS_PER_REQUEST_REFRESH_KEY = "tools.per.request.refresh";
089:
090: /** Default value for per request tool refreshing */
091: boolean TOOLS_PER_REQUEST_REFRESH_DEFAULT = false;
092:
093: /** prefix for key used in the session to store session scope pull tools */
094: String SESSION_TOOLS_ATTRIBUTE_PREFIX = "turbine.sessiontools.";
095:
096: /**
097: * Get the context containing global tools that will be
098: * use as part of the Turbine Pull Model.
099: *
100: * @return A Context object which contains the
101: * Global Tool instances.
102: */
103: Context getGlobalContext();
104:
105: /**
106: * Populate the given context with all request, session, authorized
107: * and persistent scope tools (it is assumed that the context
108: * already wraps the global context, and thus already contains
109: * the global tools).
110: *
111: * @param context a Velocity Context to populate
112: * @param data a RunData object for request specific data
113: */
114: void populateContext(Context context, RunData data);
115:
116: /**
117: * Return the absolute path of the resources directory
118: * used by application tools.
119: *
120: * @return A directory path in the file system or null.
121: */
122: String getAbsolutePathToResourcesDirectory();
123:
124: /**
125: * Return the resources directory. This is relative
126: * to the webapp context.
127: *
128: * @return A directory path to the resources directory relative to the webapp root or null.
129: */
130: String getResourcesDirectory();
131:
132: /**
133: * Refresh the global tools .
134: * @deprecated No longer needed as Pull and Velocity Service are now more separate.
135: */
136: void refreshGlobalTools();
137:
138: /**
139: * Shoud we refresh the tools
140: * on each request. For development purposes.
141: *
142: * @return true if we should refresh the tools on every request.
143: * @deprecated No longer needed as Pull and Velocity Service are now more separate.
144: */
145: boolean refreshToolsPerRequest();
146:
147: /**
148: * Release tool instances from the given context to the
149: * object pool
150: *
151: * @param context a Velocity Context to release tools from
152: */
153: void releaseTools(Context context);
154: }
|