Search in sources :

Example 1 with MapInterceptor

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

the class MapServiceContextImpl method interceptAfterRemove.

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

Example 2 with MapInterceptor

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

the class MapServiceContextImpl method interceptPut.

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

Example 3 with MapInterceptor

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

the class MapServiceContextImpl method interceptAfterGet.

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

Example 4 with MapInterceptor

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

the class MapServiceContextImpl method interceptGet.

// todo interceptors should get a wrapped object which includes the serialized version
@Override
public Object interceptGet(String mapName, Object value) {
    MapContainer mapContainer = getMapContainer(mapName);
    InterceptorRegistry interceptorRegistry = mapContainer.getInterceptorRegistry();
    List<MapInterceptor> interceptors = interceptorRegistry.getInterceptors();
    Object result = null;
    if (!interceptors.isEmpty()) {
        result = toObject(value);
        for (MapInterceptor interceptor : interceptors) {
            Object temp = interceptor.interceptGet(result);
            if (temp != null) {
                result = temp;
            }
        }
    }
    return result == null ? value : result;
}
Also used : MapInterceptor(com.hazelcast.map.MapInterceptor)

Example 5 with MapInterceptor

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

the class PostJoinMapOperation method run.

@Override
public void run() throws Exception {
    MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    for (MapIndexInfo mapIndex : indexInfoList) {
        final MapContainer mapContainer = mapServiceContext.getMapContainer(mapIndex.mapName);
        final Indexes indexes = mapContainer.getIndexes();
        for (MapIndexInfo.IndexInfo indexInfo : mapIndex.lsIndexes) {
            indexes.addOrGetIndex(indexInfo.attributeName, indexInfo.ordered);
        }
    }
    for (InterceptorInfo interceptorInfo : interceptorInfoList) {
        final MapContainer mapContainer = mapServiceContext.getMapContainer(interceptorInfo.mapName);
        InterceptorRegistry interceptorRegistry = mapContainer.getInterceptorRegistry();
        Map<String, MapInterceptor> interceptorMap = interceptorRegistry.getId2InterceptorMap();
        List<Map.Entry<String, MapInterceptor>> entryList = interceptorInfo.interceptors;
        for (Map.Entry<String, MapInterceptor> entry : entryList) {
            if (!interceptorMap.containsKey(entry.getKey())) {
                interceptorRegistry.register(entry.getKey(), entry.getValue());
            }
        }
    }
    createQueryCaches();
}
Also used : MapInterceptor(com.hazelcast.map.MapInterceptor) Indexes(com.hazelcast.query.impl.Indexes) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer) InterceptorRegistry(com.hazelcast.map.impl.InterceptorRegistry) MapService(com.hazelcast.map.impl.MapService) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap)

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