public void notifyListeners(Packet packet) { List<ItemListenerHolder> list = queueItemListeners.get(packet.getName()); if (list != null) { for (ItemListenerHolder listenerHolder : list) { ItemListener<Object> listener = listenerHolder.listener; Boolean added = (Boolean) toObject(packet.getValue()); if (added) { listener.itemAdded(new DataAwareItemEvent(packet.getName(), ItemEventType.ADDED, listenerHolder.includeValue ? new Data(packet.getKey()) : null, null)); } else { listener.itemRemoved(new DataAwareItemEvent(packet.getName(), ItemEventType.REMOVED, listenerHolder.includeValue ? new Data(packet.getKey()) : null, null)); } } } }
@Test @SuppressWarnings("unchecked") public void add() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:added"); out.expectedMessageCount(1); final ItemEvent<String> event = new ItemEvent<String>("mm", ItemEventType.ADDED, "foo", null); argument.getValue().itemAdded(event); assertMockEndpointsSatisfied(2000, TimeUnit.MILLISECONDS); this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.ADDED); }
@Test @SuppressWarnings("unchecked") public void remove() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:removed"); out.expectedMessageCount(1); final ItemEvent<String> event = new ItemEvent<String>("mm", ItemEventType.REMOVED, "foo", null); argument.getValue().itemRemoved(event); assertMockEndpointsSatisfied(2000, TimeUnit.MILLISECONDS); this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.REMOVED); }
@Test @SuppressWarnings("unchecked") public void add() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:added"); out.expectedMessageCount(1); final ItemEvent<String> event = new ItemEvent<String>("foo", ItemEventType.ADDED, "foo", null); argument.getValue().itemAdded(event); assertMockEndpointsSatisfied(2000, TimeUnit.MILLISECONDS); this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.ADDED); }
@Test @SuppressWarnings("unchecked") public void remove() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:removed"); out.expectedMessageCount(1); final ItemEvent<String> event = new ItemEvent<String>("foo", ItemEventType.REMOVED, "foo", null); argument.getValue().itemRemoved(event); assertMockEndpointsSatisfied(2000, TimeUnit.MILLISECONDS); this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.REMOVED); }
public void notifyListeners(Packet packet) { List<ItemListener> list = queueItemListeners.get(packet.getName()); if (list != null) { for (ItemListener<Object> listener : list) { Boolean added = (Boolean) toObject(packet.getValue()); if (added) { listener.itemAdded(new DataAwareItemEvent(packet.getName(), ItemEventType.ADDED, new Data(packet.getKey()))); } else { listener.itemRemoved(new DataAwareItemEvent(packet.getName(), ItemEventType.ADDED, new Data(packet.getKey()))); } } } }
public DataAwareItemEvent(String name, ItemEventType itemEventType, Data itemData) { super(name, itemEventType, null); this.itemData = itemData; }
public DataAwareItemEvent(String name, ItemEventType itemEventType, Data itemData, Member member) { super(name, itemEventType, null, member); this.itemData = itemData; }