code: public static LeafResource create(Resource resource)
    {
      try
      {
        // if we can access the file then there is no reason to decorate it...
        resource.getFile();
        return new LeafResourceImpl(resource);
      }
      catch(IOException e)
      {
        return new LocalCacheLeafResource(resource);
      }
    }
docs: Decorates the resource to implement a caching strategy.
  
  @param resource the resource to cache locally
  @return the (locally cached) resource