org.apache.cayenne.conf
Class ClasspathResourceFinder

java.lang.Object
  extended by org.apache.cayenne.conf.ClasspathResourceFinder
All Implemented Interfaces:
ResourceFinder

public class ClasspathResourceFinder
extends Object
implements ResourceFinder

A ResourceFinder that looks up resources in the classpath.

Since:
3.0

Field Summary
protected  ClassLoader classLoader
           
protected  Collection<String> rootPaths
           
 
Constructor Summary
ClasspathResourceFinder()
           
 
Method Summary
 void addRootPath(String path)
          Adds a base path to be used for resource lookup.
 ClassLoader getClassLoader()
          Returns ClassLoader override initialized via setClassLoader(ClassLoader).
 URL getResource(String name)
          Returns a single resource matching a given name.
protected  ClassLoader getResourceClassLoader()
          Returns a non-null ClassLoader that should be used to locate resources.
 Collection<URL> getResources(String name)
          Returns a collection of resource URLs with a given name found in the environment using some lookup strategy.
 void setClassLoader(ClassLoader classLoader)
          Sets an overriding ClassLoader for this resource finder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classLoader

protected ClassLoader classLoader

rootPaths

protected Collection<String> rootPaths
Constructor Detail

ClasspathResourceFinder

public ClasspathResourceFinder()
Method Detail

getResource

public URL getResource(String name)
Description copied from interface: ResourceFinder
Returns a single resource matching a given name. If more than one resource matches the name, it is implementation specific which one will be returned.

Specified by:
getResource in interface ResourceFinder

getResources

public Collection<URL> getResources(String name)
Description copied from interface: ResourceFinder
Returns a collection of resource URLs with a given name found in the environment using some lookup strategy.

Specified by:
getResources in interface ResourceFinder

addRootPath

public void addRootPath(String path)
Adds a base path to be used for resource lookup. In the context of ClasspathResourceFinder, a "path" corresponds to a package name, only separated by "/" instead of ".". Default root path is empty String. This method allows to add more lookup roots.


getClassLoader

public ClassLoader getClassLoader()
Returns ClassLoader override initialized via setClassLoader(ClassLoader). Null by default.


setClassLoader

public void setClassLoader(ClassLoader classLoader)
Sets an overriding ClassLoader for this resource finder. Setting it is only needed if the default thread class loader is not appropriate for looking up the resources.


getResourceClassLoader

protected ClassLoader getResourceClassLoader()
Returns a non-null ClassLoader that should be used to locate resources. The lookup following order is used to find it: explicitly set class loader, current thread class loader, this class class loader, system class loader.



Copyright © 2001-2011 Apache Cayenne. All Rights Reserved.