Search in sources :

Example 11 with ItemListener

use of com.hazelcast.collection.ItemListener in project hazelcast by hazelcast.

the class AbstractCollectionProxyImpl method initialize.

@Override
public void initialize() {
    final NodeEngine nodeEngine = getNodeEngine();
    CollectionConfig config = getConfig(nodeEngine);
    checkCollectionConfig(config, nodeEngine.getSplitBrainMergePolicyProvider());
    final List<ItemListenerConfig> itemListenerConfigs = config.getItemListenerConfigs();
    for (ItemListenerConfig itemListenerConfig : itemListenerConfigs) {
        ItemListener listener = itemListenerConfig.getImplementation();
        if (listener == null && itemListenerConfig.getClassName() != null) {
            try {
                listener = ClassLoaderUtil.newInstance(nodeEngine.getConfigClassLoader(), itemListenerConfig.getClassName());
            } catch (Exception e) {
                throw ExceptionUtil.rethrow(e);
            }
        }
        if (listener != null) {
            if (listener instanceof HazelcastInstanceAware) {
                ((HazelcastInstanceAware) listener).setHazelcastInstance(nodeEngine.getHazelcastInstance());
            }
            addItemListener(listener, itemListenerConfig.isIncludeValue());
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) ItemListener(com.hazelcast.collection.ItemListener) ConfigValidator.checkCollectionConfig(com.hazelcast.internal.config.ConfigValidator.checkCollectionConfig) CollectionConfig(com.hazelcast.config.CollectionConfig) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware)

Aggregations

ItemListener (com.hazelcast.collection.ItemListener)11 ItemEvent (com.hazelcast.collection.ItemEvent)6 Data (com.hazelcast.internal.serialization.Data)5 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)3 DataAwareItemEvent (com.hazelcast.collection.impl.common.DataAwareItemEvent)3 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 UUID (java.util.UUID)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Test (org.junit.Test)3 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)2 HazelcastInstanceAware (com.hazelcast.core.HazelcastInstanceAware)2 NodeEngine (com.hazelcast.spi.impl.NodeEngine)2 EventRegistration (com.hazelcast.spi.impl.eventservice.EventRegistration)2 EventService (com.hazelcast.spi.impl.eventservice.EventService)2 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)1 QueueService (com.hazelcast.collection.impl.queue.QueueService)1 VersionedObject (com.hazelcast.collection.impl.queue.model.VersionedObject)1 CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)1