public final class

EnabledModuleCachingPluginAccessor

extends Object
implements PluginAccessor
java.lang.Object
   ↳ com.atlassian.plugin.manager.EnabledModuleCachingPluginAccessor

Class Overview

A caching decorator which caches getEnabledModuleDescriptorsByClass(Class) on PluginAccessor interface.

Summary

Fields
protected final PluginAccessor delegate
Public Constructors
EnabledModuleCachingPluginAccessor(PluginAccessor delegate, PluginEventManager pluginEventManager)
Public Methods
ClassLoader getClassLoader()
Retrieve the class loader responsible for loading classes and resources from plugins.
@Deprecated Class<?> getDynamicPluginClass(String className)
Retrieve a class from a currently loaded (and active) dynamically loaded plugin.
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.
@Deprecated <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(Class<D> descriptorClazz, boolean verbose)
Get all enabled module descriptors that have a specific descriptor class.
@Deprecated <M> List<ModuleDescriptor<M>> getEnabledModuleDescriptorsByType(String type)
Get all enabled module descriptors that have a specific descriptor type.
<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)
Retrieve all plugin modules that implement or extend a specific class, and has a descriptor class as the descriptorClazz
@Deprecated <M> List<M> getEnabledModulesByClassAndDescriptor(Class[]<ModuleDescriptor<M>> descriptorClazz, Class<M> moduleClass)
Retrieve all plugin modules that implement or extend a specific class, and has a descriptor class as one of descriptorClazz
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)
Retrieve a resource from a currently loaded (and active) plugin.
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)
void onPluginDisable(PluginDisabledEvent event)
Clears the enabled module cache when any plugin is disabled.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.plugin.PluginAccessor

Fields

protected final PluginAccessor delegate

Public Constructors

public EnabledModuleCachingPluginAccessor (PluginAccessor delegate, PluginEventManager pluginEventManager)

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)

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

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

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

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)

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)

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)

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.

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.

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)

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.

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)

public void onPluginDisable (PluginDisabledEvent event)

Clears the enabled module cache when any plugin is disabled. The cache already has weak keys and values, but this ensures old modules are never returned from disabled plugins.

Parameters
event The plugin disabled event