@Override
public Object call() {
final ClientEndpoint endpoint = getEndpoint();
final ClientEngine clientEngine = getClientEngine();
final MapService mapService = getService();
EntryListener<Object, Object> listener = new EntryListener<Object, Object>() {
private void handleEvent(EntryEvent<Object, Object> event) {
if (endpoint.live()) {
Data key = clientEngine.toData(event.getKey());
Data value = clientEngine.toData(event.getValue());
Data oldValue = clientEngine.toData(event.getOldValue());
PortableEntryEvent portableEntryEvent = new PortableEntryEvent(key, value, oldValue, event.getEventType(), event.getMember().getUuid());
endpoint.sendEvent(portableEntryEvent, getCallId());
}
}
public void entryAdded(EntryEvent<Object, Object> event) {
handleEvent(event);
}
public void entryRemoved(EntryEvent<Object, Object> event) {
handleEvent(event);
}
public void entryUpdated(EntryEvent<Object, Object> event) {
handleEvent(event);
}
public void entryEvicted(EntryEvent<Object, Object> event) {
handleEvent(event);
}
};
EventFilter eventFilter;
if (getPredicate() == null) {
eventFilter = new EntryEventFilter(includeValue, key);
} else {
eventFilter = new QueryEventFilter(includeValue, key, getPredicate());
}
String registrationId = mapService.addEventListener(listener, eventFilter, name);
endpoint.setListenerRegistration(MapService.SERVICE_NAME, name, registrationId);
return registrationId;
}