1 16 17 package org.apache.axis.transport.jms; 18 19 import java.util.HashMap ; 20 21 import javax.jms.Destination ; 22 import javax.jms.MessageListener ; 23 import javax.jms.Session ; 24 25 32 public abstract class JMSEndpoint 33 { 34 private JMSConnector m_connector; 35 36 protected JMSEndpoint(JMSConnector connector) 37 { 38 m_connector = connector; 39 } 40 41 abstract Destination getDestination(Session session) 42 throws Exception ; 43 44 52 public byte[] call(byte[] message, long timeout)throws Exception 53 { 54 return m_connector.getSendConnection().call(this, message, timeout, null); 55 } 56 57 66 public byte[] call(byte[] message, long timeout, HashMap properties) 67 throws Exception 68 { 69 if(properties != null) 70 properties = (HashMap )properties.clone(); 71 return m_connector.getSendConnection().call(this, message, timeout, properties); 72 } 73 74 80 public void send(byte[] message)throws Exception 81 { 82 m_connector.getSendConnection().send(this, message, null); 83 } 84 85 92 public void send(byte[] message, HashMap properties) 93 throws Exception 94 { 95 if(properties != null) 96 properties = (HashMap )properties.clone(); 97 m_connector.getSendConnection().send(this, message, properties); 98 } 99 100 106 public void registerListener(MessageListener listener) 107 throws Exception 108 { 109 m_connector.getReceiveConnection().subscribe(createSubscription(listener, null)); 110 } 111 112 119 public void registerListener(MessageListener listener, HashMap properties) 120 throws Exception 121 { 122 if(properties != null) 123 properties = (HashMap )properties.clone(); 124 m_connector.getReceiveConnection().subscribe(createSubscription(listener, properties)); 125 } 126 127 132 public void unregisterListener(MessageListener listener) 133 { 134 m_connector.getReceiveConnection().unsubscribe(createSubscription(listener, null)); 135 } 136 137 143 public void unregisterListener(MessageListener listener, HashMap properties) 144 { 145 if(properties != null) 146 properties = (HashMap )properties.clone(); 147 m_connector.getReceiveConnection().unsubscribe(createSubscription(listener, properties)); 148 } 149 150 protected Subscription createSubscription(MessageListener listener, 151 HashMap properties) 152 { 153 return new Subscription(listener, this, properties); 154 } 155 156 public int hashCode() 157 { 158 return toString().hashCode(); 159 } 160 161 public boolean equals(Object object) 162 { 163 if(object == null || !(object instanceof JMSEndpoint)) 164 return false; 165 return true; 166 } 167 } 168 | Popular Tags |