Tuscany Common

org.apache.tuscany.common.resource.impl
Class ResourceLoaderImpl

java.lang.Object
  extended by org.apache.tuscany.common.resource.impl.ResourceLoaderImpl
All Implemented Interfaces:
ResourceLoader

public class ResourceLoaderImpl
extends java.lang.Object
implements ResourceLoader

Default implementation of the ResourceLoader interface

Version:
$Rev: 369102 $ $Date: 2006-01-14 13:48:56 -0800 (Sat, 14 Jan 2006) $

Constructor Summary
ResourceLoaderImpl(java.lang.ClassLoader classLoader)
          Constructs a new ResourceLoaderImpl to wrap a ClassLoader.
 
Method Summary
 java.lang.Class<?> addClass(byte[] bytes)
          Converts an array of bytes into a Class.
 boolean equals(java.lang.Object obj)
           
 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.
 int hashCode()
           
 java.lang.Class<?> loadClass(java.lang.String name)
          Loads the class with the specified binary name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLoaderImpl

public ResourceLoaderImpl(java.lang.ClassLoader classLoader)
Constructs a new ResourceLoaderImpl to wrap a ClassLoader.

Parameters:
classLoader - the classloader to wrap
Method Detail

getClassLoader

public java.lang.ClassLoader getClassLoader()
                                     throws java.lang.IllegalStateException
Description copied from interface: ResourceLoader
Returns the underlying classloader this loader is wrapping.

Specified by:
getClassLoader in interface ResourceLoader
Returns:
the underlying classloader this loader is wrapping
Throws:
java.lang.IllegalStateException

getParents

public java.util.List<ResourceLoader> getParents()
Description copied from interface: ResourceLoader
Returns the parent resource loaders.

Specified by:
getParents in interface ResourceLoader
Returns:
resource loaders that are parents to this one

loadClass

public java.lang.Class<?> loadClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Description copied from interface: ResourceLoader
Loads the class with the specified binary name.

Specified by:
loadClass in interface ResourceLoader
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

public java.lang.Class<?> addClass(byte[] bytes)
Description copied from interface: ResourceLoader
Converts an array of bytes into a Class.

Specified by:
addClass in interface ResourceLoader
Parameters:
bytes - the bytecode for the class; must match the class file format
Returns:
a Class defined from the supplied bytecode

getResources

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

Specified by:
getResources in interface ResourceLoader
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

getResource

public java.net.URL getResource(java.lang.String name)
Description copied from interface: ResourceLoader
Finds the first resource with the given name.

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

Specified by:
getResource in interface ResourceLoader
Parameters:
name - the resource name
Returns:
a URL that can be used to read the resource, or null if no resource could be found

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

Tuscany Common

-