Package com.atlassian.plugin
Interface PluginAccessor
public interface PluginAccessor
Allows access to the current plugin system state
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classThe plugin descriptor file. -
Method Summary
Modifier and TypeMethodDescriptiondefault <D extends ModuleDescriptor<?>>
List<D>getActiveModuleDescriptorsByClass(Class<D> descriptorClazz) Deprecated.Retrieve the class loader responsible for loading classes and resources from plugins.getDynamicModules(Plugin plugin) Retrieve all currently registered dynamic modules i.e.getDynamicResourceAsStream(String resourcePath) Retrieve a resource from a currently loaded (and active) dynamically loaded plugin.<D extends ModuleDescriptor<?>>
List<D>getEnabledModuleDescriptorsByClass(Class<D> descriptorClazz) Get all enabled module descriptors that have a specific descriptor class.<M> List<M>getEnabledModulesByClass(Class<M> moduleClass) Retrieve all plugin modules that implement or extend a specific class.getEnabledPlugin(String pluginKey) Retrieve a given plugin if it is enabled.getEnabledPluginModule(String completeKey) Retrieve an enabled plugin module by complete module key.Get all of the currently enabled plugins.default <M> Collection<ModuleDescriptor<M>>getModuleDescriptors(ModuleDescriptorPredicate<M> moduleDescriptorPredicate) Deprecated.in 5.0 for removal in 6.0.<M> Collection<ModuleDescriptor<M>>getModuleDescriptors(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate) Gets all module descriptors of installed modules that match the given predicate.default <M> Collection<M>getModules(ModuleDescriptorPredicate<M> moduleDescriptorPredicate) Deprecated.in 5.0 for removal in 6.0.<M> Collection<M>getModules(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate) Gets all installed modules that match the given predicate.Retrieve a given plugin (whether enabled or not).getPluginModule(String completeKey) Retrieve any plugin module by complete module key.Gets the state of the plugin upon restart.Gets all of the currently installed plugins.default Collection<Plugin>getPlugins(PluginPredicate pluginPredicate) Deprecated.in 5.0 for removal in 6.0, usegetPlugins(Predicate)insteadgetPlugins(Predicate<Plugin> pluginPredicate) Gets all installed plugins that match the given predicate.booleanisPluginEnabled(String key) Whether or not a given plugin is currently enabled.booleanisPluginModuleEnabled(String completeKey) Whether or not a given plugin module is currently enabled.booleanisSystemPlugin(String key)
-
Method Details
-
getPlugins
Collection<Plugin> getPlugins()Gets all of the currently installed plugins.- Returns:
- a collection of installed
Plugins.
-
getPlugins
Deprecated.in 5.0 for removal in 6.0, usegetPlugins(Predicate)insteadGets all installed plugins that match the given predicate.- Parameters:
pluginPredicate- thePluginPredicateto match.- Returns:
- a collection of
Plugins that match the given predicate. - Since:
- 0.17
-
getPlugins
Gets all installed plugins that match the given predicate. -
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. UsegetModules(Predicate)instead.Gets all installed modules that match the given predicate.- Parameters:
moduleDescriptorPredicate- theModuleDescriptorPredicateto 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. UsegetModuleDescriptors(Predicate)instead.Gets all module descriptors of installed modules that match the given predicate.- Parameters:
moduleDescriptorPredicate- theModuleDescriptorPredicateto match.- Returns:
- a collection of
ModuleDescriptors that match the given predicate. - Since:
- 0.17
-
getModules
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
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
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
Retrieve any plugin module by complete module key.Note: the module may or may not be disabled.
-
getEnabledPluginModule
Retrieve an enabled plugin module by complete module key. -
isPluginEnabled
Whether or not a given plugin is currently enabled.- Throws:
IllegalArgumentException- If the plugin key is null
-
isPluginModuleEnabled
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
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 whenScopeManageris removed. UsegetEnabledModuleDescriptorsByClass(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
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
- Returns:
- true if the plugin is a system plugin.
-
getPluginRestartState
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
Retrieve all currently registered dynamic modules i.e. any module that has been added topluginviaPluginController.addDynamicModule(Plugin, com.atlassian.plugin.module.Element)during the lifetime of this plugin, but not removed viaPluginController.removeDynamicModule(Plugin, ModuleDescriptor).- Parameters:
plugin- to query- Returns:
- modules added, may be empty
- See Also:
-
ScopeManageris removed.