@Test public void testNotifyMessageListeners() throws Exception { final MessageListenerManager manager = new MessageListenerManager(); final String name = "default"; assertTrue(manager.noListenerRegistered(name)); final String myMessage = "my myMessage"; final CountDownLatch latch = new CountDownLatch(1); MessageListener listener = new MessageListener<Object>() { public void onMessage(Message<Object> message) { if (message.getMessageObject().equals(myMessage)) { latch.countDown(); } } }; manager.registerListener(name, listener); assertFalse(manager.noListenerRegistered(name)); new Thread(new Runnable() { public void run() { Packet packet = new Packet(); packet.setName(name); packet.setKey(toByte(myMessage)); manager.notifyMessageListeners(packet); } }).start(); assertTrue(latch.await(10, TimeUnit.SECONDS)); }
public void notifyMessageListeners(Packet packet) { List<MessageListener> list = messageListeners.get(packet.getName()); if (list != null) { for (MessageListener<Object> messageListener : list) { messageListener.onMessage(new DataMessage(packet.getName(), new Data(packet.getKey()))); } } }
MessageListenerManager { public void notifyMessageListeners(Packet packet) { List<MessageListener> list = messageListeners.get(packet.getName()); if (list != null) { for (MessageListener<Object> messageListener : list) { messageListener.onMessage(new DataMessage(packet.getName(), new Data(packet.getKey()))); } } } }
MessageListenerManager { public void notifyMessageListeners(Packet packet) { List<MessageListener> list = messageListeners.get(packet.getName()); if (list != null) { for (MessageListener<Object> messageListener : list) { messageListener.onMessage(new DataMessage(packet.getName(), new Data(packet.getKey()))); } } }  }
MessageListenerManager { public void notifyMessageListeners(Packet packet) { List<MessageListener> list = messageListeners.get(packet.getName()); if (list != null) { for (MessageListener<Object> messageListener : list) { messageListener.onMessage(new DataMessage(packet.getName(), new Data(packet.getKey()))); } } }  void registerListener(String name, MessageListener messageListener); void removeListener(String name, MessageListener messageListener); boolean noListenerRegistered(String name); void notifyMessageListeners(Packet packet); Call createNewAddListenerCall(final ProxyHelper proxyHelper); Collection<Call> calls(final HazelcastClient client); }
MessageListenerManager { public void notifyMessageListeners(Packet packet) { List<MessageListener> list = messageListeners.get(packet.getName()); if (list != null) { for (MessageListener<Object> messageListener : list) { messageListener.onMessage(new DataMessage(packet.getName(), new Data(packet.getKey()))); } } }  void registerListener(String name, MessageListener messageListener); void removeListener(String name, MessageListener messageListener); boolean noListenerRegistered(String name); void notifyMessageListeners(Packet packet); Call createNewAddListenerCall(final ProxyHelper proxyHelper); Collection<Call> calls(final HazelcastClient client);  }