1 55 56 package org.jboss.axis.transport.jms; 57 58 import javax.jms.Destination ; 59 import javax.jms.JMSException ; 60 import javax.jms.MessageListener ; 61 import javax.jms.Session ; 62 import java.util.HashMap ; 63 64 71 public abstract class JMSEndpoint 72 { 73 private JMSConnector m_connector; 74 75 protected JMSEndpoint(JMSConnector connector) 76 { 77 m_connector = connector; 78 } 79 80 abstract Destination getDestination(Session session) 81 throws Exception ; 82 83 91 public byte[] call(byte[] message, long timeout) throws Exception 92 { 93 return m_connector.getSendConnection().call(this, message, timeout, null); 94 } 95 96 105 public byte[] call(byte[] message, long timeout, HashMap properties) 106 throws Exception 107 { 108 if (properties != null) 109 properties = (HashMap )properties.clone(); 110 return m_connector.getSendConnection().call(this, message, timeout, properties); 111 } 112 113 119 public void send(byte[] message) throws Exception 120 { 121 m_connector.getSendConnection().send(this, message, null); 122 } 123 124 131 public void send(byte[] message, HashMap properties) 132 throws Exception 133 { 134 if (properties != null) 135 properties = (HashMap )properties.clone(); 136 m_connector.getSendConnection().send(this, message, properties); 137 } 138 139 145 public void registerListener(MessageListener listener) 146 throws Exception 147 { 148 m_connector.getReceiveConnection().subscribe(createSubscription(listener, null)); 149 } 150 151 158 public void registerListener(MessageListener listener, HashMap properties) 159 throws Exception 160 { 161 if (properties != null) 162 properties = (HashMap )properties.clone(); 163 m_connector.getReceiveConnection().subscribe(createSubscription(listener, properties)); 164 } 165 166 171 public void unregisterListener(MessageListener listener) 172 { 173 m_connector.getReceiveConnection().unsubscribe(createSubscription(listener, null)); 174 } 175 176 182 public void unregisterListener(MessageListener listener, HashMap properties) 183 { 184 if (properties != null) 185 properties = (HashMap )properties.clone(); 186 m_connector.getReceiveConnection().unsubscribe(createSubscription(listener, properties)); 187 } 188 189 protected Subscription createSubscription(MessageListener listener, 190 HashMap properties) 191 { 192 return new Subscription(listener, this, properties); 193 } 194 195 public int hashCode() 196 { 197 return toString().hashCode(); 198 } 199 200 public boolean equals(Object object) 201 { 202 if (object == null || !(object instanceof JMSEndpoint)) 203 return false; 204 return true; 205 } 206 } 207 | Popular Tags |