Changeset 72 for trunk/src/main/java/omq/client
- Timestamp:
- 06/29/13 20:44:27 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/main/java/omq/client/proxy/Proxymq.java
r70 r72 1 1 package omq.client.proxy; 2 2 3 import java.io.IOException;4 3 import java.lang.reflect.Array; 5 4 import java.lang.reflect.InvocationHandler; 6 5 import java.lang.reflect.Method; 7 import java.util.Collection;8 6 import java.util.HashMap; 9 7 import java.util.Map; … … 16 14 import omq.client.listener.ResponseListener; 17 15 import omq.common.broker.Broker; 18 import omq.common.event.Event;19 import omq.common.event.EventDispatcher;20 import omq.common.event.EventListener;21 16 import omq.common.message.Request; 22 17 import omq.common.message.Response; … … 25 20 import omq.exception.OmqException; 26 21 import omq.exception.RetryException; 27 import omq.exception.SerializerException;28 22 import omq.exception.TimeoutException; 29 23 … … 55 49 private transient Broker broker; 56 50 private transient ResponseListener rListener; 57 private transient EventDispatcher dispatcher;58 51 private transient Serializer serializer; 59 52 private transient Properties env; 60 53 private transient Map<String, byte[]> results; 61 private transient Map<String, EventListener<?>> listeners;62 54 63 55 private static final Map<String, Class<?>> primitiveClasses = new HashMap<String, Class<?>>(); … … 92 84 this.broker = broker; 93 85 rListener = broker.getResponseListener(); 94 dispatcher = broker.getEventDispatcher();95 86 serializer = broker.getSerializer(); 96 87 … … 105 96 serializerType = env.getProperty(ParameterQueue.SERIALIZER_NAME, Serializer.JAVA); 106 97 107 listeners = new HashMap<String, EventListener<?>>();108 109 98 // Create a new hashmap and registry it in rListener 110 99 results = new HashMap<String, byte[]>(); … … 121 110 if (methodName.equals("getRef")) { 122 111 return getRef(); 123 } else if (methodName.equals("addListener")) {124 addListener((EventListener<?>) arguments[0]);125 return null;126 } else if (methodName.equals("removeListener")) {127 removeListener((EventListener<?>) arguments[0]);128 return null;129 } else if (methodName.equals("getListeners")) {130 return getListeners();131 112 } 132 113 } … … 306 287 } 307 288 308 @Override309 public void notifyEvent(Event event) throws IOException, SerializerException {310 }311 312 @Override313 public void addListener(EventListener<?> eventListener) throws Exception {314 if (eventListener.getTopic() == null) {315 eventListener.setTopic(uid);316 }317 listeners.put(eventListener.getTopic(), eventListener);318 dispatcher.addListener(eventListener);319 }320 321 @Override322 public void removeListener(EventListener<?> eventListener) throws Exception {323 listeners.remove(eventListener.getTopic());324 dispatcher.removeListener(eventListener);325 }326 327 @Override328 public Collection<EventListener<?>> getListeners() throws Exception {329 return listeners.values();330 }331 332 289 }
Note: See TracChangeset
for help on using the changeset viewer.