Search in sources :

Example 1 with CacheEntryCreatedListener

use of javax.cache.event.CacheEntryCreatedListener in project cache2k by cache2k.

the class CacheEntryListenerServer method runHandlers.

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;
        }
    }
}
Also used : CacheEntryExpiredListener(javax.cache.event.CacheEntryExpiredListener) CacheEntryUpdatedListener(javax.cache.event.CacheEntryUpdatedListener) CacheEntryListener(javax.cache.event.CacheEntryListener) CacheEntryCreatedListener(javax.cache.event.CacheEntryCreatedListener) ArrayList(java.util.ArrayList) CacheEntryRemovedListener(javax.cache.event.CacheEntryRemovedListener)

Aggregations

ArrayList (java.util.ArrayList)1 CacheEntryCreatedListener (javax.cache.event.CacheEntryCreatedListener)1 CacheEntryExpiredListener (javax.cache.event.CacheEntryExpiredListener)1 CacheEntryListener (javax.cache.event.CacheEntryListener)1 CacheEntryRemovedListener (javax.cache.event.CacheEntryRemovedListener)1 CacheEntryUpdatedListener (javax.cache.event.CacheEntryUpdatedListener)1