KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > tx > TransactionBatchWriterFactory


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.tx;
5
6 import com.tc.object.dna.impl.DNAEncoding;
7 import com.tc.object.dna.impl.ObjectStringSerializer;
8 import com.tc.object.msg.CommitTransactionMessageFactory;
9
10 public class TransactionBatchWriterFactory implements TransactionBatchFactory {
11
12   private long batchIDSequence = 0;
13   private final CommitTransactionMessageFactory messageFactory;
14   private final DNAEncoding encoding;
15
16   public TransactionBatchWriterFactory(CommitTransactionMessageFactory messageFactory, DNAEncoding encoding) {
17     this.messageFactory = messageFactory;
18     this.encoding = encoding;
19   }
20
21   public synchronized ClientTransactionBatch nextBatch() {
22     return new TransactionBatchWriter(new TxnBatchID(++batchIDSequence), new ObjectStringSerializer(), encoding,
23                                       messageFactory);
24   }
25
26 }
27
Popular Tags