]
Gustavo Fernandes updated ISPN-5482:
------------------------------------
Status: Open (was: New)
JSR-107 - Provide mechanism to handle expiration events
--------------------------------------------------------
Key: ISPN-5482
URL:
https://issues.jboss.org/browse/ISPN-5482
Project: Infinispan
Issue Type: Feature Request
Components: JCache
Reporter: Matej Čimbora
Currently, expiration events are supported only by embedded mode & additionally
require entry to be accessed in order to be created. This can lead to
CacheEntryExpiredListener not being notified when an entry expires.
Note: Not covered by TCK tests.
Example:
{code}
@Test
public void testExpiration(Method m) {
Cache<String, String> cache1 = getCache1(m);
Cache<String, String> cache2 = getCache2(m);
TestExpiredListener listener = new TestExpiredListener();
MutableCacheEntryListenerConfiguration conf1 = new
MutableCacheEntryListenerConfiguration(FactoryBuilder.factoryOf(listener), null, false,
false);
cache1.registerCacheEntryListener(conf1);
cache2.put("key1", "val1");
sleep(5000);
// Required by embedded JCache implementation to work
assert cache1.get("key1") == null;
// Failing for remote JCache implementation
assertEquals(1, listener.invocationCount);
}
private static class TestExpiredListener implements CacheEntryExpiredListener,
Serializable {
private int invocationCount;
@Override
public void onExpired(Iterable iterable) throws CacheEntryListenerException {
Iterator iterator = iterable.iterator();
while (iterator.hasNext()) {
iterator.next();
invocationCount++;
}
}
}
{code}