com.atlassian.plugin.manager
Class EnabledModuleCachingPluginAccessor

java.lang.Object
  extended by com.atlassian.plugin.manager.EnabledModuleCachingPluginAccessor
All Implemented Interfaces:
PluginAccessor

public final class EnabledModuleCachingPluginAccessor
extends Object
implements PluginAccessor

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

Since:
2.7.0

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.plugin.PluginAccessor
PluginAccessor.Descriptor
 
Field Summary
protected  PluginAccessor delegate
           
 
Constructor Summary
EnabledModuleCachingPluginAccessor(PluginAccessor delegate, PluginEventManager pluginEventManager)
           
 
Method Summary
 ClassLoader getClassLoader()
          Retrieve the class loader responsible for loading classes and resources from plugins.
 Class<?> getDynamicPluginClass(String className)
          Deprecated. 
 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)
          Deprecated. 
<M> List<ModuleDescriptor<M>>
getEnabledModuleDescriptorsByType(String type)
          Deprecated. 
<M> List<M>
getEnabledModulesByClass(Class<M> moduleClass)
          Retrieve all plugin modules that implement or extend a specific class.
<M> List<M>
getEnabledModulesByClassAndDescriptor(Class<ModuleDescriptor<M>>[] descriptorClazz, Class<M> moduleClass)
          Deprecated. 
<M> List<M>
getEnabledModulesByClassAndDescriptor(Class<ModuleDescriptor<M>> descriptorClass, Class<M> moduleClass)
          Deprecated. 
 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.
 InputStream getPluginResourceAsStream(String pluginKey, String resourcePath)
          Deprecated. 
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.plugin.PluginAccessor
getClassLoader, getDynamicPluginClass, getDynamicResourceAsStream, getEnabledModuleDescriptorsByClass, getEnabledModuleDescriptorsByType, getEnabledModulesByClass, getEnabledModulesByClassAndDescriptor, getEnabledModulesByClassAndDescriptor, getEnabledPlugin, getEnabledPluginModule, getEnabledPlugins, getModuleDescriptors, getModules, getPlugin, getPluginModule, getPluginResourceAsStream, getPluginRestartState, getPlugins, getPlugins, isPluginEnabled, isPluginModuleEnabled, isSystemPlugin
 

Field Detail

delegate

protected final PluginAccessor delegate
Constructor Detail

EnabledModuleCachingPluginAccessor

public EnabledModuleCachingPluginAccessor(PluginAccessor delegate,
                                          PluginEventManager pluginEventManager)
Method Detail

getEnabledModuleDescriptorsByClass

public <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(Class<D> descriptorClazz)
Description copied from interface: PluginAccessor
Get all enabled module descriptors that have a specific descriptor class.

Specified by:
getEnabledModuleDescriptorsByClass in interface PluginAccessor
Parameters:
descriptorClazz - module descriptor class
Returns:
List of ModuleDescriptors that implement or extend the given class.

onPluginDisable

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

getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: PluginAccessor
Retrieve the class loader responsible for loading classes and resources from plugins.

Specified by:
getClassLoader in interface PluginAccessor
Returns:
the class loader

getDynamicResourceAsStream

public InputStream getDynamicResourceAsStream(String resourcePath)
Description copied from interface: PluginAccessor
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.

Specified by:
getDynamicResourceAsStream in interface PluginAccessor
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

getEnabledModulesByClass

public <M> List<M> getEnabledModulesByClass(Class<M> moduleClass)
Description copied from interface: PluginAccessor
Retrieve all plugin modules that implement or extend a specific class.

Specified by:
getEnabledModulesByClass in interface PluginAccessor
Returns:
List of modules that implement or extend the given class.

getEnabledPlugin

public Plugin getEnabledPlugin(String pluginKey)
                        throws IllegalArgumentException
Description copied from interface: PluginAccessor
Retrieve a given plugin if it is enabled.

Specified by:
getEnabledPlugin in interface PluginAccessor
Returns:
The enabled plugin, or null if that plugin does not exist or is disabled.
Throws:
IllegalArgumentException - If the plugin key is null

getEnabledPluginModule

public ModuleDescriptor<?> getEnabledPluginModule(String completeKey)
Description copied from interface: PluginAccessor
Retrieve an enabled plugin module by complete module key.

Specified by:
getEnabledPluginModule in interface PluginAccessor

getEnabledPlugins

public Collection<Plugin> getEnabledPlugins()
Description copied from interface: PluginAccessor
Get all of the currently enabled plugins.

Specified by:
getEnabledPlugins in interface PluginAccessor
Returns:
a collection of installed and enabled Plugins.

getModuleDescriptors

public <M> Collection<ModuleDescriptor<M>> getModuleDescriptors(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
Description copied from interface: PluginAccessor
Gets all module descriptors of installed modules that match the given predicate.

Specified by:
getModuleDescriptors in interface PluginAccessor
Parameters:
moduleDescriptorPredicate - the ModuleDescriptorPredicate to match.
Returns:
a collection of ModuleDescriptors that match the given predicate.

getModules

public <M> Collection<M> getModules(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
Description copied from interface: PluginAccessor
Gets all installed modules that match the given predicate.

Specified by:
getModules in interface PluginAccessor
Parameters:
moduleDescriptorPredicate - the ModuleDescriptorPredicate to match.
Returns:
a collection of modules as per ModuleDescriptor.getModule() that match the given predicate.

getPlugin

public Plugin getPlugin(String key)
                 throws IllegalArgumentException
Description copied from interface: PluginAccessor
Retrieve a given plugin (whether enabled or not).

Specified by:
getPlugin in interface PluginAccessor
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

getPluginModule

public ModuleDescriptor<?> getPluginModule(String completeKey)
Description copied from interface: PluginAccessor
Retrieve any plugin module by complete module key.

Note: the module may or may not be disabled.

Specified by:
getPluginModule in interface PluginAccessor

getPluginRestartState

public PluginRestartState getPluginRestartState(String key)
Description copied from interface: PluginAccessor
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

Specified by:
getPluginRestartState in interface PluginAccessor
Parameters:
key - The plugin key
Returns:
The state of the plugin on restart

getPlugins

public Collection<Plugin> getPlugins()
Description copied from interface: PluginAccessor
Gets all of the currently installed plugins.

Specified by:
getPlugins in interface PluginAccessor
Returns:
a collection of installed Plugins.

getPlugins

public Collection<Plugin> getPlugins(PluginPredicate pluginPredicate)
Description copied from interface: PluginAccessor
Gets all installed plugins that match the given predicate.

Specified by:
getPlugins in interface PluginAccessor
Parameters:
pluginPredicate - the PluginPredicate to match.
Returns:
a collection of Plugins that match the given predicate.

isPluginEnabled

public boolean isPluginEnabled(String key)
                        throws IllegalArgumentException
Description copied from interface: PluginAccessor
Whether or not a given plugin is currently enabled.

Specified by:
isPluginEnabled in interface PluginAccessor
Throws:
IllegalArgumentException - If the plugin key is null

isPluginModuleEnabled

public boolean isPluginModuleEnabled(String completeKey)
Description copied from interface: PluginAccessor
Whether or not a given plugin module is currently enabled. This also checks if the plugin it is contained within is enabled also

Specified by:
isPluginModuleEnabled in interface PluginAccessor
See Also:
PluginAccessor.isPluginEnabled(String)

isSystemPlugin

public boolean isSystemPlugin(String key)
Specified by:
isSystemPlugin in interface PluginAccessor
Returns:
true if the plugin is a system plugin.

getDynamicPluginClass

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

Description copied from interface: PluginAccessor
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.

Specified by:
getDynamicPluginClass in interface PluginAccessor
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

getEnabledModuleDescriptorsByClass

@Deprecated
public <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(Class<D> descriptorClazz,
                                                                                             boolean verbose)
Deprecated. 

Description copied from interface: PluginAccessor
Get all enabled module descriptors that have a specific descriptor class.

Specified by:
getEnabledModuleDescriptorsByClass in interface PluginAccessor
Parameters:
descriptorClazz - module descriptor class
verbose - log verbose messages flag
Returns:
List of ModuleDescriptors that implement or extend the given class.

getEnabledModuleDescriptorsByType

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

Description copied from interface: PluginAccessor
Get all enabled module descriptors that have a specific descriptor type.

Specified by:
getEnabledModuleDescriptorsByType in interface PluginAccessor
Returns:
List of ModuleDescriptors that are of a given type.
Throws:
PluginParseException

getEnabledModulesByClassAndDescriptor

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

Description copied from interface: PluginAccessor
Retrieve all plugin modules that implement or extend a specific class, and has a descriptor class as the descriptorClazz

Specified by:
getEnabledModulesByClassAndDescriptor in interface PluginAccessor
Parameters:
descriptorClass - @NotNull
moduleClass - @NotNull
Returns:
List of modules that implement or extend the given class. Empty list if none found

getEnabledModulesByClassAndDescriptor

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

Description copied from interface: PluginAccessor
Retrieve all plugin modules that implement or extend a specific class, and has a descriptor class as one of descriptorClazz

Specified by:
getEnabledModulesByClassAndDescriptor in interface PluginAccessor
Parameters:
descriptorClazz - @NotNull
moduleClass - @NotNull
Returns:
List of modules that implement or extend the given class. Empty list if none found

getPluginResourceAsStream

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

Description copied from interface: PluginAccessor
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.

Specified by:
getPluginResourceAsStream in interface PluginAccessor


Copyright © 2013 Atlassian. All Rights Reserved.