1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| package org.jboss.cache.pojo.interceptors; |
9 |
| |
10 |
| import org.jboss.aop.joinpoint.Invocation; |
11 |
| import org.jboss.aop.joinpoint.MethodInvocation; |
12 |
| import org.jboss.cache.Fqn; |
13 |
| import org.jboss.cache.pojo.impl.InternalConstant; |
14 |
| |
15 |
| import javax.transaction.Transaction; |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| public class PojoFailedTxMockupInterceptor extends AbstractInterceptor |
27 |
| { |
28 |
| public static boolean TX_ROLLBACK = false; |
29 |
| |
30 |
0
| public static void setTxRollback(boolean isTrue)
|
31 |
| { |
32 |
0
| TX_ROLLBACK = isTrue;
|
33 |
| } |
34 |
| |
35 |
25119
| public Object invoke(Invocation in) throws Throwable
|
36 |
| { |
37 |
25119
| if (!(in instanceof MethodInvocation))
|
38 |
| { |
39 |
0
| throw new IllegalArgumentException(
|
40 |
| "PojoFailedTxMockupInterceptor.invoke(): invocation not MethodInvocation"); |
41 |
| } |
42 |
25119
| MethodInvocation invocation = (MethodInvocation) in;
|
43 |
25119
| try
|
44 |
| { |
45 |
25119
| Object obj = null;
|
46 |
25119
| obj = invocation.invokeNext();
|
47 |
25116
| if(TX_ROLLBACK)
|
48 |
| { |
49 |
34
| Transaction tx = (Transaction)
|
50 |
| invocation.getMetaData().getMetaData(PojoTxInterceptor.TAG, PojoTxInterceptor.TX); |
51 |
| |
52 |
34
| Fqn id = (Fqn) invocation.getArguments()[0];
|
53 |
| |
54 |
34
| if(!id.isChildOrEquals(InternalConstant.JBOSS_INTERNAL))
|
55 |
| { |
56 |
11
| tx.setRollbackOnly();
|
57 |
11
| TX_ROLLBACK = false;
|
58 |
| } |
59 |
| } |
60 |
25116
| return obj;
|
61 |
| } finally |
62 |
| { |
63 |
| } |
64 |
| } |
65 |
| } |