Giriş
Şu satırı dahil ederiz
import com.hazelcast.map.MapInterceptor;
interceptPut metodu
map.put() çağrılınca interceptPut() tetiklenir
Örnek
Şöyle yaparız
public class TestInterceptor implements MapInterceptor { private static final long serialVersionUID = 4971835785800511499L; @Override public Object interceptGet(Object value) { return value; } @Override public void afterGet(Object value) { } @Override public Object interceptPut(Object oldValue, Object newValue) { System.out.println("old: " + oldValue + " new: " + newValue); if (newValue.equals(new TestPojo("Version2"))) { return new TestPojo("Version3"); } return newValue != null ? newValue : oldValue; } @Override public void afterPut(Object value) { } @Override public Object interceptRemove(Object removedValue) { return null; } @Override public void afterRemove(Object oldValue) { } } IMap<String, TestPojo> map = ...; map.addInterceptor(new TestInterceptor());
Hiç yorum yok:
Yorum Gönder