Package org.pkl.core.module
Interface ModuleKey
- All Superinterfaces:
ReaderBase
- All Known Implementing Classes:
ModuleKeys.ExternalResolver,ModuleKeys.ProjectPackage
SPI for identifying, resolving, caching, and resolving a Pkl module. Standard implementations can
be created using
ModuleKeys.-
Method Summary
Modifier and TypeMethodDescriptionThe relative file cache path for this module, ornullif this module should not be cached on the file system.getUri()Returns the absolute URI of this module.default booleanisCached()Tells if this module should be cached in memory.default booleanisLocal()Tells if the modules represented by this module key is local to the environment.resolve(SecurityManager securityManager) Resolves this module to a canonical form suitable for loading and caching the module.default URIresolveUri(URI uri) Methods inherited from interface org.pkl.core.runtime.ReaderBase
hasElement, hasFragmentPaths, hasHierarchicalUris, isGlobbable, listElements, resolveUri
-
Method Details
-
getUri
URI getUri()Returns the absolute URI of this module. This URI is used for identifying the module in user facing messages, for example stack traces. Typically, this URI contains all information necessary for resolving and loading the module. -
resolve
ResolvedModuleKey resolve(SecurityManager securityManager) throws IOException, SecurityManagerException Resolves this module to a canonical form suitable for loading and caching the module. This may involve I/O. ThrowsFileNotFoundExceptionif this module cannot be found.- Throws:
IOExceptionSecurityManagerException
-
resolveUri
- Throws:
IOExceptionSecurityManagerException
-
isCached
default boolean isCached()Tells if this module should be cached in memory.Caching a module means caching its entire evaluation state, not just its resolved URI or source code.
Turning off module caching is mostly useful for synthetic modules that cannot be referenced (imported) from other modules. An example for this is a module representing code typed in a REPL.
-
isLocal
default boolean isLocal()Tells if the modules represented by this module key is local to the environment.A module that is local, and also
ReaderBase.hasHierarchicalUris(), supports triple-dot imports.As a best practice, a module key should be considered local if its source can be loaded in a low latency environment (for example, from disk or from memory). On the flip-side, a module loaded from a remove server should not be considered local.
-
getFileCacheLocation
The relative file cache path for this module, ornullif this module should not be cached on the file system.
-