|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ClassLoader
org.luaj.vm2.server.LuajClassLoader
public class LuajClassLoader
Class loader that can be used to launch a lua script in a Java VM that has a unique set of classes for org.luaj classes.
Note: This class is experimental and subject to change in future versions.
By using a custom class loader per script, it allows the script to have its own set of globals, including static values such as shared metatables that cannot access lua values from other scripts because their classes are loaded from different class loaders. Thus normally unsafe libraries such as luajava can be exposed to scripts in a server environment using these techniques.
All classes in the package "org.luaj.vm2." are considered user classes, and
loaded into this class loader from their bytes in the class path. Other
classes are considered systemc classes and loaded via the system loader. This
class set can be extended by overriding isUserClass(String)
.
The Launcher
interface is loaded as a system class by exception so
that the caller may use it to launch lua scripts.
By default NewLauncher()
creates a subclass of Launcher
of
type DefaultLauncher
which creates debug globals, runs the script,
and prints the return values. This behavior can be changed by supplying a
different implementation class to NewLauncher(Class)
which must
extend Launcher
.
Launcher
,
NewLauncher()
,
NewLauncher(Class)
,
DefaultLauncher
Constructor Summary | |
---|---|
LuajClassLoader()
|
Method Summary | |
---|---|
static boolean |
isUserClass(java.lang.String classname)
Test if a class name should be considered a user class and loaded by this loader, or a system class and loaded by the system loader. |
java.lang.Class<?> |
loadClass(java.lang.String classname)
|
static Launcher |
NewLauncher()
Construct a default Launcher instance that will load classes in
its own LuajClassLoader using the default implementation class
DefaultLauncher . |
static Launcher |
NewLauncher(java.lang.Class<? extends Launcher> launcher_class)
Construct a Launcher instance that will load classes in
its own LuajClassLoader using a user-supplied implementation class
that implements Launcher . |
Methods inherited from class java.lang.ClassLoader |
---|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, 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, toString, wait, wait, wait |
Constructor Detail |
---|
public LuajClassLoader()
Method Detail |
---|
public static Launcher NewLauncher() throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException
Launcher
instance that will load classes in
its own LuajClassLoader
using the default implementation class
DefaultLauncher
.
The Launcher
that is returned will be a pristine luaj vm
whose classes are loaded into this loader including static variables
such as shared metatables, and should not be able to directly access
variables from other Launcher instances.
Launcher
instance that can be used to launch scripts.
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
public static Launcher NewLauncher(java.lang.Class<? extends Launcher> launcher_class) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException
Launcher
instance that will load classes in
its own LuajClassLoader
using a user-supplied implementation class
that implements Launcher
.
The Launcher
that is returned will be a pristine luaj vm
whose classes are loaded into this loader including static variables
such as shared metatables, and should not be able to directly access
variables from other Launcher instances.
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
public static boolean isUserClass(java.lang.String classname)
classname
- Class name to test.
public java.lang.Class<?> loadClass(java.lang.String classname) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |