public void initCacheListeners(CacheListener<K, V>[] newListeners) {
    synchronized (regionAttributes) {
      if (newListeners == null || newListeners.length == 0) {
        regionAttributes.cacheListeners = null;
      } else {
        List<CacheListener<K, V>> nl = Arrays.asList(newListeners);
        if (nl.contains(null)) {
          throw new IllegalArgumentException(
              "initCacheListeners parameter had a null element");
        }
        regionAttributes.cacheListeners = new ArrayList<>(nl);
      }
    }
    regionAttributes.setHasCacheListeners(true);
  }
Removes all cache listeners and then adds each listener in the specified array.

@param newListeners a possibly null or empty array of listeners to add to this factory.
@throws IllegalArgumentException if the {@code newListeners} array has a null element
@since GemFire 5.0
geode-core/src/main/java/org/apache/geode/cache/AttributesFactory.java