@Override protected void onPostExecute(Object o) { if (listener != null) { if (o != null) { listener.onGet(o); } else { listener.onNotFound(key); } } }
public void testFilterConvertedCalledOnlyOnce() { Object value = new Object(); CacheEventFilterConverter<Object, Object, Object> filterConverter = when(mock(CacheEventFilterConverter.class) .filterAndConvert( anyObject(), anyObject(), any(Metadata.class), anyObject(), any(Metadata.class), any(EventType.class))) .thenReturn(value) .getMock(); CacheListener listener = new CacheListener(); cache.addListener(listener, filterConverter, filterConverter); cache.put("key", "value"); assertEquals(2, listener.getInvocationCount()); verify(filterConverter, times(2)) .filterAndConvert( anyObject(), anyObject(), any(Metadata.class), anyObject(), any(Metadata.class), any(EventType.class)); verify(filterConverter, never()) .accept( anyObject(), anyObject(), any(Metadata.class), anyObject(), any(Metadata.class), any(EventType.class)); verify(filterConverter, never()) .convert( anyObject(), anyObject(), any(Metadata.class), anyObject(), any(Metadata.class), any(EventType.class)); }
public void removeEvent() { if (_value instanceof CacheListener) ((CacheListener) _value).removeEvent(); }
// called after updating the changes. public void onAfterUpdate() { if (listener != null) { listener.updated(name, info); } }
/** Send a key addition event to all registered listeners */ protected void noteAddition(K key, V newValue) { for (CacheListener<K, V> listener : listeners) { listener.noteKeyAddition(this, key, newValue); } }
/** Send a key update event to all registered listeners */ protected void noteUpdate(K key, V newValue, V oldValue) { for (CacheListener<K, V> listener : listeners) { listener.noteKeyUpdate(this, key, newValue, oldValue); } }
/** Send a key removal event to all registered listeners */ protected void noteRemoval(K key, V oldValue) { for (CacheListener<K, V> listener : listeners) { listener.noteKeyRemoval(this, key, oldValue); } }