XATransactionInfo xref

View Javadoc

    1   /***
    2    *
    3    * Copyright 2004 Protique Ltd
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   **/
    18
    19  package org.codehaus.activemq.message;
    20
    21  /***
    22   * Provides a infomation about an XA Transaction
    23   *
    24   * @version $Revision: 1.4 $
    25   */
    26  public class XATransactionInfo extends AbstractPacket implements TransactionType {
    27
    28      private ActiveMQXid xid;
    29      private int type;
    30      private int transactionTimeout;
    31
    32
    33      /***
    34       * Return the type of Packet
    35       *
    36       * @return integer representation of the type of Packet
    37       */
    38
    39      public int getPacketType() {
    40          return XA_TRANSACTION_INFO;
    41      }
    42
    43      /***
    44       * Test for equality
    45       *
    46       * @param obj object to test
    47       * @return true if equivalent
    48       */
    49      public boolean equals(Object obj) {
    50          boolean result = false;
    51          if (obj != null && obj instanceof XATransactionInfo) {
    52              XATransactionInfo info = (XATransactionInfo) obj;
    53              result = this.xid.equals(info.xid) && this.type == info.type;
    54          }
    55          return result;
    56      }
    57
    58      /***
    59       * @return hash code for instance
    60       */
    61      public int hashCode() {
    62          return xid.hashCode() ^ type;
    63      }
    64
    65
    66      /***
    67       * @return Returns the type of transacton command.
    68       */
    69      public int getType() {
    70          return this.type;
    71      }
    72
    73      /***
    74       * @param newType the type of transaction command The type to set.
    75       */
    76      public void setType(int newType) {
    77          this.type = newType;
    78      }
    79
    80      public ActiveMQXid getXid() {
    81          return xid;
    82      }
    83
    84      public void setXid(ActiveMQXid xid) {
    85          this.xid = xid;
    86      }
    87
    88      /***
    89       * @return Returns the transactionTimeout.
    90       */
    91      public int getTransactionTimeout() {
    92          return transactionTimeout;
    93      }
    94
    95      /***
    96       * @param transactionTimeout The transactionTimeout to set.
    97       */
    98      public void setTransactionTimeout(int transactionTimeout) {
    99          this.transactionTimeout = transactionTimeout;
    100     }
    101 }