1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.jms.xa; |
12 | |
|
13 | |
import java.lang.reflect.Proxy; |
14 | |
|
15 | |
import javax.jms.Connection; |
16 | |
import javax.jms.ConnectionFactory; |
17 | |
import javax.jms.JMSException; |
18 | |
import javax.jms.QueueConnection; |
19 | |
import javax.jms.QueueConnectionFactory; |
20 | |
import javax.jms.TopicConnection; |
21 | |
import javax.jms.TopicConnectionFactory; |
22 | |
import javax.jms.XAConnection; |
23 | |
import javax.jms.XAConnectionFactory; |
24 | |
import javax.jms.XAQueueConnection; |
25 | |
import javax.jms.XAQueueConnectionFactory; |
26 | |
import javax.jms.XATopicConnection; |
27 | |
import javax.jms.XATopicConnectionFactory; |
28 | |
|
29 | |
import org.apache.commons.logging.Log; |
30 | |
import org.apache.commons.logging.LogFactory; |
31 | |
|
32 | |
public class ConnectionFactoryWrapper |
33 | |
implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory |
34 | |
{ |
35 | |
|
36 | |
|
37 | |
|
38 | 18 | protected static final transient Log logger = LogFactory.getLog(ConnectionFactoryWrapper.class); |
39 | |
|
40 | |
protected final Object factory; |
41 | |
|
42 | |
public ConnectionFactoryWrapper(Object factory) |
43 | 12 | { |
44 | 12 | this.factory = factory; |
45 | 12 | } |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
public Connection createConnection() throws JMSException |
53 | |
{ |
54 | 12 | XAConnection xac = ((XAConnectionFactory) factory).createXAConnection(); |
55 | 12 | Connection proxy = (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(), |
56 | |
new Class[]{Connection.class}, new ConnectionInvocationHandler(xac)); |
57 | 12 | return proxy; |
58 | |
} |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public Connection createConnection(String username, String password) throws JMSException |
67 | |
{ |
68 | 0 | XAConnection xac = ((XAConnectionFactory) factory).createXAConnection(username, password); |
69 | 0 | Connection proxy = (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(), |
70 | |
new Class[]{Connection.class}, new ConnectionInvocationHandler(xac)); |
71 | 0 | return proxy; |
72 | |
} |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
public QueueConnection createQueueConnection() throws JMSException |
80 | |
{ |
81 | 0 | XAQueueConnection xaqc = ((XAQueueConnectionFactory) factory).createXAQueueConnection(); |
82 | 0 | QueueConnection proxy = (QueueConnection) Proxy.newProxyInstance(Connection.class.getClassLoader(), |
83 | |
new Class[]{QueueConnection.class}, new ConnectionInvocationHandler(xaqc)); |
84 | 0 | return proxy; |
85 | |
} |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
public QueueConnection createQueueConnection(String username, String password) throws JMSException |
94 | |
{ |
95 | 0 | XAQueueConnection xaqc = ((XAQueueConnectionFactory) factory).createXAQueueConnection(username, |
96 | |
password); |
97 | 0 | QueueConnection proxy = (QueueConnection) Proxy.newProxyInstance(Connection.class.getClassLoader(), |
98 | |
new Class[]{QueueConnection.class}, new ConnectionInvocationHandler(xaqc)); |
99 | 0 | return proxy; |
100 | |
} |
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public TopicConnection createTopicConnection() throws JMSException |
108 | |
{ |
109 | 0 | XATopicConnection xatc = ((XATopicConnectionFactory) factory).createXATopicConnection(); |
110 | 0 | TopicConnection proxy = (TopicConnection) Proxy.newProxyInstance(Connection.class.getClassLoader(), |
111 | |
new Class[]{TopicConnection.class}, new ConnectionInvocationHandler(xatc)); |
112 | 0 | return proxy; |
113 | |
} |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public TopicConnection createTopicConnection(String username, String password) throws JMSException |
122 | |
{ |
123 | 0 | XATopicConnection xatc = ((XATopicConnectionFactory) factory).createXATopicConnection(username, |
124 | |
password); |
125 | 0 | TopicConnection proxy = (TopicConnection) Proxy.newProxyInstance(Connection.class.getClassLoader(), |
126 | |
new Class[]{TopicConnection.class}, new ConnectionInvocationHandler(xatc)); |
127 | 0 | return proxy; |
128 | |
} |
129 | |
|
130 | |
} |