Class DefaultPluginManager
- All Implemented Interfaces:
PluginAccessor,PluginController,PluginSystemLifecycle,SplitStartupPluginSystemLifecycle
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
installPlugins(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 ClassesModifier and TypeClassDescriptionstatic classNested classes/interfaces inherited from interface com.atlassian.plugin.PluginAccessor
PluginAccessor.Descriptor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefaultPluginManager(DefaultPluginManager.Builder<? extends DefaultPluginManager.Builder> builder) DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager) DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, boolean verifyRequiredPlugins) DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception) DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, boolean verifyRequiredPlugins) DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, boolean verifyRequiredPlugins, Predicate<Plugin> delayLoadOf) DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, Predicate<Plugin> delayLoadOf) DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, Predicate<Plugin> delayLoadOf) -
Method Summary
Modifier and TypeMethodDescriptionaddDynamicModule(Plugin maybePluginInternal, Element module) protected voidaddPlugins(PluginLoader loader, Collection<Plugin> pluginsToInstall) Update the local plugin state and enable state aware modules.voiddisablePlugin(String key) protected voiddisablePluginInternal(String key, boolean persistDisabledState) voiddisablePluginModule(String completeKey) voidvoidPerform the first part of startup.voidenablePluginModule(String completeKey) voidenablePlugins(String... keys) Enable a set of plugins by key.getDynamicModules(Plugin maybePluginInternal) Class<?>getDynamicPluginClass(String className) <D extends ModuleDescriptor<?>>
List<D>getEnabledModuleDescriptorsByClass(Class<D> descriptorClazz) This method has been reverted to pre PLUG-40 to fix performance issues that were encountered during load testing.<M> List<M>getEnabledModulesByClass(Class<M> moduleClass) getEnabledPlugin(String pluginKey) getEnabledPluginModule(String completeKey) static Stringstatic String<M> Collection<ModuleDescriptor<M>>getModuleDescriptors(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate) <M> Collection<M>getModules(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate) getPluginModule(String completeKey) getPlugins(Predicate<Plugin> pluginPredicate) static Stringprotected PluginPersistentStategetState()voidinit()installPlugins(PluginArtifact... pluginArtifacts) booleanisPluginEnabled(String key) This method checks to see if the plugin is enabled based on the state manager and the plugin.booleanisPluginModuleEnabled(String completeKey) booleanisSystemPlugin(String key) voidPerform the second part of startup.static DefaultPluginManager.Builder<? extends DefaultPluginManager.Builder<?>>protected voidnotifyModuleDisabled(ModuleDescriptor<?> module) protected voidnotifyModuleEnabled(ModuleDescriptor<?> module) protected voidnotifyUninstallPlugin(Plugin plugin) voidvoidvoidvoidprotected voidonUpdateRequiresRestartState(String pluginKey, PluginRestartState pluginRestartState) voidremoveDynamicModule(Plugin maybePluginInternal, ModuleDescriptor<?> module) protected voidremoveStateFromStore(PluginPersistentStateStore stateStore, Plugin plugin) voidrevertRestartRequiredChange(String pluginKey) intvoidsetPluginInstaller(PluginInstaller pluginInstaller) Set the plugin installation strategy for this managervoidshutdown()Fires the shutdown eventvoidUninstalls the given plugin, emitting disabled and uninstalled events as it does so.protected voiduninstallNoEvent(Plugin plugin) Preforms an uninstallation without broadcasting the uninstallation event.voiduninstallPlugins(Collection<Plugin> plugins) protected voidunloadPlugin(Plugin plugin) Unload a plugin.protected voidupdatePlugin(Plugin oldPlugin, Plugin newPlugin) Replace an already loaded plugin with another version.final voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.plugin.PluginAccessor
getActiveModuleDescriptorsByClass, getModuleDescriptors, getModules, getPlugins
-
Constructor Details
-
DefaultPluginManager
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager) -
DefaultPluginManager
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception) -
DefaultPluginManager
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, boolean verifyRequiredPlugins) -
DefaultPluginManager
@ExperimentalApi public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, Predicate<Plugin> delayLoadOf) -
DefaultPluginManager
@ExperimentalApi public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, Predicate<Plugin> delayLoadOf) -
DefaultPluginManager
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, boolean verifyRequiredPlugins) -
DefaultPluginManager
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, boolean verifyRequiredPlugins, Predicate<Plugin> delayLoadOf) -
DefaultPluginManager
protected DefaultPluginManager(DefaultPluginManager.Builder<? extends DefaultPluginManager.Builder> builder)
-
-
Method Details
-
getStartupOverrideFileProperty
-
getLateStartupEnableRetryProperty
-
getMinimumPluginVersionsFileProperty
-
newBuilder
-
init
public void init()- Specified by:
initin interfacePluginSystemLifecycle
-
earlyStartup
@ExperimentalApi public void earlyStartup()Description copied from interface:SplitStartupPluginSystemLifecyclePerform the first part of startup. This initializes the plugin system, and installs and enables early plugins.- Specified by:
earlyStartupin interfaceSplitStartupPluginSystemLifecycle- See Also:
-
lateStartup
@ExperimentalApi public void lateStartup()Description copied from interface:SplitStartupPluginSystemLifecyclePerform the second part of startup. This installs and enables late plugins, and performs any final validation steps. This may only be called afterSplitStartupPluginSystemLifecycle.earlyStartup(), and calling both earlyStartup and lateStartup is equivalent to callingPluginSystemLifecycle.init().- Specified by:
lateStartupin interfaceSplitStartupPluginSystemLifecycle- See Also:
-
shutdown
public void shutdown()Fires the shutdown event- Specified by:
shutdownin interfacePluginSystemLifecycle- Throws:
IllegalStateException- if already shutdown or already in the process of shutting down.- Since:
- 2.0.0
-
warmRestart
public final void warmRestart()- Specified by:
warmRestartin interfacePluginSystemLifecycle
-
onPluginModuleAvailable
-
onPluginRefresh
-
setPluginInstaller
Set the plugin installation strategy for this manager- Parameters:
pluginInstaller- the plugin installation strategy to use- See Also:
-
installPlugins
- Specified by:
installPluginsin interfacePluginController
-
scanForNewPlugins
public int scanForNewPlugins()- Specified by:
scanForNewPluginsin interfacePluginController
-
onUpdateRequiresRestartState
protected void onUpdateRequiresRestartState(String pluginKey, PluginRestartState pluginRestartState) -
uninstall
Uninstalls the given plugin, emitting disabled and uninstalled events as it does so.- Specified by:
uninstallin interfacePluginController- Parameters:
plugin- the plugin to uninstall.- Throws:
PluginException- If the plugin or loader doesn't support uninstallation
-
uninstallPlugins
- Specified by:
uninstallPluginsin interfacePluginController
-
uninstallNoEvent
Preforms an uninstallation without broadcasting the uninstallation event.- Parameters:
plugin- The plugin to uninstall- Since:
- 2.5.0
-
revertRestartRequiredChange
- Specified by:
revertRestartRequiredChangein interfacePluginController- Parameters:
pluginKey- The plugin key to revert- Throws:
PluginException- If the revert cannot be completed
-
removeStateFromStore
-
unloadPlugin
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
-
getState
-
addPlugins
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
PluginExceptionwill be thrown.- Parameters:
loader- the loader used to load this plugin. This should only be null when called internally from init(), in which case the loader is looked up per plugin in candidatePluginsToPluginLoader.pluginsToInstall- the plugins to add- Throws:
PluginParseException- if the plugin cannot be parsed- Since:
- 2.0.2
-
updatePlugin
Replace an already loaded plugin with another version. Relevant stored configuration for the plugin will be preserved.- Parameters:
oldPlugin- Plugin to replacenewPlugin- New plugin to install- Throws:
PluginException- if the plugin cannot be updated
-
getPlugins
- Specified by:
getPluginsin interfacePluginAccessor
-
getPlugins
- Specified by:
getPluginsin interfacePluginAccessor- Since:
- 0.17
- See Also:
-
getEnabledPlugins
- Specified by:
getEnabledPluginsin interfacePluginAccessor- See Also:
-
getModules
- Specified by:
getModulesin interfacePluginAccessor- Since:
- 0.17
- See Also:
-
getModuleDescriptors
public <M> Collection<ModuleDescriptor<M>> getModuleDescriptors(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate) - Specified by:
getModuleDescriptorsin interfacePluginAccessor- Since:
- 0.17
- See Also:
-
getPlugin
- Specified by:
getPluginin interfacePluginAccessor
-
getEnabledPlugin
- Specified by:
getEnabledPluginin interfacePluginAccessor
-
getPluginModule
- Specified by:
getPluginModulein interfacePluginAccessor
-
getEnabledPluginModule
- Specified by:
getEnabledPluginModulein interfacePluginAccessor
-
getEnabledModulesByClass
- Specified by:
getEnabledModulesByClassin interfacePluginAccessor- See Also:
-
getEnabledModuleDescriptorsByClass
public <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(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:
getEnabledModuleDescriptorsByClassin interfacePluginAccessor- See Also:
-
enablePlugins
Enable a set of plugins by key. This will implicitly and recursively enable all dependent plugins.- Specified by:
enablePluginsin interfacePluginController- Parameters:
keys- The plugin keys. Must not be null.- Since:
- 2.5.0
-
disablePlugin
- Specified by:
disablePluginin interfacePluginController
-
disablePluginWithoutPersisting
- Specified by:
disablePluginWithoutPersistingin interfacePluginController
-
disablePluginInternal
-
disablePluginModule
- Specified by:
disablePluginModulein interfacePluginController
-
notifyModuleDisabled
-
enablePluginModule
- Specified by:
enablePluginModulein interfacePluginController
-
notifyModuleEnabled
-
isPluginModuleEnabled
- Specified by:
isPluginModuleEnabledin interfacePluginAccessor
-
isPluginEnabled
This method checks to see if the plugin is enabled based on the state manager and the plugin.- Specified by:
isPluginEnabledin interfacePluginAccessor- Parameters:
key- The plugin key- Returns:
- True if the plugin is enabled
-
getDynamicResourceAsStream
- Specified by:
getDynamicResourceAsStreamin interfacePluginAccessor
-
getDynamicPluginClass
- Throws:
ClassNotFoundException
-
getClassLoader
- Specified by:
getClassLoaderin interfacePluginAccessor
-
isSystemPlugin
- Specified by:
isSystemPluginin interfacePluginAccessor
-
getPluginRestartState
- Specified by:
getPluginRestartStatein interfacePluginAccessor
-
addDynamicModule
- Specified by:
addDynamicModulein interfacePluginController
-
getDynamicModules
- Specified by:
getDynamicModulesin interfacePluginAccessor
-
removeDynamicModule
- Specified by:
removeDynamicModulein interfacePluginController
-