Search in sources :

Example 6 with MapInterceptor

use of com.hazelcast.map.MapInterceptor in project hazelcast by hazelcast.

the class MapAddInterceptorMessageTask method createOperationSupplier.

@Override
protected Supplier<Operation> createOperationSupplier() {
    final MapService mapService = getService(MapService.SERVICE_NAME);
    final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    final MapInterceptor mapInterceptor = serializationService.toObject(parameters.interceptor);
    id = mapServiceContext.generateInterceptorId(parameters.name, mapInterceptor);
    return new AddInterceptorOperationSupplier(id, parameters.name, mapInterceptor);
}
Also used : AddInterceptorOperationSupplier(com.hazelcast.client.impl.AddInterceptorOperationSupplier) MapInterceptor(com.hazelcast.map.MapInterceptor) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 7 with MapInterceptor

use of com.hazelcast.map.MapInterceptor in project hazelcast by hazelcast.

the class PostJoinMapOperation method addMapInterceptors.

public void addMapInterceptors(MapContainer mapContainer) {
    InterceptorRegistry interceptorRegistry = mapContainer.getInterceptorRegistry();
    List<MapInterceptor> interceptorList = interceptorRegistry.getInterceptors();
    Map<String, MapInterceptor> interceptorMap = interceptorRegistry.getId2InterceptorMap();
    Map<MapInterceptor, String> revMap = new HashMap<MapInterceptor, String>();
    for (Map.Entry<String, MapInterceptor> entry : interceptorMap.entrySet()) {
        revMap.put(entry.getValue(), entry.getKey());
    }
    InterceptorInfo interceptorInfo = new InterceptorInfo(mapContainer.getName());
    for (MapInterceptor interceptor : interceptorList) {
        interceptorInfo.addInterceptor(revMap.get(interceptor), interceptor);
    }
    interceptorInfoList.add(interceptorInfo);
}
Also used : InterceptorRegistry(com.hazelcast.map.impl.InterceptorRegistry) MapInterceptor(com.hazelcast.map.MapInterceptor) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap)

Example 8 with MapInterceptor

use of com.hazelcast.map.MapInterceptor in project hazelcast by hazelcast.

the class MapServiceContextImpl method interceptAfterPut.

@Override
public void interceptAfterPut(String mapName, Object newValue) {
    MapContainer mapContainer = getMapContainer(mapName);
    List<MapInterceptor> interceptors = mapContainer.getInterceptorRegistry().getInterceptors();
    if (!interceptors.isEmpty()) {
        newValue = toObject(newValue);
        for (MapInterceptor interceptor : interceptors) {
            interceptor.afterPut(newValue);
        }
    }
}
Also used : MapInterceptor(com.hazelcast.map.MapInterceptor)

Example 9 with MapInterceptor

use of com.hazelcast.map.MapInterceptor in project hazelcast by hazelcast.

the class MapServiceContextImpl method interceptRemove.

@Override
public Object interceptRemove(String mapName, Object value) {
    MapContainer mapContainer = getMapContainer(mapName);
    List<MapInterceptor> interceptors = mapContainer.getInterceptorRegistry().getInterceptors();
    Object result = null;
    if (!interceptors.isEmpty()) {
        result = toObject(value);
        for (MapInterceptor interceptor : interceptors) {
            Object temp = interceptor.interceptRemove(result);
            if (temp != null) {
                result = temp;
            }
        }
    }
    return result == null ? value : result;
}
Also used : MapInterceptor(com.hazelcast.map.MapInterceptor)

Example 10 with MapInterceptor

use of com.hazelcast.map.MapInterceptor in project hazelcast by hazelcast.

the class InterceptorRegistry method deregister.

/**
     * De-registers {@link MapInterceptor} for the supplied `id`, if there is any.
     *
     * This method is called by {@link com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread}
     * when de-registering via {@link com.hazelcast.map.impl.operation.RemoveInterceptorOperation}
     *
     * @param id id of the interceptor
     */
public synchronized void deregister(String id) {
    assert !(Thread.currentThread() instanceof PartitionOperationThread);
    if (!id2InterceptorMap.containsKey(id)) {
        return;
    }
    Map<String, MapInterceptor> tmpMap = new HashMap<String, MapInterceptor>(id2InterceptorMap);
    MapInterceptor removedInterceptor = tmpMap.remove(id);
    id2InterceptorMap = unmodifiableMap(tmpMap);
    List<MapInterceptor> tmpInterceptors = new ArrayList<MapInterceptor>(interceptors);
    tmpInterceptors.remove(removedInterceptor);
    interceptors = unmodifiableList(tmpInterceptors);
}
Also used : PartitionOperationThread(com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread) HashMap(java.util.HashMap) MapInterceptor(com.hazelcast.map.MapInterceptor) ArrayList(java.util.ArrayList)

Aggregations

MapInterceptor (com.hazelcast.map.MapInterceptor)10 HashMap (java.util.HashMap)3 InterceptorRegistry (com.hazelcast.map.impl.InterceptorRegistry)2 MapService (com.hazelcast.map.impl.MapService)2 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)2 AbstractMap (java.util.AbstractMap)2 Map (java.util.Map)2 AddInterceptorOperationSupplier (com.hazelcast.client.impl.AddInterceptorOperationSupplier)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 Indexes (com.hazelcast.query.impl.Indexes)1 PartitionOperationThread (com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread)1 ArrayList (java.util.ArrayList)1