|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.plugin.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 PluginStateStore.
installPlugin(PluginArtifact) explicitly stores
the plugin via a PluginInstaller, whereas uninstall(Plugin) relies on the
underlying PluginLoader to remove the plugin if necessary.
| Field Summary |
|---|
| Fields inherited from interface com.atlassian.plugin.PluginManager |
|---|
PLUGIN_DESCRIPTOR_FILENAME |
| Constructor Summary | |
|---|---|
DefaultPluginManager(PluginStateStore 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> pluginsToAdd)
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,
PluginStateStore stateStore)
|
|
protected void |
disablePluginState(Plugin plugin,
PluginStateStore 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,
PluginStateStore stateStore)
|
|
protected void |
enablePluginState(Plugin plugin,
PluginStateStore stateStore)
|
|
java.lang.ClassLoader |
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<T> moduleDescriptorClass)
Get all enabled module descriptors that have a specific descriptor class. |
|
|
getEnabledModuleDescriptorsByClass(java.lang.Class<T> moduleDescriptorClass,
boolean verbose)
This method has been reverted to pre PLUG-40 to fix performance issues that were encountered during load testing. |
|
java.util.List<ModuleDescriptor<?>> |
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<T> moduleClass)
Retrieve all plugin modules that implement or extend a specific class. |
|
|
getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<T>>[] descriptorClasses,
java.lang.Class<T> moduleClass)
Deprecated. since 0.17, use getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead. |
|
|
getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<T>> descriptorClass,
java.lang.Class<T> 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. |
|
protected java.util.List<java.lang.String> |
getEnabledStateAwareModuleKeys(Plugin plugin)
|
|
|
getModuleDescriptors(ModuleDescriptorPredicate<T> moduleDescriptorPredicate)
Gets all module descriptors of installed modules that match the given predicate. |
|
|
getModules(ModuleDescriptorPredicate<T> 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. |
|
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 PluginManagerState |
getState()
|
|
protected PluginStateStore |
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 should be 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)
|
|
protected void |
removeStateFromStore(PluginStateStore 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(PluginStateStore store,
java.util.List<PluginLoader> pluginLoaders,
ModuleDescriptorFactory moduleDescriptorFactory,
PluginEventManager pluginEventManager)
| Method Detail |
|---|
public void init()
throws PluginParseException
init in interface PluginManagerPluginParseExceptionpublic void shutdown()
shutdown in interface PluginManagerpublic void setPluginInstaller(PluginInstaller pluginInstaller)
pluginInstaller - the plugin installation strategy to usePluginInstallerprotected final PluginStateStore 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 PluginControllerPluginException - if there was some problem uninstalling the plugin.
protected void removeStateFromStore(PluginStateStore 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 PluginManagerState getState()
protected void addPlugin(PluginLoader loader,
Plugin plugin)
throws PluginParseException
#addPlugins(PluginLoader,Collection...) instead
PluginParseException
protected void addPlugins(PluginLoader loader,
java.util.Collection<Plugin> pluginsToAdd)
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 pluginpluginsToAdd - 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(PluginPredicate)public java.util.Collection<Plugin> getEnabledPlugins()
PluginAccessor
getEnabledPlugins in interface PluginAccessorPlugins.PluginAccessor.getEnabledPlugins()public <T> java.util.Collection<T> getModules(ModuleDescriptorPredicate<T> 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 <T> java.util.Collection<ModuleDescriptor<T>> getModuleDescriptors(ModuleDescriptorPredicate<T> 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 <T> java.util.List<T> getEnabledModulesByClass(java.lang.Class<T> moduleClass)
PluginAccessor
getEnabledModulesByClass in interface PluginAccessorPluginAccessor.getEnabledModulesByClass(Class)
public <T> java.util.List<T> getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<T>>[] descriptorClasses,
java.lang.Class<T> moduleClass)
getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.
PluginAccessor
getEnabledModulesByClassAndDescriptor in interface PluginAccessordescriptorClasses - @NotNullmoduleClass - @NotNull
PluginAccessor.getEnabledModulesByClassAndDescriptor(Class[], Class)
public <T> java.util.List<T> getEnabledModulesByClassAndDescriptor(java.lang.Class<ModuleDescriptor<T>> descriptorClass,
java.lang.Class<T> moduleClass)
getModules(com.atlassian.plugin.predicate.ModuleDescriptorPredicate) with an appropriate predicate instead.
PluginAccessor
getEnabledModulesByClassAndDescriptor in interface PluginAccessordescriptorClass - @NotNullmoduleClass - @NotNull
PluginAccessor.getEnabledModulesByClassAndDescriptor(Class, Class)public <T extends ModuleDescriptor> java.util.List<T> getEnabledModuleDescriptorsByClass(java.lang.Class<T> moduleDescriptorClass)
PluginAccessor
getEnabledModuleDescriptorsByClass in interface PluginAccessormoduleDescriptorClass - module descriptor class
ModuleDescriptors that implement or extend the given class.
public <T extends ModuleDescriptor> java.util.List<T> getEnabledModuleDescriptorsByClass(java.lang.Class<T> moduleDescriptorClass,
boolean verbose)
getEnabledModuleDescriptorsByClass in interface PluginAccessormoduleDescriptorClass - module descriptor classverbose - log verbose messages flag
ModuleDescriptors that implement or extend the given class.PluginAccessor.getEnabledModuleDescriptorsByClass(Class)
public java.util.List<ModuleDescriptor<?>> 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,
PluginStateStore 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,
PluginStateStore stateStore)
protected java.util.List<java.lang.String> getEnabledStateAwareModuleKeys(Plugin plugin)
protected void notifyPluginDisabled(Plugin plugin)
public void disablePluginModule(java.lang.String completeKey)
PluginController
disablePluginModule in interface PluginController
protected void disablePluginModuleState(ModuleDescriptor module,
PluginStateStore stateStore)
protected void notifyModuleDisabled(ModuleDescriptor module)
public void enablePluginModule(java.lang.String completeKey)
PluginController
enablePluginModule in interface PluginController
protected void enablePluginModuleState(ModuleDescriptor module,
PluginStateStore 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 java.lang.ClassLoader 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 void setDescriptorParserFactory(DescriptorParserFactory descriptorParserFactory)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||