Package org.pkl.core.resource
Interface ResourceReader
- All Superinterfaces:
AutoCloseable,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 Summary
Methods inherited from interface org.pkl.core.runtime.ReaderBase
hasElement, hasFragmentPaths, hasHierarchicalUris, isGlobbable, listElements, resolveUri
-
Method Details
-
getUriScheme
String getUriScheme()The URI scheme associated with resources read by this resource reader. -
read
Optional<Object> read(URI uri) throws IOException, URISyntaxException, SecurityManagerException, ExternalReaderProcessException Reads the resource with the given URI. ReturnsOptional.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.
-
close
default void close()Closes this reader, releasing any resources held. See the documentation of factory methods inResourceReadersfor which factories need to be closed.- Specified by:
closein interfaceAutoCloseable
-