Interface Plugin
- All Superinterfaces:
Comparable<Plugin>,Resourced,ScopeAware
- All Known Subinterfaces:
ContainerManagedPlugin
- All Known Implementing Classes:
DummyPlugin
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThis is the historical version of plugins.static final intThis is the version of plugins which introduced dynamic plugins for all.static final intThis is the versions of plugins that adds remotes plugins (developed outside of the plugin framework itself). -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModuleDescriptor(ModuleDescriptor<?> moduleDescriptor) booleanvoiddisable()Disables the plugin.voidenable()Enables the plugin.Get the classloader for the plugin.Obtain the date that the plugin system most recently completed enabling of this plugin.Obtain the date that the plugin system most recently commenced enabling this plugin.The date this plugin was installed into the system, is the same as the loaded date for non artifact backed pluginsThe date this plugin was loaded into the system.Determines which plugin keys are dependencies, categorising them as mandatory, optional or dynamic.Returns the i18nKey used to get an internationalised name for this plugin.Gets the installation modegetKey()Get theModuleDescriptorfor a particular key.Get theCollectionofdescriptors.<M> List<ModuleDescriptor<M>>getModuleDescriptorsByModuleClass(Class<M> moduleClass) Get thedescriptorswhose module class implements or is assignable from the suppliedClass.getName()Returns the non-localised name of this plugin if defined.Retrieve the original, unprocessed or transformedPluginArtifactused to create this plugin instance.Returns this plugin's current state.intGets the version of the plugins system to handle this plugingetResource(String path) Retrieve the URL of the resource from the plugin.getResourceAsStream(String name) Load a given resource from the plugin.booleanvoidinstall()Installs the plugin into any internal, managing container.booleanWhether the plugin is a "bundled" plugin that can't be removed.booleanShould the plugin file be deleted on uninstall?booleanWhether or not this plugin is loaded dynamically at runtime.booleanbooleanDeprecated.booleanWhether or not this plugin can be 'uninstalled'.<T> Class<T>Get the plugin to load a specific class.voidresolve()Perform any required resolution.voidsetEnabledByDefault(boolean enabledByDefault) voidsetI18nNameKey(String i18nNameKey) Sets the i18nKey used to get an internationalised name for this plugin.voidvoidSets the non-localised name of this plugin.voidsetPluginInformation(PluginInformation pluginInformation) voidsetPluginsVersion(int version) Sets the version of the plugins systemvoidsetResources(Resourced resources) voidsetSystemPlugin(boolean system) Deprecated.since 2.6.0 providePluginMetadataManagerwith information about the plugin instead.voidUninstalls the plugin from any internal container.Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.atlassian.plugin.Resourced
getResourceDescriptor, getResourceDescriptors, getResourceLocationMethods inherited from interface com.atlassian.plugin.ScopeAware
getScopeKey
-
Field Details
-
VERSION_1
static final int VERSION_1This is the historical version of plugins. Which is mostly static plugins loaded from the same classpath to the application.- See Also:
-
VERSION_2
static final int VERSION_2This is the version of plugins which introduced dynamic plugins for all. Based on OSGi and Spring DM. Those plugins undergo some transformations to make the plugin artifact compatible with the OSGi + Spring DM container.- See Also:
-
VERSION_3
static final int VERSION_3This is the versions of plugins that adds remotes plugins (developed outside of the plugin framework itself). Plugins version 3 don't undergo any transformation so it is up to the plugin developer to write their own Spring configuration files if this is their chosen framework, but other frameworks can be introduced.- See Also:
-
-
Method Details
-
getPluginsVersion
int getPluginsVersion()Gets the version of the plugins system to handle this plugin- Returns:
- The plugins version. If undefined, assumed to be 1.
-
setPluginsVersion
void setPluginsVersion(int version) Sets the version of the plugins system- Parameters:
version- The version
-
getName
String getName()Returns the non-localised name of this plugin if defined.This corresponds to the value of the
namefield in the plugin's XML configuration file.You would expect a plugin developer to fill in one of either
name, ori18n-name-key, but the framework does no validation and makes no guarantees that this is the case.- Returns:
- the non-localised name of this plugin if defined, or null.
- See Also:
-
setName
Sets the non-localised name of this plugin.- Parameters:
name- the name.- See Also:
-
getI18nNameKey
String getI18nNameKey()Returns the i18nKey used to get an internationalised name for this plugin.This corresponds to the value of the
i18n-name-keyfield in the plugin's XML configuration file.You would expect a plugin developer to fill in one of either
name, ori18n-name-key, but the framework does no validation and makes no guarantees that this is the case.- Returns:
- the i18n Name Key for this plugin if defined, or null.
- See Also:
-
setI18nNameKey
Sets the i18nKey used to get an internationalised name for this plugin.- Parameters:
i18nNameKey- the i18n Name Key.- See Also:
-
getKey
String getKey() -
setKey
-
addModuleDescriptor
-
getModuleDescriptors
Collection<ModuleDescriptor<?>> getModuleDescriptors()Get theCollectionofdescriptors.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.
- Returns:
- the modules contained by this plugin in the order they are to be enabled
-
getModuleDescriptor
Get theModuleDescriptorfor a particular key. Returnsnullif the plugin does not exist.Note: The
ModuleDescriptor.getModule()may throwClassCastExceptionif the expected type is incorrect.- Parameters:
key- theStringcomplete key of the module, in the form "org.example.plugin:module-key".- Returns:
- the
ModuleDescriptorof the expected type.
-
getModuleDescriptorsByModuleClass
Get thedescriptorswhose module class implements or is assignable from the suppliedClass.Note: The
ModuleDescriptor.getModule()may throwClassCastExceptionif the expected type is incorrect. Normally this method would not be supplied with anything other thanObjector <?>, unless you are confident in the super type of the module classes thisPluginprovides.- Type Parameters:
M- The expected module type of the returneddescriptors.- Parameters:
moduleClass- thesuper classthedescriptorsreturn.- Returns:
- the
Listofdescriptorsof the expected type.
-
getInstallationMode
InstallationMode getInstallationMode()Gets the installation mode- Returns:
- the plugin's installation mode, local or remote.
- Since:
- 3.0
-
isEnabledByDefault
boolean isEnabledByDefault() -
setEnabledByDefault
void setEnabledByDefault(boolean enabledByDefault) -
getPluginInformation
PluginInformation getPluginInformation() -
setPluginInformation
-
setResources
-
getPluginState
PluginState getPluginState()Returns this plugin's current state.- Returns:
- the current state of the plugin.
- Since:
- 2.2.0
-
isSystemPlugin
Deprecated.since 2.6.0 usePluginMetadataManager.isSystemProvided(Plugin)} instead.Whether the plugin is a "system" plugin that shouldn't be made visible to the user.- Returns:
trueif this plugin is a "system" plugin.
-
setSystemPlugin
Deprecated.since 2.6.0 providePluginMetadataManagerwith information about the plugin instead. There is no way to programatically set this value now.- Parameters:
system- whether the plugin is a "system" plugin that shouldn't be made visible to the user.
-
containsSystemModule
boolean containsSystemModule() -
isBundledPlugin
boolean isBundledPlugin()Whether the plugin is a "bundled" plugin that can't be removed.- Returns:
trueif this plugin is a "bundled" plugin.
-
getDateLoaded
Date getDateLoaded()The date this plugin was loaded into the system.- Returns:
- The date this plugin was loaded into the system.
-
getDateInstalled
Date getDateInstalled()The date this plugin was installed into the system, is the same as the loaded date for non artifact backed plugins- Returns:
- The date this plugin was installed into the system
- Since:
- 3.0.0
-
isUninstallable
boolean isUninstallable()Whether or not this plugin can be 'uninstalled'.- Returns:
trueif this plugin can be 'uninstalled'.
-
isDeleteable
boolean isDeleteable()Should the plugin file be deleted on uninstall?- Returns:
trueif this plugin file should be deleted on uninstall.
-
isDynamicallyLoaded
boolean isDynamicallyLoaded()Whether or not this plugin is loaded dynamically at runtime.- Returns:
trueif this plugin is loaded dynamically at runtime.
-
loadClass
Get the plugin to load a specific class.- Parameters:
clazz- The name of the class to be loadedcallingClass- The class calling the loading (used to help find a classloader)- Returns:
- The loaded class.
- Throws:
ClassNotFoundException- if the class cannot be located.
-
getClassLoader
ClassLoader getClassLoader()Get the classloader for the plugin.- Returns:
- The classloader used to load classes for this plugin
-
getResource
Retrieve the URL of the resource from the plugin.- Parameters:
path- the name of the resource to be loaded- Returns:
- The URL to the resource, or null if the resource is not found
-
getResourceAsStream
Load a given resource from the plugin. Plugins that are loaded dynamically will need to implement this in a way that loads the resource from the same context as the plugin. Static plugins can just pull them from their own classloader.- Parameters:
name- The name of the resource to be loaded.- Returns:
- An InputStream for the resource, or null if the resource is not found.
-
install
void install()Installs the plugin into any internal, managing container. This method will be called on every startup. Unless an exception is thrown, the plugin should be in thePluginState.INSTALLEDstate. If the plugin is already in thePluginState.INSTALLEDstate, nothing will happen.- Throws:
PluginException- If the plugin could not be installed- Since:
- 2.2.0
-
uninstall
void uninstall()Uninstalls the plugin from any internal container. This method will be called on every shutdown. Unless an exception is thrown, the plugin should be in thePluginState.UNINSTALLEDstate. If the plugin is already in thePluginState.UNINSTALLEDstate, nothing will happen.- Throws:
PluginException- If the plugin could not be uninstalled- Since:
- 2.2.0
-
enable
void enable()Enables the plugin. Unless an exception is thrown, the plugin should then be in either thePluginState.ENABLINGorPluginState.ENABLEDstate. If the plugin is already in thePluginState.ENABLINGorPluginState.ENABLEDstate, nothing will happen.- Throws:
PluginException- If the plugin could not be enabled- Since:
- 2.2.0
-
disable
void disable()Disables the plugin. Unless an exception is thrown, the plugin should be in thePluginState.DISABLEDstate. If the plugin is already in thePluginState.DISABLEDstate, nothing will happen.- Throws:
PluginException- If the plugin could not be disabled- Since:
- 2.2.0 If the plugin could not be disabled
-
getDependencies
Determines which plugin keys are dependencies, categorising them as mandatory, optional or dynamic.- Returns:
- not null, possibly empty
- Since:
- 4.0
-
getActivePermissions
- Returns:
- the list of permissions currently valid for the plugin
- Since:
- 3.0
-
hasAllPermissions
boolean hasAllPermissions()- Returns:
trueif the plugin has all the permissions- Since:
- 3.0
-
resolve
void resolve()Perform any required resolution. This is a hook to allow the plugin system to perform a resolution pass over a group of modules before the enable pass.- Since:
- 4.0.0
-
getDateEnabling
Obtain the date that the plugin system most recently commenced enabling this plugin. This may return null if the plugin has never commenced enabling, or if the value is unavailable for other reasons, such as wrappers around legacy implementations.- Returns:
- the date that the plugin most recently entered
PluginState.ENABLING. - Since:
- 4.0.0
-
getDateEnabled
Obtain the date that the plugin system most recently completed enabling of this plugin. This will return null if the plugin has never been enabled, has not completed enabling since it most recently started enabling, or if the value is unavailable for any other reason, such as wrappers around legacy implementations.- Returns:
- the date that the plugin most recently entered
PluginState.ENABLED, if this was not before the most recentPluginState.ENABLING, otherwise null. - Since:
- 4.0.0
-
getPluginArtifact
Retrieve the original, unprocessed or transformedPluginArtifactused 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
PluginArtifactBackedPlugininterface that is no longer present.- Returns:
- null if this plugin has no artifact
- Since:
- 4.0.0
-
PluginMetadataManager.isSystemProvided(Plugin)} instead.