Class PluginLoader
- java.lang.Object
-
- PluginLoader
-
public class PluginLoader extends Object
This class loads plugins and instantiates them
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPluginLoader.LoadingException
-
Constructor Summary
Constructors Constructor Description PluginLoader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <OBJECT> OBJECTload(Class<OBJECT> pluginInterface, File plugin)Loads the class from its class file and returns an instance of it<OBJECT> OBJECTload(String plugin, Class<OBJECT> pluginInterface)Compiles a plugin given as a java class in source code form and loads it into the Java Runtime.
-
-
-
Method Detail
-
load
public <OBJECT> OBJECT load(String plugin, Class<OBJECT> pluginInterface) throws PluginLoader.LoadingException
Compiles a plugin given as a java class in source code form and loads it into the Java Runtime. It only loads classes that extend the given java class. After successfully loading it, an instance of each found class that extends the given class will be returned to the caller. If a class already exists, it will be updated if its code has changed. If the code has not changed, the loading is skipped and a new instance of the class is returned.- Parameters:
plugin- The string containing the source code of the plugin classpluginInterface- The interface/class the plugin class has to implement/extend- Returns:
- OBJECT The new instance of the class
- Throws:
PluginLoader.LoadingException- When something goes wrong while compiling or loading the class
-
load
public <OBJECT> OBJECT load(Class<OBJECT> pluginInterface, File plugin) throws PluginLoader.LoadingException
Loads the class from its class file and returns an instance of it- Parameters:
plugin- The string containing the source code of the plugin classpluginInterface- The interface/class the plugin class has to implement/extend- Returns:
- OBJECT The new instance of the class
- Throws:
PluginLoader.LoadingException- When something goes wrong while loading the class
-
-