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

Public Methods

public abstract ClassLoader getClassLoader ()

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

Returns
  • the class loader

public abstract 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 abstract 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 abstract List<D> getEnabledModuleDescriptorsByClass (Class<D> descriptorClazz)

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

Parameters
descriptorClazz module descriptor class
Returns

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

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

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

public abstract 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 abstract 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 abstract ModuleDescriptor<?> getEnabledPluginModule (String completeKey)

Retrieve an enabled plugin module by complete module key.

public abstract Collection<Plugin> getEnabledPlugins ()

Get all of the currently enabled plugins.

Returns
  • a collection of installed and enabled Plugins.

public abstract 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 abstract 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 abstract 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 abstract ModuleDescriptor<?> getPluginModule (String completeKey)

Retrieve any plugin module by complete module key.

Note: the module may or may not be disabled.

public abstract 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 abstract 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 abstract Collection<Plugin> getPlugins ()

Gets all of the currently installed plugins.

Returns
  • a collection of installed Plugins.

public abstract 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 abstract boolean isPluginEnabled (String key)

Whether or not a given plugin is currently enabled.

Throws
IllegalArgumentException If the plugin key is null

public abstract 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 abstract boolean isSystemPlugin (String key)

Returns
  • true if the plugin is a system plugin.