KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > command > TransactionInfo


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.command;
19
20 import java.io.IOException JavaDoc;
21
22 import org.apache.activemq.state.CommandVisitor;
23
24 /**
25  *
26  * @openwire:marshaller code="7"
27  * @version $Revision: 1.10 $
28  */

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     /**
61      * @openwire:property version=1 cache=true
62      */

63     public ConnectionId getConnectionId() {
64         return connectionId;
65     }
66     public void setConnectionId(ConnectionId connectionId) {
67         this.connectionId = connectionId;
68     }
69
70     /**
71      * @openwire:property version=1 cache=true
72      */

73     public TransactionId getTransactionId() {
74         return transactionId;
75     }
76     public void setTransactionId(TransactionId transactionId) {
77         this.transactionId = transactionId;
78     }
79
80     /**
81      * @openwire:property version=1
82      */

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 JavaDoc {
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 JavaDoc("Transaction info type unknown: "+type);
110         }
111     }
112
113 }
114
Popular Tags