public interface

PluginAccessor

com.atlassian.plugin.PluginAccessor
Known Indirect Subclasses

Class Overview

Allows access to the current plugin system state

Summary

Nested Classes
class PluginAccessor.Descriptor The plugin descriptor file. 
Public Methods
ClassLoader getClassLoader()
Retrieve the class loader responsible for loading classes and resources from plugins.
@Deprecated Class<?> getDynamicPluginClass(String className)
This method is deprecated. since 0.21 this method is not used, use getPlugin(String).getClassLoader().loadClass(String)
InputStream 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.
<D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(Class<D> descriptorClazz, boolean verbose)
This method is deprecated. Since 2.3.0, use #getEnabledModuleDescriptorsByClass(Class) instead
@Deprecated <M> List<ModuleDescriptor<M>> getEnabledModuleDescriptorsByType(String type)
This method is deprecated. since 0.17, use getModuleDescriptors(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.
<M> List<M> getEnabledModulesByClass(Class<M> moduleClass)
Retrieve all plugin modules that implement or extend a specific class.
@Deprecated <M> List<M> getEnabledModulesByClassAndDescriptor(Class<ModuleDescriptor<M>> descriptorClass, Class<M> moduleClass)
This method is deprecated. since 0.17, use getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.
@Deprecated <M> List<M> getEnabledModulesByClassAndDescriptor(Class[]<ModuleDescriptor<M>> descriptorClazz, Class<M> moduleClass)
This method is deprecated. since 0.17, use getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.
Plugin getEnabledPlugin(String pluginKey)
Retrieve a given plugin if it is enabled.
ModuleDescriptor<?> getEnabledPluginModule(String completeKey)
Retrieve an enabled plugin module by complete module key.
Collection<Plugin> getEnabledPlugins()
Get all of the currently enabled plugins.
<M> Collection<ModuleDescriptor<M>> getModuleDescriptors(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
Gets all module descriptors of installed modules that match the given predicate.
<M> Collection<M> getModules(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
Gets all installed modules that match the given predicate.
Plugin getPlugin(String key)
Retrieve a given plugin (whether enabled or not).
ModuleDescriptor<?> getPluginModule(String completeKey)
Retrieve any plugin module by complete module key.
@Deprecated InputStream getPluginResourceAsStream(String pluginKey, String resourcePath)
This method is deprecated. since 0.21 this method is not used, use getPlugin(String).getClassLoader().getResourceAsStream(String)
PluginRestartState getPluginRestartState(String key)
Gets the state of the plugin upon restart.
Collection<Plugin> getPlugins()
Gets all of the currently installed plugins.
Collection<Plugin> getPlugins(PluginPredicate pluginPredicate)
Gets all installed plugins that match the given predicate.
boolean isPluginEnabled(String key)
Whether or not a given plugin is currently enabled.
boolean isPluginModuleEnabled(String completeKey)
Whether or not a given plugin module is currently enabled.
boolean isSystemPlugin(String key)

Public Methods

public ClassLoader getClassLoader ()

Retrieve the class loader responsible for loading classes and resources from plugins.

Returns
  • the class loader

@Deprecated public Class<?> getDynamicPluginClass (String className)

This method is deprecated.
since 0.21 this method is not used, use getPlugin(String).getClassLoader().loadClass(String)

Retrieve a class from a currently loaded (and active) dynamically loaded plugin. Will return the first class found, so plugins with overlapping class names will behave eratically.

Parameters
className the name of the class to retrieve
Returns
  • the dynamically loaded class that matches that name
Throws
ClassNotFoundException thrown if no classes by that name could be found in any of the enabled dynamic plugins

public 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 eratically.

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

public List<D> getEnabledModuleDescriptorsByClass (Class<D> descriptorClazz)

Get all enabled module descriptors that have a specific descriptor class.

Parameters
descriptorClazz module descriptor class
Returns

public List<D> getEnabledModuleDescriptorsByClass (Class<D> descriptorClazz, boolean verbose)

This method is deprecated.
Since 2.3.0, use #getEnabledModuleDescriptorsByClass(Class) instead

Get all enabled module descriptors that have a specific descriptor class.

Parameters
descriptorClazz module descriptor class
verbose log verbose messages flag
Returns

@Deprecated public List<ModuleDescriptor<M>> getEnabledModuleDescriptorsByType (String type)

This method is deprecated.
since 0.17, use getModuleDescriptors(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.

Get all enabled module descriptors that have a specific descriptor type.

Returns

public 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.

@Deprecated public List<M> getEnabledModulesByClassAndDescriptor (Class<ModuleDescriptor<M>> descriptorClass, Class<M> moduleClass)

This method is deprecated.
since 0.17, use getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.

Retrieve all plugin modules that implement or extend a specific class, and has a descriptor class as the descriptorClazz

Parameters
descriptorClass @NotNull
moduleClass @NotNull
Returns
  • List of modules that implement or extend the given class. Empty list if none found

@Deprecated public List<M> getEnabledModulesByClassAndDescriptor (Class[]<ModuleDescriptor<M>> descriptorClazz, Class<M> moduleClass)

This method is deprecated.
since 0.17, use getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.

Retrieve all plugin modules that implement or extend a specific class, and has a descriptor class as one of descriptorClazz

Parameters
descriptorClazz @NotNull
moduleClass @NotNull
Returns
  • List of modules that implement or extend the given class. Empty list if none found

public 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

public ModuleDescriptor<?> getEnabledPluginModule (String completeKey)

Retrieve an enabled plugin module by complete module key.

public Collection<Plugin> getEnabledPlugins ()

Get all of the currently enabled plugins.

Returns
  • a collection of installed and enabled Plugins.

public Collection<ModuleDescriptor<M>> getModuleDescriptors (ModuleDescriptorPredicate<M> moduleDescriptorPredicate)

Gets all module descriptors of installed modules that match the given predicate.

Parameters
moduleDescriptorPredicate the ModuleDescriptorPredicate to match.
Returns

public Collection<M> getModules (ModuleDescriptorPredicate<M> moduleDescriptorPredicate)

Gets all installed modules that match the given predicate.

Parameters
moduleDescriptorPredicate the ModuleDescriptorPredicate to match.
Returns
  • a collection of modules as per getModule() that match the given predicate.

public 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

public ModuleDescriptor<?> getPluginModule (String completeKey)

Retrieve any plugin module by complete module key.

Note: the module may or may not be disabled.

@Deprecated public InputStream getPluginResourceAsStream (String pluginKey, String resourcePath)

This method is deprecated.
since 0.21 this method is not used, use getPlugin(String).getClassLoader().getResourceAsStream(String)

Retrieve a resource from a currently loaded (and active) plugin. For statically loaded plugins, this just means pulling the resource from the PluginManager's classloader. For dynamically loaded plugins, this means retrieving the resource from the plugin's private classloader.

public 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

public Collection<Plugin> getPlugins ()

Gets all of the currently installed plugins.

Returns
  • a collection of installed Plugins.

public Collection<Plugin> getPlugins (PluginPredicate pluginPredicate)

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.

public boolean isPluginEnabled (String key)

Whether or not a given plugin is currently enabled.

Throws
IllegalArgumentException If the plugin key is null

public 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

public boolean isSystemPlugin (String key)

Returns
  • true if the plugin is a system plugin.