Class ResourceReaders

java.lang.Object
org.pkl.core.resource.ResourceReaders

public final class ResourceReaders extends Object
Predefined resource readers for OS environment variables and external properties.
  • Method Details

    • environmentVariable

      public static ResourceReader environmentVariable()
      A resource reader for OS environment variables. If this resource reader is present, Pkl code can read environment variable FOO_BAR with read("env:FOO_BAR"), provided that resource URI env:FOO_BAR matches an entry in the resource allowlist ( --allowed-resources).
    • externalProperty

      public static ResourceReader externalProperty()
      A resource reader for external properties. If this resource reader is present, Pkl code can read external property foo.bar with read("prop:foo.bar"), provided that resource URI prop:foo.bar matches an entry in the resource allowlist ( --allowed-resources).
    • file

      public static ResourceReader file()
    • http

      public static ResourceReader http()
      A resource reader for HTTP resources. If this resource reader is present, Pkl code can read HTTP resource http://apple.com/foo/bar.txt with read("http://apple.com/foo/bar.txt"), provided that resource URI "http://apple.com/foo/bar.txt" matches an entry in the resource allowlist ( --allowed-resources).
    • https

      public static ResourceReader https()
      A resource reader for HTTPS resources. If this resource reader is present, Pkl code can read HTTPS resource https://apple.com/foo/bar.txt with read("https://apple.com/foo/bar.txt"), provided that resource URI "https://apple.com/foo/bar.txt" matches an entry in the resource allowlist ( --allowed-resources).
    • classPath

      public static ResourceReader classPath(ClassLoader classLoader)
      A resource reader for JVM class path resources. If this resource reader is present, Pkl code can read class path resource /foo/bar.txt with read("modulepath:foo/bar.txt"), provided that resource URI "modulepath:foo/bar.txt" matches an entry in the resource allowlist (--allowed-resources).
    • modulePath

      public static ResourceReader modulePath(ModulePathResolver resolver)
      A resource reader for Pkl module path (--module-path) resources. If this resource reader is present, Pkl code can read module path resource /foo/bar.txt with read("modulepath:foo/bar.txt"), provided that resource URI "modulepath:foo/bar.txt" matches an entry in the resource allowlist (--allowed-resources).
    • pkg

      public static ResourceReader pkg()
      A resource reader for package: resources. If this resource reader is present, Pkl code can read resources from within packages with read("package://example.com/foo@1.0.0#/foo.txt"), or using dependency notation with read("@foo/foo.txt") assuming that the Pkl module is within a project that declares a dependency named foo.
    • projectpackage

      public static ResourceReader projectpackage()
    • fromServiceProviders

      public static List<ResourceReader> fromServiceProviders()
      Returns resource readers registered as service providers of type org.pkl.core.resource.ResourceReader.
    • externalProcess

      public static ResourceReader externalProcess(String scheme, ExternalReaderProcess process)
      Returns a reader for external reader resources.

      NOTE: process needs to be closed to avoid resource leaks.

    • externalProcess

      public static ResourceReader externalProcess(String scheme, ExternalReaderProcess process, long evaluatorId)
      Returns a reader for external reader resources.

      NOTE: process needs to be closed to avoid resource leaks.

    • externalResolver

      public static ResourceReader externalResolver(ResourceReaderSpec spec, ExternalResourceResolver resolver)
      Returns a reader for external and client reader resources.