Tuscany Common

org.apache.tuscany.common.resource
Interface ResourceLoader

All Known Implementing Classes:
ResourceLoaderImpl

public interface ResourceLoader

Interface which abstracts the implementation of something that is able to load resources (such as a ClassLoader). All Tuscany code should use this API rather than a ClassLoader directly in order to reduce the risk of memory leaks due to ClassLoader references.

Version:
$Rev: 379878 $ $Date: 2006-02-22 12:45:50 -0800 (Wed, 22 Feb 2006) $

Method Summary
 java.lang.Class<?> addClass(byte[] bytes)
          Converts an array of bytes into a Class.
 java.lang.ClassLoader getClassLoader()
          Returns the underlying classloader this loader is wrapping.
 java.util.List<ResourceLoader> getParents()
          Returns the parent resource loaders.
 java.net.URL getResource(java.lang.String name)
          Finds the first resource with the given name.
 java.util.Iterator<java.net.URL> getResources(java.lang.String name)
          Find resources with the given name that are available from this ResourceLoader or any of its parents.
 java.lang.Class<?> loadClass(java.lang.String name)
          Loads the class with the specified binary name.
 

Method Detail

getParents

java.util.List<ResourceLoader> getParents()
Returns the parent resource loaders.

Returns:
resource loaders that are parents to this one

loadClass

java.lang.Class<?> loadClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Loads the class with the specified binary name.

Parameters:
name - the binary name of the class
Returns:
the resulting Class object
Throws:
java.lang.ClassNotFoundException - if the class was not found
See Also:
ClassLoader.loadClass(String)

addClass

java.lang.Class<?> addClass(byte[] bytes)
Converts an array of bytes into a Class.

Parameters:
bytes - the bytecode for the class; must match the class file format
Returns:
a Class defined from the supplied bytecode

getResource

java.net.URL getResource(java.lang.String name)
Finds the first resource with the given name.

Each parent is searched first (in the order returned by getParents()) and the first resource located is found. If no parent returns a resource then the first resource defined by this ResourceLoader is returned.

Parameters:
name - the resource name
Returns:
a URL that can be used to read the resource, or null if no resource could be found

getResources

java.util.Iterator<java.net.URL> getResources(java.lang.String name)
                                              throws java.io.IOException
Find resources with the given name that are available from this ResourceLoader or any of its parents.

Parameters:
name - the resource name
Returns:
an Iterator of URL objects for the resource
Throws:
java.io.IOException - if there was a problem locating the resources

getClassLoader

java.lang.ClassLoader getClassLoader()
Returns the underlying classloader this loader is wrapping.

Returns:
the underlying classloader this loader is wrapping

Tuscany Common

-