|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| package org.objectweb.easybeans.transaction.interceptors; |
|
27 |
| |
|
28 |
| import javax.ejb.EJBException; |
|
29 |
| import javax.transaction.InvalidTransactionException; |
|
30 |
| import javax.transaction.SystemException; |
|
31 |
| import javax.transaction.Transaction; |
|
32 |
| |
|
33 |
| import org.objectweb.easybeans.api.EasyBeansInvocationContext; |
|
34 |
| import org.objectweb.easybeans.log.JLog; |
|
35 |
| import org.objectweb.easybeans.log.JLogFactory; |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| public class CMTNotSupportedTransactionInterceptor extends AbsTransactionInterceptor { |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| private JLog logger = JLogFactory.getLog(CMTNotSupportedTransactionInterceptor.class); |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
0
| public CMTNotSupportedTransactionInterceptor() {
|
|
53 |
0
| super();
|
|
54 |
| } |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
0
| @Override
|
|
66 |
| public Object intercept(final EasyBeansInvocationContext invocationContext) throws Exception { |
|
67 |
0
| logger.debug("Calling Not Supported TX interceptor");
|
|
68 |
| |
|
69 |
| |
|
70 |
0
| Transaction transaction;
|
|
71 |
0
| try {
|
|
72 |
0
| transaction = getTransactionManager().getTransaction();
|
|
73 |
| } catch (SystemException se) { |
|
74 |
0
| throw new EJBException("Cannot get the current transaction on transaction manager.", se);
|
|
75 |
| } |
|
76 |
| |
|
77 |
0
| logger.debug("Transaction found = {0}", transaction);
|
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
0
| Transaction suspendedTransaction = null;
|
|
86 |
0
| if (transaction != null) {
|
|
87 |
0
| try {
|
|
88 |
0
| logger.debug("Suspending transaction {0}", transaction);
|
|
89 |
0
| suspendedTransaction = getTransactionManager().suspend();
|
|
90 |
| } catch (SystemException se) { |
|
91 |
0
| throw new EJBException("Cannot call suspend() on the transaction manager.", se);
|
|
92 |
| } |
|
93 |
| } |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
0
| try {
|
|
101 |
0
| return invocationContext.proceed();
|
|
102 |
| } finally { |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
0
| if (suspendedTransaction != null) {
|
|
109 |
| |
|
110 |
0
| logger.debug("Resuming transaction {0}", transaction);
|
|
111 |
| |
|
112 |
0
| try {
|
|
113 |
0
| getTransactionManager().resume(suspendedTransaction);
|
|
114 |
| } catch (InvalidTransactionException ite) { |
|
115 |
0
| throw new EJBException(
|
|
116 |
| "Cannot call resume() on the given transaction. There is an invalid transaction", ite); |
|
117 |
| } catch (IllegalStateException ise) { |
|
118 |
0
| throw new EJBException(
|
|
119 |
| "Cannot call resume() on the given transaction. There is another associated transaction", |
|
120 |
| ise); |
|
121 |
| } catch (SystemException se) { |
|
122 |
0
| throw new EJBException("Cannot call resume() on the given transaction. Unexpected error condition",
|
|
123 |
| se); |
|
124 |
| } |
|
125 |
| } |
|
126 |
| } |
|
127 |
| } |
|
128 |
| |
|
129 |
| } |