|
||||||||||
| 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(com.atlassian.plugin.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)
Disable a plugin by key. |
|
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 |
enablePlugin(java.lang.String key)
Enable a plugin by key. |
|
void |
enablePluginModule(java.lang.String completeKey)
Enable a plugin module by key. |
|
protected void |
enablePluginModuleState(ModuleDescriptor<?> module,
PluginPersistentStateStore stateStore)
|
|
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)
Get all enabled module descriptors that have a specific descriptor class. |
|
|
getEnabledModuleDescriptorsByClass(java.lang.Class<D> descriptorClazz,
boolean verbose)
This method has been reverted to pre PLUG-40 to fix performance issues that were encountered during load testing. |
|
|
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()
Initialize all plugins in all loaders |
|
java.lang.String |
installPlugin(PluginArtifact pluginArtifact)
Installs a plugin and returns the plugin key |
|
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 |
onPluginRefresh(PluginRefreshedEvent event)
|
|
protected void |
removeStateFromStore(PluginPersistentStateStore stateStore,
Plugin plugin)
|
|
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)
Uninstall the plugin, disabling it first. |
|
protected void |
unloadPlugin(Plugin plugin)
Unload a plugin. |
|
protected void |
updatePlugin(Plugin oldPlugin,
Plugin newPlugin)
Replace an already loaded plugin with another version. |
|
| 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
init in interface PluginSystemLifecyclePluginParseException
java.lang.IllegalStateException - if already initialized or already in the process of initialization.public void shutdown()
shutdown in interface PluginSystemLifecyclejava.lang.IllegalStateException - if already shutdown or already in the process of shutting down.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 PluginControllerPluginParseException - if the plugin is not a valid plugin
public int scanForNewPlugins()
throws PluginParseException
PluginController
scanForNewPlugins in interface PluginControllerPluginParseException
public void uninstall(Plugin plugin)
throws PluginException
PluginController
uninstall in interface PluginControllerplugin -
PluginException - If the plugin or loader doesn't support uninstallation
protected void removeStateFromStore(PluginPersistentStateStore stateStore,
Plugin plugin)
protected void unloadPlugin(Plugin plugin)
throws PluginException
plugin - the plugin to remove
PluginException - if th eplugin 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 PluginAccessorpublic 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)
PluginAccessor
getEnabledModuleDescriptorsByClass in interface PluginAccessordescriptorClazz - module descriptor class
ModuleDescriptors that implement or extend the given class.
public <D extends ModuleDescriptor<?>> java.util.List<D> getEnabledModuleDescriptorsByClass(java.lang.Class<D> descriptorClazz,
boolean verbose)
getEnabledModuleDescriptorsByClass in interface PluginAccessordescriptorClazz - module descriptor classverbose - log verbose messages flag
ModuleDescriptors that implement or extend the given class.PluginAccessor.getEnabledModuleDescriptorsByClass(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 enablePlugin(java.lang.String key)
PluginController
enablePlugin in interface PluginController
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)
PluginController
disablePlugin in interface PluginController
protected void disablePluginState(Plugin plugin,
PluginPersistentStateStore stateStore)
protected void notifyPluginDisabled(Plugin plugin)
public void disablePluginModule(java.lang.String completeKey)
PluginController
disablePluginModule in interface PluginController
protected void disablePluginModuleState(ModuleDescriptor<?> module,
PluginPersistentStateStore stateStore)
protected void notifyModuleDisabled(ModuleDescriptor<?> module)
public void enablePluginModule(java.lang.String completeKey)
PluginController
enablePluginModule in interface PluginController
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 | |||||||||