|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.plugin.manager.DefaultPluginManager
public class DefaultPluginManager
This implementation delegates the initiation and classloading of plugins to a
list of PluginLoaders and records the
state of plugins in a
PluginPersistentStateStore.
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)
|
|
| 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. |
|
|
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. |
|
|
getEnabledModuleDescriptorsByClass(java.lang.Class<D> descriptorClazz,
boolean verbose)
Get all enabled module descriptors that have a specific descriptor class. |
|
|
getEnabledModuleDescriptorsByType(java.lang.String type)
Deprecated. since 0.17, use getModuleDescriptors(com.atlassian.plugin.predicate.ModuleDescriptorPredicate)
with an appropriate predicate instead. |
|
|
getEnabledModulesByClass(java.lang.Class<M> moduleClass)
Retrieve all plugin modules that implement or extend a specific class. |
|
|
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. |
|
|
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. |
|
|
getModuleDescriptors(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
Gets all module descriptors of installed modules that match the given predicate. |
|
|
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 |
|---|
public DefaultPluginManager(PluginPersistentStateStore store,
java.util.List<PluginLoader> pluginLoaders,
ModuleDescriptorFactory moduleDescriptorFactory,
PluginEventManager pluginEventManager)
| Method Detail |
|---|
public void init()
throws PluginParseException,
NotificationException
PluginSystemLifecycle
init in interface PluginSystemLifecyclePluginParseException - If parsing the plugins failed.
NotificationException - If any of the Event Listeners throw an exception on the Framework startup events.public void shutdown()
shutdown in interface PluginSystemLifecyclejava.lang.IllegalStateException - if already shutdown or already in the
process of shutting down.public final void warmRestart()
PluginSystemLifecycle
warmRestart in interface PluginSystemLifecyclepublic void onPluginModuleAvailable(PluginModuleAvailableEvent event)
public void onPluginModuleUnavailable(PluginModuleUnavailableEvent event)
public void onPluginContainerUnavailable(PluginContainerUnavailableEvent event)
public void onPluginRefresh(PluginRefreshedEvent event)
public void setPluginInstaller(PluginInstaller pluginInstaller)
pluginInstaller - the plugin installation strategy to usePluginInstallerprotected final PluginPersistentStateStore getStore()
public java.lang.String installPlugin(PluginArtifact pluginArtifact)
throws PluginParseException
PluginController
installPlugin in interface PluginControllerpluginArtifact - The plugin artifact to install
PluginParseException - if the plugin is not a valid plugin
public java.util.Set<java.lang.String> installPlugins(PluginArtifact... pluginArtifacts)
throws PluginParseException
PluginController
installPlugins in interface PluginControllerpluginArtifacts - The list of plugin artifacts to install
PluginParseException - if any plugin is not a valid plugin
public int scanForNewPlugins()
throws PluginParseException
PluginController
scanForNewPlugins in interface PluginControllerPluginParseException
protected void onUpdateRequiresRestartState(java.lang.String pluginKey,
PluginRestartState pluginRestartState)
public void uninstall(Plugin plugin)
throws PluginException
uninstall in interface PluginControllerplugin - the plugin to uninstall.
PluginException - If the plugin or loader doesn't support
uninstallationprotected void uninstallNoEvent(Plugin plugin)
plugin - The plugin to uninstall
public void revertRestartRequiredChange(java.lang.String pluginKey)
throws PluginException
PluginController
revertRestartRequiredChange in interface PluginControllerpluginKey - The plugin key to revert
PluginException - If the revert cannot be completed
protected void removeStateFromStore(PluginPersistentStateStore stateStore,
Plugin plugin)
protected void unloadPlugin(Plugin plugin)
throws PluginException
plugin - the plugin to remove
PluginException - if the plugin cannot be uninstalledprotected void notifyUninstallPlugin(Plugin plugin)
protected PluginPersistentState getState()
@Deprecated
protected void addPlugin(PluginLoader loader,
Plugin plugin)
throws PluginParseException
#addPlugins(PluginLoader,Collection...) instead
PluginParseException
protected void addPlugins(PluginLoader loader,
java.util.Collection<Plugin> pluginsToInstall)
throws PluginParseException
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.
loader - the loader used to load this pluginpluginsToInstall - the plugins to add
PluginParseException - if the plugin cannot be parsed
protected void updatePlugin(Plugin oldPlugin,
Plugin newPlugin)
throws PluginException
oldPlugin - Plugin to replacenewPlugin - New plugin to install
PluginException - if the plugin cannot be updatedpublic java.util.Collection<Plugin> getPlugins()
PluginAccessor
getPlugins in interface PluginAccessorPlugins.public java.util.Collection<Plugin> getPlugins(PluginPredicate pluginPredicate)
PluginAccessor
getPlugins in interface PluginAccessorpluginPredicate - the PluginPredicate to match.
Plugins that match the given predicate.PluginAccessor.getPlugins(com.atlassian.plugin.predicate.PluginPredicate)public java.util.Collection<Plugin> getEnabledPlugins()
PluginAccessor
getEnabledPlugins in interface PluginAccessorPlugins.PluginAccessor.getEnabledPlugins()public <M> java.util.Collection<M> getModules(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
PluginAccessor
getModules in interface PluginAccessormoduleDescriptorPredicate - the ModuleDescriptorPredicate to match.
ModuleDescriptor.getModule() that match the given predicate.PluginAccessor.getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate)public <M> java.util.Collection<ModuleDescriptor<M>> getModuleDescriptors(ModuleDescriptorPredicate<M> moduleDescriptorPredicate)
PluginAccessor
getModuleDescriptors in interface PluginAccessormoduleDescriptorPredicate - the ModuleDescriptorPredicate to match.
ModuleDescriptors that match the given predicate.PluginAccessor.getModuleDescriptors(com.atlassian.plugin.predicate.ModuleDescriptorPredicate)public Plugin getPlugin(java.lang.String key)
PluginAccessor
getPlugin in interface PluginAccessorkey - The plugin key. Cannot be null.
public Plugin getEnabledPlugin(java.lang.String pluginKey)
PluginAccessor
getEnabledPlugin in interface PluginAccessorpublic ModuleDescriptor<?> getPluginModule(java.lang.String completeKey)
PluginAccessorNote: the module may or may not be disabled.
getPluginModule in interface PluginAccessorpublic ModuleDescriptor<?> getEnabledPluginModule(java.lang.String completeKey)
PluginAccessor
getEnabledPluginModule in interface PluginAccessorpublic <M> java.util.List<M> getEnabledModulesByClass(java.lang.Class<M> moduleClass)
PluginAccessor
getEnabledModulesByClass in interface PluginAccessorPluginAccessor.getEnabledModulesByClass(Class)
@Deprecated
public <M> java.util.List<M> getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<M>>[] descriptorClasses,
java.lang.Class<M> moduleClass)
getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate)
with an appropriate predicate instead.
PluginAccessor
getEnabledModulesByClassAndDescriptor in interface PluginAccessordescriptorClasses - @NotNullmoduleClass - @NotNull
PluginAccessor.getEnabledModulesByClassAndDescriptor(Class[], Class)
@Deprecated
public <M> java.util.List<M> getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<M>> descriptorClass,
java.lang.Class<M> moduleClass)
getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate)
with an appropriate predicate instead.
PluginAccessor
getEnabledModulesByClassAndDescriptor in interface PluginAccessordescriptorClass - @NotNullmoduleClass - @NotNull
PluginAccessor.getEnabledModulesByClassAndDescriptor(Class, Class)public <D extends ModuleDescriptor<?>> java.util.List<D> getEnabledModuleDescriptorsByClass(java.lang.Class<D> descriptorClazz)
getEnabledModuleDescriptorsByClass in interface PluginAccessordescriptorClazz - module descriptor class
ModuleDescriptors that implement or extend the given class.PluginAccessor.getEnabledModuleDescriptorsByClass(Class)
public <D extends ModuleDescriptor<?>> java.util.List<D> getEnabledModuleDescriptorsByClass(java.lang.Class<D> descriptorClazz,
boolean verbose)
PluginAccessor
getEnabledModuleDescriptorsByClass in interface PluginAccessordescriptorClazz - module descriptor classverbose - log verbose messages flag
ModuleDescriptors that implement or extend the given class.
@Deprecated
public <M> java.util.List<ModuleDescriptor<M>> getEnabledModuleDescriptorsByType(java.lang.String type)
throws PluginParseException,
java.lang.IllegalArgumentException
getModuleDescriptors(com.atlassian.plugin.predicate.ModuleDescriptorPredicate)
with an appropriate predicate instead.
PluginAccessor
getEnabledModuleDescriptorsByType in interface PluginAccessorModuleDescriptors that are of a given type.
PluginParseException
java.lang.IllegalArgumentExceptionPluginAccessor.getEnabledModuleDescriptorsByType(String)public void enablePlugins(java.lang.String... keys)
enablePlugins in interface PluginControllerkeys - The plugin keys. Must not be null.@Deprecated public void enablePlugin(java.lang.String key)
PluginController
enablePlugin in interface PluginControllerkey - The plugin key.
protected void enablePluginState(Plugin plugin,
PluginPersistentStateStore stateStore)
protected void notifyPluginEnabled(Plugin plugin)
enablePlugin(String) to just update the local state, state aware
modules and loaders, but not affect the global plugin state.
plugin - the plugin being enabledpublic void disablePlugin(java.lang.String key)
PluginControllerCalling 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).
disablePlugin in interface PluginControllerkey - The plugin key.PluginController.disablePluginWithoutPersisting(String)public void disablePluginWithoutPersisting(java.lang.String key)
PluginControllerCalling 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.
disablePluginWithoutPersisting in interface PluginControllerkey - The plugin key.PluginController.disablePlugin(String)
protected void disablePluginInternal(java.lang.String key,
boolean persistDisabledState)
protected void disablePluginState(Plugin plugin,
PluginPersistentStateStore stateStore)
protected void notifyPluginDisabled(Plugin plugin)
public void disablePluginModule(java.lang.String completeKey)
PluginController
disablePluginModule in interface PluginControllercompleteKey - The "complete key" of the plugin module.
protected void disablePluginModuleState(ModuleDescriptor<?> module,
PluginPersistentStateStore stateStore)
protected void notifyModuleDisabled(ModuleDescriptor<?> module)
public void enablePluginModule(java.lang.String completeKey)
PluginController
enablePluginModule in interface PluginControllercompleteKey - The "complete key" of the plugin module.
protected void enablePluginModuleState(ModuleDescriptor<?> module,
PluginPersistentStateStore stateStore)
protected void notifyModuleEnabled(ModuleDescriptor<?> module)
public boolean isPluginModuleEnabled(java.lang.String completeKey)
PluginAccessor
isPluginModuleEnabled in interface PluginAccessorPluginAccessor.isPluginEnabled(String)public boolean isPluginEnabled(java.lang.String key)
isPluginEnabled in interface PluginAccessorkey - The plugin key
public java.io.InputStream getDynamicResourceAsStream(java.lang.String name)
PluginAccessor
getDynamicResourceAsStream in interface PluginAccessorname - the path to the resource to retrieve
public java.lang.Class<?> getDynamicPluginClass(java.lang.String className)
throws java.lang.ClassNotFoundException
PluginAccessor
getDynamicPluginClass in interface PluginAccessorclassName - the name of the class to retrieve
java.lang.ClassNotFoundException - thrown if no classes by that name could be found in any of the enabled dynamic pluginspublic PluginsClassLoader getClassLoader()
PluginAccessor
getClassLoader in interface PluginAccessor
public java.io.InputStream getPluginResourceAsStream(java.lang.String pluginKey,
java.lang.String resourcePath)
PluginAccessor
getPluginResourceAsStream in interface PluginAccessorpublic boolean isSystemPlugin(java.lang.String key)
isSystemPlugin in interface PluginAccessorpublic PluginRestartState getPluginRestartState(java.lang.String key)
PluginAccessor
getPluginRestartState in interface PluginAccessorkey - The plugin key
@Deprecated public void setDescriptorParserFactory(DescriptorParserFactory descriptorParserFactory)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||