Class PluginManager


  • public class PluginManager
    extends java.lang.Object
    Manages Plugins, registering them with a CandidateRegistry when loaded and removing them when unloaded.
    • Constructor Summary

      Constructors 
      Constructor Description
      PluginManager​(ComponentScannerFactory componentScannerFactory, org.int4.dirk.api.CandidateRegistry registry)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Plugin loadPlugin​(java.net.URL... urls)
      Loads classes from a plugin defined by a Module.
      Plugin loadPluginAndScan​(java.lang.String... packageNamePrefixes)
      Scans the given package prefixes and creates a Plugin for any annotated types located during the scan.
      Plugin loadPluginAndScan​(java.net.URL... urls)
      Loads jars at the given URLs, scans for annotated types and creates a Plugin.
      void unload​(Plugin plugin)
      Attempts to unload the given plugin.
      • Methods inherited from class java.lang.Object

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

      • PluginManager

        public PluginManager​(ComponentScannerFactory componentScannerFactory,
                             org.int4.dirk.api.CandidateRegistry registry)
        Constructs a new instance. A CandidateRegistry must be provided where types part of a Plugin can be registered and unregistered.
        Parameters:
        componentScannerFactory - a ComponentScannerFactory, cannot be null
        registry - a CandidateRegistry, cannot be null
    • Method Detail

      • loadPluginAndScan

        public Plugin loadPluginAndScan​(java.lang.String... packageNamePrefixes)
                                 throws org.int4.dirk.api.definition.AutoDiscoveryException,
                                        org.int4.dirk.api.definition.DefinitionException,
                                        org.int4.dirk.api.definition.DependencyException
        Scans the given package prefixes and creates a Plugin for any annotated types located during the scan.
        Parameters:
        packageNamePrefixes - a list of packages to scan
        Returns:
        a Plugin, never null
        Throws:
        org.int4.dirk.api.definition.AutoDiscoveryException - when auto discovery fails to find all required types
        org.int4.dirk.api.definition.DefinitionException - when a definition problem was encountered
        org.int4.dirk.api.definition.DependencyException - when dependencies between registered types cannot be resolved
      • loadPluginAndScan

        public Plugin loadPluginAndScan​(java.net.URL... urls)
                                 throws org.int4.dirk.api.definition.AutoDiscoveryException,
                                        org.int4.dirk.api.definition.DefinitionException,
                                        org.int4.dirk.api.definition.DependencyException
        Loads jars at the given URLs, scans for annotated types and creates a Plugin.
        Parameters:
        urls - a list of URLs to load and scan
        Returns:
        a Plugin, never null
        Throws:
        org.int4.dirk.api.definition.AutoDiscoveryException - when auto discovery fails to find all required types
        org.int4.dirk.api.definition.DefinitionException - when a definition problem was encountered
        org.int4.dirk.api.definition.DependencyException - when dependencies between registered types cannot be resolved
      • unload

        public void unload​(Plugin plugin)
                    throws org.int4.dirk.api.definition.AutoDiscoveryException,
                           org.int4.dirk.api.definition.DefinitionException,
                           org.int4.dirk.api.definition.DependencyException
        Attempts to unload the given plugin. This may fail if not all types can be removed for the underlying CandidateRegistry.
        Parameters:
        plugin - a Plugin to unload, cannot be null
        Throws:
        org.int4.dirk.api.definition.AutoDiscoveryException - when auto discovery fails to find all required types
        org.int4.dirk.api.definition.DefinitionException - when a definition problem was encountered
        org.int4.dirk.api.definition.DependencyException - when dependencies between registered types cannot be resolved
      • loadPlugin

        public Plugin loadPlugin​(java.net.URL... urls)
                          throws org.int4.dirk.api.definition.AutoDiscoveryException,
                                 org.int4.dirk.api.definition.DefinitionException,
                                 org.int4.dirk.api.definition.DependencyException
        Loads classes from a plugin defined by a Module.
        Parameters:
        urls - one or more jar files
        Returns:
        a Plugin, never null
        Throws:
        org.int4.dirk.api.definition.AutoDiscoveryException - when auto discovery fails to find all required types
        org.int4.dirk.api.definition.DefinitionException - when a definition problem was encountered
        org.int4.dirk.api.definition.DependencyException - when dependencies between registered types cannot be resolved