Class PluginLoader


  • class PluginLoader
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) <PreferredType,​AlternateType>
      java.lang.Object
      loadPlugin​(java.lang.Class<PreferredType> preferredPluginType, java.lang.Class<AlternateType> alternatePluginType)
      Scans the classpath for given preferredPluginType.
      (package private) <T> T loadPlugin​(java.lang.Class<T> pluginType)
      Scans the classpath for given pluginType.
      (package private) <T> java.util.List<T> loadPlugins​(java.lang.Class<T> pluginType)
      Scans the classpath for given pluginType and returns a list of its instances.
      • Methods inherited from class java.lang.Object

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

      • PluginLoader

        @Deprecated
        PluginLoader​(PluginSwitch pluginSwitch,
                     java.lang.String alias)
        Deprecated.
        Let's avoid adding more aliases. It complicates the API. Instead of an alias, we can use fully qualified class name of the alternative implementation.

        Adds an alias for a class name to this plugin loader. Instead of the fully qualified type name, the alias can be used as a convenience name for a known plugin.

    • Method Detail

      • loadPlugin

        <T> T loadPlugin​(java.lang.Class<T> pluginType)
        Scans the classpath for given pluginType. If not found, default class is used.
      • loadPlugin

        <PreferredType,​AlternateType> java.lang.Object loadPlugin​(java.lang.Class<PreferredType> preferredPluginType,
                                                                        java.lang.Class<AlternateType> alternatePluginType)
        Scans the classpath for given preferredPluginType. If not found scan for alternatePluginType. If neither a preferred or alternate plugin is found, default to default class of preferredPluginType.
        Returns:
        An object of either preferredPluginType or alternatePluginType
      • loadPlugins

        <T> java.util.List<T> loadPlugins​(java.lang.Class<T> pluginType)
        Scans the classpath for given pluginType and returns a list of its instances.
        Returns:
        An list of pluginType or an empty list if none was found.