1 4 package com.tc.object.tx; 5 6 import com.tc.net.protocol.tcm.ChannelIDProvider; 7 import com.tc.object.lockmanager.api.LockID; 8 import com.tc.object.logging.RuntimeLogger; 9 10 13 public class ClientTransactionFactoryImpl implements ClientTransactionFactory { 14 private long transactionID = 0; 15 private final RuntimeLogger runtimeLogger; 16 private final ChannelIDProvider cidProvider; 17 18 public ClientTransactionFactoryImpl(RuntimeLogger runtimeLogger, ChannelIDProvider cidProvider) { 19 this.runtimeLogger = runtimeLogger; 20 this.cidProvider = cidProvider; 21 } 22 23 public ClientTransaction newInstance() { 24 return new ClientTransactionImpl(nextTransactionID(), runtimeLogger, cidProvider); 25 } 26 27 public ClientTransaction newNullInstance(LockID id, TxnType type) { 28 ClientTransaction tc = new NullClientTransaction(nextTransactionID(), cidProvider); 29 tc.setTransactionContext(new TransactionContext(id, type, new LockID[] { id })); 30 return tc; 31 } 32 33 private synchronized TransactionID nextTransactionID() { 34 return new TransactionID(transactionID++); 35 } 36 } | Popular Tags |