Class ResourceManager
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfetchResourceURL
(Class<?> rootClass, String resourcePath) Get the URL to the specified resource relative to the specified classabstract URL
fetchResourceURL
(String subdomain, Class<?> rootClass, String resourcePath) Get the URL to the specified resource relative to the specified classstatic String
get the path to the project home based on the "xal.home" property or corresponding "OPENXAL_HOME" environment variable if necessarystatic URL
getResourceURL
(Class<?> rootClass, String resourcePath) Get the URL to the specified resource relative to the specified classstatic URL
getResourceURL
(String subdomain, Class<?> rootClass, String resourcePath) Get the URL to the specified resource relative to the specified class
-
Field Details
-
PROJECT_HOME_PROPERTY
root location of the project- See Also:
-
RESOURCES_FILE_SEARCH_PROPERTY
- See Also:
-
-
Constructor Details
-
ResourceManager
public ResourceManager()
-
-
Method Details
-
fetchResourceURL
Get the URL to the specified resource relative to the specified class- Parameters:
rootClass
- class at the root of the group (this class must be at the same location as the resources directory in the jar file)resourcePath
- to the resource relative to the group's resources directory- Returns:
- URL to the resource
-
fetchResourceURL
Get the URL to the specified resource relative to the specified class- Parameters:
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)resourcePath
- to the resource relative to the group's resources directory- Returns:
- URL to the resource
-
getResourceURL
Get the URL to the specified resource relative to the specified class- Parameters:
rootClass
- class at the root of the group (this class must be at the same location as the resources directory in the jar file)resourcePath
- to the resource relative to the group's resources directory- Returns:
- URL to the resource
-
getResourceURL
Get the URL to the specified resource relative to the specified class- Parameters:
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)resourcePath
- to the resource relative to the group's resources directory- Returns:
- URL to the resource
-
getProjectHomePath
get the path to the project home based on the "xal.home" property or corresponding "OPENXAL_HOME" environment variable if necessary
-