Search in sources :

Example 1 with CollectionConfig

use of com.hazelcast.config.CollectionConfig in project hazelcast by hazelcast.

the class AbstractCollectionProxyImpl method initialize.

@Override
public void initialize() {
    final NodeEngine nodeEngine = getNodeEngine();
    CollectionConfig config = getConfig(nodeEngine);
    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.NodeEngine) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) ItemListener(com.hazelcast.core.ItemListener) CollectionConfig(com.hazelcast.config.CollectionConfig) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware)

Aggregations

CollectionConfig (com.hazelcast.config.CollectionConfig)1 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)1 HazelcastInstanceAware (com.hazelcast.core.HazelcastInstanceAware)1 ItemListener (com.hazelcast.core.ItemListener)1 NodeEngine (com.hazelcast.spi.NodeEngine)1