1 45 package org.exolab.jms.client; 46 47 import java.io.IOException ; 48 import java.io.ObjectInput ; 49 import java.io.ObjectOutput ; 50 51 import javax.jms.JMSException ; 52 import javax.jms.Queue ; 53 import javax.jms.TemporaryQueue ; 54 import javax.naming.Reference ; 55 import javax.naming.Referenceable ; 56 57 import org.exolab.jms.common.uuid.UUID; 58 59 60 67 public class JmsTemporaryQueue 68 extends JmsQueue 69 implements TemporaryQueue , JmsTemporaryDestination { 70 71 74 static final long serialVersionUID = 2; 75 76 80 private long _connectionId; 81 82 85 private transient JmsConnection _connection = null; 86 87 88 91 public JmsTemporaryQueue() { 92 super(TEMP_QUEUE_PREFIX + UUID.next()); 93 } 94 95 public void delete() 97 throws JMSException { 98 _connection.deleteTemporaryDestination(this); 100 } 101 102 public void setOwningConnection(JmsConnection connection) { 104 _connection = connection; 105 _connectionId = connection.getConnectionId(); 106 } 107 108 public JmsConnection getOwningConnection() { 110 return _connection; 111 } 112 113 public long getConnectionId() { 115 return _connectionId; 116 } 117 118 public Reference getReference() { 120 return null; 122 } 123 124 public boolean validForConnection(JmsConnection connection) { 126 boolean result = false; 127 128 if (connection != null 129 && connection.getConnectionId() == _connectionId) { 130 result = true; 131 } 132 133 return result; 134 } 135 136 public void writeExternal(ObjectOutput stream) 138 throws IOException { 139 stream.writeLong(serialVersionUID); 140 stream.writeLong(_connectionId); 141 super.writeExternal(stream); 142 } 143 144 public void readExternal(ObjectInput stream) 146 throws IOException , ClassNotFoundException { 147 long version = stream.readLong(); 148 if (version == serialVersionUID) { 149 _connectionId = stream.readLong(); 150 super.readExternal(stream); 151 } else { 152 throw new IOException ("JmsTemporaryQueue with version " 153 + version + " is not supported."); 154 } 155 } 156 } 157 | Popular Tags |