Search in sources :

Example 1 with CacheClosedListener

use of org.cache2k.event.CacheClosedListener in project cache2k by cache2k.

the class Cache2kBuilderTest method cacheClosedEventFired.

private void cacheClosedEventFired(boolean _wiredCache) {
    final AtomicBoolean _FIRED = new AtomicBoolean();
    Cache2kBuilder _builder = Cache2kBuilder.forUnknownTypes();
    _builder.addCacheClosedListener(new CacheClosedListener() {

        @Override
        public void onCacheClosed(final Cache cache) {
            _FIRED.set(true);
        }
    });
    if (_wiredCache) {
        StaticUtil.enforceWiredCache(_builder);
    }
    Cache c = _builder.build();
    c.close();
    assertTrue(_FIRED.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CacheClosedListener(org.cache2k.event.CacheClosedListener) Cache2kBuilder(org.cache2k.Cache2kBuilder) Cache(org.cache2k.Cache)

Aggregations

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Cache (org.cache2k.Cache)1 Cache2kBuilder (org.cache2k.Cache2kBuilder)1 CacheClosedListener (org.cache2k.event.CacheClosedListener)1