com.jme.util.resource
Class ClasspathResourceLocator
java.lang.Object
com.jme.util.resource.ClasspathResourceLocator
- All Implemented Interfaces:
- ResourceLocator
public class ClasspathResourceLocator
- extends java.lang.Object
- implements ResourceLocator
A conservative ResourceLocator implementation that only resolves Classpath
resources with absolute resource name paths.
Lookups succeed only for resources requested with absolute paths, and there
is no recursion (hence it is conservative).
There is no benefit of ClasspathResourceLocator.locateResource(String)
over Class.getClassLoader().getResource(), except that this class
implements ResourceLocator, and you can therefore use it to control resource
loading of utility classes that use ResourceLocatorTool to flexibly load
resources.
- Author:
- Blaine Simpson (blaine dot simpson at admc dot com)
- See Also:
ResourceLocator
Method Summary |
java.lang.ClassLoader |
getResourceClassLoader()
|
java.net.URL |
locateResource(java.lang.String resourceName)
Locates a resource according to the strategy of the resource locator implementation (subclass). |
void |
setResourceClassLoader(java.lang.ClassLoader resourceClassLoader)
For apps with classloader tree customization, or which run under an
infrastructure which customizes the classloader hierarchy, this method
lets you specify the exact ClassLoader to use to retrieve resource URLs. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
resourceClassLoader
protected java.lang.ClassLoader resourceClassLoader
ClasspathResourceLocator
public ClasspathResourceLocator()
getResourceClassLoader
public java.lang.ClassLoader getResourceClassLoader()
- See Also:
setResourceClassLoader(ClassLoader)
setResourceClassLoader
public void setResourceClassLoader(java.lang.ClassLoader resourceClassLoader)
- For apps with classloader tree customization, or which run under an
infrastructure which customizes the classloader hierarchy, this method
lets you specify the exact ClassLoader to use to retrieve resource URLs.
locateResource
public java.net.URL locateResource(java.lang.String resourceName)
- Description copied from interface:
ResourceLocator
- Locates a resource according to the strategy of the resource locator implementation (subclass).
- Specified by:
locateResource
in interface ResourceLocator
- Parameters:
resourceName
- the name of the resource to locate; it this is a path it must be slash separated (no backslashes)
- Returns:
- a URL for the resource, null if the resource was not found
- See Also:
SimpleResourceLocator
,
MultiFormatResourceLocator