01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.tx;
05:
06: import com.tc.object.lockmanager.api.LockID;
07: import com.tc.object.logging.RuntimeLogger;
08:
09: /**
10: * @author steve
11: */
12: public class ClientTransactionFactoryImpl implements
13: ClientTransactionFactory {
14: private long transactionID = 0;
15: private final RuntimeLogger runtimeLogger;
16:
17: public ClientTransactionFactoryImpl(RuntimeLogger runtimeLogger) {
18: this .runtimeLogger = runtimeLogger;
19: }
20:
21: public ClientTransaction newInstance() {
22: return new ClientTransactionImpl(nextTransactionID(),
23: runtimeLogger);
24: }
25:
26: public ClientTransaction newNullInstance(LockID id, TxnType type) {
27: ClientTransaction tc = new NullClientTransaction(
28: nextTransactionID());
29: tc.setTransactionContext(new TransactionContextImpl(id, type,
30: new LockID[] { id }));
31: return tc;
32: }
33:
34: private synchronized TransactionID nextTransactionID() {
35: return new TransactionID(transactionID++);
36: }
37: }
|