01: /*
02: * Copyright 2007 Hippo.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package nl.hippo.cms.searchandreplace.util;
17:
18: import nl.hippo.cms.searchandreplace.log.SearchAndReplaceLog;
19: import org.apache.commons.httpclient.HttpMethod;
20:
21: /**
22: * <p>
23: * A utility class to help with cleaning up HTTP methods.
24: * </p>
25: */
26: public class MethodCleanup {
27: /**
28: * <p>
29: * The only and private constructor to prevent instantiation of this
30: * class.
31: * </p>
32: */
33: public MethodCleanup() {
34: super ();
35: }
36:
37: /**
38: * <p>
39: * Release the connection of an HTTP method without throwing exceptions.
40: * If the releasing of the connection throws an exception, the exception
41: * is logged.
42: * </p>
43: *
44: * @param method
45: * the method of which to release the connection.
46: * @param role
47: * the role of the method.
48: * @param log
49: * the log to which to log a messge if releasing the
50: * connection of the HTTP method throws an exception.
51: */
52: public static void releaseConnection(HttpMethod method,
53: String role, SearchAndReplaceLog log) {
54: try {
55: method.releaseConnection();
56: } catch (Exception e) {
57: log.warning(
58: "An error occurred during releasing of connection of HTTP method: "
59: + role, e);
60: }
61: }
62: }
|