Class PluginLoader


  • public class PluginLoader
    extends java.lang.Object
    The plug-in loader class checking for plug-in dependencies in a Module project.
    Author:
    Christopher Mindus
    • Constructor Summary

      Constructors 
      ConstructorDescription
      PluginLoader​(PropFactory factory, java.lang.ClassLoader classLoader)
      Creates the instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      java.lang.ClassLoadercreateClassLoader​(java.lang.ClassLoader parentClassLoader)
      Creates a new classloader that also handles loading classes from the added plugins.
      java.lang.StringgetLoadedPlugins()
      Gets the comma-separated list of loaded plugins.
      java.util.List<IPluginDescriptor<?>>loadPlugins​(java.lang.String names)
      Loads required plug-in's.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PluginLoader

        public PluginLoader​(PropFactory factory,
                            java.lang.ClassLoader classLoader)
        Creates the instance.
        Parameters:
        factory - The factory to register the plug-ins in.
        classLoader - The ClassLoader to use when running in a Server environment.
    • Method Detail

      • loadPlugins

        public java.util.List<IPluginDescriptor<?>> loadPlugins​(java.lang.String names)
                                                         throws java.io.IOException
        Loads required plug-in's.

        Each plug-in must have a class called "name.server.Descriptor" that implement the interface com.iizix.IPluginDescriptor available.

        The plug-in definition should be found at the "name/schema/properties.xml", but the iiziGo modules have the "iizigo" module instead of "iizix". To figure out translation of names, a class called "name.server.Descriptor" is loaded and should implement the interface

        Parameters:
        names - The plug-in name, e.g. "com.iizigo.db,com.iizigo.term,com.iizigo.ws".
        Returns:
        The list of plug-in descriptors.
        Throws:
        java.io.IOException - If a plug-in failed to load.
      • getLoadedPlugins

        public java.lang.String getLoadedPlugins()
        Gets the comma-separated list of loaded plugins.
        Returns:
        The comma-separated list of loaded plugins, empty string for none.
      • createClassLoader

        public java.lang.ClassLoader createClassLoader​(java.lang.ClassLoader parentClassLoader)
        Creates a new classloader that also handles loading classes from the added plugins.
        Parameters:
        parentClassLoader - The parent class loaders, must be defined.
        Returns:
        A new class loader.