Package party.iroiro.luajava
Class ClassPathLoader
java.lang.Object
party.iroiro.luajava.ClassPathLoader
- All Implemented Interfaces:
ExternalLoader
An
ExternalLoader that loads modules from classpath
The path to the resource is converted from module name with
getPath(String). For example, loading a abc.def module
will load a Lua file at classpath://abc/def.lua.
To use this class, call Lua.setExternalLoader(ExternalLoader) with an instance of this class,
and then you can load modules with the Lua require function from classpath.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn output stream used to convert aByteArrayOutputStreamto aByteBuffer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ClassLoaderThe class loader used to load Lua modules from the classpath. -
Constructor Summary
ConstructorsConstructorDescriptionUseClassUtils.getDefaultClassLoader()for resource loadingClassPathLoader(ClassLoader classLoader) Creates a new ClassPathLoader with the specified class loader. -
Method Summary
-
Field Details
-
classLoader
The class loader used to load Lua modules from the classpath.
-
-
Constructor Details
-
ClassPathLoader
public ClassPathLoader()UseClassUtils.getDefaultClassLoader()for resource loading -
ClassPathLoader
Creates a new ClassPathLoader with the specified class loader.- Parameters:
classLoader- the classloader for resource loading
-
-
Method Details
-
load
Description copied from interface:ExternalLoaderReads an external Lua module file into a direct bufferThis is used internally by
Luaimplementations and should not be called directly.- Specified by:
loadin interfaceExternalLoader- Parameters:
module- the moduleignored- the Lua state requesting the module- Returns:
- a direct buffer containing the module file, with position at zero, limit as the length
-
getPath
Converts a dot-separated module path to a file system path.- Parameters:
module- dot separated module path- Returns:
- module path with
.replaced by/, appended with.lua
-