KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > transport > jms > Subscription


1 /*
2  * Copyright 2001, 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.transport.jms;
18
19 import javax.jms.MessageListener JavaDoc;
20 import java.util.HashMap JavaDoc;
21
22 /*
23  * Subscription class holds information about a subscription
24  *
25  * @author Jaime Meritt (jmeritt@sonicsoftware.com)
26  * @author Richard Chung (rchung@sonicsoftware.com)
27  * @author Dave Chappell (chappell@sonicsoftware.com)
28  */

29 public class Subscription
30 {
31     MessageListener JavaDoc m_listener;
32     JMSEndpoint m_endpoint;
33     String JavaDoc m_messageSelector;
34     int m_ackMode;
35
36     Subscription(MessageListener JavaDoc listener,
37                  JMSEndpoint endpoint,
38                  HashMap JavaDoc properties)
39     {
40         m_listener = listener;
41         m_endpoint = endpoint;
42         m_messageSelector = MapUtils.removeStringProperty(
43                                             properties,
44                                             JMSConstants.MESSAGE_SELECTOR,
45                                             null);
46         m_ackMode = MapUtils.removeIntProperty(properties,
47                                                JMSConstants.ACKNOWLEDGE_MODE,
48                                                JMSConstants.DEFAULT_ACKNOWLEDGE_MODE);
49     }
50
51     public int hashCode()
52     {
53         return toString().hashCode();
54     }
55
56     public boolean equals(Object JavaDoc obj)
57     {
58         if(obj == null || !(obj instanceof Subscription))
59             return false;
60         Subscription other = (Subscription)obj;
61         if(m_messageSelector == null)
62         {
63             if(other.m_messageSelector != null)
64                 return false;
65         }
66         else
67         {
68             if(other.m_messageSelector == null ||
69                !other.m_messageSelector.equals(m_messageSelector))
70                 return false;
71         }
72         return m_ackMode == other.m_ackMode &&
73                m_endpoint.equals(other.m_endpoint) &&
74                other.m_listener.equals(m_listener);
75     }
76
77     public String JavaDoc toString()
78     {
79         return m_listener.toString();
80     }
81
82 }
Popular Tags