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);
}
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);
}
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);
}
}
}
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;
}
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);
}
Aggregations