Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/notify/TxnNotifys.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.notify; | |
2 | |
3 import java.io.IOException; | |
4 | |
5 import java.util.HashMap; | |
6 import java.util.ArrayList; | |
7 import java.util.LinkedList; | |
8 import java.util.Iterator; | |
9 import java.util.logging.Level; | |
10 | |
11 import org.dancres.blitz.txn.TxnState; | |
12 | |
13 import org.dancres.blitz.oid.OID; | |
14 | |
15 /** | |
16 Tracks notify registrations associated with specific transactions. | |
17 This is done so that when we receive a transaction ended event we can | |
18 cleanup any outstanding templates associated with that transaction. | |
19 | |
20 @deprecated Transactional de-reg is handled by the generator when receiving | |
21 end of transaction message. | |
22 */ | |
23 class TxnNotifys { | |
24 private HashMap theRegsByTxn = new HashMap(); | |
25 | |
26 synchronized void track(OID aOID, TxnState aTxn) { | |
27 // System.out.println("Tracking: " + aOID + ", " + aTxn.getId()); | |
28 | |
29 LinkedList myRegs = getRegs(aTxn); | |
30 | |
31 if (myRegs == null) { | |
32 myRegs = new LinkedList(); | |
33 theRegsByTxn.put(aTxn.getId(), myRegs); | |
34 } | |
35 | |
36 myRegs.add(aOID); | |
37 } | |
38 | |
39 /** | |
40 Return an Iterator of OID's | |
41 */ | |
42 void unRegAll(TxnState aTxn) { | |
43 Iterator myEventGenOIDs = null; | |
44 | |
45 synchronized(this) { | |
46 LinkedList myRegs = (LinkedList) theRegsByTxn.remove(aTxn.getId()); | |
47 | |
48 if (myRegs != null) | |
49 myEventGenOIDs = myRegs.iterator(); | |
50 } | |
51 | |
52 if (myEventGenOIDs != null) { | |
53 while (myEventGenOIDs.hasNext()) { | |
54 OID myOID = (OID) myEventGenOIDs.next(); | |
55 | |
56 try { | |
57 EventGeneratorFactory.get().cancel(myOID); | |
58 } catch (IOException aDbe) { | |
59 } | |
60 } | |
61 } | |
62 } | |
63 | |
64 private LinkedList getRegs(TxnState aTxn) { | |
65 return (LinkedList) theRegsByTxn.get(aTxn.getId()); | |
66 } | |
67 } |