Search in sources :

Example 1 with CacheWrapper

use of org.jivesoftware.util.cache.CacheWrapper in project Openfire by igniterealtime.

the class ClusterListener method simuateCacheInserts.

private void simuateCacheInserts(Cache<Object, Object> cache) {
    MapListener mapListener = mapListeners.get(cache);
    if (mapListener != null) {
        if (cache instanceof CacheWrapper) {
            Cache wrapped = ((CacheWrapper) cache).getWrappedCache();
            if (wrapped instanceof ClusteredCache) {
                ClusteredCache clusteredCache = (ClusteredCache) wrapped;
                for (Map.Entry entry : cache.entrySet()) {
                    MapEvent event = new MapEvent(clusteredCache.map, MapEvent.ENTRY_INSERTED, entry.getKey(), null, entry.getValue());
                    mapListener.entryInserted(event);
                }
            }
        }
    }
}
Also used : CacheWrapper(org.jivesoftware.util.cache.CacheWrapper) MapListener(com.tangosol.util.MapListener) MapEvent(com.tangosol.util.MapEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Cache(org.jivesoftware.util.cache.Cache)

Example 2 with CacheWrapper

use of org.jivesoftware.util.cache.CacheWrapper in project Openfire by igniterealtime.

the class ClusterListener method simulateCacheInserts.

private void simulateCacheInserts(Cache cache) {
    EntryListener EntryListener = EntryListeners.get(cache);
    if (EntryListener != null) {
        if (cache instanceof CacheWrapper) {
            Cache wrapped = ((CacheWrapper) cache).getWrappedCache();
            if (wrapped instanceof ClusteredCache) {
                ClusteredCache clusteredCache = (ClusteredCache) wrapped;
                for (Map.Entry entry : (Set<Map.Entry>) cache.entrySet()) {
                    EntryEvent event = new EntryEvent(clusteredCache.map.getName(), cluster.getLocalMember(), EntryEventType.ADDED.getType(), entry.getKey(), null, entry.getValue());
                    EntryListener.entryAdded(event);
                }
            }
        }
    }
}
Also used : CacheWrapper(org.jivesoftware.util.cache.CacheWrapper) HashSet(java.util.HashSet) Set(java.util.Set) EntryEvent(com.hazelcast.core.EntryEvent) EntryListener(com.hazelcast.core.EntryListener) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Cache(org.jivesoftware.util.cache.Cache)

Example 3 with CacheWrapper

use of org.jivesoftware.util.cache.CacheWrapper in project Openfire by igniterealtime.

the class ClusterListener method addMapListener.

private void addMapListener(Cache cache, MapListener listener) {
    if (cache instanceof CacheWrapper) {
        Cache wrapped = ((CacheWrapper) cache).getWrappedCache();
        if (wrapped instanceof ClusteredCache) {
            ((ClusteredCache) wrapped).addMapListener(listener, new MapEventFilter(MapEventFilter.E_KEYSET), false);
            // Keep track of the listener that we added to the cache
            mapListeners.put(cache, listener);
        }
    }
}
Also used : CacheWrapper(org.jivesoftware.util.cache.CacheWrapper) MapEventFilter(com.tangosol.util.filter.MapEventFilter) Cache(org.jivesoftware.util.cache.Cache)

Example 4 with CacheWrapper

use of org.jivesoftware.util.cache.CacheWrapper in project Openfire by igniterealtime.

the class ClusterListener method addEntryListener.

private void addEntryListener(Cache cache, EntryListener listener) {
    if (cache instanceof CacheWrapper) {
        Cache wrapped = ((CacheWrapper) cache).getWrappedCache();
        if (wrapped instanceof ClusteredCache) {
            ((ClusteredCache) wrapped).addEntryListener(listener, false);
            // Keep track of the listener that we added to the cache
            EntryListeners.put(cache, listener);
        }
    }
}
Also used : CacheWrapper(org.jivesoftware.util.cache.CacheWrapper) Cache(org.jivesoftware.util.cache.Cache)

Aggregations

Cache (org.jivesoftware.util.cache.Cache)4 CacheWrapper (org.jivesoftware.util.cache.CacheWrapper)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 EntryEvent (com.hazelcast.core.EntryEvent)1 EntryListener (com.hazelcast.core.EntryListener)1 MapEvent (com.tangosol.util.MapEvent)1 MapListener (com.tangosol.util.MapListener)1 MapEventFilter (com.tangosol.util.filter.MapEventFilter)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1