1 18 package org.apache.activemq.state; 19 20 import java.util.ArrayList ; 21 import java.util.List ; 22 23 import org.apache.activemq.command.Command; 24 import org.apache.activemq.command.TransactionId; 25 26 import java.util.concurrent.atomic.AtomicBoolean ; 27 28 public class TransactionState { 29 final TransactionId id; 30 31 public final ArrayList commands = new ArrayList (); 32 private final AtomicBoolean shutdown = new AtomicBoolean (false); 33 34 private boolean prepared; 35 36 private int preparedResult; 37 38 public TransactionState(TransactionId id) { 39 this.id = id; 40 } 41 public String toString() { 42 return id.toString(); 43 } 44 45 public void addCommand(Command operation) { 46 checkShutdown(); 47 commands.add(operation); 48 } 49 50 public List getCommands() { 51 return commands; 52 } 53 54 private void checkShutdown() { 55 if( shutdown.get() ) 56 throw new IllegalStateException ("Disposed"); 57 } 58 59 public void shutdown() { 60 shutdown.set(false); 61 } 62 public TransactionId getId() { 63 return id; 64 } 65 66 public void setPrepared(boolean prepared) { 67 this.prepared = prepared; 68 } 69 public boolean isPrepared() { 70 return prepared; 71 } 72 public void setPreparedResult(int preparedResult) { 73 this.preparedResult = preparedResult; 74 } 75 public int getPreparedResult() { 76 return preparedResult; 77 } 78 79 } 80 | Popular Tags |