protected void doInternalInit(InternalCache theCache) throws CacheException {
    if (isClosed()) {
      // DynamicRegions are not enabled in this vm. Just return.
      return;
    }

    try {
      cache = theCache;
      dynamicRegionList = theCache.getRegion(DYNAMIC_REGION_LIST_NAME);
      final boolean isClient = config.getPoolName() != null;
      if (dynamicRegionList == null) {
        InternalRegionFactory factory = cache.createInternalRegionFactory();
        factory.setDestroyLockFlag(true).setInternalRegion(true).setSnapshotInputStream(null)
            .setImageTarget(null);
        if (config.getPersistBackup()) {
          factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
          factory.setDiskWriteAttributes(new DiskWriteAttributesFactory().create());
          if (config.getDiskDir() != null) {
            factory.setDiskDirs(new File[] {config.getDiskDir()});
          }
        }

        if (isClient) {
          factory.setScope(Scope.LOCAL);
          factory.setDataPolicy(DataPolicy.NORMAL);
          factory.setStatisticsEnabled(true);
          String cpName = config.getPoolName();
          if (cpName != null) {
            Pool cp = PoolManager.find(cpName);
            if (cp == null) {
              throw new IllegalStateException(
                  "Invalid pool name specified. This pool is not registered with the cache: "
                      + cpName);
            } else {
              if (!cp.getSubscriptionEnabled()) {
                throw new IllegalStateException(
                    "The client pool of a DynamicRegionFactory must be configured with queue-enabled set to true.");
              }
              factory.setPoolName(cpName);
            }
          }
          factory.setInternalMetaRegion(new LocalMetaRegion(factory.getCreateAttributes(),
              factory.getInternalRegionArguments()));
        } else {
          factory.setScope(Scope.DISTRIBUTED_ACK);
          factory.setValueConstraint(DynamicRegionAttributes.class);

          if (!config.getPersistBackup()) { // if persistBackup, the data policy has already
                                            // been set
            factory.setDataPolicy(DataPolicy.REPLICATE);
          }

          for (GatewaySender gs : cache.getGatewaySenders()) {
            if (!gs.isParallel()) {
              factory.addGatewaySenderId(gs.getId());
            }
          }
          factory.setInternalMetaRegion(new DistributedMetaRegion(factory.getCreateAttributes()));
        }
        dynamicRegionList = factory.create(DYNAMIC_REGION_LIST_NAME);
        if (isClient) {
          dynamicRegionList.registerInterest("ALL_KEYS");
        }
        if (theCache.getLogger().fineEnabled()) {
          theCache.getLogger().fine("Created dynamic region: " + dynamicRegionList);
        }
      } else {
        if (theCache.getLogger().fineEnabled()) {
          theCache.getLogger().fine("Retrieved dynamic region: " + dynamicRegionList);
        }
      }

      createDefinedDynamicRegions();

    } catch (CacheException e) {
      theCache.getLogger().warning(
          "Error initializing DynamicRegionFactory", e);
      throw e;
    }
  }
The method is for internal use only. It is called implicitly during cache creation.
<p>
This method is called internally during cache initialization at the correct time. Initialize
the factory with a GemFire Cache. We create the metadata Region which holds all our dynamically
created regions.

@param theCache The GemFire {@code Cache}
geode-core/src/main/java/org/apache/geode/cache/DynamicRegionFactory.java