net.xoetrope.optional.resources
Class XRemoteClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by net.xoetrope.optional.resources.XRemoteClassLoader
All Implemented Interfaces:
XResourceLoader

public class XRemoteClassLoader
extends java.lang.ClassLoader
implements XResourceLoader

Used to locate project files. It searches for files within the paths specified in the paths array. The paths/URIs can be specified in the startup file as follows:
NumRemoteClassLoaderPaths=2
RemoteClassLoaderPath1=http://localhost:8080/
RemoteClassLoaderPath2=http://localhost:8080/myresources/

Copyright: Copyright (c) Xoetrope Ltd., 1998-2003

$Revision: 2.3 $


Field Summary
protected  java.net.URI[] uri
          the URIs that are searched
 
Constructor Summary
XRemoteClassLoader(XProject project)
          Create a new class loader.
 
Method Summary
 java.lang.Class findClass(java.lang.String className)
          Finds the specified class.
 java.lang.Class findClass(java.lang.String className, boolean resolveIt)
          Overrides the method from ClassLoader.
 java.net.URL findResource(java.lang.String fileName)
          Overrides the Classloader method and searches for the resource file specifies by the parameter fileName.
 java.io.InputStream getResourceAsStream(java.lang.String fileName)
          Overrides the Classloader method and searches for the resource file specifies by the parameter fileName.
 boolean setSources(java.lang.String[] projectUris)
          Set the URIs for loading files
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uri

protected java.net.URI[] uri
the URIs that are searched

Constructor Detail

XRemoteClassLoader

public XRemoteClassLoader(XProject project)
Create a new class loader. Initially no search path is set.

Parameters:
the - owner project
Method Detail

setSources

public boolean setSources(java.lang.String[] projectUris)
Set the URIs for loading files

Specified by:
setSources in interface XResourceLoader
Parameters:
projectUris - The String array of URLs for inclusion in the search.
Returns:
true on success, false if there were problems.

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String fileName)
Overrides the Classloader method and searches for the resource file specifies by the parameter fileName.

Overrides:
getResourceAsStream in class java.lang.ClassLoader
Parameters:
fileName - The name of the file to be found.
Returns:
An InputStream created by from the filename if found or null if not found.

findResource

public java.net.URL findResource(java.lang.String fileName)
Overrides the Classloader method and searches for the resource file specifies by the parameter fileName.

Overrides:
findResource in class java.lang.ClassLoader
Parameters:
fileName - The name of the file to be found.
Returns:
A URL from the filename if found or null if not found.

findClass

public java.lang.Class findClass(java.lang.String className)
                          throws java.lang.ClassNotFoundException
Finds the specified class. This method should be overridden by class loader implementations that follow the new delegation model for loading classes, and will be called by the loadClass method after checking the parent class loader for the requested class. The default implementation throws ClassNotFoundException.

Overrides:
findClass in class java.lang.ClassLoader
Parameters:
className - the class to locate
Returns:
the resulting Class object
Throws:
java.lang.ClassNotFoundException - if the class could not be found

findClass

public java.lang.Class findClass(java.lang.String className,
                                 boolean resolveIt)
                          throws java.lang.ClassNotFoundException
Overrides the method from ClassLoader. This method is called auotmatically if the system classloader cannot find the class it is looking for. We then have the chance to find, load and return the class.

Parameters:
className - The name of the class we are being asked to find
resolveIt - Simply forward the value passed in
Returns:
The newly created Class
Throws:
java.lang.ClassNotFoundException - pronlems...