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: public class TransactionState {
08: private static final int APPLY_COMMITTED = 0x01;
09: private static final int BROADCAST_COMPLETED = 0x02;
10: private static final int TXN_RELAYED = 0x04;
11:
12: private static final int TXN_PROCESSING_COMPLETE = (APPLY_COMMITTED
13: | BROADCAST_COMPLETED | TXN_RELAYED);
14:
15: private int state = 0x00;
16:
17: public void applyAndCommitSkipped() {
18: state |= APPLY_COMMITTED;
19: }
20:
21: public boolean isComplete() {
22: return (state == TXN_PROCESSING_COMPLETE);
23: }
24:
25: public void broadcastCompleted() {
26: state |= BROADCAST_COMPLETED;
27: }
28:
29: public void applyCommitted() {
30: state |= APPLY_COMMITTED;
31: }
32:
33: public String toString() {
34: return "TransactionState = [ "
35: + ((state & APPLY_COMMITTED) == APPLY_COMMITTED ? " APPLY_COMMITED : "
36: : " : ")
37: + ((state & TXN_RELAYED) == TXN_RELAYED ? " TXN_RELAYED : "
38: : " : ")
39: + ((state & BROADCAST_COMPLETED) == BROADCAST_COMPLETED ? " BROADCAST_COMPLETE } "
40: : " ]");
41: }
42:
43: public void relayTransactionComplete() {
44: state |= TXN_RELAYED;
45: }
46:
47: }
|