@Override public Object call() throws Exception { final ClientEndpoint endpoint = getEndpoint(); final ClientEngine clientEngine = getClientEngine(); ItemListener listener = new ItemListener() { @Override public void itemAdded(ItemEvent item) { send(item); } @Override public void itemRemoved(ItemEvent item) { send(item); } private void send(ItemEvent event) { if (endpoint.live()) { Data item = serializationService.toData(event.getItem()); final ItemEventType eventType = event.getEventType(); final String uuid = event.getMember().getUuid(); PortableItemEvent portableItemEvent = new PortableItemEvent(item, eventType, uuid); endpoint.sendEvent(portableItemEvent, getCallId()); } } }; final EventService eventService = clientEngine.getEventService(); final CollectionEventFilter filter = new CollectionEventFilter(includeValue); final EventRegistration registration = eventService.registerListener(getServiceName(), name, filter, listener); final String registrationId = registration.getId(); endpoint.setListenerRegistration(getServiceName(), name, registrationId); return registrationId; }
@Override protected int getPartition() { ClientEngine clientEngine = getClientEngine(); Data key = serializationService.toData(name); return clientEngine.getPartitionService().getPartitionId(key); }