com.atlassian.plugin.manager
Class DefaultPluginManager

java.lang.Object
  extended by com.atlassian.plugin.manager.DefaultPluginManager
All Implemented Interfaces:
PluginAccessor, PluginController, PluginSystemLifecycle
Direct Known Subclasses:
DefaultPluginManager

public class DefaultPluginManager
extends java.lang.Object
implements PluginController, PluginAccessor, PluginSystemLifecycle

This implementation delegates the initiation and classloading of plugins to a list of PluginLoaders and records the state of plugins in a PluginPersistentStateStore.

This class is responsible for enabling and disabling plugins and plugin modules and reflecting these state changes in the PluginPersistentStateStore.

An interesting quirk in the design is that installPlugin(com.atlassian.plugin.PluginArtifact) explicitly stores the plugin via a PluginInstaller, whereas uninstall(Plugin) relies on the underlying PluginLoader to remove the plugin if necessary.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.plugin.PluginAccessor
PluginAccessor.Descriptor
 
Constructor Summary
DefaultPluginManager(PluginPersistentStateStore store, java.util.List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager)
           
DefaultPluginManager(PluginPersistentStateStore store, java.util.List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, boolean verifyRequiredPlugins)
           
 
Method Summary
protected  void addPlugin(PluginLoader loader, Plugin plugin)
          Deprecated. Since 2.0.2, use #addPlugins(PluginLoader,Collection...) instead
protected  void addPlugins(PluginLoader loader, java.util.Collection<Plugin> pluginsToInstall)
          Update the local plugin state and enable state aware modules.
 void disablePlugin(java.lang.String key)
          Disables the plugin with the given key.
protected  void disablePluginInternal(java.lang.String key, boolean persistDisabledState)
           
 void disablePluginModule(java.lang.String completeKey)
          Disable a plugin module by key.
protected  void disablePluginModuleState(ModuleDescriptor<?> module, PluginPersistentStateStore stateStore)
           
protected  void disablePluginState(Plugin plugin, PluginPersistentStateStore stateStore)
           
 void disablePluginWithoutPersisting(java.lang.String key)
          Disables the plugin with the given key without persisting the disabled state.
 void enablePlugin(java.lang.String key)
          Deprecated. since 2.5.0, use {#link enablePlugins(String... keys)} instead
 void enablePluginModule(java.lang.String completeKey)
          Enable a plugin module by key.
protected  void enablePluginModuleState(ModuleDescriptor<?> module, PluginPersistentStateStore stateStore)
           
 void enablePlugins(java.lang.String... keys)
          Enable a set of plugins by key.
protected  void enablePluginState(Plugin plugin, PluginPersistentStateStore stateStore)
           
 PluginsClassLoader getClassLoader()
          Retrieve the class loader responsible for loading classes and resources from plugins.
 java.lang.Class<?> getDynamicPluginClass(java.lang.String className)
          Retrieve a class from a currently loaded (and active) dynamically loaded plugin.
 java.io.InputStream getDynamicResourceAsStream(java.lang.String name)
          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)
          This method has been reverted to pre PLUG-40 to fix performance issues that were encountered during load testing.
<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>>[] descriptorClasses, 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)
          Retrieve a resource from a currently loaded (and active) plugin.
 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.
protected  PluginPersistentState getState()
           
protected  PluginPersistentStateStore getStore()
           
 void init()
          Initialise the plugin system.
 java.lang.String installPlugin(PluginArtifact pluginArtifact)
          Installs a plugin and returns the plugin key
 java.util.Set<java.lang.String> installPlugins(PluginArtifact... pluginArtifacts)
          Installs multiple plugins and returns the list of plugin keys.
 boolean isPluginEnabled(java.lang.String key)
          This method checks to see if the plugin is enabled based on the state manager and the plugin.
 boolean isPluginModuleEnabled(java.lang.String completeKey)
          Whether or not a given plugin module is currently enabled.
 boolean isSystemPlugin(java.lang.String key)
           
