com.atlassian.plugin
Interface PluginAccessor

All Known Subinterfaces:
PluginManager
All Known Implementing Classes:
DefaultPluginManager, DefaultPluginManager

public interface PluginAccessor

Allows access to the current plugin system state


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

Method Detail

getPlugins

java.util.Collection<Plugin> getPlugins()
Gets all of the currently installed plugins.

Returns:
a collection of installed Plugins.

getPlugins

java.util.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.
Since:
0.17

getEnabledPlugins

java.util.Collection<Plugin> getEnabledPlugins()
Get all of the currently enabled plugins.

Returns:
a collection of installed and enabled Plugins.

getModules

<M> java.util.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 ModuleDescriptor.getModule() that match the given predicate.
Since:
0.17

getModuleDescriptors

<M> java.util.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:
a collection of ModuleDescriptors that match the given predicate.
Since:
0.17

getPlugin

Plugin getPlugin(java.lang.String key)
Retrieve a given plugin (whether enabled or not).

Returns:
The enabled plugin, or null if that plugin does not exist.

getEnabledPlugin

Plugin getEnabledPlugin(java.lang.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.

getPluginModule

ModuleDescriptor<?> getPluginModule(java.lang.String completeKey)
Retrieve any plugin module by complete module key.

Note: the module may or may not be disabled.


getEnabledPluginModule

ModuleDescriptor<?> getEnabledPluginModule(java.lang.String completeKey)
Retrieve an enabled plugin module by complete module key.


isPluginEnabled

boolean isPluginEnabled(java.lang.String key)
Whether or not a given plugin is currently enabled.


isPluginModuleEnabled

boolean isPluginModuleEnabled(java.lang.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

See Also:
isPluginEnabled(String)

getEnabledModulesByClass

<M> java.util.List<M> getEnabledModulesByClass(java.lang.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.

getEnabledModulesByClassAndDescriptor

@Deprecated
<M> java.util.List<M> getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<M>>[] descriptorClazz,
                                                                       java.lang.Class<M> moduleClass)
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

getEnabledModulesByClassAndDescriptor

@Deprecated
<M> java.util.List<M> getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<M>> descriptorClass,
                                                                       java.lang.Class<M> moduleClass)
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

getEnabledModuleDescriptorsByClass

<D extends ModuleDescriptor<?>> java.util.List<D> getEnabledModuleDescriptorsByClass(java.lang.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.

getEnabledModuleDescriptorsByClass

<D extends ModuleDescriptor<?>> java.util.List<D> getEnabledModuleDescriptorsByClass(java.lang.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:
List of ModuleDescriptors that implement or extend the given class.

getEnabledModuleDescriptorsByType

@Deprecated
<M> java.util.List<ModuleDescriptor<M>> getEnabledModuleDescriptorsByType(java.lang.String type)
                                                                      throws PluginParseException
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:
List of ModuleDescriptors that are of a given type.
Throws:
PluginParseException

getDynamicResourceAsStream

java.io.InputStream getDynamicResourceAsStream(java.lang.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

getPluginResourceAsStream

@Deprecated
java.io.InputStream getPluginResourceAsStream(java.lang.String pluginKey,
                                                         java.lang.String resourcePath)
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.


getDynamicPluginClass

@Deprecated
java.lang.Class<?> getDynamicPluginClass(java.lang.String className)
                                         throws java.lang.ClassNotFoundException
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:
java.lang.ClassNotFoundException - thrown if no classes by that name could be found in any of the enabled dynamic plugins

getClassLoader

java.lang.ClassLoader getClassLoader()
Retrieve the class loader responsible for loading classes and resources from plugins.

Returns:
the class loader
Since:
0.21

isSystemPlugin

boolean isSystemPlugin(java.lang.String key)
Returns:
true if the plugin is a system plugin.

getPluginRestartState

PluginRestartState getPluginRestartState(java.lang.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


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.