Class PluginLoader


  • public class PluginLoader
    extends Object
    This class loads plugins and instantiates them
    • Constructor Detail

      • PluginLoader

        public PluginLoader()
    • 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 class
        pluginInterface - 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 class
        pluginInterface - 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