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.TemporaryTopic ; 54 import javax.jms.Topic ; 55 import javax.naming.Reference ; 56 import javax.naming.Referenceable ; 57 58 import org.exolab.jms.common.uuid.UUID; 59 60 61 68 public class JmsTemporaryTopic 69 extends JmsTopic 70 implements TemporaryTopic , JmsTemporaryDestination, Externalizable , Referenceable { 71 72 75 static final long serialVersionUID = 2; 76 77 82 private long _connectionId; 83 84 87 transient private JmsConnection _connection = null; 88 89 90 93 public JmsTemporaryTopic() { 94 super(TEMP_TOPIC_PREFIX + UUID.next()); 95 } 96 97 public void delete() 99 throws JMSException { 100 _connection.deleteTemporaryDestination(this); 102 } 103 104 public void setOwningConnection(JmsConnection connection) { 106 _connection = connection; 107 _connectionId = _connection.getConnectionId(); 108 } 109 110 public JmsConnection getOwningConnection() { 112 return _connection; 113 } 114 115 public long getConnectionId() { 117 return _connectionId; 118 } 119 120 public boolean validForConnection(JmsConnection connection) { 122 boolean result = false; 123 124 if (connection != null 125 && connection.getConnectionId() == _connectionId) { 126 result = true; 127 } 128 129 return result; 130 } 131 132 public Reference getReference() { 134 return null; 136 } 137 138 public void writeExternal(ObjectOutput stream) 140 throws IOException { 141 stream.writeLong(serialVersionUID); 142 stream.writeLong(_connectionId); 143 super.writeExternal(stream); 144 } 145 146 public void readExternal(ObjectInput stream) 148 throws IOException , ClassNotFoundException { 149 long version = stream.readLong(); 150 if (version == serialVersionUID) { 151 _connectionId = stream.readLong(); 152 super.readExternal(stream); 153 } else { 154 throw new IOException ("JmsTemporaryTopic with version " + 155 version + " is not supported."); 156 } 157 } 158 } 159 | Popular Tags |