|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xwiki.classloader.internal.ResourceLoader
public class ResourceLoader
This class aids in accessing remote resources referred by URLs. The URLs are resolved into resource handles which can be used to access the resources directly and uniformly, regardless of the URL type. The
resource loader is particularly useful when dealing with resources fetched from JAR files. It maintains the cache of
opened JAR files (so that so that subsequent requests for resources coming from the same base Jar file can be handled
efficiently). It fully supports JAR class-path (references from a JAR file to other JAR files) and JAR index (JAR
containing information about content of other JARs). The caching policy of downloaded JAR files can be customized via
the constructor parameter jarHandler; the default policy is to use separate cache per each
ResourceLoader instance.
This class is particularly useful when implementing custom class loaders. It provides bottom-level resource fetching
functionality. By using one of the loader methods which accepts an array of URLs, it is straightforward to implement
class-path searching similar to that of URLClassLoader, with JAR dependencies (Class-Path) properly
resolved and with JAR indexes properly handled.
This class provides two set of methods: get methods that return ResourceHandles (or their
enumerations) and find methods that return URLs (or their enumerations). If the resource is not found, null
(or empty enumeration) is returned. Resource handles represent a connection to the resource and they should be closed
when done processing, just like input streams. In contrast, find methods return URLs that can be used to open
multiple connections to the resource. In typical class loader applications, when a single retrieval is sufficient, it
is preferable to use get methods since they pose slightly smaller communication overhead.
| Constructor Summary | |
|---|---|
ResourceLoader(java.net.URLStreamHandler jarHandler)
Constructs new ResourceLoader with specified JAR file handler which can implement custom JAR caching policy. |
|
| Method Summary | |
|---|---|
java.net.URL |
findResource(java.net.URL[] sources,
java.lang.String name)
Finds resource with given name at the given search path. |
java.net.URL |
findResource(java.net.URL source,
java.lang.String name)
Fined resource with given name at the given source URL. |
java.util.Enumeration<java.net.URL> |
findResources(java.net.URL[] sources,
java.lang.String name)
Finds all resources with given name at the given search path. |
java.util.Enumeration<java.net.URL> |
findResources(java.net.URL source,
java.lang.String name)
Finds all resources with given name at the given source URL. |
edu.emory.mathcs.util.classloader.ResourceHandle |
getResource(java.net.URL[] sources,
java.lang.String name)
Gets resource with given name at the given search path. |
edu.emory.mathcs.util.classloader.ResourceHandle |
getResource(java.net.URL source,
java.lang.String name)
Gets resource with given name at the given source URL. |
java.util.Enumeration<edu.emory.mathcs.util.classloader.ResourceHandle> |
getResources(java.net.URL[] sources,
java.lang.String name)
Gets all resources with given name at the given search path. |
java.util.Enumeration<edu.emory.mathcs.util.classloader.ResourceHandle> |
getResources(java.net.URL source,
java.lang.String name)
Gets all resources with given name at the given source URL. |
protected static boolean |
isDir(java.net.URL url)
Test whether given URL points to a directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResourceLoader(java.net.URLStreamHandler jarHandler)
jarHandler - JAR file handler| Method Detail |
|---|
public edu.emory.mathcs.util.classloader.ResourceHandle getResource(java.net.URL source,
java.lang.String name)
source - the source URLname - the resource name
public edu.emory.mathcs.util.classloader.ResourceHandle getResource(java.net.URL[] sources,
java.lang.String name)
sources - the source URL pathname - the resource name
public java.util.Enumeration<edu.emory.mathcs.util.classloader.ResourceHandle> getResources(java.net.URL source,
java.lang.String name)
The search is lazy, that is, "find next resource" operation is triggered by calling
Enumeration.hasMoreElements().
source - the source URLname - the resource name
public java.util.Enumeration<edu.emory.mathcs.util.classloader.ResourceHandle> getResources(java.net.URL[] sources,
java.lang.String name)
The search is lazy, that is, "find next resource" operation is triggered by calling
Enumeration.hasMoreElements().
sources - the source URL pathname - the resource name
public java.net.URL findResource(java.net.URL source,
java.lang.String name)
source - the source URLname - the resource name
public java.net.URL findResource(java.net.URL[] sources,
java.lang.String name)
sources - the source URL pathname - the resource name
public java.util.Enumeration<java.net.URL> findResources(java.net.URL source,
java.lang.String name)
The search is lazy, that is, "find next resource" operation is triggered by calling
Enumeration.hasMoreElements().
source - the source URLname - the resource name
public java.util.Enumeration<java.net.URL> findResources(java.net.URL[] sources,
java.lang.String name)
The search is lazy, that is, "find next resource" operation is triggered by calling
Enumeration.hasMoreElements().
sources - the source URL pathname - the resource name
protected static boolean isDir(java.net.URL url)
url - the URL to test
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||