Class ModuleResource
- All Implemented Interfaces:
- InputStreamSource,- Resource
Resource implementation for Module resolution,
 performing getInputStream() access via Module.getResourceAsStream(java.lang.String).
 Alternatively, consider accessing resources in a module path layout via
 ClassPathResource for exported resources, or specifically relative to
 a Class via 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.
- Since:
- 6.1
- Author:
- Juergen Hoeller, Sam Brannen
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionModuleResource(Module module, String path) Create a newModuleResourcefor the givenModuleand the given resource path.
- 
Method SummaryModifier and TypeMethodDescriptioncreateRelative(String relativePath) This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.booleanThis implementation compares description strings.Return a description for this resource, to be used for error output when working with the resource.This implementation always returnsnull, assuming that this resource type does not have a filename.Return anInputStreamfor the content of an underlying resource.final ModuleReturn theModulefor this resource.final StringgetPath()Return the path for this resource.inthashCode()This implementation returns the description's hash code.Methods inherited from class org.springframework.core.io.AbstractResourcecontentLength, exists, getFile, getFileForLastModifiedCheck, getURI, getURL, isFile, isOpen, isReadable, lastModified, readableChannel, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.core.io.ResourcegetContentAsByteArray, getContentAsString
- 
Constructor Details- 
ModuleResourceCreate a newModuleResourcefor the givenModuleand the given resource path.- Parameters:
- module- the runtime module to search within
- path- the resource path within the module
 
 
- 
- 
Method Details- 
getModuleReturn theModulefor this resource.
- 
getPathReturn the path for this resource.
- 
getInputStreamDescription copied from interface:InputStreamSourceReturn anInputStreamfor the content of an underlying resource.It is usually expected that every such 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 getInputStream()call returns a fresh stream.- Returns:
- the input stream for the underlying resource (must not be null)
- Throws:
- FileNotFoundException- if the underlying resource does not exist
- IOException- if the content stream could not be opened
- See Also:
 
- 
createRelativeDescription copied from class:AbstractResourceThis implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.- Specified by:
- createRelativein interface- Resource
- Overrides:
- createRelativein class- AbstractResource
- Parameters:
- relativePath- the relative path (relative to this resource)
- Returns:
- the resource handle for the relative resource
 
- 
getFilenameDescription copied from class:AbstractResourceThis implementation always returnsnull, assuming that this resource type does not have a filename.- Specified by:
- getFilenamein interface- Resource
- Overrides:
- getFilenamein class- AbstractResource
 
- 
getDescriptionDescription copied from interface:ResourceReturn 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 toStringmethod.- See Also:
 
- 
equalsDescription copied from class:AbstractResourceThis implementation compares description strings.- Overrides:
- equalsin class- AbstractResource
- See Also:
 
- 
hashCodepublic int hashCode()Description copied from class:AbstractResourceThis implementation returns the description's hash code.- Overrides:
- hashCodein class- AbstractResource
- See Also:
 
 
-