org.omegahat.Environment.System
Class DynamicClassLoader
java.lang.Object
|
+--java.lang.ClassLoader
|
+--org.omegahat.Environment.System.DynamicClassLoader
- public class DynamicClassLoader
- extends java.lang.ClassLoader
This class is designed to handle dynamically created classes. These
are, for example, implementations of interfaces that are parameterized
by Omegahat Functions
and ExpressionInts.
The trick in this class is that object defining the class is converted
directly in memory to the byte array defining the class
and the class defined from this representation. Thus, no file need
ever be written to disk. Given an appropriate security model, this
works nicely. If nothing else, it keeps the file namespace clean.
|
Field Summary |
protected java.util.Hashtable |
classTable
|
|
Method Summary |
java.util.Hashtable |
classTable()
|
java.util.Hashtable |
classTable(java.util.Hashtable table)
|
java.lang.Class |
defineClass(java.lang.Class sourceInterface)
Defines and loads a new class that implements the specified
interface using Omegahat interpreted functions or methods. |
java.lang.Class |
defineClass(jas.ClassEnv classDef,
java.lang.String name)
|
java.lang.Class |
defineClass(java.lang.Class sourceInterface,
java.lang.String name)
Define a new class, whose name is specified by name ,
that implements the specified interface and whose methods are
implemented by evaluating interpreted Omegahat functions/methods. |
java.lang.Class |
defineClass(EvaluableInterfaceGenerator classDef)
Allows the user to generate the template for
generating the class' byte-code with more control while
still using the class loader to actually manage the class in
the Virtual Machine. |
java.lang.Class |
defineClass(java.lang.String interfaceName)
Create and load a new class that implements the interface
identified by interfaceName and is named
FunctioninterfaceName (less package) |
java.lang.Class |
defineClass(java.lang.String[] interfaceNames,
java.lang.String className)
|
java.lang.Class |
defineClass(java.lang.String name,
java.io.ByteArrayOutputStream stream)
|
java.lang.Class |
defineClass(java.lang.String interfaceName,
java.lang.String className)
Create and load a new class that implements the interface
identified by interfaceName
and extends FunctionListener
allowing the methods to be handled by a function
or collection of functions, a Method. |
java.lang.Class |
loadClass(java.lang.String name,
boolean resolve)
|
boolean |
removeClass(java.lang.Class c)
|
| Methods inherited from class java.lang.ClassLoader |
defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setSigners |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
classTable
protected java.util.Hashtable classTable
DynamicClassLoader
public DynamicClassLoader()
DynamicClassLoader
public DynamicClassLoader(java.lang.ClassLoader parent)
DynamicClassLoader
public DynamicClassLoader(java.util.Hashtable table)
defineClass
public java.lang.Class defineClass(java.lang.String name,
java.io.ByteArrayOutputStream stream)
defineClass
public java.lang.Class defineClass(java.lang.String interfaceName,
java.lang.String className)
throws java.lang.ClassNotFoundException
- Create and load a new class that implements the interface
identified by
interfaceName
and extends FunctionListener
allowing the methods to be handled by a function
or collection of functions, a Method.
- See Also:
defineClass(java.lang.String[], java.lang.String)
defineClass
public java.lang.Class defineClass(java.lang.String[] interfaceNames,
java.lang.String className)
throws java.lang.ClassNotFoundException
defineClass
public java.lang.Class defineClass(java.lang.String interfaceName)
throws java.lang.ClassNotFoundException
- Create and load a new class that implements the interface
identified by
interfaceName and is named
FunctioninterfaceName (less package)
- See Also:
defineClass(java.lang.String, java.lang.String)
defineClass
public java.lang.Class defineClass(java.lang.Class sourceInterface)
- Defines and loads a new class that implements the specified
interface using Omegahat interpreted functions or methods.
The name of the new class is computed from the name of the
interface being implemented by prefixing its actual class name
(i.e. removing the package prefix) and prefixing it with the
word
Function.
Allows the call to be of the form
defineClass(ActionListener)
rather than specifying strings.
- See Also:
defineClass
public java.lang.Class defineClass(java.lang.Class sourceInterface,
java.lang.String name)
- Define a new class, whose name is specified by
name ,
that implements the specified interface and whose methods are
implemented by evaluating interpreted Omegahat functions/methods.
defineClass
public java.lang.Class defineClass(EvaluableInterfaceGenerator classDef)
- Allows the user to generate the template for
generating the class' byte-code with more control while
still using the class loader to actually manage the class in
the Virtual Machine.
loadClass
public java.lang.Class loadClass(java.lang.String name,
boolean resolve)
- Overrides:
loadClass in class java.lang.ClassLoader
defineClass
public java.lang.Class defineClass(jas.ClassEnv classDef,
java.lang.String name)
classTable
public java.util.Hashtable classTable()
classTable
public java.util.Hashtable classTable(java.util.Hashtable table)
removeClass
public boolean removeClass(java.lang.Class c)