public final class ClasspathResource
extends java.lang.Object
This class searches for content entries in all META-INF/MANIFEST.MF files. It will find files with a given Content-Type: attribute. This allows to add arbitrary resources by content-type just by creating a JAR wrapper and adding them to the classpath.
Example:
Name: test.txt Content-Type: text/plain
Modifier and Type | Field and Description |
---|---|
private static ClasspathResource |
classpathResource |
private static java.lang.String |
CONTENT_TYPE_KEY |
private java.util.Map |
contentMappings
Actual Type: Map<String,List<URL>>.
|
private static java.lang.String |
MANIFEST_PATH |
Modifier | Constructor and Description |
---|---|
private |
ClasspathResource() |
Modifier and Type | Method and Description |
---|---|
private void |
addToMapping(java.lang.String contentType,
java.lang.String name,
java.lang.ClassLoader classLoader) |
private java.util.Set |
getClassLoadersForResources() |
static ClasspathResource |
getInstance()
Retrieve the singleton instance of this class.
|
java.util.List |
listResourcesOfMimeType(java.lang.String mimeType)
Retrieve a list of resources known to have the given mime-type.
|
private void |
loadManifests() |
private final java.util.Map contentMappings
private static final java.lang.String MANIFEST_PATH
private static final java.lang.String CONTENT_TYPE_KEY
private static ClasspathResource classpathResource
public static ClasspathResource getInstance()
private java.util.Set getClassLoadersForResources()
private void loadManifests()
private void addToMapping(java.lang.String contentType, java.lang.String name, java.lang.ClassLoader classLoader)
public java.util.List listResourcesOfMimeType(java.lang.String mimeType)
mimeType
- the mime-type to search for.