Package dev.getelements.elements.rt
Interface ResourceLoader
- All Superinterfaces:
AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes theResourceLoader
and cleaning up any resources.default Resource
load
(InputStream is) Loads theResource
from theInputStream
in non-verbose mode.load
(InputStream is, boolean verbose) Loads aResource
from the suppliedInputStream
.load
(String moduleName, Attributes attributes, Object... args) Loads theResource
specified by the supplied module name.default Resource
Performs the same operation asload(String, Attributes, Object...)
usingAttributes.EMPTY
as the specifiedAttributes
.default Resource
load
(ReadableByteChannel rbc) Loads theResource
from theReadableByteChannel
in non-verbose mode.load
(ReadableByteChannel rbc, boolean verbose) Loads aResource
from the suppliedReadableByteChannel
.
-
Method Details
-
load
Loads theResource
from theInputStream
in non-verbose mode.- Parameters:
is
- theInputStream
from which to load theResource
- Returns:
- the
Resource
- Throws:
ResourcePersistenceException
-
load
Loads theResource
from theReadableByteChannel
in non-verbose mode.- Parameters:
rbc
- theInputStream
from which to load theResource
- Returns:
- the
Resource
- Throws:
ResourcePersistenceException
-
load
Loads aResource
from the suppliedInputStream
. The contents of theInputStream
should be generated form a call toResource.serialize(OutputStream)
.- Parameters:
is
- theInputStream
from which to load theResource
verbose
- indicates if the resource shoudl be loaded verbosely.- Returns:
- the loaded
Resource
- Throws:
ResourcePersistenceException
- if the resource was corrupted of failed to load for some reason
-
load
Loads aResource
from the suppliedReadableByteChannel
. The contents of theInputStream
should be generated form a call toResource.serialize(OutputStream)
orResource.serialize(WritableByteChannel)
.- Parameters:
rbc
- theInputStream
from which to load theResource
verbose
- indicates if the resource shoudl be loaded verbosely.- Returns:
- the loaded
Resource
- Throws:
ResourcePersistenceException
- if the resource was corrupted of failed to load for some reason
-
load
Performs the same operation asload(String, Attributes, Object...)
usingAttributes.EMPTY
as the specifiedAttributes
.- Throws:
ModuleNotFoundException
-
load
Resource load(String moduleName, Attributes attributes, Object... args) throws ModuleNotFoundException Loads theResource
specified by the supplied module name. The supplied module name is specific to the particular implementation of theResourceLoader
, but should be a unique identifier specifying the unit or module of code to load. Since aResource
can be represented by any number of languages, the string passed is highly specific to the underlying implementation's semantics.- Parameters:
moduleName
- the module nameattributes
-Attributes
assocaited with theResource
args
- various initialization arguments to be passed to the underlyingResource
- Returns:
- the
Resource
instance, never null - Throws:
ModuleNotFoundException
- if the source for theResource
cannot be found.
-
close
void close()Closes theResourceLoader
and cleaning up any resources. Any openResource
instances may be closed, but this is not a guarantee. All resources open should be closed before closing thisResourceLoader
. UsingResource
s after closing this instance, or closing this instance while resources are open should be considered undefined behavior. This also closes the resources which may be associated with thisResourceLoader
. Invoking this method twice on the same object should also be considered undefined behavior.- Specified by:
close
in interfaceAutoCloseable
-