01: /*
02: * All content copyright (c) 2003-2006 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.l2.msg.RelayedCommitTransactionMessage;
08: import com.tc.object.gtx.GlobalTransactionIDGenerator;
09: import com.tc.object.msg.CommitTransactionMessage;
10:
11: import java.io.IOException;
12:
13: public final class CommitTransactionMessageToTransactionBatchReader
14: implements TransactionBatchReaderFactory {
15:
16: private final GlobalTransactionIDGenerator gtxm;
17: private final ServerTransactionFactory activeTxnFactory = new ActiveServerTransactionFactory();
18: private final ServerTransactionFactory passiveTxnFactory = new PassiveServerTransactionFactory();
19:
20: public CommitTransactionMessageToTransactionBatchReader(
21: GlobalTransactionIDGenerator gtxm) {
22: this .gtxm = gtxm;
23: }
24:
25: // Used by active server
26: public TransactionBatchReader newTransactionBatchReader(
27: CommitTransactionMessage ctm) throws IOException {
28: return new TransactionBatchReaderImpl(gtxm, ctm.getBatchData(),
29: ctm.getClientID(), ctm.getSerializer(),
30: activeTxnFactory);
31: }
32:
33: // Used by passive server
34: public TransactionBatchReader newTransactionBatchReader(
35: RelayedCommitTransactionMessage ctm) throws IOException {
36: return new TransactionBatchReaderImpl(ctm, ctm.getBatchData(),
37: ctm.getClientID(), ctm.getSerializer(),
38: passiveTxnFactory);
39: }
40: }
|