01: package org.apache.turbine.services.rundata;
02:
03: /*
04: * Copyright 2001-2005 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License")
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import javax.servlet.ServletConfig;
20:
21: import javax.servlet.http.HttpServletRequest;
22: import javax.servlet.http.HttpServletResponse;
23:
24: import org.apache.turbine.services.TurbineServices;
25:
26: import org.apache.turbine.util.RunData;
27: import org.apache.turbine.util.TurbineException;
28:
29: /**
30: * Static wrapper for the RunData service. The name is completely
31: * out of line of the other Turbine Services. So what? All the good
32: * ones were taken.
33: *
34: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
35: * @version $Id: TurbineRunDataFacade.java 264148 2005-08-29 14:21:04Z henning $
36: */
37:
38: public abstract class TurbineRunDataFacade {
39: /**
40: * Utility method for accessing the service
41: * implementation
42: *
43: * @return a RunDataService implementation instance
44: */
45: public static RunDataService getService() {
46: return (RunDataService) TurbineServices.getInstance()
47: .getService(RunDataService.SERVICE_NAME);
48: }
49:
50: /**
51: * Gets a default RunData object.
52: *
53: * @param req a servlet request.
54: * @param res a servlet response.
55: * @param config a servlet config.
56: * @return a new or recycled RunData object.
57: * @throws TurbineException if the operation fails.
58: */
59: public static RunData getRunData(HttpServletRequest req,
60: HttpServletResponse res, ServletConfig config)
61: throws TurbineException {
62: return getService().getRunData(req, res, config);
63: }
64:
65: /**
66: * Gets a RunData object from a specific configuration.
67: *
68: * @param key a configuration key.
69: * @param req a servlet request.
70: * @param res a servlet response.
71: * @param config a servlet config.
72: * @return a new or recycled RunData object.
73: * @throws TurbineException if the operation fails.
74: */
75: public static RunData getRunData(String key,
76: HttpServletRequest req, HttpServletResponse res,
77: ServletConfig config) throws TurbineException {
78: return getService().getRunData(key, req, res, config);
79: }
80:
81: /**
82: * Puts the used RunData object back to the factory for recycling.
83: *
84: * @param data the used RunData object.
85: * @return true, if pooling is supported and the object was accepted.
86: */
87: public static boolean putRunData(RunData data) {
88: return getService().putRunData(data);
89: }
90: }
|