Interface PluginAccessor


public interface PluginAccessor
Allows access to the current plugin system state
  • Method Details

    • getPlugins

      Collection<Plugin> getPlugins()
      Gets all of the currently installed plugins.
      Returns:
      a collection of installed Plugins.
    • getPlugins

      @Deprecated default Collection<Plugin> getPlugins(PluginPredicate pluginPredicate)
      Deprecated.
      in 5.0 for removal in 6.0, use getPlugins(Predicate) instead
      Gets all installed plugins that match the given predicate.
      Parameters:
      pluginPredicate - the PluginPredicate to match.
      Returns:
      a collection of Plugins that match the given predicate.
      Since:
      0.17
    • getPlugins

      Collection<Plugin> getPlugins(Predicate<Plugin> pluginPredicate)
      Gets all installed plugins that match the given predicate.
      Parameters:
      pluginPredicate - the Predicate describing which plugins to match.
      Returns:
      a collection of Plugins that match the given predicate.
      Since:
      5.0
    • getEnabledPlugins

      Collection<Plugin> getEnabledPlugins()
      Get all of the currently enabled plugins.
      Returns:
      a collection of installed and enabled Plugins.
    • getModules

      @Deprecated default <M> Collection<M> getModules(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
      Deprecated.
      in 5.0 for removal in 6.0. Use getModules(Predicate) instead.
      Gets all installed modules that match the given predicate.
      Parameters:
      moduleDescriptorPredicate - the ModuleDescriptorPredicate to match.
      Returns:
      a collection of modules as per ModuleDescriptor.getModule() that match the given predicate.
      Since:
      0.17
    • getModuleDescriptors

      @Deprecated default <M> Collection<ModuleDescriptor<M>> getModuleDescriptors(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
      Deprecated.
      in 5.0 for removal in 6.0. Use getModuleDescriptors(Predicate) instead.
      Gets all module descriptors of installed modules that match the given predicate.
      Parameters:
      moduleDescriptorPredicate - the ModuleDescriptorPredicate to match.
      Returns:
      a collection of ModuleDescriptors that match the given predicate.
      Since:
      0.17
    • getModules

      <M> Collection<M> getModules(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate)
      Gets all installed modules that match the given predicate.
      Parameters:
      moduleDescriptorPredicate - describes which modules to match
      Returns:
      a collection of modules as per ModuleDescriptor.getModule() that match the given predicate.
      Since:
      5.0
    • getModuleDescriptors

      <M> Collection<ModuleDescriptor<M>> getModuleDescriptors(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate)
      Gets all module descriptors of installed modules that match the given predicate.
      Parameters:
      moduleDescriptorPredicate - describes which modules to match
      Returns:
      a collection of ModuleDescriptors that match the given predicate.
      Since:
      5.0
    • getPlugin

      Plugin getPlugin(String key)
      Retrieve a given plugin (whether enabled or not).
      Parameters:
      key - The plugin key. Cannot be null.
      Returns:
      The enabled plugin, or null if that plugin does not exist.
      Throws:
      IllegalArgumentException - If the plugin key is null
    • getEnabledPlugin

      Plugin getEnabledPlugin(String pluginKey)
      Retrieve a given plugin if it is enabled.
      Returns:
      The enabled plugin, or null if that plugin does not exist or is disabled.
      Throws:
      IllegalArgumentException - If the plugin key is null
    • getPluginModule

      ModuleDescriptor<?> getPluginModule(String completeKey)
      Retrieve any plugin module by complete module key.

      Note: the module may or may not be disabled.

    • getEnabledPluginModule

      ModuleDescriptor<?> getEnabledPluginModule(String completeKey)
      Retrieve an enabled plugin module by complete module key.
    • isPluginEnabled

      boolean isPluginEnabled(String key)
      Whether or not a given plugin is currently enabled.
      Throws:
      IllegalArgumentException - If the plugin key is null
    • isPluginModuleEnabled

      boolean isPluginModuleEnabled(String completeKey)
      Whether or not a given plugin module is currently enabled. This also checks if the plugin it is contained within is enabled also
      See Also:
    • getEnabledModulesByClass

      <M> List<M> getEnabledModulesByClass(Class<M> moduleClass)
      Retrieve all plugin modules that implement or extend a specific class.
      Returns:
      List of modules that implement or extend the given class.
    • getEnabledModuleDescriptorsByClass

      <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(Class<D> descriptorClazz)
      Get all enabled module descriptors that have a specific descriptor class.
      Parameters:
      descriptorClazz - module descriptor class
      Returns:
      List of ModuleDescriptors that implement or extend the given class.
    • getActiveModuleDescriptorsByClass

      @Deprecated default <D extends ModuleDescriptor<?>> List<D> getActiveModuleDescriptorsByClass(Class<D> descriptorClazz)
      Deprecated.
      in 5.0 for removal in 6.0 when ScopeManager is removed. Use getEnabledModuleDescriptorsByClass(Class) instead.
      Get all enabled module descriptors that have a specific descriptor class and are considered active for the current request.

      Result of this method should not be cached across requests.

      Parameters:
      descriptorClazz - module descriptor class
      Returns:
      List of ModuleDescriptors that implement or extend the given class and active for the current request.
      See Also:
    • getDynamicResourceAsStream

      InputStream getDynamicResourceAsStream(String resourcePath)
      Retrieve a resource from a currently loaded (and active) dynamically loaded plugin. Will return the first resource found, so plugins with overlapping resource names will behave erratically.
      Parameters:
      resourcePath - the path to the resource to retrieve
      Returns:
      the dynamically loaded resource that matches that path, or null if no such resource is found
    • getClassLoader

      ClassLoader getClassLoader()
      Retrieve the class loader responsible for loading classes and resources from plugins.
      Returns:
      the class loader
      Since:
      0.21
    • isSystemPlugin

      boolean isSystemPlugin(String key)
      Returns:
      true if the plugin is a system plugin.
    • getPluginRestartState

      PluginRestartState getPluginRestartState(String key)
      Gets the state of the plugin upon restart. Only useful for plugins that contain module descriptors with the \@RestartRequired annotation, and therefore, cannot be dynamically installed, upgraded, or removed at runtime
      Parameters:
      key - The plugin key
      Returns:
      The state of the plugin on restart
    • getDynamicModules

      Iterable<ModuleDescriptor<?>> getDynamicModules(Plugin plugin)
      Retrieve all currently registered dynamic modules i.e. any module that has been added to plugin via PluginController.addDynamicModule(Plugin, com.atlassian.plugin.module.Element) during the lifetime of this plugin, but not removed via PluginController.removeDynamicModule(Plugin, ModuleDescriptor).
      Parameters:
      plugin - to query
      Returns:
      modules added, may be empty
      See Also: