Interface ResourceReader

  • All Superinterfaces:
    ReaderBase

    public interface ResourceReader
    extends ReaderBase
    SPI for reading external resources from Pkl. Once a resource reader has been registered, Pkl code can read its resources with read("<URI>"), provided that resource URIs match an entry in the resource allowlist (--allowed-resources).

    See ResourceReaders for predefined resource readers.

    • Method Detail

      • getUriScheme

        java.lang.String getUriScheme()
        The URI scheme associated with resources read by this resource reader.
      • read

        java.util.Optional<java.lang.Object> read​(java.net.URI uri)
                                           throws java.io.IOException,
                                                  java.net.URISyntaxException,
                                                  SecurityManagerException
        Reads the resource with the given URI. Returns Optional.empty() if a resource with the given URI cannot be found.

        Supported resource types are:

        Throws:
        • IOException — if an error occurred while reading the resource, outside of the resource not being found.
        • URISyntaxException — if the URI format is invalid for the resource.
        • SecurityManagerException — If the resource read is invalid per the security manager.
        Throws:
        java.io.IOException
        java.net.URISyntaxException
        SecurityManagerException