protected  void notifyModuleDisabled(ModuleDescriptor<?> module)
           
protected  void notifyModuleEnabled(ModuleDescriptor<?> module)
           
protected  void notifyPluginDisabled(Plugin plugin)
           
protected  void notifyPluginEnabled(Plugin plugin)
          Called on all clustered application nodes, rather than enablePlugin(String) to just update the local state, state aware modules and loaders, but not affect the global plugin state.
protected  void notifyUninstallPlugin(Plugin plugin)
           
 void onPluginContainerUnavailable(PluginContainerUnavailableEvent event)
           
 void onPluginModuleAvailable(PluginModuleAvailableEvent event)
           
 void onPluginModuleUnavailable(PluginModuleUnavailableEvent event)
           
 void onPluginRefresh(PluginRefreshedEvent event)
           
protected  void onUpdateRequiresRestartState(java.lang.String pluginKey, PluginRestartState pluginRestartState)
           
protected  void removeStateFromStore(PluginPersistentStateStore stateStore, Plugin plugin)
           
 void revertRestartRequiredChange(java.lang.String pluginKey)
          Restores the state of any plugin requiring a restart that had been removed, upgraded, or installed.
 int scanForNewPlugins()
          Search all loaders and add any new plugins you find.
 void setDescriptorParserFactory(DescriptorParserFactory descriptorParserFactory)
          Deprecated. Since 2.0.0.beta2
 void setPluginInstaller(PluginInstaller pluginInstaller)
          Set the plugin installation strategy for this manager
 void shutdown()
          Fires the shutdown event
 void uninstall(Plugin plugin)
          Uninstalls the given plugin, emitting disabled and uninstalled events as it does so.
protected  void uninstallNoEvent(Plugin plugin)
          Preforms an uninstallation without broadcasting the uninstallation event.
protected  void unloadPlugin(Plugin plugin)
          Unload a plugin.
protected  void updatePlugin(Plugin oldPlugin, Plugin newPlugin)
          Replace an already loaded plugin with another version.
 void warmRestart()
          Restart all plugins by disabling and enabling them in the order they were loaded (by plugin loader)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPluginManager

public DefaultPluginManager(PluginPersistentStateStore store,
                            java.util.List<PluginLoader> pluginLoaders,
                            ModuleDescriptorFactory moduleDescriptorFactory,
                            PluginEventManager pluginEventManager)

DefaultPluginManager

public DefaultPluginManager(PluginPersistentStateStore store,
                            java.util.List<PluginLoader> pluginLoaders,
                            ModuleDescriptorFactory moduleDescriptorFactory,
                            PluginEventManager pluginEventManager,
                            boolean verifyRequiredPlugins)
Method Detail

init

public void init()
          throws PluginParseException,
                 NotificationException
Description copied from interface: PluginSystemLifecycle
Initialise the plugin system. This must be called before anything else.

Specified by:
init in interface PluginSystemLifecycle
Throws:
PluginParseException - If parsing the plugins failed.
NotificationException - If any of the Event Listeners throw an exception on the Framework startup events.

shutdown

public void shutdown()
Fires the shutdown event

Specified by:
shutdown in interface PluginSystemLifecycle
Throws:
java.lang.IllegalStateException - if already shutdown or already in the process of shutting down.
Since:
2.0.0

warmRestart

public final void warmRestart()
Description copied from interface: PluginSystemLifecycle
Restart all plugins by disabling and enabling them in the order they were loaded (by plugin loader)

Specified by:
warmRestart in interface PluginSystemLifecycle

onPluginModuleAvailable

public void onPluginModuleAvailable(PluginModuleAvailableEvent event)

onPluginModuleUnavailable

public void onPluginModuleUnavailable(PluginModuleUnavailableEvent event)

onPluginContainerUnavailable

public void onPluginContainerUnavailable(PluginContainerUnavailableEvent event)

onPluginRefresh

public void onPluginRefresh(PluginRefreshedEvent event)

