@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());
     }
   }
 }
Exemple #2
0
  public MapMergePolicy getMergePolicy(String mergePolicyName) {
    MapMergePolicy mergePolicy = mergePolicyMap.get(mergePolicyName);
    if (mergePolicy == null && mergePolicyName != null) {
      try {

        // check if user has entered custom class name instead of policy name
        mergePolicy =
            ClassLoaderUtil.newInstance(nodeEngine.getConfigClassLoader(), mergePolicyName);
        mergePolicyMap.put(mergePolicyName, mergePolicy);
      } catch (Exception e) {
        logger.severe(e);
        throw ExceptionUtil.rethrow(e);
      }
    }
    if (mergePolicy == null) {
      return mergePolicyMap.get(MapConfig.DEFAULT_MAP_MERGE_POLICY);
    }
    return mergePolicy;
  }