001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mq;
023:
024: import java.io.Externalizable;
025:
026: import javax.jms.Destination;
027:
028: /**
029: * Used to Acknowledge sent messages.
030: * <p>
031: * This class holds the minimum amount of information needed to identify a
032: * message to the JMSServer.
033: *
034: * @author Hiram Chirino (Cojonudo14@hotmail.com)
035: * @author David Maplesden (David.Maplesden@orion.co.nz)
036: * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
037: * @version $Revision: 57198 $
038: */
039: public class AcknowledgementRequest implements Externalizable {
040: // Constants -----------------------------------------------------
041:
042: /** The serialVersionUID */
043: private static final long serialVersionUID = -2227528634302168874L;
044:
045: // Attributes ----------------------------------------------------
046:
047: /** Is it an acknowledgement */
048: public boolean isAck;
049: /** The destination */
050: public Destination destination = null;
051: /** The messageID */
052: public String messageID = null;
053: /** The subscriberId */
054: public int subscriberId;
055:
056: // Static --------------------------------------------------------
057:
058: // Constructors --------------------------------------------------
059:
060: public AcknowledgementRequest() {
061: this (false);
062: }
063:
064: public AcknowledgementRequest(boolean ack) {
065: this .isAck = ack;
066: }
067:
068: // Public --------------------------------------------------------
069:
070: public boolean isAck() {
071: return isAck;
072: }
073:
074: // Object overrides ----------------------------------------------
075:
076: public boolean equals(Object o) {
077:
078: if (!(o instanceof AcknowledgementRequest)) {
079: return false;
080: }
081:
082: return messageID.equals(((AcknowledgementRequest) o).messageID)
083: && destination
084: .equals(((AcknowledgementRequest) o).destination)
085: && subscriberId == ((AcknowledgementRequest) o).subscriberId;
086: }
087:
088: public int hashCode() {
089: return messageID.hashCode();
090: }
091:
092: public String toString() {
093: return "AcknowledgementRequest:" + ((isAck) ? "ACK" : "NACK")
094: + "," + destination + "," + messageID;
095: }
096:
097: public void readExternal(java.io.ObjectInput in)
098: throws java.io.IOException {
099: isAck = in.readBoolean();
100: destination = SpyDestination.readDest(in);
101: messageID = in.readUTF();
102: subscriberId = in.readInt();
103: }
104:
105: // Externalizable implementation ---------------------------------
106:
107: public void writeExternal(java.io.ObjectOutput out)
108: throws java.io.IOException {
109: out.writeBoolean(isAck);
110: SpyDestination.writeDest(out, destination);
111: out.writeUTF(messageID);
112: out.writeInt(subscriberId);
113: }
114:
115: // Package protected ---------------------------------------------
116:
117: // Protected -----------------------------------------------------
118:
119: // Private -------------------------------------------------------
120:
121: // Inner classes -------------------------------------------------
122: }
|