1 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.Destination ; 57 import javax.jms.JMSException ; 58 import javax.naming.Referenceable ; 59 60 import org.exolab.jms.message.DestinationImpl; 61 62 63 69 abstract public class JmsDestination 70 extends DestinationImpl 71 implements Destination , Externalizable , Referenceable { 72 73 76 public JmsDestination() { 77 } 78 79 84 protected JmsDestination(String name) { 85 super(name); 86 } 87 88 93 public String getName() { 94 return getDestination(); 95 } 96 97 102 public void setPersistent(boolean flag) { 103 persistent_ = flag; 104 } 105 106 111 public boolean getPersistent() { 112 return persistent_; 113 } 114 115 public String toString() { 117 return getDestination() + "-" + persistent_; 118 } 119 120 public int hashCode() { 122 return getName().hashCode(); 123 } 124 125 public void writeExternal(ObjectOutput stream) 127 throws IOException { 128 stream.writeLong(serialVersionUID); 129 stream.writeBoolean(persistent_); 130 super.writeExternal(stream); 131 } 132 133 public void readExternal(ObjectInput stream) 135 throws IOException , ClassNotFoundException { 136 long version = stream.readLong(); 137 if (version == serialVersionUID) { 138 persistent_ = stream.readBoolean(); 139 super.readExternal(stream); 140 } else { 141 throw new IOException ("JmsDestination with version " + 142 version + " is not supported."); 143 } 144 } 145 146 153 public boolean isTemporaryDestination() { 154 boolean result = false; 155 156 if ((getDestination().startsWith(TEMP_QUEUE_PREFIX)) || 157 (getDestination().startsWith(TEMP_TOPIC_PREFIX))) { 158 result = true; 159 } 160 161 return result; 162 } 163 164 171 public static boolean isTemporaryDestination(DestinationImpl destination) { 172 boolean result = false; 173 174 if ((destination.getDestination().startsWith(TEMP_QUEUE_PREFIX)) || 175 (destination.getDestination().startsWith(TEMP_TOPIC_PREFIX))) { 176 result = true; 177 } 178 179 return result; 180 } 181 182 183 187 private boolean persistent_ = false; 188 189 192 final static String TEMP_QUEUE_PREFIX = "tempqueue:"; 193 194 197 final static String TEMP_TOPIC_PREFIX = "temptopic:"; 198 199 202 static final long serialVersionUID = 1; 203 } 204 205 | Popular Tags |