Package org.pf4j

Class AbstractExtensionFinder

java.lang.Object
org.pf4j.AbstractExtensionFinder
All Implemented Interfaces:
EventListener, ExtensionFinder, PluginStateListener
Direct Known Subclasses:
LegacyExtensionFinder, ServiceProviderExtensionFinder

public abstract class AbstractExtensionFinder extends Object implements ExtensionFinder, PluginStateListener
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • pluginManager

      protected PluginManager pluginManager
    • entries

      protected volatile Map<String,Set<String>> entries
    • extensionInfos

      protected volatile Map<String,ExtensionInfo> extensionInfos
    • checkForExtensionDependencies

      protected Boolean checkForExtensionDependencies
  • Constructor Details

    • AbstractExtensionFinder

      public AbstractExtensionFinder(PluginManager pluginManager)
  • Method Details

    • readPluginsStorages

      public abstract Map<String,Set<String>> readPluginsStorages()
    • readClasspathStorages

      public abstract Map<String,Set<String>> readClasspathStorages()
    • find

      public <T> List<ExtensionWrapper<T>> find(Class<T> type)
      Description copied from interface: ExtensionFinder
      Retrieves a list with all extensions found for an extension point.
      Specified by:
      find in interface ExtensionFinder
    • find

      public <T> List<ExtensionWrapper<T>> find(Class<T> type, String pluginId)
      Description copied from interface: ExtensionFinder
      Retrieves a list with all extensions found for an extension point and a plugin.
      Specified by:
      find in interface ExtensionFinder
    • find

      public List<ExtensionWrapper> find(String pluginId)
      Description copied from interface: ExtensionFinder
      Retrieves a list with all extensions found for a plugin
      Specified by:
      find in interface ExtensionFinder
    • findClassNames

      public Set<String> findClassNames(String pluginId)
      Description copied from interface: ExtensionFinder
      Retrieves a list with all extension class names found for a plugin.
      Specified by:
      findClassNames in interface ExtensionFinder
    • pluginStateChanged

      public void pluginStateChanged(PluginStateEvent event)
      Description copied from interface: PluginStateListener
      Invoked when a plugin's state (for example DISABLED, STARTED) is changed.
      Specified by:
      pluginStateChanged in interface PluginStateListener
    • isCheckForExtensionDependencies

      public final boolean isCheckForExtensionDependencies()
      Returns true, if the extension finder checks extensions for its required plugins. This feature has to be enabled, in order check the availability of Extension.plugins() configured by an extension.

      This feature is enabled by default, if at least one available plugin makes use of optional plugin dependencies. Those optional plugins might not be available at runtime. Therefore any extension is checked by default against available plugins before its instantiation.

      Notice: This feature requires the optional ASM library to be available on the applications classpath.

      Returns:
      true, if the extension finder checks extensions for its required plugins
    • setCheckForExtensionDependencies

      public void setCheckForExtensionDependencies(boolean checkForExtensionDependencies)
      Plugin developers may enable / disable checks for required plugins of an extension. This feature has to be enabled, in order check the availability of Extension.plugins() configured by an extension.

      This feature is enabled by default, if at least one available plugin makes use of optional plugin dependencies. Those optional plugins might not be available at runtime. Therefore any extension is checked by default against available plugins before its instantiation.

      Notice: This feature requires the optional ASM library to be available on the applications classpath.

      Parameters:
      checkForExtensionDependencies - true to enable checks for optional extensions, otherwise false
    • debugExtensions

      protected void debugExtensions(Set<String> extensions)
    • readStorages

      private Map<String,Set<String>> readStorages()
    • getEntries

      private Map<String,Set<String>> getEntries()
    • getExtensionInfo

      private ExtensionInfo getExtensionInfo(String className, ClassLoader classLoader)
      Returns the parameters of an Extension annotation without loading the corresponding class into the class loader.
      Parameters:
      className - name of the class, that holds the requested Extension annotation
      classLoader - class loader to access the class
      Returns:
      the contents of the Extension annotation or null, if the class does not have an Extension annotation
    • createExtensionWrapper

      private ExtensionWrapper createExtensionWrapper(Class<?> extensionClass)
    • findExtensionAnnotation

      private Extension findExtensionAnnotation(Class<?> clazz)
    • checkDifferentClassLoaders

      private void checkDifferentClassLoaders(Class<?> type, Class<?> extensionClass)