use of com.hazelcast.collection.impl.collection.CollectionEventFilter in project hazelcast by hazelcast.
the class ListAddListenerMessageTask method call.
@Override
protected Object call() {
ClientEndpoint endpoint = getEndpoint();
Data partitionKey = serializationService.toData(parameters.name);
ItemListener listener = createItemListener(endpoint, partitionKey);
EventService eventService = clientEngine.getEventService();
CollectionEventFilter filter = new CollectionEventFilter(parameters.includeValue);
EventRegistration registration;
if (parameters.localOnly) {
registration = eventService.registerLocalListener(getServiceName(), parameters.name, filter, listener);
} else {
registration = eventService.registerListener(getServiceName(), parameters.name, filter, listener);
}
String registrationId = registration.getId();
endpoint.addListenerDestroyAction(getServiceName(), parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.collection.impl.collection.CollectionEventFilter in project hazelcast by hazelcast.
the class SetAddListenerMessageTask method call.
@Override
protected Object call() {
ClientEndpoint endpoint = getEndpoint();
Data partitionKey = serializationService.toData(parameters.name);
ItemListener listener = createItemListener(endpoint, partitionKey);
EventService eventService = clientEngine.getEventService();
CollectionEventFilter filter = new CollectionEventFilter(parameters.includeValue);
EventRegistration registration;
if (parameters.localOnly) {
registration = eventService.registerLocalListener(getServiceName(), parameters.name, filter, listener);
} else {
registration = eventService.registerListener(getServiceName(), parameters.name, filter, listener);
}
String registrationId = registration.getId();
endpoint.addListenerDestroyAction(getServiceName(), parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.collection.impl.collection.CollectionEventFilter in project hazelcast by hazelcast.
the class CollectionOperation method publishEvent.
protected void publishEvent(ItemEventType eventType, Data data) {
EventService eventService = getNodeEngine().getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name);
final Address address = getNodeEngine().getThisAddress();
for (EventRegistration registration : registrations) {
CollectionEventFilter filter = (CollectionEventFilter) registration.getFilter();
final boolean includeValue = filter.isIncludeValue();
CollectionEvent event = new CollectionEvent(name, includeValue ? data : null, eventType, address);
eventService.publishEvent(getServiceName(), registration, event, name.hashCode());
}
}
Aggregations