Search in sources :

Example 6 with ListenerAdapter

use of com.hazelcast.map.impl.ListenerAdapter in project hazelcast by hazelcast.

the class AbstractQueryCacheEndToEndConstructor method createSubscriberAccumulator.

@Override
public final void createSubscriberAccumulator(AccumulatorInfo info) {
    QueryCacheEventService eventService = context.getQueryCacheEventService();
    ListenerAdapter listener = new SubscriberListener(context, info);
    publisherListenerId = eventService.addPublisherListener(info.getMapName(), info.getCacheId(), listener);
    queryCache.setPublisherListenerId(publisherListenerId);
}
Also used : ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService)

Example 7 with ListenerAdapter

use of com.hazelcast.map.impl.ListenerAdapter in project hazelcast by hazelcast.

the class InternalQueryCacheListenerAdapter method callListener.

private void callListener(IMapEvent event, int eventType) {
    int adapterIndex = Integer.numberOfTrailingZeros(eventType);
    ListenerAdapter listenerAdapter = listenerAdapters[adapterIndex];
    if (listenerAdapter == null) {
        return;
    }
    listenerAdapter.onEvent(event);
}
Also used : ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter)

Example 8 with ListenerAdapter

use of com.hazelcast.map.impl.ListenerAdapter in project hazelcast by hazelcast.

the class NodeQueryCacheEventService method addListener.

@Override
public UUID addListener(String mapName, String cacheId, MapListener listener, EventFilter filter) {
    checkHasText(mapName, "mapName");
    checkHasText(cacheId, "cacheId");
    checkNotNull(listener, "listener cannot be null");
    ListenerAdapter queryCacheListenerAdaptor = createQueryCacheListenerAdaptor(listener);
    ListenerAdapter listenerAdaptor = new SimpleQueryCacheListenerAdapter(queryCacheListenerAdaptor);
    ContextMutexFactory.Mutex mutex = lifecycleMutexFactory.mutexFor(mapName);
    try {
        synchronized (mutex) {
            EventRegistration registration = eventService.registerLocalListener(SERVICE_NAME, cacheId, filter == null ? TrueEventFilter.INSTANCE : filter, listenerAdaptor);
            return registration.getId();
        }
    } finally {
        closeResource(mutex);
    }
}
Also used : QueryCacheListenerAdapter(com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) ContextMutexFactory(com.hazelcast.internal.util.ContextMutexFactory)

Example 9 with ListenerAdapter

use of com.hazelcast.map.impl.ListenerAdapter in project hazelcast by hazelcast.

the class QueryCacheEventListenerAdapters method createQueryCacheListenerAdapters.

static ListenerAdapter[] createQueryCacheListenerAdapters(MapListener mapListener) {
    ListenerAdapter[] mapListenerAdapters = MapListenerAdaptors.createListenerAdapters(mapListener);
    ListenerAdapter eventLostAdapter = EVENT_LOST_LISTENER_ADAPTER.createNew(mapListener);
    ListenerAdapter[] adapters = new ListenerAdapter[mapListenerAdapters.length + 1];
    System.arraycopy(mapListenerAdapters, 0, adapters, 0, mapListenerAdapters.length);
    adapters[mapListenerAdapters.length] = eventLostAdapter;
    return adapters;
}
Also used : ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter)

Example 10 with ListenerAdapter

use of com.hazelcast.map.impl.ListenerAdapter in project hazelcast by hazelcast.

the class EntryEventDataCacheTest method createInvalidationEventRejectingFilter.

private static EventListenerFilter createInvalidationEventRejectingFilter() {
    ListenerAdapter listenerAdapter = createListenerAdapter(new EntryAddedListener() {

        @Override
        public void entryAdded(EntryEvent event) {
        }
    });
    int flags = setAndGetListenerFlags(listenerAdapter);
    return new EventListenerFilter(flags, TrueEventFilter.INSTANCE);
}
Also used : ListenerAdapters.createListenerAdapter(com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) EntryAddedListener(com.hazelcast.map.listener.EntryAddedListener) EventListenerFilter(com.hazelcast.map.impl.EventListenerFilter)

Aggregations

ListenerAdapter (com.hazelcast.map.impl.ListenerAdapter)18 ListenerAdapters.createListenerAdapter (com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter)11 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)2 Nonnull (javax.annotation.Nonnull)2 Address (com.hazelcast.cluster.Address)1 EntryEvent (com.hazelcast.core.EntryEvent)1 Data (com.hazelcast.internal.serialization.Data)1 ContextMutexFactory (com.hazelcast.internal.util.ContextMutexFactory)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 IMapEvent (com.hazelcast.map.IMapEvent)1 MapInterceptor (com.hazelcast.map.MapInterceptor)1 EventListenerFilter (com.hazelcast.map.impl.EventListenerFilter)1 InterceptorRegistry (com.hazelcast.map.impl.InterceptorRegistry)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapDataSerializerHook (com.hazelcast.map.impl.MapDataSerializerHook)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)1 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)1 QueryCacheListenerAdapter (com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter)1