Search in sources :

Example 1 with CacheEventListenerAdaptor

use of com.hazelcast.cache.impl.CacheEventListenerAdaptor in project hazelcast by hazelcast.

the class ClientCacheProxy method registerCacheEntryListener.

@Override
public void registerCacheEntryListener(CacheEntryListenerConfiguration cacheEntryListenerConfiguration, boolean addToConfig) {
    ensureOpen();
    if (cacheEntryListenerConfiguration == null) {
        throw new NullPointerException("CacheEntryListenerConfiguration can't be null");
    }
    CacheEventListenerAdaptor<K, V> adaptor = new CacheEventListenerAdaptor<K, V>(this, cacheEntryListenerConfiguration, clientContext.getSerializationService(), clientContext.getHazelcastInstance());
    EventHandler handler = createHandler(adaptor);
    String regId = clientContext.getListenerService().registerListener(createCacheEntryListenerCodec(), handler);
    if (regId != null) {
        if (addToConfig) {
            cacheConfig.addCacheEntryListenerConfiguration(cacheEntryListenerConfiguration);
        }
        addListenerLocally(regId, cacheEntryListenerConfiguration);
        if (addToConfig) {
            updateCacheListenerConfigOnOtherNodes(cacheEntryListenerConfiguration, true);
        }
    }
}
Also used : CacheEventListenerAdaptor(com.hazelcast.cache.impl.CacheEventListenerAdaptor) EventHandler(com.hazelcast.client.spi.EventHandler)

Aggregations

CacheEventListenerAdaptor (com.hazelcast.cache.impl.CacheEventListenerAdaptor)1 EventHandler (com.hazelcast.client.spi.EventHandler)1