KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > msg > AcknowledgeTransactionMessageImpl


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.object.msg;
5
6 import com.tc.bytes.TCByteBuffer;
7 import com.tc.io.TCByteBufferOutput;
8 import com.tc.net.protocol.tcm.ChannelID;
9 import com.tc.net.protocol.tcm.MessageChannel;
10 import com.tc.net.protocol.tcm.MessageMonitor;
11 import com.tc.net.protocol.tcm.TCMessageHeader;
12 import com.tc.net.protocol.tcm.TCMessageType;
13 import com.tc.object.session.SessionID;
14 import com.tc.object.tx.TransactionID;
15
16 import java.io.IOException JavaDoc;
17
18 /**
19  * @author steve
20  */

21 public class AcknowledgeTransactionMessageImpl extends DSOMessageBase implements AcknowledgeTransactionMessage {
22   private final static byte REQUEST_ID = 1;
23   private final static byte REQUESTER_ID = 2;
24
25   private TransactionID requestID;
26   private ChannelID requesterID;
27
28   public AcknowledgeTransactionMessageImpl(MessageMonitor monitor, TCByteBufferOutput out, MessageChannel channel,
29                                            TCMessageType type) {
30     super(monitor, out, channel, type);
31   }
32
33   public AcknowledgeTransactionMessageImpl(SessionID sessionID, MessageMonitor monitor, MessageChannel channel,
34                                            TCMessageHeader header, TCByteBuffer[] data) {
35     super(sessionID, monitor, channel, header, data);
36   }
37
38   protected void dehydrateValues() {
39     putNVPair(REQUEST_ID, requestID.toLong());
40     putNVPair(REQUESTER_ID, requesterID.toLong());
41   }
42
43   protected boolean hydrateValue(byte name) throws IOException JavaDoc {
44     switch (name) {
45       case REQUESTER_ID:
46         requesterID = new ChannelID(getLongValue());
47         return true;
48       case REQUEST_ID:
49         requestID = new TransactionID(getLongValue());
50         return true;
51       default:
52         return false;
53     }
54   }
55
56   public void initialize(ChannelID channelID, TransactionID txID) {
57     this.requesterID = channelID;
58     this.requestID = txID;
59   }
60
61   public ChannelID getRequesterID() {
62     return requesterID;
63   }
64
65   public TransactionID getRequestID() {
66     return requestID;
67   }
68
69 }
Popular Tags