JXTA

net.jxta.impl.loader
Class RefJxtaLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by net.jxta.platform.JxtaLoader
                  extended by net.jxta.impl.loader.RefJxtaLoader

public class RefJxtaLoader
extends JxtaLoader

This class is the reference implementation of the JxtaLoader.


Constructor Summary
RefJxtaLoader(URL[] urls, ClassLoader parent, CompatibilityEquater equator)
          Construct a new loader for the specified URLS with the specified parent loader and specified compatibility equator.
RefJxtaLoader(URL[] urls, CompatibilityEquater equator)
          Construct a new loader for the specified URLS with the default parent loader and specified compatibility equator.
 
Method Summary
 Class<? extends Module> defineClass(ModuleImplAdvertisement impl)
          Defines a new class from a Module Impl Advertisement.
 Class<? extends Module> findClass(ModuleSpecID spec)
          Finds and loads the class with the specified spec ID from the URL search path.
 ModuleImplAdvertisement findModuleImplAdvertisement(Class clazz)
          Finds the ModuleImplAdvertisement for the associated class in the context of this ClassLoader.
 ModuleImplAdvertisement findModuleImplAdvertisement(ModuleSpecID msid)
          Finds the ModuleImplAdvertisement for the associated class in the context of this ClassLoader.
 Class<? extends Module> loadClass(ModuleSpecID spec)
          Loads the class with the specified spec ID from the URL search path.
 Class<? extends Module> loadClass(String name, boolean resolve)
          
 Class<? extends Module> loadClass(String name, URL url)
          Loads a class
protected  Class<? extends Module> loadClass(String name, URL url, boolean resolve)
          Make a stub for a version that uses URL, so that code that load services can be written properly, even if it works only for classes that do not need download.
 String toString()
          
 
Methods inherited from class net.jxta.platform.JxtaLoader
addURL
 
Methods inherited from class java.net.URLClassLoader
definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RefJxtaLoader

public RefJxtaLoader(URL[] urls,
                     CompatibilityEquater equator)
Construct a new loader for the specified URLS with the default parent loader and specified compatibility equator.

Parameters:
urls - The URLs from which to load classes and resources.
equator - The equator to use in comparing compatibility statements.

RefJxtaLoader

public RefJxtaLoader(URL[] urls,
                     ClassLoader parent,
                     CompatibilityEquater equator)
Construct a new loader for the specified URLS with the specified parent loader and specified compatibility equator.

Parameters:
urls - The URLs from which to load classes and resources.
parent - The parent class loader for delegation.
equator - The equator to use in comparing compatibility statements.
Method Detail

loadClass

protected Class<? extends Module> loadClass(String name,
                                            URL url,
                                            boolean resolve)
                                     throws ClassNotFoundException
Make a stub for a version that uses URL, so that code that load services can be written properly, even if it works only for classes that do not need download.

Parameters:
name - The class name.
url - The location of the class.
resolve - If true then resolve the class.
Returns:
the class
Throws:
ClassNotFoundException - if class not found

loadClass

public Class<? extends Module> loadClass(String name,
                                         boolean resolve)
                                  throws ClassNotFoundException

Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException

findClass

public Class<? extends Module> findClass(ModuleSpecID spec)
                                  throws ClassNotFoundException
Finds and loads the class with the specified spec ID from the URL search path. Any URLs referring to JAR files are loaded and opened as needed until the class is found.

Specified by:
findClass in class JxtaLoader
Parameters:
spec - the specid of the class to load.
Returns:
the resulting class.
Throws:
ClassNotFoundException - if the class could not be found.

loadClass

public Class<? extends Module> loadClass(ModuleSpecID spec)
                                  throws ClassNotFoundException
Loads the class with the specified spec ID from the URL search path.

Specified by:
loadClass in class JxtaLoader
Parameters:
spec - the specid of the class to load.
Returns:
the resulting class.
Throws:
ClassNotFoundException - if the class could not be found.

loadClass

public Class<? extends Module> loadClass(String name,
                                         URL url)
                                  throws ClassNotFoundException
Loads a class

Parameters:
name - class name
url - url to class
Returns:
the Class
Throws:
ClassNotFoundException - if class not found

defineClass

public Class<? extends Module> defineClass(ModuleImplAdvertisement impl)
                                    throws ClassFormatError
Defines a new class from a Module Impl Advertisement.

Specified by:
defineClass in class JxtaLoader
Parameters:
impl - The moduleImplAdvertisement containing the class specification
Returns:
The Class object that was created from the specified class data.
Throws:
ClassFormatError

findModuleImplAdvertisement

public ModuleImplAdvertisement findModuleImplAdvertisement(Class clazz)
Finds the ModuleImplAdvertisement for the associated class in the context of this ClassLoader.

Specified by:
findModuleImplAdvertisement in class JxtaLoader
Parameters:
clazz - The class who's ModuleImplAdvertisement is desired.
Returns:
The matching ModuleImplAdvertisement otherwise null if there is no known association.

findModuleImplAdvertisement

public ModuleImplAdvertisement findModuleImplAdvertisement(ModuleSpecID msid)
Finds the ModuleImplAdvertisement for the associated class in the context of this ClassLoader.

Specified by:
findModuleImplAdvertisement in class JxtaLoader
Parameters:
msid - The module spec id who's ModuleImplAdvertisement is desired.
Returns:
The matching ModuleImplAdvertisement otherwise null if there is no known association.

toString

public String toString()

Overrides:
toString in class Object

JXSE