001 /**
002 *
003 * Copyright 2004 Protique Ltd
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 **/
018
019 package org.activemq.message;
020
021 /**
022 * Provides a infomation about an XA Transaction
023 *
024 * @version $Revision: 1.1.1.1 $
025 */
026 public class XATransactionInfo extends AbstractPacket implements TransactionType {
027
028 private ActiveMQXid xid;
029 private int type;
030 private int transactionTimeout;
031
032
033 /**
034 * Return the type of Packet
035 *
036 * @return integer representation of the type of Packet
037 */
038
039 public int getPacketType() {
040 return XA_TRANSACTION_INFO;
041 }
042
043 /**
044 * Test for equality
045 *
046 * @param obj object to test
047 * @return true if equivalent
048 */
049 public boolean equals(Object obj) {
050 boolean result = false;
051 if (obj != null && obj instanceof XATransactionInfo) {
052 XATransactionInfo info = (XATransactionInfo) obj;
053 result = this.xid.equals(info.xid) && this.type == info.type;
054 }
055 return result;
056 }
057
058 /**
059 * @return hash code for instance
060 */
061 public int hashCode() {
062 return xid.hashCode() ^ type;
063 }
064
065
066 /**
067 * @return Returns the type of transacton command.
068 */
069 public int getType() {
070 return this.type;
071 }
072
073 /**
074 * @param newType the type of transaction command The type to set.
075 */
076 public void setType(int newType) {
077 this.type = newType;
078 }
079
080 public ActiveMQXid getXid() {
081 return xid;
082 }
083
084 public void setXid(ActiveMQXid xid) {
085 this.xid = xid;
086 }
087
088 /**
089 * @return Returns the transactionTimeout.
090 */
091 public int getTransactionTimeout() {
092 return transactionTimeout;
093 }
094
095 /**
096 * @param transactionTimeout The transactionTimeout to set.
097 */
098 public void setTransactionTimeout(int transactionTimeout) {
099 this.transactionTimeout = transactionTimeout;
100 }
101
102 public String toString() {
103 return super.toString() + " XATransactionInfo{ " +
104 "transactionTimeout = " + transactionTimeout +
105 ", xid = " + xid +
106 ", type = " + type +
107 " }";
108 }
109 }