1 45 package org.exolab.jms.client; 46 47 import java.io.Externalizable ; 48 import java.io.IOException ; 49 import java.io.ObjectInput ; 50 import java.io.ObjectOutput ; 51 52 import javax.jms.JMSException ; 53 import javax.jms.Queue ; 54 import javax.naming.Reference ; 55 import javax.naming.StringRefAddr ; 56 57 58 66 public class JmsQueue 67 extends JmsDestination 68 implements Queue , Externalizable { 69 70 73 static final long serialVersionUID = 1; 74 75 76 79 public JmsQueue() { 80 } 81 82 87 public JmsQueue(String name) { 88 super(name); 89 } 90 91 97 public String getQueueName() 98 throws JMSException { 99 return getName(); 100 } 101 102 103 public boolean equals(Object object) { 105 boolean result = false; 106 107 if ((object instanceof JmsQueue) 108 && (((JmsQueue) object).getName().equals(this.getName()))) { 109 result = true; 110 } 111 112 return result; 113 } 114 115 public int hashCode() { 117 return getName().hashCode(); 118 } 119 120 public void writeExternal(ObjectOutput stream) 122 throws IOException { 123 stream.writeLong(serialVersionUID); 124 super.writeExternal(stream); 125 } 126 127 public void readExternal(ObjectInput stream) 129 throws IOException , ClassNotFoundException { 130 long version = stream.readLong(); 131 if (version == serialVersionUID) { 132 super.readExternal(stream); 133 } else { 134 throw new IOException ("JmsQueue with version " 135 + version + " is not supported."); 136 } 137 } 138 139 144 public Reference getReference() { 145 Reference reference = new Reference ( 146 JmsQueue.class.getName(), new StringRefAddr ("name", getName()), 147 JmsDestinationFactory.class.getName(), null); 148 149 reference.add(new StringRefAddr ("persistent", 151 (getPersistent() ? "true" : "false"))); 152 153 return reference; 154 } 155 } 156 | Popular Tags |