1 18 package org.apache.activemq.command; 19 20 import java.io.IOException ; 21 22 import org.apache.activemq.state.CommandVisitor; 23 24 29 public class TransactionInfo extends BaseCommand { 30 31 public static final byte DATA_STRUCTURE_TYPE=CommandTypes.TRANSACTION_INFO; 32 33 34 public static final byte BEGIN = 0; 35 public static final byte PREPARE=1; 36 public static final byte COMMIT_ONE_PHASE=2; 37 public static final byte COMMIT_TWO_PHASE=3; 38 public static final byte ROLLBACK=4; 39 public static final byte RECOVER=5; 40 public static final byte FORGET=6; 41 public static final byte END=7; 42 43 protected byte type; 44 protected ConnectionId connectionId; 45 protected TransactionId transactionId; 46 47 public TransactionInfo() { 48 } 49 50 public TransactionInfo(ConnectionId connectionId, TransactionId transactionId, byte type) { 51 this.connectionId=connectionId; 52 this.transactionId=transactionId; 53 this.type=type; 54 } 55 56 public byte getDataStructureType() { 57 return DATA_STRUCTURE_TYPE; 58 } 59 60 63 public ConnectionId getConnectionId() { 64 return connectionId; 65 } 66 public void setConnectionId(ConnectionId connectionId) { 67 this.connectionId = connectionId; 68 } 69 70 73 public TransactionId getTransactionId() { 74 return transactionId; 75 } 76 public void setTransactionId(TransactionId transactionId) { 77 this.transactionId = transactionId; 78 } 79 80 83 public byte getType() { 84 return type; 85 } 86 public void setType(byte type) { 87 this.type = type; 88 } 89 90 public Response visit(CommandVisitor visitor) throws Exception { 91 switch( type ) { 92 case TransactionInfo.BEGIN: 93 return visitor.processBeginTransaction(this); 94 case TransactionInfo.END: 95 return visitor.processEndTransaction(this); 96 case TransactionInfo.PREPARE: 97 return visitor.processPrepareTransaction(this); 98 case TransactionInfo.COMMIT_ONE_PHASE: 99 return visitor.processCommitTransactionOnePhase(this); 100 case TransactionInfo.COMMIT_TWO_PHASE: 101 return visitor.processCommitTransactionTwoPhase(this); 102 case TransactionInfo.ROLLBACK: 103 return visitor.processRollbackTransaction(this); 104 case TransactionInfo.RECOVER: 105 return visitor.processRecoverTransactions(this); 106 case TransactionInfo.FORGET: 107 return visitor.processForgetTransaction(this); 108 default: 109 throw new IOException ("Transaction info type unknown: "+type); 110 } 111 } 112 113 } 114 | Popular Tags |