MethodCleanup.java :  » Content-Management-System » hippo-cms » nl » hippo » cms » brokenlinkchecker » util » Java Open Source

Java Open Source » Content Management System » hippo cms 
hippo cms » nl » hippo » cms » brokenlinkchecker » util » MethodCleanup.java
/*
 * Copyright 2007 Hippo.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.hippo.cms.brokenlinkchecker.util;

import nl.hippo.cms.brokenlinkchecker.log.BrokenLinkCheckerLog;
import org.apache.commons.httpclient.HttpMethod;

/**
 * <p>
 * A utility class to help with cleaning up HTTP methods.
 * </p>
 */
public class MethodCleanup {
    /**
         * <p>
         * The only and private constructor to prevent instantiation of this
         * class.
         * </p>
         */
    public MethodCleanup() {
  super();
    }

    /**
         * <p>
         * Release the connection of an HTTP method without throwing exceptions.
         * If the releasing of the connection throws an exception, the exception
         * is logged.
         * </p>
         * 
         * @param method
         *                the method of which to release the connection.
         * @param role
         *                the role of the method.
         * @param log
         *                the log to which to log a messge if releasing the
         *                connection of the HTTP method throws an exception.
         */
    public static void releaseConnection(HttpMethod method, String role,
      BrokenLinkCheckerLog log) {
  try {
      method.releaseConnection();
  } catch (Exception e) {
      log.warning(
        "An error occurred during releasing of connection of HTTP method: "
          + role, e);
  }
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.