code: public I_CmsTemplateContextProvider getTemplateContextProvider(CmsObject cms, String path) throws CmsException {
  
          CmsResource resource = cms.readResource(path);
          I_CmsResourceLoader loader = OpenCms.getResourceManager().getLoader(resource);
          if (loader instanceof A_CmsXmlDocumentLoader) {
              String propertyName = ((A_CmsXmlDocumentLoader)loader).getTemplatePropertyDefinition();
              List<CmsProperty> properties = cms.readPropertyObjects(resource, true);
              CmsProperty property = CmsProperty.get(propertyName, properties);
              if ((property != null) && !property.isNullProperty()) {
                  String propertyValue = property.getValue();
                  if (CmsTemplateContextManager.hasPropertyPrefix(propertyValue)) {
                      return getTemplateContextProvider(removePropertyPrefix(propertyValue));
                  }
              }
              return null;
          } else {
              return null;
          }
      }
docs: Gets the template context provider for a given path.<p>
  
  @param cms the current CMS context
  @param path the path for which the template context provider should be determined
  
  @return the template context provider for the given path
  
  @throws CmsException if something goes wrong