javax.cache.event.CacheEntryUpdatedListener Java Examples
The following examples show how to use
javax.cache.event.CacheEntryUpdatedListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param cache Ignite cache. * @throws Exception If fail. */ private void executeContinuousQuery(IgniteCache<Object, Object> cache) throws Exception { ContinuousQuery<Integer, String> qry = new ContinuousQuery<>(); qry.setLocalListener( new CacheEntryUpdatedListener<Integer, String>() { @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> events) throws CacheEntryListenerException { for (CacheEntryEvent<? extends Integer, ? extends String> event : events) System.out.println("Key = " + event.getKey() + ", Value = " + event.getValue()); } } ); Class<CacheEntryEventSerializableFilter> remoteFilterCls = (Class<CacheEntryEventSerializableFilter>) extLdr.loadClass(EXT_FILTER_CLASS); qry.setRemoteFilterFactory(new ClassFilterFactory(remoteFilterCls)); cache.query(qry); for (int i = 0; i < 100; i++) cache.put(i, "Message " + i); }
Example #2
Source File: EventListenerAdaptors.java From ehcache3 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") static <K, V> List<EventListenerAdaptor<K, V>> ehListenersFor(CacheEntryListener<? super K, ? super V> listener, CacheEntryEventFilter<? super K, ? super V> filter, Cache<K, V> source, boolean requestsOld) { List<EventListenerAdaptor<K, V>> rv = new ArrayList<>(); if (listener instanceof CacheEntryUpdatedListener) { rv.add(new UpdatedAdaptor<>(source, (CacheEntryUpdatedListener<K, V>) listener, (CacheEntryEventFilter<K, V>) filter, requestsOld)); } if (listener instanceof CacheEntryCreatedListener) { rv.add(new CreatedAdaptor<>(source, (CacheEntryCreatedListener<K, V>) listener, (CacheEntryEventFilter<K, V>) filter, requestsOld)); } if (listener instanceof CacheEntryRemovedListener) { rv.add(new RemovedAdaptor<>(source, (CacheEntryRemovedListener<K, V>) listener, (CacheEntryEventFilter<K, V>) filter, requestsOld)); } if (listener instanceof CacheEntryExpiredListener) { rv.add(new ExpiredAdaptor<>(source, (CacheEntryExpiredListener<K, V>) listener, (CacheEntryEventFilter<K, V>) filter, requestsOld)); } return rv; }
Example #3
Source File: CacheContinuousQueryHandler.java From ignite with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param cacheName Cache name. * @param topic Topic for ordered messages. * @param locLsnr Local listener. * @param rmtFilter Remote filter. * @param oldValRequired Old value required flag. * @param sync Synchronous flag. * @param ignoreExpired Ignore expired events flag. */ public CacheContinuousQueryHandler( String cacheName, Object topic, @Nullable CacheEntryUpdatedListener<K, V> locLsnr, @Nullable CacheEntryEventSerializableFilter<K, V> rmtFilter, boolean oldValRequired, boolean sync, boolean ignoreExpired, boolean ignoreClsNotFound) { assert topic != null; this.cacheName = cacheName; this.topic = topic; this.locLsnr = locLsnr; this.rmtFilter = rmtFilter; this.oldValRequired = oldValRequired; this.sync = sync; this.ignoreExpired = ignoreExpired; this.ignoreClsNotFound = ignoreClsNotFound; cacheId = CU.cacheId(cacheName); }
Example #4
Source File: GridCacheContinuousQueryAbstractSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception If failed. */ @Test public void testFilterException() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>(); qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() { @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) { // No-op. } }); qry.setRemoteFilter(new CacheEntryEventSerializableFilter<Integer, Integer>() { @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends Integer> evt) { throw new RuntimeException("Test error."); } }); try (QueryCursor<Cache.Entry<Integer, Integer>> ignored = cache.query(qry)) { for (int i = 0; i < 100; i++) cachePut(cache, i, i); } }
Example #5
Source File: GridCacheContinuousQueryAbstractSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception if failed. * @param bypassFilter Whether remote filter should be bypassed. * @param setLocLsnr Whether local listner should be setted. */ private void doQueryWithRemoteFilter(boolean setLocLsnr, boolean bypassFilter) throws Exception { FILTERED.clear(); ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>(); Map<Integer, Integer> listened = new ConcurrentHashMap<>(); if (setLocLsnr) { qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() { @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) { evts.forEach(event -> listened.put(event.getKey(), event.getValue())); } }); } qry.setRemoteFilter(evt -> { FILTERED.put(evt.getKey(), evt.getValue()); return bypassFilter; }); try (QueryCursor<Cache.Entry<Integer, Integer>> qryCursor = grid(0).cache(DEFAULT_CACHE_NAME).query(qry)) { checkLsnrAndFilterResults(setLocLsnr, bypassFilter, listened); } }
Example #6
Source File: JCSListener.java From commons-jcs with Apache License 2.0 | 6 votes |
public JCSListener(final CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) { oldValue = cacheEntryListenerConfiguration.isOldValueRequired(); synchronous = cacheEntryListenerConfiguration.isSynchronous(); final Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory = cacheEntryListenerConfiguration .getCacheEntryEventFilterFactory(); if (filterFactory == null) { filter = NoFilter.INSTANCE; } else { filter = filterFactory.create(); } delegate = cacheEntryListenerConfiguration.getCacheEntryListenerFactory().create(); remove = CacheEntryRemovedListener.class.isInstance(delegate); expire = CacheEntryExpiredListener.class.isInstance(delegate); update = CacheEntryUpdatedListener.class.isInstance(delegate); create = CacheEntryCreatedListener.class.isInstance(delegate); }
Example #7
Source File: CacheContinuousQueryConcurrentPartitionUpdateTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param cache Cache. * @return Event counter. */ private T2<AtomicInteger, QueryCursor> startListener(IgniteCache<Object, Object> cache) { final AtomicInteger evtCnt = new AtomicInteger(); ContinuousQuery<Object, Object> qry = new ContinuousQuery<>(); qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() { @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) { for (CacheEntryEvent evt : evts) { assertNotNull(evt.getKey()); assertNotNull(evt.getValue()); if ((Integer)evt.getValue() >= 0) evtCnt.incrementAndGet(); } } }); QueryCursor cur = cache.query(qry); return new T2<>(evtCnt, cur); }
Example #8
Source File: IgniteCacheGroupsTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param node Node. * @param cacheName Cache name. * @return Received events counter. */ private AtomicInteger registerListener(Ignite node, String cacheName) { ContinuousQuery qry = new ContinuousQuery(); final AtomicInteger cntr = new AtomicInteger(); qry.setLocalListener(new CacheEntryUpdatedListener() { @Override public void onUpdated(Iterable iterable) { for (Object evt : iterable) cntr.incrementAndGet(); } }); node.cache(cacheName).query(qry); return cntr; }
Example #9
Source File: ListenerEntry.java From triava with Apache License 2.0 | 6 votes |
/** * Returns whether this {@link ListenerEntry} is listening to the given eventType * @param eventType The event Type * @return true, if the listener is listening to the given eventType */ boolean isListeningFor(EventType eventType) { switch (eventType) { case CREATED: return listener instanceof CacheEntryCreatedListener; case EXPIRED: return listener instanceof CacheEntryExpiredListener; case REMOVED: return listener instanceof CacheEntryRemovedListener; case UPDATED: return listener instanceof CacheEntryUpdatedListener; } return false; }
Example #10
Source File: CacheContinuousBatchAckTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param ccfg Cache configuration. * @throws Exception If failed. */ private void checkBackupAcknowledgeMessage(CacheConfiguration<Object, Object> ccfg) throws Exception { QueryCursor qry = null; IgniteCache<Object, Object> cache = null; try { ContinuousQuery q = new ContinuousQuery(); q.setLocalListener(new CacheEntryUpdatedListener() { @Override public void onUpdated(Iterable iterable) throws CacheEntryListenerException { // No-op. } }); cache = grid(SERVER).getOrCreateCache(ccfg); qry = cache.query(q); for (int i = 0; i < GridTestUtils.SF.applyLB(10000, 1000); i++) cache.put(i, i); assertFalse(GridTestUtils.waitForCondition(fail::get, 1300L)); } finally { if (qry != null) qry.close(); if (cache != null) grid(SERVER).destroyCache(cache.getName()); } }
Example #11
Source File: BlazingCacheCacheEntryListenerWrapper.java From blazingcache with Apache License 2.0 | 5 votes |
void onEntryUpdated(K key, V oldValue, V value) { if (onUpdate) { BlazingCacheCacheEntryEvent event = new BlazingCacheCacheEntryEvent(key, oldValue, value, parent, EventType.UPDATED, true); if (filter != null && !filter.evaluate(event)) { return; } ((CacheEntryUpdatedListener) listener).onUpdated(Arrays.asList(event)); } }
Example #12
Source File: BlazingCacheCacheEntryListenerWrapper.java From blazingcache with Apache License 2.0 | 5 votes |
BlazingCacheCacheEntryListenerWrapper(boolean synchronous, boolean oldValueRequired, CacheEntryListener<K, V> listener, CacheEntryEventFilter<K, V> filter, CacheEntryListenerConfiguration<K, V> configuration, BlazingCacheCache<K, V> parent) { this.synchronous = synchronous; this.parent = parent; this.oldValueRequired = oldValueRequired; this.listener = listener; this.filter = filter; this.configuration = configuration; this.onCreate = listener instanceof CacheEntryCreatedListener; this.onUpdate = listener instanceof CacheEntryUpdatedListener; this.onRemove = listener instanceof CacheEntryRemovedListener; this.needPreviousValue = oldValueRequired || onRemove || onUpdate; }
Example #13
Source File: GridCacheContinuousQueryAbstractSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception if failed. * @param bypassFilter Whether remote filter should be bypassed. * @param setLocLsnr Whether local listner should be setted. */ private void doQueryWithRemoteFilterFactory(boolean setLocLsnr, boolean bypassFilter) throws Exception { FILTERED.clear(); ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>(); Map<Integer, Integer> listened = new ConcurrentHashMap<>(); if (setLocLsnr) { qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() { @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) { evts.forEach(event -> listened.put(event.getKey(), event.getValue())); } }); } qry.setRemoteFilterFactory( FactoryBuilder.factoryOf((CacheEntryEventSerializableFilter<Integer, Integer>)evt -> { FILTERED.put(evt.getKey(), evt.getValue()); return bypassFilter; })); try (QueryCursor<Cache.Entry<Integer, Integer>> qryCursor = grid(0).cache(DEFAULT_CACHE_NAME).query(qry)) { checkLsnrAndFilterResults(setLocLsnr, bypassFilter, listened); } }
Example #14
Source File: GridCacheContinuousQueryAbstractSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @SuppressWarnings("TryFinallyCanBeTryWithResources") @Test public void testNodeJoinWithoutCache() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>(); final CountDownLatch latch = new CountDownLatch(1); qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() { @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) { latch.countDown(); } }); QueryCursor<Cache.Entry<Integer, Integer>> cur = cache.query(qry); try { try (Ignite ignite = startClientGrid(NO_CACHE_IGNITE_INSTANCE_NAME)) { log.info("Started node without cache: " + ignite); } cachePut(cache, 1, 1); assertTrue(latch.await(5000, MILLISECONDS)); } finally { cur.close(); } }
Example #15
Source File: GridCacheContinuousQueryNodesFilteringTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Start first, attribute-bearing, node, create new cache and launch continuous query on it. * * @return Node. * @throws Exception if failed. */ private Ignite startNodeWithCache() throws Exception { Ignite node1 = startGrid("node1", getConfiguration("node1", true, null)); CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setName("attrsTestCache"); ccfg.setNodeFilter(new IgnitePredicate<ClusterNode>() { /** {@inheritDoc} */ @Override public boolean apply(ClusterNode node) { return "data".equals(node.attribute("node-type")); } }); IgniteCache<Integer, Integer> cache = node1.createCache(ccfg); ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>(); qry.setRemoteFilterFactory(new RemoteFilterFactory()); qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() { /** {@inheritDoc} */ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) { // No-op. } }); RemoteFilterFactory.clsLdr = getExternalClassLoader(); cache.query(qry); // Switch class loader before starting the second node. RemoteFilterFactory.clsLdr = getClass().getClassLoader(); return node1; }
Example #16
Source File: CacheContinuousQueryExecuteInPrimaryTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ private void doTestWithoutEventsEntries(CacheConfiguration<Integer, String> ccfg) throws Exception { try (IgniteCache<Integer, String> cache = grid(0).createCache(ccfg)) { int ITERATION_CNT = 100; final AtomicBoolean noOneListen = new AtomicBoolean(true); for (int i = 0; i < ITERATION_CNT; i++) { ContinuousQuery<Integer, String> qry = new ContinuousQuery<>(); qry.setLocalListener(new CacheEntryUpdatedListener<Integer, String>() { @Override public void onUpdated( Iterable<CacheEntryEvent<? extends Integer, ? extends String>> iterable) throws CacheEntryListenerException { noOneListen.set(false); } }); qry.setRemoteFilterFactory(FactoryBuilder.factoryOf( new CacheEntryEventSerializableFilter<Integer, String>() { @Override public boolean evaluate( CacheEntryEvent<? extends Integer, ? extends String> cacheEntryEvent) throws CacheEntryListenerException { return false; } })); executeQuery(cache, qry, ccfg.getAtomicityMode() != ATOMIC); } assertTrue(noOneListen.get()); } finally { ignite(0).destroyCache(ccfg.getName()); } }
Example #17
Source File: EventTypeAwareListener.java From caffeine with Apache License 2.0 | 5 votes |
/** Returns if the backing listener consumes this type of event. */ @SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault") public boolean isCompatible(@NonNull EventType eventType) { switch (eventType) { case CREATED: return (listener instanceof CacheEntryCreatedListener<?, ?>); case UPDATED: return (listener instanceof CacheEntryUpdatedListener<?, ?>); case REMOVED: return (listener instanceof CacheEntryRemovedListener<?, ?>); case EXPIRED: return (listener instanceof CacheEntryExpiredListener<?, ?>); } throw new IllegalStateException("Unknown event type: " + eventType); }
Example #18
Source File: EventTypeAwareListener.java From caffeine with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void onUpdated(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) { if (listener instanceof CacheEntryUpdatedListener<?, ?>) { ((CacheEntryUpdatedListener<K, V>) listener).onUpdated(events); } }
Example #19
Source File: CacheContinuousQueryHandlerV2.java From ignite with Apache License 2.0 | 5 votes |
/** * Constructor. * * @param cacheName Cache name. * @param topic Topic for ordered messages. * @param locLsnr Local listener. * @param rmtFilterFactory Remote filter factory. * @param oldValRequired Old value required flag. * @param sync Synchronous flag. * @param ignoreExpired Ignore expired events flag. * @param types Event types. */ public CacheContinuousQueryHandlerV2( String cacheName, Object topic, @Nullable CacheEntryUpdatedListener<K, V> locLsnr, @Nullable Factory<? extends CacheEntryEventFilter<K, V>> rmtFilterFactory, boolean oldValRequired, boolean sync, boolean ignoreExpired, boolean ignoreClsNotFound, @Nullable Byte types) { super(cacheName, topic, locLsnr, null, oldValRequired, sync, ignoreExpired, ignoreClsNotFound); this.rmtFilterFactory = rmtFilterFactory; if (types != null) { assert types != 0; this.types = types; } }
Example #20
Source File: EventTypeFilter.java From caffeine with Apache License 2.0 | 5 votes |
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault") private boolean isCompatible(CacheEntryEvent<? extends K, ? extends V> event) { switch (event.getEventType()) { case CREATED: return (listener instanceof CacheEntryCreatedListener<?, ?>); case UPDATED: return (listener instanceof CacheEntryUpdatedListener<?, ?>); case REMOVED: return (listener instanceof CacheEntryRemovedListener<?, ?>); case EXPIRED: return (listener instanceof CacheEntryExpiredListener<?, ?>); } throw new CacheEntryListenerException("Unknown event type: " + event.getEventType()); }
Example #21
Source File: CacheContinuousQueryManager.java From ignite with Apache License 2.0 | 5 votes |
/** * @param locLsnr Local listener. * @param rmtFilter Remote filter. * @param loc Local flag. * @param notifyExisting Notify existing flag. * @param sync Synchronous flag. * @return Continuous routine ID. * @throws IgniteCheckedException In case of error. */ public UUID executeInternalQuery(final CacheEntryUpdatedListener<?, ?> locLsnr, final CacheEntryEventSerializableFilter rmtFilter, final boolean loc, final boolean notifyExisting, final boolean ignoreClassNotFound, final boolean sync) throws IgniteCheckedException { return executeQuery0( locLsnr, new IgniteOutClosure<CacheContinuousQueryHandler>() { @Override public CacheContinuousQueryHandler apply() { return new CacheContinuousQueryHandler( cctx.name(), TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()), locLsnr, rmtFilter, true, sync, true, ignoreClassNotFound); } }, ContinuousQuery.DFLT_PAGE_SIZE, ContinuousQuery.DFLT_TIME_INTERVAL, ContinuousQuery.DFLT_AUTO_UNSUBSCRIBE, true, notifyExisting, loc, false, false); }
Example #22
Source File: CacheContinuousQueryManager.java From ignite with Apache License 2.0 | 5 votes |
/** * @param locLsnr Local listener. * @param rmtFilter Remote filter. * @param rmtFilterFactory Remote filter factory * @param bufSize Buffer size. * @param timeInterval Time interval. * @param autoUnsubscribe Auto unsubscribe flag. * @param loc Local flag. * @return Continuous routine ID. * @throws IgniteCheckedException In case of error. */ public UUID executeQuery(@Nullable final CacheEntryUpdatedListener locLsnr, @Nullable final EventListener locTransLsnr, @Nullable final CacheEntryEventSerializableFilter<K, V> rmtFilter, @Nullable final Factory<CacheEntryEventFilter<K, V>> rmtFilterFactory, @Nullable final Factory<IgniteClosure<K, V>> rmtTransFactory, int bufSize, long timeInterval, boolean autoUnsubscribe, boolean loc, final boolean keepBinary, final boolean includeExpired) throws IgniteCheckedException { IgniteOutClosure<CacheContinuousQueryHandler> clsr; if (rmtTransFactory != null) { clsr = new IgniteOutClosure<CacheContinuousQueryHandler>() { @Override public CacheContinuousQueryHandler apply() { return new CacheContinuousQueryHandlerV3( cctx.name(), TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()), locTransLsnr, securityAwareFilterFactory(rmtFilterFactory), securityAwareTransformerFactory(rmtTransFactory), true, false, !includeExpired, false); } }; } else if (rmtFilterFactory != null) { clsr = new IgniteOutClosure<CacheContinuousQueryHandler>() {
Example #23
Source File: JCSListener.java From commons-jcs with Apache License 2.0 | 5 votes |
public void onUpdated(final List<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException { if (update) { CacheEntryUpdatedListener.class.cast(delegate).onUpdated(filter(events)); } }
Example #24
Source File: CacheEntryEventProbe.java From ignite with Apache License 2.0 | 5 votes |
/** * @param cntr Received event counter. * @return Local listener. */ protected CacheEntryUpdatedListener<Integer, Integer> localListener(final AtomicLong cntr) { return new CacheEntryUpdatedListener<Integer, Integer>() { @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> events) throws CacheEntryListenerException { int size = 0; for (CacheEntryEvent<? extends Integer, ? extends Integer> e : events) ++size; cntr.addAndGet(size); } }; }
Example #25
Source File: CacheMvccBasicContinuousQueryTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testCachingMaxSize() throws Exception { Ignite node = startGrids(1); final IgniteCache cache = node.createCache( cacheConfiguration(cacheMode(), FULL_SYNC, 1, 2) .setCacheMode(CacheMode.PARTITIONED) .setIndexedTypes(Integer.class, Integer.class)); ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>(); qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() { @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) { // No-op. } }); GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { try (QueryCursor<Cache.Entry<Integer, Integer>> ignored = cache.query(qry)) { try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { for (int i = 0; i < TX_SIZE_THRESHOLD + 1; i++) cache.query(new SqlFieldsQuery("INSERT INTO Integer (_key, _val) values (" + i + ", 1)")).getAll(); tx.commit(); } } return null; } }, CacheException.class, "Transaction is too large. Consider reducing transaction size"); }
Example #26
Source File: CacheEntryListenerClient.java From cache2k with Apache License 2.0 | 5 votes |
@Override public void onUpdated(Iterable<CacheEntryEvent<? extends K, ? extends V>> cacheEntryEvents) throws CacheEntryListenerException { if (isDirectCallable()) { for (CacheEntryListener<K,V> l : listenerServer.getListeners()) { if (l instanceof CacheEntryUpdatedListener) { ((CacheEntryUpdatedListener<K,V>) l).onUpdated(cacheEntryEvents); } } return; } for (CacheEntryEvent<? extends K, ? extends V> event : cacheEntryEvents) { getClient().invoke(new OnCacheEntryEventHandler<K, V>(event)); } }
Example #27
Source File: CacheEntryListenerServer.java From cache2k with Apache License 2.0 | 5 votes |
private void runHandlers(EventType eventType, TestCacheEntryEvent event) { ArrayList events = new ArrayList(1); events.add(event); for (CacheEntryListener listener : listeners) { switch (eventType) { case CREATED : if (listener instanceof CacheEntryCreatedListener) { ((CacheEntryCreatedListener) listener).onCreated(events); } break; case UPDATED: if (listener instanceof CacheEntryUpdatedListener) { ((CacheEntryUpdatedListener) listener).onUpdated(events); } break; case REMOVED: if (listener instanceof CacheEntryRemovedListener) { ((CacheEntryRemovedListener) listener).onRemoved(events); } break; case EXPIRED: if (listener instanceof CacheEntryExpiredListener) { ((CacheEntryExpiredListener) listener).onExpired(events); } break; default: break; } } }
Example #28
Source File: ListenerEntry.java From triava with Apache License 2.0 | 5 votes |
private void sendEvents(TCacheEntryEventCollection<K, V> eventColl, CacheEntryListener<K, V> listener) { EventType eventType = eventColl.eventType(); // System.out.println("sendEvents to listener " + listener + ", eventType=" + eventColl.eventType()); switch (eventType) { case CREATED: if (listener instanceof CacheEntryCreatedListener) eventManager.created((CacheEntryCreatedListener<K, V>)listener, eventColl); break; case EXPIRED: if (listener instanceof CacheEntryExpiredListener) eventManager.expired((CacheEntryExpiredListener<K, V>)listener, eventColl); break; case UPDATED: if (listener instanceof CacheEntryUpdatedListener) eventManager.updated((CacheEntryUpdatedListener<K,V>)listener, eventColl); break; case REMOVED: if (listener instanceof CacheEntryRemovedListener) eventManager.removed((CacheEntryRemovedListener<K,V>)listener, eventColl); break; default: // By default do nothing. If new event types are added to the Spec, they will be ignored. } }
Example #29
Source File: EventListenerAdaptors.java From ehcache3 with Apache License 2.0 | 4 votes |
UpdatedAdaptor(Cache<K, V> source, CacheEntryUpdatedListener<K, V> listener, CacheEntryEventFilter<K, V> filter, boolean requestsOld) { super(source, filter, requestsOld); this.listener = listener; }
Example #30
Source File: Listener.java From cache2k with Apache License 2.0 | 4 votes |
public Updated(final CacheEntryListenerConfiguration<K, V> _config, final CacheEntryEventFilter<K, V> _filter, final CacheEntryUpdatedListener<K, V> _listener) { super(_config, _filter, _listener); listener = _listener; }