KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > l1 > impl > TransactionAcknowledgeActionImpl


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

4 package com.tc.objectserver.l1.impl;
5
6 import com.tc.logging.TCLogger;
7 import com.tc.logging.TCLogging;
8 import com.tc.net.protocol.tcm.MessageChannel;
9 import com.tc.net.protocol.tcm.TCMessageType;
10 import com.tc.object.msg.AcknowledgeTransactionMessage;
11 import com.tc.object.net.DSOChannelManager;
12 import com.tc.object.net.NoSuchChannelException;
13 import com.tc.object.tx.ServerTransactionID;
14
15 /**
16  * @author steve
17  */

18 public class TransactionAcknowledgeActionImpl implements TransactionAcknowledgeAction {
19   private final DSOChannelManager channelManager;
20   private final TCLogger logger = TCLogging.getLogger(TransactionAcknowledgeActionImpl.class);
21
22   public TransactionAcknowledgeActionImpl(DSOChannelManager channelManager) {
23     this.channelManager = channelManager;
24   }
25
26   public void acknowledgeTransaction(ServerTransactionID stxID) {
27     try {
28       MessageChannel channel = channelManager.getActiveChannel(stxID.getChannelID());
29       AcknowledgeTransactionMessage m = (AcknowledgeTransactionMessage) channel
30           .createMessage(TCMessageType.ACKNOWLEDGE_TRANSACTION_MESSAGE);
31       m.initialize(stxID.getChannelID(), stxID.getClientTransactionID());
32       m.send();
33     } catch (NoSuchChannelException e) {
34       logger.info("An attempt was made to send a commit ack but the client seems to have gone away:"
35                   + stxID );
36       return;
37     }
38   }
39 }
Popular Tags