setPluginInstaller

public void setPluginInstaller(PluginInstaller pluginInstaller)
Set the plugin installation strategy for this manager

Parameters:
pluginInstaller - the plugin installation strategy to use
See Also:
PluginInstaller

getStore

protected final PluginPersistentStateStore getStore()

installPlugin

public java.lang.String installPlugin(PluginArtifact pluginArtifact)
                               throws PluginParseException
Description copied from interface: PluginController
Installs a plugin and returns the plugin key

Specified by:
installPlugin in interface PluginController
Parameters:
pluginArtifact - The plugin artifact to install
Returns:
The plugin key
Throws:
PluginParseException - if the plugin is not a valid plugin

installPlugins

public java.util.Set<java.lang.String> installPlugins(PluginArtifact... pluginArtifacts)
                                               throws PluginParseException
Description copied from interface: PluginController
Installs multiple plugins and returns the list of plugin keys. All plugin artifacts must be for valid plugins or none will be installed.

Specified by:
installPlugins in interface PluginController
Parameters:
pluginArtifacts - The list of plugin artifacts to install
Returns:
A list of plugin keys
Throws:
PluginParseException - if any plugin is not a valid plugin

scanForNewPlugins

public int scanForNewPlugins()
                      throws PluginParseException
Description copied from interface: PluginController
Search all loaders and add any new plugins you find.

Specified by:
scanForNewPlugins in interface PluginController
Returns:
The number of new plugins found.
Throws:
PluginParseException

onUpdateRequiresRestartState

protected void onUpdateRequiresRestartState(java.lang.String pluginKey,
                                            PluginRestartState pluginRestartState)

uninstall

public void uninstall(Plugin plugin)
               throws PluginException
Uninstalls the given plugin, emitting disabled and uninstalled events as it does so.

Specified by:
uninstall in interface PluginController
Parameters:
plugin - the plugin to uninstall.
Throws:
PluginException - If the plugin or loader doesn't support uninstallation

uninstallNoEvent

protected void uninstallNoEvent(Plugin plugin)
Preforms an uninstallation without broadcasting the uninstallation event.

Parameters:
plugin - The plugin to uninstall
Since:
2.5.0

revertRestartRequiredChange

public void revertRestartRequiredChange(java.lang.String pluginKey)
                                 throws PluginException
Description copied from interface: PluginController
Restores the state of any plugin requiring a restart that had been removed, upgraded, or installed. If marked as removed, the mark will be deleted. If marked as upgrade, an attempt to restore the original plugin artifact will be made. If marked as install, the artifact will be deleted.

Specified by:
revertRestartRequiredChange in interface PluginController
Parameters:
pluginKey - The plugin key to revert
Throws:
PluginException - If the revert cannot be completed

removeStateFromStore

protected void removeStateFromStore(PluginPersistentStateStore stateStore,
                                    Plugin plugin)

unloadPlugin

protected void unloadPlugin(Plugin plugin)
                     throws PluginException
Unload a plugin. Called when plugins are added locally, or remotely in a clustered application.

Parameters:
plugin - the plugin to remove
Throws:
PluginException - if the plugin cannot be uninstalled

notifyUninstallPlugin

protected void notifyUninstallPlugin(Plugin plugin)

getState

protected PluginPersistentState getState()

addPlugin

@Deprecated
protected void addPlugin(PluginLoader loader,
                                    Plugin plugin)
                  throws PluginParseException
Deprecated. Since 2.0.2, use #addPlugins(PluginLoader,Collection...) instead

Throws:
PluginParseException

addPlugins

protected void addPlugins(PluginLoader loader,
                          java.util.Collection<Plugin> pluginsToInstall)
                   throws PluginParseException
Update the local plugin state and enable state aware modules.

If there is an existing plugin with the same key, the version strings of the existing plugin and the plugin provided to this method will be parsed and compared. If the installed version is newer than the provided version, it will not be changed. If the specified plugin's version is the same or newer, the existing plugin state will be saved and the plugin will be unloaded before the provided plugin is installed. If the existing plugin cannot be unloaded a PluginException will be thrown.

