public interface Plugin extends ScopeAware, Resourced, Comparable<Plugin>
| Modifier and Type | Field and Description |
|---|---|
static int |
VERSION_1
This is the historical version of plugins.
|
static int |
VERSION_2
This is the version of plugins which introduced dynamic plugins for all.
|
static int |
VERSION_3
This is the versions of plugins that adds remotes plugins (developed outside of the plugin framework itself).
|
| Modifier and Type | Method and Description |
|---|---|
void |
addModuleDescriptor(ModuleDescriptor<?> moduleDescriptor) |
boolean |
containsSystemModule() |
void |
disable()
Disables the plugin.
|
void |
enable()
Enables the plugin.
|
Set<String> |
getActivePermissions() |
ClassLoader |
getClassLoader()
Get the classloader for the plugin.
|
Date |
getDateEnabled()
Obtain the date that the plugin system most recently completed enabling of this plugin.
|
Date |
getDateEnabling()
Obtain the date that the plugin system most recently commenced enabling this plugin.
|
Date |
getDateInstalled()
The date this plugin was installed into the system, is the same as the loaded date for non artifact backed plugins
|
Date |
getDateLoaded()
The date this plugin was loaded into the system.
|
PluginDependencies |
getDependencies()
Determines which plugin keys are dependencies, categorising them as mandatory, optional or dynamic.
|
String |
getI18nNameKey()
Returns the i18nKey used to get an internationalised name for this plugin.
|
InstallationMode |
getInstallationMode()
Gets the installation mode
|
String |
getKey() |
ModuleDescriptor<?> |
getModuleDescriptor(String key)
Get the
ModuleDescriptor for a particular key. |
Collection<ModuleDescriptor<?>> |
getModuleDescriptors()
Get the
Collection of descriptors. |
<M> List<ModuleDescriptor<M>> |
getModuleDescriptorsByModuleClass(Class<M> moduleClass)
Get the
descriptors whose module class implements or is assignable from the supplied Class. |
String |
getName()
Returns the non-localised name of this plugin if defined.
|
PluginArtifact |
getPluginArtifact()
Retrieve the original, unprocessed or transformed
PluginArtifact used to create this plugin instance. |
PluginInformation |
getPluginInformation() |
PluginState |
getPluginState()
Returns this plugin's current state.
|
int |
getPluginsVersion()
Gets the version of the plugins system to handle this plugin
|
URL |
getResource(String path)
Retrieve the URL of the resource from the plugin.
|
InputStream |
getResourceAsStream(String name)
Load a given resource from the plugin.
|
boolean |
hasAllPermissions() |
void |
install()
Installs the plugin into any internal, managing container.
|
boolean |
isBundledPlugin()
Whether the plugin is a "bundled" plugin that can't be removed.
|
boolean |
isDeleteable()
Should the plugin file be deleted on uninstall?
|
boolean |
isDynamicallyLoaded()
Whether or not this plugin is loaded dynamically at runtime.
|
boolean |
isEnabledByDefault() |
boolean |
isSystemPlugin()
Deprecated.
since 2.6.0 use
PluginMetadataManager.isSystemProvided(Plugin)}
instead. |
boolean |
isUninstallable()
Whether or not this plugin can be 'uninstalled'.
|
<T> Class<T> |
loadClass(String clazz,
Class<?> callingClass)
Get the plugin to load a specific class.
|
void |
resolve()
Perform any required resolution.
|
void |
setEnabledByDefault(boolean enabledByDefault) |
void |
setI18nNameKey(String i18nNameKey)
Sets the i18nKey used to get an internationalised name for this plugin.
|
void |
setKey(String aPackage) |
void |
setName(String name)
Sets the non-localised name of this plugin.
|
void |
setPluginInformation(PluginInformation pluginInformation) |
void |
setPluginsVersion(int version)
Sets the version of the plugins system
|
void |
setResources(Resourced resources) |
void |
setSystemPlugin(boolean system)
Deprecated.
since 2.6.0 provide
PluginMetadataManager with information about the
plugin instead. There is no way to programatically set this value now. |
void |
uninstall()
Uninstalls the plugin from any internal container.
|
getScopeKeygetResourceDescriptor, getResourceDescriptors, getResourceLocationcompareTostatic final int VERSION_1
static final int VERSION_2
static final int VERSION_3
int getPluginsVersion()
void setPluginsVersion(int version)
version - The versionString getName()
This corresponds to the value of the name field in the plugin's XML configuration file.
You would expect a plugin developer to fill in one of either name, or i18n-name-key,
but the framework does no validation and makes no guarantees that this is the case.
getI18nNameKey()void setName(String name)
name - the name.getName()String getI18nNameKey()
This corresponds to the value of the i18n-name-key field in the plugin's XML configuration file.
You would expect a plugin developer to fill in one of either name, or i18n-name-key,
but the framework does no validation and makes no guarantees that this is the case.
getName()void setI18nNameKey(String i18nNameKey)
i18nNameKey - the i18n Name Key.getI18nNameKey()String getKey()
void setKey(String aPackage)
void addModuleDescriptor(ModuleDescriptor<?> moduleDescriptor)
Collection<ModuleDescriptor<?>> getModuleDescriptors()
Collection of descriptors.
The iteration order of the collection is the order that the modules will be enabled, and should be the same order that the modules appear in the plugin descriptor.
ModuleDescriptor<?> getModuleDescriptor(String key)
ModuleDescriptor for a particular key. Returns null if the plugin does not exist.
Note: The ModuleDescriptor.getModule() may throw ClassCastException if the expected type is incorrect.
key - the String complete key of the module, in the form "org.example.plugin:module-key".ModuleDescriptor of the expected type.<M> List<ModuleDescriptor<M>> getModuleDescriptorsByModuleClass(Class<M> moduleClass)
descriptors whose module class implements or is assignable from the supplied Class.
Note: The ModuleDescriptor.getModule() may throw ClassCastException if the expected type is incorrect.
Normally this method would not be supplied with anything other than Object or <?>, unless you are
confident in the super type of the module classes this Plugin provides.
M - The expected module type of the returned descriptors.moduleClass - the super class the descriptors return.List of descriptors of the expected type.InstallationMode getInstallationMode()
boolean isEnabledByDefault()
void setEnabledByDefault(boolean enabledByDefault)
PluginInformation getPluginInformation()
void setPluginInformation(PluginInformation pluginInformation)
void setResources(Resourced resources)
PluginState getPluginState()
boolean isSystemPlugin()
PluginMetadataManager.isSystemProvided(Plugin)}
instead.true if this plugin is a "system" plugin.void setSystemPlugin(boolean system)
PluginMetadataManager with information about the
plugin instead. There is no way to programatically set this value now.system - whether the plugin is a "system" plugin that shouldn't be made visible to the user.boolean containsSystemModule()
boolean isBundledPlugin()
true if this plugin is a "bundled" plugin.Date getDateLoaded()
Date getDateInstalled()
boolean isUninstallable()
true if this plugin can be 'uninstalled'.boolean isDeleteable()
true if this plugin file should be deleted on uninstall.boolean isDynamicallyLoaded()
true if this plugin is loaded dynamically at runtime.<T> Class<T> loadClass(String clazz, Class<?> callingClass) throws ClassNotFoundException
clazz - The name of the class to be loadedcallingClass - The class calling the loading (used to help find a classloader)ClassNotFoundException - if the class cannot be located.ClassLoader getClassLoader()
URL getResource(String path)
path - the name of the resource to be loadedInputStream getResourceAsStream(String name)
name - The name of the resource to be loaded.void install()
throws PluginException
PluginState.INSTALLED state. If the plugin is already
in the PluginState.INSTALLED state, nothing will happen.PluginException - If the plugin could not be installedvoid uninstall()
throws PluginException
PluginState.UNINSTALLED state. If the plugin is already
in the PluginState.UNINSTALLED state, nothing will happen.PluginException - If the plugin could not be uninstalledvoid enable()
throws PluginException
PluginState.ENABLING or PluginState.ENABLED state. If the plugin is already in the
PluginState.ENABLING or PluginState.ENABLED state, nothing will happen.PluginException - If the plugin could not be enabledvoid disable()
throws PluginException
PluginState.DISABLED
state. If the plugin is already in the PluginState.DISABLED state, nothing will happen.PluginException - If the plugin could not be disabled@Nonnull PluginDependencies getDependencies()
Set<String> getActivePermissions()
boolean hasAllPermissions()
true if the plugin has all the permissionsvoid resolve()
@Nullable Date getDateEnabling()
PluginState.ENABLING.@Nullable Date getDateEnabled()
PluginState.ENABLED,
if this was not before the most recent PluginState.ENABLING, otherwise null.@Internal PluginArtifact getPluginArtifact()
PluginArtifact used to create this plugin instance.
Note that this method may be removed without notice; it is for use only by the host application.
This method was originally part of the internal PluginArtifactBackedPlugin interface that is no
longer present.
Copyright © 2019 Atlassian. All rights reserved.