Resource implementation for java.lang.Module resolution,
performing getInputStream() access via Module#getResourceAsStream.
Alternatively, consider accessing resources in a module path layout via
ClassPathResource for exported resources, or specifically relative to
a Class via ClassPathResource#ClassPathResource(String, Class)
for local resolution within the containing module of that specific class.
In common scenarios, module resources will simply be transparently visible as
classpath resources and therefore do not need any special treatment at all.
Module#getResourceAsStream, ClassPathResource
| Access | Constructor and Description |
|---|---|
| public | ModuleResource(Module
the runtime module to search within module, String the resource path within the module path)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public Resource | createRelative(String
the relative path (relative to this resource) relativePath)Overrides org. Implements org. This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource. |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides org. This implementation compares description strings. |
| public String | getDescription()
Implements org. Return a description for this resource, to be used for error output when working with the resource. |
| public String | getFilename()
Overrides org. Implements org. This implementation always returns |
| public InputStream | getInputStream()
Implements org. Return an |
| public final Module | |
| public final String | |
| public int | hashCode()
Overrides org. This implementation returns the description's hash code. |
| module | back to summary |
|---|---|
| private final Module module | |
| path | back to summary |
|---|---|
| private final String path | |
| ModuleResource | back to summary |
|---|---|
| public ModuleResource(Module module, String path) Create a new | |
| createRelative | back to summary |
|---|---|
| public Resource createRelative(String relativePath) Overrides org. Implements org. Doc from org. This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides org. Doc from org. This implementation compares description strings.
| |
| getDescription | back to summary |
|---|---|
| public String getDescription() Implements org. Doc from org. Return a description for this resource, to be used for error output when working with the resource. Implementations are also encouraged to return this value
from their
| |
| getFilename | back to summary |
|---|---|
| public String getFilename() Overrides org. Implements org. Doc from org. This implementation always returns | |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws IOException Implements org. Doc from org. Return an It is expected that each call creates a fresh stream. This requirement is particularly important when you consider an API such
as JavaMail, which needs to be able to read the stream multiple times when
creating mail attachments. For such a use case, it is required
that each
| |
| getModule | back to summary |
|---|---|
| public final Module getModule() Return the | |
| getPath | back to summary |
|---|---|
| public final String getPath() Return the path for this resource. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. Doc from org. This implementation returns the description's hash code.
| |