KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jms > serverless > QueueReceiverAddress


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.jms.serverless;
8
9 import org.jboss.logging.Logger;
10 import org.jgroups.Address;
11 import java.io.Serializable JavaDoc;
12
13 /**
14  * A wrapper around information that uniquely identifies a QueueReceiver in a group.
15  *
16  * @author Ovidiu Feodorov <ovidiu@jboss.org>
17  * @version $Revision: 1.1 $ $Date: 2004/04/15 22:54:19 $
18  *
19  **/

20 public class QueueReceiverAddress implements Serializable JavaDoc {
21
22     static final long serialVersionUID = 11480310721131223L;
23
24     private static final Logger log = Logger.getLogger(QueueReceiverAddress.class);
25
26     private Address addr;
27     private String JavaDoc sessionID;
28     private String JavaDoc queueReceiverID;
29     private boolean nextForDelivery;
30
31     public QueueReceiverAddress(Address addr, String JavaDoc sessionID, String JavaDoc queueReceiverID) {
32
33         if (addr == null) {
34             throw new NullPointerException JavaDoc("null address");
35         }
36         if (sessionID == null) {
37             throw new NullPointerException JavaDoc("null session ID");
38         }
39         if (queueReceiverID == null) {
40             throw new NullPointerException JavaDoc("null queue receiver ID");
41         }
42
43         this.addr = addr;
44         this.sessionID = sessionID;
45         this.queueReceiverID = queueReceiverID;
46     }
47
48     public Address getAddress() {
49         return addr;
50     }
51
52     public String JavaDoc getSessionID() {
53         return sessionID;
54     }
55
56     public String JavaDoc getReceiverID() {
57         return queueReceiverID;
58     }
59
60     public boolean isNextForDelivery() {
61         return nextForDelivery;
62     }
63
64     public void setNextForDelivery(boolean b) {
65         nextForDelivery = b;
66     }
67
68     public boolean equals(Object JavaDoc o) {
69
70         if (this == o) {
71             return true;
72         }
73         
74         if (!(o instanceof QueueReceiverAddress)) {
75             return false;
76         }
77
78         QueueReceiverAddress that = (QueueReceiverAddress)o;
79
80         return
81             (addr != null && addr.equals(that.addr)) &&
82             (sessionID != null && sessionID.equals(that.sessionID)) &&
83             (queueReceiverID != null && queueReceiverID.equals(that.queueReceiverID));
84         
85     }
86
87     public int hashCode() {
88
89         // TO_DO
90

91         return
92             (addr == null ? 0 : addr.hashCode()) +
93             (sessionID == null ? 0 : sessionID.hashCode()) +
94             (queueReceiverID == null ? 0 : queueReceiverID.hashCode());
95             
96     }
97
98     public String JavaDoc toString() {
99         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("QueueReceiverAddress[");
100         sb.append(addr);
101         sb.append("/sessionID=");
102         sb.append(sessionID);
103         sb.append("/receiverID=");
104         sb.append(queueReceiverID);
105         sb.append("]");
106         return sb.toString();
107     }
108
109 }
110
Popular Tags