1
2
3
4
5
6
7
8
9
10 package org.mule.providers.jms.xa;
11
12 import java.lang.reflect.InvocationHandler;
13 import java.lang.reflect.InvocationTargetException;
14 import java.lang.reflect.Method;
15
16 public class ConsumerProducerInvocationHandler implements InvocationHandler
17 {
18
19 private Object target;
20 private SessionInvocationHandler sessionInvocationHandler;
21
22 public ConsumerProducerInvocationHandler(SessionInvocationHandler sessionInvocationHandler, Object target)
23 {
24 this.sessionInvocationHandler = sessionInvocationHandler;
25 this.target = target;
26 }
27
28
29
30
31
32
33
34 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
35 {
36 if (ConnectionFactoryWrapper.logger.isDebugEnabled())
37 {
38 ConnectionFactoryWrapper.logger.debug("Invoking " + method);
39 }
40 if (!method.getName().equals("close"))
41 {
42 sessionInvocationHandler.enlist();
43 }
44 try
45 {
46 return method.invoke(target, args);
47 }
48 catch (InvocationTargetException e)
49 {
50 throw e.getCause();
51 }
52 }
53 }