Class ResourceReaders


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

      • 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).
      • 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​(java.lang.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.
      • fromServiceProviders

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