private void initializeDeclarativeCache()
      throws TimeoutException, CacheWriterException, GatewayException, RegionExistsException {
    URL url = getCacheXmlURL();
    String cacheXmlDescription = cacheConfig.getCacheXMLDescription();
    if (url == null && cacheXmlDescription == null) {
      initializePdxRegistry();
      readyDynamicRegionFactory();
      // nothing needs to be done
      return;
    }

    InputStream stream = null;
    try {
      logCacheXML(url, cacheXmlDescription);
      if (cacheXmlDescription != null) {
        if (logger.isTraceEnabled()) {
          logger.trace("initializing cache with generated XML: {}", cacheXmlDescription);
        }
        stream = new StringBufferInputStream(cacheXmlDescription);
      } else {
        stream = url.openStream();
      }
      loadCacheXml(stream);

    } catch (IOException ex) {
      throw new CacheXmlException(String.format(
          "While opening Cache XML %s the following error occurred %s", url, ex));

    } catch (CacheXmlException ex) {
      throw new CacheXmlException(
          String.format("While reading Cache XML %s. %s", url, ex.getMessage()), ex.getCause());

    } finally {
      closeQuietly(stream);
    }
  }
Initialize the contents of this {@code Cache} according to the declarative caching XML file
specified by the given {@code DistributedSystem}. Note that this operation cannot be performed
in the constructor because creating regions in the cache, etc. uses the cache itself (which
isn't initialized until the constructor returns).

@throws CacheXmlException If something goes wrong while parsing the declarative caching XML
        file.
@throws TimeoutException If a {@link Region#put(Object, Object)}times out while initializing
        the cache.
@throws CacheWriterException If a {@code CacheWriterException} is thrown while initializing the
        cache.
@throws RegionExistsException If the declarative caching XML file describes a region that
        already exists (including the root region).
@throws GatewayException If a {@code GatewayException} is thrown while initializing the cache.
@see #loadCacheXml
geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java