View Javadoc

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