org.jini.rio.boot
Class CommonClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.jini.rio.boot.CommonClassLoader
All Implemented Interfaces:
ComponentLoader

public class CommonClassLoader
extends URLClassLoader
implements ComponentLoader

The CommonClassLoader implements ComponentLoader interface and is created by the RioServiceDescriptor or RioActivatableServiceDescriptor when starting a Rio service and contains common declared platform JARs to be made available to its children.

The CommonClassLoader enables a platform oriented framework conducive towards creating a layered product. The resulting capabilities allow the declaration of JARs that are added to the CommonClassLoader, making the classes accessible by all ClassLoader instances which delegate to the CommonClassLoader. In this fashion a platform can be declared, initialized and made available.

The ClassLoader hierarchy when starting a Rio service is as follows :

          AppCL
            |
    CommonClassLoader
            +
            |
    +-------+-------+----...---+
    |               |          |
  Service-1CL   Service-2CL  Service-nCL


Method Summary
 void addCommonJARs(URL[] jars)
          Add common JARs
 void addComponent(String name, URL[] urls)
          Registers a class name, and the code source which is used as the search path to load the class.
static CommonClassLoader getInstance()
          Get an instance of the CommonCLassLoader
 URL[] getURLs()
          Override getURLs to ensure when an Object is marshalled its annotation is correct
 Object load(String name)
          Creates an Object which has been added to the ComponentLoader using the addSystemComponent method, or is in the classpath of the ComponentLoader.
 boolean testComponentExistence(String name)
          Test whether a named component (Class) exists.
 boolean testResourceExistence(String name)
          Test whether a named resource exists.
 String toString()
          Returns a string representation of this class loader.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, 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, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static CommonClassLoader getInstance()
Get an instance of the CommonCLassLoader

Returns:
The CommonClassLoader

getURLs

public URL[] getURLs()
Override getURLs to ensure when an Object is marshalled its annotation is correct

Overrides:
getURLs in class URLClassLoader
Returns:
Array of URLs

testComponentExistence

public boolean testComponentExistence(String name)
Description copied from interface: ComponentLoader
Test whether a named component (Class) exists.

Specified by:
testComponentExistence in interface ComponentLoader
Parameters:
name - The component name
Returns:
true If the requested component can be located, false otherwise.
See Also:
ComponentLoader.testComponentExistence(java.lang.String)

addCommonJARs

public void addCommonJARs(URL[] jars)
Add common JARs

Parameters:
jars - Array of URLs

testResourceExistence

public boolean testResourceExistence(String name)
Description copied from interface: ComponentLoader
Test whether a named resource exists. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a '/ '-separated path name that identifies the resource.

Specified by:
testResourceExistence in interface ComponentLoader
Parameters:
name - The resource name
Returns:
true If the requested resource can be located, false otherwise.
See Also:
ComponentLoader.testResourceExistence(java.lang.String)

addComponent

public void addComponent(String name,
                         URL[] urls)
Description copied from interface: ComponentLoader
Registers a class name, and the code source which is used as the search path to load the class.

Specified by:
addComponent in interface ComponentLoader
Parameters:
name - The name of the class
urls - Codebase for the class identified by the name parameter
See Also:
ComponentLoader.addComponent(java.lang.String, java.net.URL[])

load

public Object load(String name)
            throws ClassNotFoundException,
                   IllegalAccessException,
                   InstantiationException
Description copied from interface: ComponentLoader
Creates an Object which has been added to the ComponentLoader using the addSystemComponent method, or is in the classpath of the ComponentLoader. The Object is loaded from the registered code source.

Specified by:
load in interface ComponentLoader
Parameters:
name - The name of the class. The resulting class will be loaded and a new instance of the class created using a zero-arg contructor.
Throws:
ClassNotFoundException - - If the class cannot be located by the class loader or it has not been registered
IllegalAccessException - - If the Class or its nullary constructor is not accessible.
InstantiationException - - If this Class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
See Also:
ComponentLoader.load(java.lang.String)

toString

public String toString()
Returns a string representation of this class loader.

Overrides:
toString in class Object


Copyright (c) 2005 Sun Microsystems, Inc.
Copyright (c) 2006 GigaSpaces Technologies, Inc.
All Rights Reserved.