Parameters:
loader - the loader used to load this plugin
pluginsToInstall - the plugins to add
Throws:
PluginParseException - if the plugin cannot be parsed
Since:
2.0.2

updatePlugin

protected void updatePlugin(Plugin oldPlugin,
                            Plugin newPlugin)
                     throws PluginException
Replace an already loaded plugin with another version. Relevant stored configuration for the plugin will be preserved.

Parameters:
oldPlugin - Plugin to replace
newPlugin - New plugin to install
Throws:
PluginException - if the plugin cannot be updated

getPlugins

public java.util.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 java.util.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.
Since:
0.17
See Also:
PluginAccessor.getPlugins(com.atlassian.plugin.predicate.PluginPredicate)

getEnabledPlugins

public java.util.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.
See Also:
PluginAccessor.getEnabledPlugins()

getModules

public <M> java.util.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.
Since:
0.17
See Also:
PluginAccessor.getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate)

getModuleDescriptors

public <M> java.util.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.
Since:
0.17
See Also:
PluginAccessor.getModuleDescriptors(com.atlassian.plugin.predicate.ModuleDescriptorPredicate)

getPlugin

public Plugin getPlugin(java.lang.String key)
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.

getEnabledPlugin

public Plugin getEnabledPlugin(java.lang.String pluginKey)
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.

getPluginModule

