01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. 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: */package org.apache.openejb.test.mdb;
18:
19: import javax.jms.MessageProducer;
20: import javax.jms.JMSException;
21: import javax.jms.MessageConsumer;
22: import javax.jms.Session;
23: import javax.jms.Connection;
24: import java.lang.reflect.Method;
25:
26: public class MdbUtil {
27: public static String getSignature(Method method) {
28: StringBuilder builder = new StringBuilder();
29: builder.append(method.getName()).append("(");
30: boolean first = true;
31: for (Class<?> type : method.getParameterTypes()) {
32: if (!first) {
33: builder.append(",");
34: }
35: builder.append(type.getName());
36: first = false;
37: }
38: builder.append(")");
39: return builder.toString();
40: }
41:
42: public static void close(MessageProducer closeable) {
43: if (closeable != null) {
44: try {
45: closeable.close();
46: } catch (JMSException e) {
47: }
48: }
49: }
50:
51: public static void close(MessageConsumer closeable) {
52: if (closeable != null) {
53: try {
54: closeable.close();
55: } catch (JMSException e) {
56: }
57: }
58: }
59:
60: public static void close(Session closeable) {
61: if (closeable != null) {
62: try {
63: closeable.close();
64: } catch (JMSException e) {
65: }
66: }
67: }
68:
69: public static void close(Connection closeable) {
70: if (closeable != null) {
71: try {
72: closeable.close();
73: } catch (JMSException e) {
74: }
75: }
76: }
77: }
|