public abstract class ResourceManager
extends java.lang.Object
Provide normalized methods for getting resources
There are two separate mechanisms for getting resources (jar based and file based)
- The jar based resource manager is the standard mechanism and it searches for resources in the binary's jar files. This the only option that should be used in production.
- The file based resource manager can be set as the default if the environment variable OPENXAL_FIND_RESOURCES_IN_ROOT is set to true. The OPENXAL_HOME environment variable must be set to the root of the project. The file based resource manager searches for resources directly on the file system relative to the project. This may be useful in development for IDE's that compile code in real time and do not generate the usual jar files. This option should not be used in production.
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
RESOURCES_FILE_SEARCH_PROPERTY |
Constructor and Description |
---|
ResourceManager() |
Modifier and Type | Method and Description |
---|---|
java.net.URL |
fetchResourceURL(java.lang.Class<?> rootClass,
java.lang.String resourcePath)
Get the URL to the specified resource relative to the specified class
|
abstract java.net.URL |
fetchResourceURL(java.lang.String subdomain,
java.lang.Class<?> rootClass,
java.lang.String resourcePath)
Get the URL to the specified resource relative to the specified class
|
static java.lang.String |
getProjectHomePath()
get the path to the project home based on the "xal.home" property or corresponding "OPENXAL_HOME" environment variable if necessary
|
static java.net.URL |
getResourceURL(java.lang.Class<?> rootClass,
java.lang.String resourcePath)
Get the URL to the specified resource relative to the specified class
|
static java.net.URL |
getResourceURL(java.lang.String subdomain,
java.lang.Class<?> rootClass,
java.lang.String resourcePath)
Get the URL to the specified resource relative to the specified class
|
protected static final java.lang.String RESOURCES_FILE_SEARCH_PROPERTY
public java.net.URL fetchResourceURL(java.lang.Class<?> rootClass, java.lang.String resourcePath)
rootClass
- class at the root of the group (this class must be at the same location as the resources directory in the jar file)path
- to the resource relative to the group's resources directorypublic abstract java.net.URL fetchResourceURL(java.lang.String subdomain, java.lang.Class<?> rootClass, java.lang.String resourcePath)
subdomain
- subdomain under which to search (e.g. for "core" with a subdomain of "test" we must search "core/test")rootClass
- class at the root of the group (this class must be at the same location as the resources directory in the jar file)path
- to the resource relative to the group's resources directorypublic static java.net.URL getResourceURL(java.lang.Class<?> rootClass, java.lang.String resourcePath)
rootClass
- class at the root of the group (this class must be at the same location as the resources directory in the jar file)path
- to the resource relative to the group's resources directorypublic static java.net.URL getResourceURL(java.lang.String subdomain, java.lang.Class<?> rootClass, java.lang.String resourcePath)
subdomain
- subdomain under which to search (e.g. for "core" with a subdomain of "test" we must search "core/test")rootClass
- class at the root of the group (this class must be at the same location as the resources directory in the jar file)path
- to the resource relative to the group's resources directorypublic static java.lang.String getProjectHomePath()