@Override
  public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context)
      throws Exception {

    EvaluationResult environment;
    String environmentId = null;
    Set<String> resourceNames = null;

    NodeList children = context.getRequestRoot().getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node child = children.item(i);
      if (child != null) {
        if (PDPConstants.ENVIRONMENT_ELEMENT.equals(child.getLocalName())) {
          if (child.getChildNodes() != null && child.getChildNodes().getLength() > 0) {
            environment =
                context.getAttribute(
                    new URI(StringAttribute.identifier),
                    new URI(PDPConstants.ENVIRONMENT_ID_DEFAULT),
                    null,
                    new URI(XACMLConstants.ENT_CATEGORY));
            if (environment != null
                && environment.getAttributeValue() != null
                && environment.getAttributeValue().isBag()) {
              BagAttribute attr = (BagAttribute) environment.getAttributeValue();
              environmentId = ((AttributeValue) attr.iterator().next()).encode();
            }
          }
        }
      }
    }

    if (isAbstractResourceCacheEnabled) {
      IdentityCacheKey cacheKey;
      String key =
          PDPConstants.RESOURCE_DESCENDANTS
              + parentResourceId
              + (environmentId != null ? environmentId : "");
      tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
      cacheKey = new IdentityCacheKey(tenantId, key);
      IdentityCacheEntry cacheEntry =
          (IdentityCacheEntry) abstractResourceCache.getValueFromCache(cacheKey);
      if (cacheEntry != null) {
        String[] values = cacheEntry.getCacheEntryArray();
        resourceNames = new HashSet<String>(Arrays.asList(values));
        if (log.isDebugEnabled()) {
          log.debug("Carbon Resource Cache Hit");
        }
      }

      if (resourceNames != null) {
        resourceNames = findDescendantResources(parentResourceId, environmentId);
        if (log.isDebugEnabled()) {
          log.debug("Carbon Resource Cache Miss");
        }
        if (resourceNames != null && !resourceNames.isEmpty()) {
          cacheEntry =
              new IdentityCacheEntry(resourceNames.toArray(new String[resourceNames.size()]));
          abstractResourceCache.addToCache(cacheKey, cacheEntry);
        }
      }
    } else {
      resourceNames = findDescendantResources(parentResourceId, environmentId);
    }

    return resourceNames;
  }
 @Override
 public void clearCache() {
   if (abstractResourceCache != null) {
     abstractResourceCache.clear();
   }
 }