public class DefaultPluginManager extends Object implements PluginController, PluginAccessor, 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultPluginManager.Builder<T extends DefaultPluginManager.Builder<?>> |
PluginAccessor.Descriptor| Modifier and Type | Method and Description |
|---|---|
ModuleDescriptor<?> |
addDynamicModule(Plugin maybePluginInternal,
org.dom4j.Element module) |
protected void |
addPlugins(PluginLoader loader,
Collection<Plugin> pluginsToInstall)
Update the local plugin state and enable state aware modules.
|
void |
disablePlugin(String key) |
protected void |
disablePluginInternal(String key,
boolean persistDisabledState) |
void |
disablePluginModule(String completeKey) |
void |
disablePluginWithoutPersisting(String key) |
void |
earlyStartup()
Perform the first part of startup.
|
void |
enablePluginModule(String completeKey) |
void |
enablePlugins(String... keys)
Enable a set of plugins by key.
|
PluginsClassLoader |
getClassLoader() |
Iterable<ModuleDescriptor<?>> |
getDynamicModules(Plugin maybePluginInternal) |
Class<?> |
getDynamicPluginClass(String className) |
InputStream |
getDynamicResourceAsStream(String name) |
<D extends ModuleDescriptor<?>> |
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) |
Plugin |
getEnabledPlugin(String pluginKey) |
ModuleDescriptor<?> |
getEnabledPluginModule(String completeKey) |
Collection<Plugin> |
getEnabledPlugins() |
static String |
getLateStartupEnableRetryProperty() |
static String |
getMinimumPluginVersionsFileProperty() |
<M> Collection<ModuleDescriptor<M>> |
getModuleDescriptors(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate) |
<M> Collection<M> |
getModules(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate) |
Plugin |
getPlugin(String key) |
ModuleDescriptor<?> |
getPluginModule(String completeKey) |
PluginRestartState |
getPluginRestartState(String key) |
Collection<Plugin> |
getPlugins() |
Collection<Plugin> |
getPlugins(Predicate<Plugin> pluginPredicate) |
static String |
getStartupOverrideFileProperty() |
protected PluginPersistentState |
getState() |
void |
init() |
Set<String> |
installPlugins(PluginArtifact... pluginArtifacts) |
boolean |
isPluginEnabled(String key)
This method checks to see if the plugin is enabled based on the state
manager and the plugin.
|
boolean |
isPluginModuleEnabled(String completeKey) |
boolean |
isSystemPlugin(String key) |
void |
lateStartup()
Perform the second part of startup.
|
static DefaultPluginManager.Builder<? extends DefaultPluginManager.Builder<?>> |
newBuilder() |
protected void |
notifyModuleDisabled(ModuleDescriptor<?> module) |
protected void |
notifyModuleEnabled(ModuleDescriptor<?> module) |
protected void |
notifyUninstallPlugin(Plugin plugin) |
void |
onPluginContainerUnavailable(PluginContainerUnavailableEvent event) |
void |
onPluginModuleAvailable(PluginModuleAvailableEvent event) |
void |
onPluginModuleUnavailable(PluginModuleUnavailableEvent event) |
void |
onPluginRefresh(PluginRefreshedEvent event) |
protected void |
onUpdateRequiresRestartState(String pluginKey,
PluginRestartState pluginRestartState) |
void |
removeDynamicModule(Plugin maybePluginInternal,
ModuleDescriptor<?> module) |
protected void |
removeStateFromStore(PluginPersistentStateStore stateStore,
Plugin plugin) |
void |
revertRestartRequiredChange(String pluginKey) |
int |
scanForNewPlugins() |
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.
|
void |
uninstallPlugins(Collection<Plugin> plugins) |
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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetActiveModuleDescriptorsByClass, getModuleDescriptors, getModules, getPluginspublic DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager)
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception)
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, boolean verifyRequiredPlugins)
@ExperimentalApi public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, Predicate<Plugin> delayLoadOf)
@ExperimentalApi public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, Predicate<Plugin> delayLoadOf)
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, boolean verifyRequiredPlugins)
public DefaultPluginManager(PluginPersistentStateStore store, List<PluginLoader> pluginLoaders, ModuleDescriptorFactory moduleDescriptorFactory, PluginEventManager pluginEventManager, PluginExceptionInterception pluginExceptionInterception, boolean verifyRequiredPlugins, Predicate<Plugin> delayLoadOf)
protected DefaultPluginManager(DefaultPluginManager.Builder<? extends DefaultPluginManager.Builder> builder)
@Internal public static String getStartupOverrideFileProperty()
@Internal public static String getLateStartupEnableRetryProperty()
@Internal public static String getMinimumPluginVersionsFileProperty()
public static DefaultPluginManager.Builder<? extends DefaultPluginManager.Builder<?>> newBuilder()
public void init()
throws PluginParseException,
NotificationException
init in interface PluginSystemLifecyclePluginParseExceptionNotificationException@ExperimentalApi
public void earlyStartup()
throws PluginParseException,
NotificationException
SplitStartupPluginSystemLifecycleearlyStartup in interface SplitStartupPluginSystemLifecyclePluginParseException - If parsing the plugins failed.NotificationException - If any of the Event Listeners throw an exception on the Framework startup events.PluginSystemLifecycle.init()@ExperimentalApi
public void lateStartup()
throws PluginParseException,
NotificationException
SplitStartupPluginSystemLifecycleSplitStartupPluginSystemLifecycle.earlyStartup(), and calling both earlyStartup and lateStartup is
equivalent to calling PluginSystemLifecycle.init().lateStartup in interface SplitStartupPluginSystemLifecyclePluginParseException - If parsing the plugins failed.NotificationException - If any of the Event Listeners throw an exception on the Framework startup events.PluginSystemLifecycle.init()public void shutdown()
shutdown in interface PluginSystemLifecycleIllegalStateException - if already shutdown or already in the
process of shutting down.public final void warmRestart()
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 usePluginInstallerpublic Set<String> installPlugins(PluginArtifact... pluginArtifacts) throws PluginParseException
installPlugins in interface PluginControllerPluginParseExceptionpublic int scanForNewPlugins()
throws PluginParseException
scanForNewPlugins in interface PluginControllerPluginParseExceptionprotected void onUpdateRequiresRestartState(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 uninstallationpublic void uninstallPlugins(Collection<Plugin> plugins) throws PluginException
uninstallPlugins in interface PluginControllerPluginExceptionprotected void uninstallNoEvent(Plugin plugin)
plugin - The plugin to uninstallpublic void revertRestartRequiredChange(String pluginKey) throws PluginException
revertRestartRequiredChange in interface PluginControllerpluginKey - The plugin key to revertPluginException - If the revert cannot be completedprotected void removeStateFromStore(PluginPersistentStateStore stateStore, Plugin plugin)
protected void unloadPlugin(Plugin plugin) throws PluginException
plugin - the plugin to removePluginException - if the plugin cannot be uninstalledprotected void notifyUninstallPlugin(Plugin plugin)
protected PluginPersistentState getState()
protected void addPlugins(@Nullable PluginLoader loader, 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 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 addPluginParseException - if the plugin cannot be parsedprotected void updatePlugin(Plugin oldPlugin, Plugin newPlugin) throws PluginException
oldPlugin - Plugin to replacenewPlugin - New plugin to installPluginException - if the plugin cannot be updatedpublic Collection<Plugin> getPlugins()
getPlugins in interface PluginAccessorpublic Collection<Plugin> getPlugins(Predicate<Plugin> pluginPredicate)
getPlugins in interface PluginAccessorPluginAccessor.getPlugins(Predicate)public Collection<Plugin> getEnabledPlugins()
getEnabledPlugins in interface PluginAccessorPluginAccessor.getEnabledPlugins()public <M> Collection<M> getModules(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate)
getModules in interface PluginAccessorPluginAccessor.getModules(Predicate)public <M> Collection<ModuleDescriptor<M>> getModuleDescriptors(Predicate<ModuleDescriptor<M>> moduleDescriptorPredicate)
getModuleDescriptors in interface PluginAccessorPluginAccessor.getModuleDescriptors(Predicate)public Plugin getPlugin(String key)
getPlugin in interface PluginAccessorpublic Plugin getEnabledPlugin(String pluginKey)
getEnabledPlugin in interface PluginAccessorpublic ModuleDescriptor<?> getPluginModule(String completeKey)
getPluginModule in interface PluginAccessorpublic ModuleDescriptor<?> getEnabledPluginModule(String completeKey)
getEnabledPluginModule in interface PluginAccessorpublic <M> List<M> getEnabledModulesByClass(Class<M> moduleClass)
getEnabledModulesByClass in interface PluginAccessorPluginAccessor.getEnabledModulesByClass(Class)public <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(Class<D> descriptorClazz)
getEnabledModuleDescriptorsByClass in interface PluginAccessorPluginAccessor.getEnabledModuleDescriptorsByClass(Class)public void enablePlugins(String... keys)
enablePlugins in interface PluginControllerkeys - The plugin keys. Must not be null.public void disablePlugin(String key)
disablePlugin in interface PluginControllerpublic void disablePluginWithoutPersisting(String key)
disablePluginWithoutPersisting in interface PluginControllerprotected void disablePluginInternal(String key, boolean persistDisabledState)
public void disablePluginModule(String completeKey)
disablePluginModule in interface PluginControllerprotected void notifyModuleDisabled(ModuleDescriptor<?> module)
public void enablePluginModule(String completeKey)
enablePluginModule in interface PluginControllerprotected void notifyModuleEnabled(ModuleDescriptor<?> module)
public boolean isPluginModuleEnabled(String completeKey)
isPluginModuleEnabled in interface PluginAccessorpublic boolean isPluginEnabled(String key)
isPluginEnabled in interface PluginAccessorkey - The plugin keypublic InputStream getDynamicResourceAsStream(String name)
getDynamicResourceAsStream in interface PluginAccessorpublic Class<?> getDynamicPluginClass(String className) throws ClassNotFoundException
ClassNotFoundExceptionpublic PluginsClassLoader getClassLoader()
getClassLoader in interface PluginAccessorpublic boolean isSystemPlugin(String key)
isSystemPlugin in interface PluginAccessorpublic PluginRestartState getPluginRestartState(String key)
getPluginRestartState in interface PluginAccessorpublic ModuleDescriptor<?> addDynamicModule(Plugin maybePluginInternal, org.dom4j.Element module)
addDynamicModule in interface PluginControllerpublic Iterable<ModuleDescriptor<?>> getDynamicModules(Plugin maybePluginInternal)
getDynamicModules in interface PluginAccessorpublic void removeDynamicModule(Plugin maybePluginInternal, ModuleDescriptor<?> module)
removeDynamicModule in interface PluginControllerCopyright © 2020 Atlassian. All rights reserved.