public ModuleDescriptor<?> getPluginModule(java.lang.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

getEnabledPluginModule

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

Specified by:
getEnabledPluginModule in interface PluginAccessor

getEnabledModulesByClass

public <M> java.util.List<M> getEnabledModulesByClass(java.lang.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.
See Also:
PluginAccessor.getEnabledModulesByClass(Class)

getEnabledModulesByClassAndDescriptor

@Deprecated
public <M> java.util.List<M> getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<M>>[] descriptorClasses,
                                                                              java.lang.Class<M> moduleClass)
Deprecated. since 0.17, use getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.

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:
descriptorClasses - @NotNull
moduleClass - @NotNull
Returns:
List of modules that implement or extend the given class. Empty list if none found
See Also:
PluginAccessor.getEnabledModulesByClassAndDescriptor(Class[], Class)

getEnabledModulesByClassAndDescriptor

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

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
See Also:
PluginAccessor.getEnabledModulesByClassAndDescriptor(Class, Class)

getEnabledModuleDescriptorsByClass

public <D extends ModuleDescriptor<?>> java.util.List<D> getEnabledModuleDescriptorsByClass(java.lang.Class<D> descriptorClazz)
This method has been reverted to pre PLUG-40 to fix performance issues that were encountered during load testing. This should be reverted to the state it was in at 54639 when the fundamental issue leading to this slowdown has been corrected (that is, slowness of PluginClassLoader).

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

getEnabledModuleDescriptorsByClass

public <D extends ModuleDescriptor<?>> java.util.List<D> getEnabledModuleDescriptorsByClass(java.lang.Class<D> descriptorClazz,
                                                                                            boolean verbose)
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> java.util.List<ModuleDescriptor<M>> getEnabledModuleDescriptorsByType(java.lang.String type)
                                                                      throws PluginParseException,
                                                                             java.lang.IllegalArgumentException
Deprecated. since 0.17, use getModuleDescriptors(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.

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
java.lang.IllegalArgumentException
See Also:
PluginAccessor.getEnabledModuleDescriptorsByType(String)

enablePlugins

public void enablePlugins(java.lang.String... keys)
Enable a set of plugins by key. This will implicitly and recursively enable all dependent plugins.

Specified by:
enablePlugins in interface PluginController
Parameters:
keys - The plugin keys. Must not be null.
Since:
2.5.0

enablePlugin

@Deprecated
public void enablePlugin(java.lang.String key)
Deprecated. since 2.5.0, use {#link enablePlugins(String... keys)} instead

Description copied from interface: PluginController
Enable a plugin by key.

Specified by:
enablePlugin in interface PluginController
Parameters:
key - The plugin key.

enablePluginState

protected void enablePluginState(Plugin plugin,
                                 PluginPersistentStateStore stateStore)

notifyPluginEnabled

protected void notifyPluginEnabled(Plugin plugin)
Called on all clustered application nodes, rather than enablePlugin(String) to just update the local state, state aware modules and loaders, but not affect the global plugin state.

Parameters:
plugin - the plugin being enabled

disablePlugin

public void disablePlugin(java.lang.String key)
Description copied from interface: PluginController
Disables the plugin with the given key.

Calling this method will persist the disabled state so that the plugin will also be disabled on next startup. This would normally be used when a user manually disables a plugin.

If you extend DefaultPluginManager and override this method, you will also need to override PluginController.disablePluginWithoutPersisting(String).

Specified by:
disablePlugin in interface PluginController
Parameters:
key - The plugin key.
See Also:
PluginController.disablePluginWithoutPersisting(String)

disablePluginWithoutPersisting

public void disablePluginWithoutPersisting(java.lang.String key)
Description copied from interface: PluginController
Disables the plugin with the given key without persisting the disabled state.

Calling this method will NOT persist the disabled state so that the framework will try to enable the plugin on next startup. This is used when a plugin has errors on startup.

If you extend DefaultPluginManager and override PluginController.disablePlugin(String), you will also need to override this method.

Specified by:
disablePluginWithoutPersisting in interface PluginController
Parameters:
key - The plugin key.
See Also:
PluginController.disablePlugin(String)

disablePluginInternal

protected void disablePluginInternal(java.lang.String key,
                                     boolean persistDisabledState)

disablePluginState

protected void disablePluginState(Plugin plugin,
                                  PluginPersistentStateStore stateStore)

notifyPluginDisabled

protected void notifyPluginDisabled(Plugin plugin)

disablePluginModule

public void disablePluginModule(java.lang.String completeKey)
Description copied from interface: PluginController
Disable a plugin module by key.

Specified by:
disablePluginModule in interface PluginController
Parameters:
completeKey - The "complete key" of the plugin module.

disablePluginModuleState

protected void disablePluginModuleState(ModuleDescriptor<?> module,
                                        PluginPersistentStateStore stateStore)

notifyModuleDisabled

protected void notifyModuleDisabled(ModuleDescriptor<?> module)

enablePluginModule

public void enablePluginModule(java.lang.String completeKey)
Description copied from interface: PluginController
Enable a plugin module by key.

Specified by:
enablePluginModule in interface PluginController
Parameters:
completeKey - The "complete key" of the plugin module.

enablePluginModuleState

protected void enablePluginModuleState(ModuleDescriptor<?> module,
                                       PluginPersistentStateStore stateStore)

notifyModuleEnabled

protected void notifyModuleEnabled(ModuleDescriptor<?> module)

isPluginModuleEnabled

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

isPluginEnabled

public boolean isPluginEnabled(java.lang.String key)
This method checks to see if the plugin is enabled based on the state manager and the plugin.

Specified by:
isPluginEnabled in interface PluginAccessor
Parameters:
key - The plugin key
Returns:
True if the plugin is enabled

getDynamicResourceAsStream

public java.io.InputStream getDynamicResourceAsStream(java.lang.String name)
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:
name - the path to the resource to retrieve
Returns:
the dynamically loaded resource that matches that path, or null if no such resource is found

getDynamicPluginClass

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

getClassLoader

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

getPluginResourceAsStream

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

isSystemPlugin

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

getPluginRestartState

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

setDescriptorParserFactory

@Deprecated
public void setDescriptorParserFactory(DescriptorParserFactory descriptorParserFactory)
Deprecated. Since 2.0.0.beta2



Copyright © 2013 Atlassian. All Rights Reserved.