1
2
3
4
5
6
7
8
9
10
11 package org.mule.util.xa;
12
13 import java.util.HashMap;
14 import java.util.Map;
15
16 import javax.transaction.xa.Xid;
17
18
19
20
21
22 public abstract class AbstractXAResourceManager extends AbstractResourceManager
23 {
24
25 protected Map suspendedContexts = new HashMap();
26 protected Map activeContexts = new HashMap();
27
28 public AbstractXAResourceManager()
29 {
30 super();
31 }
32
33 protected boolean includeBranchInXid()
34 {
35 return true;
36 }
37
38 AbstractTransactionContext getTransactionalResource(Xid xid)
39 {
40 AbstractTransactionContext context = getActiveTransactionalResource(xid);
41 if (context != null)
42 {
43 return context;
44 }
45 else
46 {
47 return getSuspendedTransactionalResource(xid);
48 }
49 }
50
51 AbstractTransactionContext getActiveTransactionalResource(Xid xid)
52 {
53 return (AbstractTransactionContext) activeContexts.get(xid);
54 }
55
56 AbstractTransactionContext getSuspendedTransactionalResource(Xid xid)
57 {
58 return (AbstractTransactionContext) suspendedContexts.get(xid);
59 }
60
61 void addActiveTransactionalResource(Xid xid, AbstractTransactionContext context)
62 {
63 activeContexts.put(xid, context);
64 }
65
66 void addSuspendedTransactionalResource(Xid xid, AbstractTransactionContext context)
67 {
68 suspendedContexts.put(xid, context);
69 }
70
71 void removeActiveTransactionalResource(Xid xid)
72 {
73 activeContexts.remove(xid);
74 }
75
76 void removeSuspendedTransactionalResource(Xid xid)
77 {
78 suspendedContexts.remove(xid);
79 }
80
81 }