01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.objectserver.tx;
06:
07: import com.tc.bytes.TCByteBuffer;
08: import com.tc.net.groups.ClientID;
09: import com.tc.object.dna.impl.ObjectStringSerializer;
10: import com.tc.object.msg.CommitTransactionMessage;
11: import com.tc.object.tx.TransactionBatch;
12:
13: import java.util.ArrayList;
14: import java.util.Iterator;
15: import java.util.LinkedList;
16: import java.util.List;
17:
18: public class TestCommitTransactionMessage implements
19: CommitTransactionMessage {
20:
21: public final List setBatchCalls = new LinkedList();
22: public final List sendCalls = new LinkedList();
23: public ObjectStringSerializer serializer;
24: private List tcByteBufferList = new ArrayList();
25: private ClientID clientID = ClientID.NULL_ID;
26:
27: public void setChannelID(ClientID clientID) {
28: this .clientID = clientID;
29: }
30:
31: public void setBatch(TransactionBatch batch,
32: ObjectStringSerializer serializer) {
33: setBatchCalls.add(batch);
34: this .serializer = serializer;
35:
36: TCByteBuffer[] tcbb = batch.getData();
37: for (int i = 0; i < tcbb.length; i++) {
38: tcByteBufferList.add(tcbb[i]);
39: }
40: }
41:
42: public TCByteBuffer[] getBatchData() {
43: TCByteBuffer[] tcbb = new TCByteBuffer[tcByteBufferList.size()];
44: int count = 0;
45: for (Iterator iter = tcByteBufferList.iterator(); iter
46: .hasNext(); count++) {
47: tcbb[count] = (TCByteBuffer) iter.next();
48: }
49: return tcbb;
50: }
51:
52: public void send() {
53: this .sendCalls.add(new Object());
54: }
55:
56: public ObjectStringSerializer getSerializer() {
57: return serializer;
58: }
59:
60: public ClientID getClientID() {
61: return clientID;
62: }
63:
64: }
|