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.jms.serverless;
023:
024: import org.jboss.logging.Logger;
025: import org.jgroups.Address;
026: import java.io.Serializable;
027:
028: /**
029: * A wrapper around information that uniquely identifies a QueueReceiver in a group.
030: *
031: * @author Ovidiu Feodorov <ovidiu@jboss.org>
032: * @version $Revision: 57195 $ $Date: 2006-09-26 08:08:17 -0400 (Tue, 26 Sep 2006) $
033: *
034: **/
035: public class QueueReceiverAddress implements Serializable {
036:
037: static final long serialVersionUID = 11480310721131223L;
038:
039: private static final Logger log = Logger
040: .getLogger(QueueReceiverAddress.class);
041:
042: private Address addr;
043: private String sessionID;
044: private String queueReceiverID;
045: private boolean nextForDelivery;
046:
047: public QueueReceiverAddress(Address addr, String sessionID,
048: String queueReceiverID) {
049:
050: if (addr == null) {
051: throw new NullPointerException("null address");
052: }
053: if (sessionID == null) {
054: throw new NullPointerException("null session ID");
055: }
056: if (queueReceiverID == null) {
057: throw new NullPointerException("null queue receiver ID");
058: }
059:
060: this .addr = addr;
061: this .sessionID = sessionID;
062: this .queueReceiverID = queueReceiverID;
063: }
064:
065: public Address getAddress() {
066: return addr;
067: }
068:
069: public String getSessionID() {
070: return sessionID;
071: }
072:
073: public String getReceiverID() {
074: return queueReceiverID;
075: }
076:
077: public boolean isNextForDelivery() {
078: return nextForDelivery;
079: }
080:
081: public void setNextForDelivery(boolean b) {
082: nextForDelivery = b;
083: }
084:
085: public boolean equals(Object o) {
086:
087: if (this == o) {
088: return true;
089: }
090:
091: if (!(o instanceof QueueReceiverAddress)) {
092: return false;
093: }
094:
095: QueueReceiverAddress that = (QueueReceiverAddress) o;
096:
097: return (addr != null && addr.equals(that.addr))
098: && (sessionID != null && sessionID
099: .equals(that.sessionID))
100: && (queueReceiverID != null && queueReceiverID
101: .equals(that.queueReceiverID));
102:
103: }
104:
105: public int hashCode() {
106:
107: // TO_DO
108:
109: return (addr == null ? 0 : addr.hashCode())
110: + (sessionID == null ? 0 : sessionID.hashCode())
111: + (queueReceiverID == null ? 0 : queueReceiverID
112: .hashCode());
113:
114: }
115:
116: public String toString() {
117: StringBuffer sb = new StringBuffer("QueueReceiverAddress[");
118: sb.append(addr);
119: sb.append("/sessionID=");
120: sb.append(sessionID);
121: sb.append("/receiverID=");
122: sb.append(queueReceiverID);
123: sb.append("]");
124: return sb.toString();
125: }
126:
127: }
|