Search in sources :

Example 16 with ListenerAdapter

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

the class ClientMultiMapProxy method addEntryListener.

@Nonnull
@Override
public UUID addEntryListener(@Nonnull EntryListener<K, V> listener, @Nonnull K key, final boolean includeValue) {
    checkNotNull(listener, NULL_LISTENER_IS_NOT_ALLOWED);
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    final Data keyData = toData(key);
    ListenerAdapter listenerAdapter = createListenerAdapter(listener);
    EventHandler<ClientMessage> handler = new ClientMultiMapToKeyEventHandler(listenerAdapter);
    return registerListener(createEntryListenerToKeyCodec(includeValue, keyData), handler);
}
Also used : ListenerAdapters.createListenerAdapter(com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) Data(com.hazelcast.internal.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) Nonnull(javax.annotation.Nonnull)

Example 17 with ListenerAdapter

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

the class ClientQueryCacheEventService 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");
    QueryCacheToListenerMapper queryCacheToListenerMapper = getOrPutIfAbsent(registrations, mapName, REGISTRY_CONSTRUCTOR);
    ListenerAdapter listenerAdaptor = createQueryCacheListenerAdaptor(listener);
    return queryCacheToListenerMapper.addListener(cacheId, listenerAdaptor, filter);
}
Also used : ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter)

Example 18 with ListenerAdapter

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

the class PostJoinMapOperation method createQueryCaches.

private void createQueryCaches() {
    MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    PublisherContext publisherContext = queryCacheContext.getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    for (AccumulatorInfo info : infoList) {
        addAccumulatorInfo(queryCacheContext, info);
        PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrCreate(info.getMapName());
        publisherRegistry.getOrCreate(info.getCacheId());
        // marker listener.
        mapServiceContext.addLocalListenerAdapter((ListenerAdapter<IMapEvent>) event -> {
        }, info.getMapName());
    }
}
Also used : MapDataSerializerHook(com.hazelcast.map.impl.MapDataSerializerHook) Address(com.hazelcast.cluster.Address) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) IMapEvent(com.hazelcast.map.IMapEvent) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) ArrayList(java.util.ArrayList) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) Operation(com.hazelcast.spi.impl.operationservice.Operation) Map(java.util.Map) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) LinkedList(java.util.LinkedList) MapContainer(com.hazelcast.map.impl.MapContainer) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MapInterceptor(com.hazelcast.map.MapInterceptor) TargetAware(com.hazelcast.spi.impl.operationservice.TargetAware) IOException(java.io.IOException) MapService(com.hazelcast.map.impl.MapService) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) AbstractMap(java.util.AbstractMap) List(java.util.List) AccumulatorInfoSupplier(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfoSupplier) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) Collections(java.util.Collections) InterceptorRegistry(com.hazelcast.map.impl.InterceptorRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) IMapEvent(com.hazelcast.map.IMapEvent) MapService(com.hazelcast.map.impl.MapService) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

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