org.enhydra.xml.xmlc.deferredparsing
Class ResourceLoaderImpl

java.lang.Object
  |
  +--org.enhydra.xml.xmlc.deferredparsing.ResourceLoaderImpl
All Implemented Interfaces:
ResourceLoader
Direct Known Subclasses:
ServletResourceLoaderImpl

public class ResourceLoaderImpl
extends Object
implements ResourceLoader

A resource loader implementation that looks up candidatePaths from configured resource dirs with fall back to the classpath.

Since:
2.3.2
Author:
Jacob Kjome

Field Summary
protected  XMLCDeferredParsingFactory fFactory
           
 
Constructor Summary
ResourceLoaderImpl(XMLCDeferredParsingFactory factory)
           
 
Method Summary
protected  URL getPathURLFromClasspath(String candidatePath)
           
protected  URL getPathURLFromResourceDir(String candidatePath)
           
protected  URL getPathURLFromResourceDirOrClasspath(String[] candidatePaths)
          Iterates over candidatePaths, where each resource is first searched for in resource dirs with fallback to the classpath.
 URL getResource(String[] candidatePaths)
          Delegates to getPathURLFromResourceDirOrClasspath(String[])
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fFactory

protected final XMLCDeferredParsingFactory fFactory
Constructor Detail

ResourceLoaderImpl

public ResourceLoaderImpl(XMLCDeferredParsingFactory factory)
Parameters:
factory - the XMLC deferred parsing factory
Method Detail

getResource

public URL getResource(String[] candidatePaths)
Delegates to getPathURLFromResourceDirOrClasspath(String[])
Specified by:
getResource in interface ResourceLoader
Parameters:
candidatePaths - an array of candidate paths from which to load a resource in order of preference
Returns:
a URL corresponding to one of the candidatePaths or null if not found

getPathURLFromResourceDirOrClasspath

protected URL getPathURLFromResourceDirOrClasspath(String[] candidatePaths)
Iterates over candidatePaths, where each resource is first searched for in resource dirs with fallback to the classpath. This allows one to make files available in the classloader, for fallback, while maintaining the capability of overriding classloader-provided files by placing equivalent files in configured resource dirs. This makes for simple development and flexible deployment.

Paths are expected to be relative, i.e., no leading slash, with directory/package names separated by forward slashes regardless of operating system platform.

Parameters:
candidatePaths - an array of candidate paths from which to load a resource in order of preference
Returns:
a URL corresponding to one of the candidatePaths or null if not found
See Also:
getPathURLFromResourceDir(String), getPathURLFromClasspath(String)

getPathURLFromResourceDir

protected URL getPathURLFromResourceDir(String candidatePath)
Parameters:
candidatePath - a candidate path from which to load a resource
Returns:
a URL corresponding the candidatePath or null if not found
See Also:
XMLCDeferredParsingFactory.getPathURLFromResourceDir(String)

getPathURLFromClasspath

protected URL getPathURLFromClasspath(String candidatePath)
Parameters:
candidatePath - a candidate path from which to load a resource
Returns:
a URL corresponding the candidatePath or null if not found
See Also:
XMLCDeferredParsingFactory.getPathURLFromClasspath(String)


Copyright © 1999-2007 enhydra.org (Mark Diekhans, David Li, Richard Kunze, Jacob Kjome). All Rights reserved.