@Override
  protected Region<K, V> lookupFallback(GemFireCache cache, String regionName) throws Exception {
    Assert.isTrue(cache instanceof ClientCache, "Unable to create regions from " + cache);

    ClientCache c = (ClientCache) cache;

    // first look at shortcut
    ClientRegionShortcut s = null;

    if (shortcut == null) {
      if (dataPolicy != null) {
        if (DataPolicy.EMPTY.equals(dataPolicy)) {
          s = ClientRegionShortcut.PROXY;
        } else if (DataPolicy.PERSISTENT_REPLICATE.equals(dataPolicy)) {
          s = ClientRegionShortcut.LOCAL_PERSISTENT;
        }
      }
      s = ClientRegionShortcut.LOCAL;
    } else {
      s = shortcut;
    }

    ClientRegionFactory<K, V> factory = c.createClientRegionFactory(s);

    // map the attributes onto the client
    if (attributes != null) {
      CacheListener<K, V>[] listeners = attributes.getCacheListeners();
      if (!ObjectUtils.isEmpty(listeners)) {
        for (CacheListener<K, V> listener : listeners) {
          factory.addCacheListener(listener);
        }
      }
      factory.setCloningEnabled(attributes.getCloningEnabled());
      factory.setConcurrencyLevel(attributes.getConcurrencyLevel());
      factory.setCustomEntryIdleTimeout(attributes.getCustomEntryIdleTimeout());
      factory.setCustomEntryTimeToLive(attributes.getCustomEntryTimeToLive());
      factory.setDiskStoreName(attributes.getDiskStoreName());
      factory.setDiskSynchronous(attributes.isDiskSynchronous());
      factory.setEntryIdleTimeout(attributes.getEntryIdleTimeout());
      factory.setEntryTimeToLive(attributes.getEntryTimeToLive());
      factory.setEvictionAttributes(attributes.getEvictionAttributes());
      factory.setInitialCapacity(attributes.getInitialCapacity());
      factory.setKeyConstraint(attributes.getKeyConstraint());
      factory.setLoadFactor(attributes.getLoadFactor());
      factory.setPoolName(attributes.getPoolName());
      factory.setRegionIdleTimeout(attributes.getRegionIdleTimeout());
      factory.setRegionTimeToLive(attributes.getRegionTimeToLive());
      factory.setStatisticsEnabled(attributes.getStatisticsEnabled());
      factory.setValueConstraint(attributes.getValueConstraint());
    }

    if (!ObjectUtils.isEmpty(cacheListeners)) {
      for (CacheListener<K, V> listener : cacheListeners) {
        factory.addCacheListener(listener);
      }
    }

    if (StringUtils.hasText(poolName)) {
      // try to eagerly initialize the pool name, if defined as a bean
      if (beanFactory.isTypeMatch(poolName, Pool.class)) {
        if (log.isDebugEnabled()) {
          log.debug(
              "Found bean definition for pool '" + poolName + "'. Eagerly initializing it...");
        }
        beanFactory.getBean(poolName, Pool.class);
      }

      factory.setPoolName(poolName);
    }

    Region<K, V> reg = factory.create(regionName);
    log.info("Created new cache region [" + regionName + "]");
    if (snapshot != null) {
      reg.loadSnapshot(snapshot.getInputStream());
    }

    return reg;
  }
  @Override
  @SuppressWarnings("deprecation")
  protected Region<K, V> lookupFallback(GemFireCache gemfireCache, String regionName)
      throws Exception {
    Assert.isTrue(
        gemfireCache instanceof Cache,
        String.format("Unable to create Regions from '%1$s'.", gemfireCache));

    Cache cache = (Cache) gemfireCache;

    RegionFactory<K, V> regionFactory = createRegionFactory(cache);

    if (hubId != null) {
      enableGateway = (enableGateway == null || enableGateway);
      Assert.isTrue(enableGateway, "The 'hubId' requires the 'enableGateway' property to be true.");
      regionFactory.setGatewayHubId(hubId);
    }

    if (enableGateway != null) {
      if (enableGateway) {
        Assert.notNull(
            hubId, "The 'enableGateway' property requires the 'hubId' property to be set.");
      }
      regionFactory.setEnableGateway(enableGateway);
    }

    if (!ObjectUtils.isEmpty(gatewaySenders)) {
      Assert.isTrue(
          hubId == null,
          "It is invalid to configure a region with both a hubId and gatewaySenders."
              + " Note that the enableGateway and hubId properties are deprecated since Gemfire 7.0");

      for (Object gatewaySender : gatewaySenders) {
        regionFactory.addGatewaySenderId(((GatewaySender) gatewaySender).getId());
      }
    }

    if (!ObjectUtils.isEmpty(asyncEventQueues)) {
      for (Object asyncEventQueue : asyncEventQueues) {
        regionFactory.addAsyncEventQueueId(((AsyncEventQueue) asyncEventQueue).getId());
      }
    }

    if (!ObjectUtils.isEmpty(cacheListeners)) {
      for (CacheListener<K, V> listener : cacheListeners) {
        regionFactory.addCacheListener(listener);
      }
    }

    if (cacheLoader != null) {
      regionFactory.setCacheLoader(cacheLoader);
    }

    if (cacheWriter != null) {
      regionFactory.setCacheWriter(cacheWriter);
    }

    resolveDataPolicy(regionFactory, persistent, dataPolicy);

    if (isDiskStoreConfigurationAllowed()) {
      regionFactory.setDiskStoreName(diskStoreName);
    }

    if (scope != null) {
      regionFactory.setScope(scope);
    }

    if (attributes != null) {
      Assert.state(
          !attributes.isLockGrantor() || (scope == null) || scope.isGlobal(),
          "Lock Grantor only applies to a 'GLOBAL' scoped Region.");
    }

    postProcess(regionFactory);

    Region<K, V> region =
        (getParent() != null
            ? regionFactory.createSubregion(getParent(), regionName)
            : regionFactory.create(regionName));

    if (log.isInfoEnabled()) {
      if (getParent() != null) {
        log.info(
            String.format(
                "Created new Cache sub-Region [%1$s] under parent Region [%2$s].",
                regionName, getParent().getName()));
      } else {
        log.info(String.format("Created new Cache Region [%1$s].", regionName));
      }
    }

    if (snapshot != null) {
      region.loadSnapshot(snapshot.getInputStream());
    }

    if (attributes != null && attributes.isLockGrantor()) {
      region.becomeLockGrantor();
    }

    return region;
  }