View Javadoc

1   /*
2    * Copyright 2008 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
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  
17  package org.springframework.ws.transport.support;
18  
19  import java.io.IOException;
20  
21  import org.apache.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  
24  import org.springframework.ws.transport.WebServiceConnection;
25  
26  /**
27   * Generic utility methods for working with Web service transports. Mainly for internal use within the framework.
28   *
29   * @author Arjen Poutsma
30   * @since 1.5.0
31   */
32  public abstract class TransportUtils {
33  
34      private static final Log logger = LogFactory.getLog(TransportUtils.class);
35  
36      /**
37       * Close the given [email protected] WebServiceConnection} and ignore any thrown exception. This is useful for typical
38       * <code>finally</code> blocks.
39       *
40       * @param connection the web service connection to close (may be <code>null</code>)
41       */
42      public static void closeConnection(WebServiceConnection connection) {
43          if (connection != null) {
44              try {
45                  connection.close();
46              }
47              catch (IOException ex) {
48                  logger.debug("Could not close WebServiceConnection", ex);
49              }
50              catch (Throwable ex) {
51                  logger.debug("Unexpected exception on closing WebServiceConnection", ex);
52              }
53          }
54      }
55  
56  }