KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > l2 > handler > ServerTransactionAckHandler


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.l2.handler;
5
6 import com.tc.async.api.AbstractEventHandler;
7 import com.tc.async.api.ConfigurationContext;
8 import com.tc.async.api.EventContext;
9 import com.tc.l2.msg.ServerTxnAckMessage;
10 import com.tc.net.groups.NodeID;
11 import com.tc.net.protocol.tcm.ChannelID;
12 import com.tc.object.tx.ServerTransactionID;
13 import com.tc.objectserver.core.api.ServerConfigurationContext;
14 import com.tc.objectserver.tx.ServerTransactionManager;
15
16 import java.util.Iterator JavaDoc;
17 import java.util.Set JavaDoc;
18
19 public class ServerTransactionAckHandler extends AbstractEventHandler {
20
21   private ServerTransactionManager transactionManager;
22
23   public void handleEvent(EventContext context) {
24     ServerTxnAckMessage msg = (ServerTxnAckMessage) context;
25     Set JavaDoc ackedTxns = msg.getAckedServerTxnIDs();
26     NodeID nodeID = msg.messageFrom();
27     ChannelID waitee = nodeID.toChannelID();
28     for (Iterator JavaDoc i = ackedTxns.iterator(); i.hasNext();) {
29       ServerTransactionID sid = (ServerTransactionID) i.next();
30       transactionManager.acknowledgement(sid.getChannelID(), sid.getClientTransactionID(), waitee);
31     }
32   }
33   
34   public void initialize(ConfigurationContext context) {
35     super.initialize(context);
36     ServerConfigurationContext oscc = (ServerConfigurationContext) context;
37     this.transactionManager = oscc.getTransactionManager();
38   }
39
40 }
41
Popular Tags