KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > util > xa > AbstractXAResourceManager


1 /*
2  * $Id: AbstractXAResourceManager.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.util.xa;
12
13 import javax.transaction.xa.Xid JavaDoc;
14
15 import java.util.HashMap JavaDoc;
16 import java.util.Map JavaDoc;
17
18 /**
19  * @author <a HREF="mailto:gnt@codehaus.org">Guillaume Nodet</a>
20  * @version $Revision: 3798 $
21  */

22 public abstract class AbstractXAResourceManager extends AbstractResourceManager
23 {
24
25     protected Map JavaDoc suspendedContexts = new HashMap JavaDoc();
26     protected Map JavaDoc activeContexts = new HashMap JavaDoc();
27
28     public AbstractXAResourceManager()
29     {
30         super();
31     }
32
33     protected boolean includeBranchInXid()
34     {
35         return true;
36     }
37
38     AbstractTransactionContext getTransactionalResource(Xid JavaDoc 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 JavaDoc xid)
52     {
53         return (AbstractTransactionContext)activeContexts.get(xid);
54     }
55
56     AbstractTransactionContext getSuspendedTransactionalResource(Xid JavaDoc xid)
57     {
58         return (AbstractTransactionContext)suspendedContexts.get(xid);
59     }
60
61     void addActiveTransactionalResource(Xid JavaDoc xid, AbstractTransactionContext context)
62     {
63         activeContexts.put(xid, context);
64     }
65
66     void addSuspendedTransactionalResource(Xid JavaDoc xid, AbstractTransactionContext context)
67     {
68         suspendedContexts.put(xid, context);
69     }
70
71     void removeActiveTransactionalResource(Xid JavaDoc xid)
72     {
73         activeContexts.remove(xid);
74     }
75
76     void removeSuspendedTransactionalResource(Xid JavaDoc xid)
77     {
78         suspendedContexts.remove(xid);
79     }
80
81 }
82
Popular Tags