1 /***
2 * Redistribution and use of this software and associated documentation
3 * ("Software"), with or without modification, are permitted provided
4 * that the following conditions are met:
5 *
6 * 1. Redistributions of source code must retain copyright
7 * statements and notices. Redistributions must also contain a
8 * copy of this document.
9 *
10 * 2. Redistributions in binary form must reproduce the
11 * above copyright notice, this list of conditions and the
12 * following disclaimer in the documentation and/or other
13 * materials provided with the distribution.
14 *
15 * 3. The name "Exolab" must not be used to endorse or promote
16 * products derived from this Software without prior written
17 * permission of Exoffice Technologies. For written permission,
18 * please contact info@exolab.org.
19 *
20 * 4. Products derived from this Software may not be called "Exolab"
21 * nor may "Exolab" appear in their names without prior written
22 * permission of Exoffice Technologies. Exolab is a registered
23 * trademark of Exoffice Technologies.
24 *
25 * 5. Due credit should be given to the Exolab Project
26 * (http://www.exolab.org/).
27 *
28 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39 * OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
42 *
43 * $Id: JmsQueue.java,v 1.10 2003/08/07 13:32:50 tanderson Exp $
44 *
45 * Date Author Changes
46 * 3/21/2000 jima Created
47 */
48 package org.exolab.jms.client;
49
50
51 import java.io.Externalizable;
52 import java.io.IOException;
53 import java.io.ObjectInput;
54 import java.io.ObjectOutput;
55
56 import javax.jms.JMSException;
57 import javax.jms.Queue;
58 import javax.naming.Reference;
59 import javax.naming.StringRefAddr;
60
61
62 /***
63 * This object represents a queue, which is a type of destination. A queue
64 * is identified by name and two queues with the same name refer to the
65 * same object.
66 *
67 * @version $Revision: 1.10 $ $Date: 2003/08/07 13:32:50 $
68 * @author <a href="mailto:jima@exoffice.com">Jim Alateras</a>
69 **/
70 public class JmsQueue
71 extends JmsDestination
72 implements Queue, Externalizable {
73
74 /***
75 * Used for serialization
76 */
77 static final long serialVersionUID = 1;
78
79
80 /***
81 * Need a default constructor for the serialization
82 */
83 public JmsQueue() {
84 }
85
86 /***
87 * Instantiate an instance of a queue name
88 *
89 * @param name queue name
90 */
91 public JmsQueue(String name) {
92 super(name);
93 }
94
95 /***
96 * Return the name of the queue
97 *
98 * @return name name of the queue
99 * @exception JMSException
100 */
101 public String getQueueName()
102 throws JMSException {
103 return getName();
104 }
105
106 // implementation of Object.equals(Object)
107 public boolean equals(Object object) {
108 boolean result = false;
109
110 if ((object instanceof JmsQueue) &&
111 (((JmsQueue) object).getName().equals(this.getName()))) {
112 result = true;
113 }
114
115 return result;
116 }
117
118 // implementation of Object.hashCode
119 public int hashCode() {
120 return getName().hashCode();
121 }
122
123 // implementation of Externalizable.writeExternal
124 public void writeExternal(ObjectOutput stream)
125 throws IOException {
126 stream.writeLong(serialVersionUID);
127 super.writeExternal(stream);
128 }
129
130 // implementation of Externalizable.writeExternal
131 public void readExternal(ObjectInput stream)
132 throws IOException, ClassNotFoundException {
133 long version = stream.readLong();
134 if (version == serialVersionUID) {
135 super.readExternal(stream);
136 } else {
137 throw new IOException("JmsQueue with version " +
138 version + " is not supported.");
139 }
140 }
141
142 // implementation of Referenceable.getReference
143 public Reference getReference() {
144 Reference reference = null;
145
146 // create the reference
147 reference = new Reference(JmsQueue.class.getName(),
148 new StringRefAddr("name", getName()),
149 JmsDestinationFactory.class.getName(), null);
150
151 // add the persistence attribute
152 reference.add(new StringRefAddr("persistent",
153 (getPersistent() ? "true" : "false")));
154
155 return reference;
156 }
157 }
This page was automatically generated by Maven