j3d.org Code

org.j3d.util
Class DynamicClassLoader

java.lang.Object
  extended by org.j3d.util.DynamicClassLoader

public class DynamicClassLoader
extends java.lang.Object

A generalised class used to dynamically load other classes according to a preset set of rules.

The class loader uses the CLASSPATH setting to locate and load a given class. If the appropriate methods are called, it will attempt to confirm that the class conforms to a specific interface or base class before actually instantiating that class. Various options are provided for this and the loader automatically checks and issues the appropriate errors.

Internationalisation Resource Names

Version:
$Revision: 1.3 $
Author:
Justin Couch

Method Summary
static java.lang.Object loadBasicClass(java.lang.String name)
          Load the named class with no checking of the background.
static java.lang.Object loadCheckedClass(java.lang.String name, java.lang.Class base)
          Load the class that has the given class as a super class.
static java.lang.Object loadCheckedClass(java.lang.String name, java.lang.String base)
          Load the class that has the given class as a super class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadBasicClass

public static java.lang.Object loadBasicClass(java.lang.String name)
                                       throws java.lang.ClassNotFoundException,
                                              java.io.InvalidClassException
Load the named class with no checking of the background. The limitation to the loading and instantiation process is that the class must have a public default constructor. As this method does not take any arguments, constructors that do require parameters cannot be called.

Parameters:
name - The fully qualified name of the class to be loaded
Returns:
An instance of the named class if it could be found.
Throws:
java.lang.NullPointerException - The class name supplied is null or zero length
java.lang.ClassNotFoundException - We couldn't locate the class anywhere
java.io.InvalidClassException - The class could not be instantiated either due to internal errors or no default constructor

loadCheckedClass

public static java.lang.Object loadCheckedClass(java.lang.String name,
                                                java.lang.String base)
                                         throws java.lang.ClassNotFoundException,
                                                java.io.InvalidClassException
Load the class that has the given class as a super class. This will check for both the interface and derived class being of the given type.

Parameters:
name - The fully qualified name of the class to be loaded
base - The fully qualified name of the base class to be checked against
Returns:
An instance of the named class if it could be found.
Throws:
java.lang.NullPointerException - The class name or base class name supplied is null or zero length
java.lang.ClassNotFoundException - We couldn't locate the class anywhere
java.io.InvalidClassException - The class could not be instantiated either due to internal errors or no default constructor

loadCheckedClass

public static java.lang.Object loadCheckedClass(java.lang.String name,
                                                java.lang.Class base)
                                         throws java.lang.ClassNotFoundException,
                                                java.io.InvalidClassException
Load the class that has the given class as a super class. This will check for both the interface and derived class being of the given type.

Parameters:
name - The fully qualified name of the class to be loaded
base - The fully qualified name of the base class to be checked against
Returns:
An instance of the named class if it could be found.
Throws:
java.lang.NullPointerException - The class name or base class name supplied is null or zero length
java.lang.ClassNotFoundException - We couldn't locate the class anywhere
java.io.InvalidClassException - The class could not be instantiated either due to internal errors or no default constructor

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org