public abstract class

AbstractPlugin

extends Object
implements Plugin Comparable<T>
java.lang.Object
   ↳ com.atlassian.plugin.impl.AbstractPlugin
Known Direct Subclasses
Known Indirect Subclasses

Summary

[Expand]
Inherited Fields
From interface com.atlassian.plugin.Plugin
Public Constructors
AbstractPlugin()
Public Methods
void addModuleDescriptor(ModuleDescriptor<?> moduleDescriptor)
void close()
Free any resources held by this plugin.
int compareTo(Plugin otherPlugin)
Compares this Plugin to another Plugin for order.
boolean containsSystemModule()
final void disable()
Disables the plugin.
final void enable()
Enables the plugin.
Date getDateLoaded()
The date this plugin was loaded into the system.
String getI18nNameKey()
Returns the i18nKey used to get an internationalised name for this plugin.
String getKey()
ModuleDescriptor<?> getModuleDescriptor(String key)
Get the ModuleDescriptor for a particular key.
Collection<ModuleDescriptor<?>> getModuleDescriptors()
Returns the module descriptors for this plugin
<T> List<ModuleDescriptor<T>> getModuleDescriptorsByModuleClass(Class<T> aClass)
String getName()
Returns the non-localised name of this plugin if defined.
PluginInformation getPluginInformation()
PluginState getPluginState()
Returns this plugin's current state.
int getPluginsVersion()
Gets the version of the plugins system to handle this plugin
Set<String> getRequiredPlugins()
@Deprecated ResourceDescriptor getResourceDescriptor(String type, String name)
This method is deprecated. No replacement.
List<ResourceDescriptor> getResourceDescriptors()
Get a List of all the descriptors .
List<ResourceDescriptor> getResourceDescriptors(String type)
Get a list of all descriptors of a particular type.
ResourceLocation getResourceLocation(String type, String name)
Get a ResourceLocation of a particular type and name.
final void install()
Installs the plugin into any internal, managing container.
boolean isBundledPlugin()
Whether the plugin is a "bundled" plugin that can't be removed.
@Deprecated boolean isEnabled()
boolean isEnabledByDefault()
boolean isSystemPlugin()
Whether the plugin is a "system" plugin that shouldn't be made visible to the user.
@Deprecated void setEnabled(boolean enabled)
Setter for the enabled state of a plugin.
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 pluginsVersion)
Sets the version of the plugins system
void setResources(Resourced resources)
void setSystemPlugin(boolean system)
String toString()
final void uninstall()
Uninstalls the plugin from any internal container.
Protected Methods
boolean compareAndSetPluginState(PluginState requiredExistingState, PluginState desiredState)
Only sets the plugin state if it is in the expected state.
void disableInternal()
Perform any internal disabling logic.
PluginState enableInternal()
Perform any internal enabling logic.
Logger getLog()
void installInternal()
Perform any internal installation logic.
void removeModuleDescriptor(String key)
void setPluginState(PluginState state)
void uninstallInternal()
Perform any internal uninstallation logic.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.plugin.Plugin
From interface com.atlassian.plugin.Resourced
From interface java.lang.Comparable

Public Constructors

public AbstractPlugin ()

Public Methods

public void addModuleDescriptor (ModuleDescriptor<?> moduleDescriptor)

public void close ()

Free any resources held by this plugin. To be called during uninstallation of the Plugin.

public int compareTo (Plugin otherPlugin)

Compares this Plugin to another Plugin for order. The primary sort field is the key, and the secondary field is the version number.

Parameters
otherPlugin The plugin to be compared.
Returns
  • a negative integer, zero, or a positive integer as this Plugin is less than, equal to, or greater than the specified Plugin.

public boolean containsSystemModule ()

public final void disable ()

Disables the plugin. Unless an exception is thrown, the plugin should be in the DISABLED state. If the plugin is already in the DISABLED state, nothing will happen.

public final void enable ()

Enables the plugin. Unless an exception is thrown, the plugin should then be in either the ENABLING or ENABLED state. If the plugin is already in the ENABLING or ENABLED state, nothing will happen.

public Date getDateLoaded ()

The date this plugin was loaded into the system.

Returns
  • The date this plugin was loaded into the system.

public String getI18nNameKey ()

Returns the i18nKey used to get an internationalised name for this plugin.

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.

Returns
  • the i18n Name Key for this plugin if defined, or null.

public String getKey ()

public ModuleDescriptor<?> getModuleDescriptor (String key)

Get the ModuleDescriptor for a particular key. Returns null if the plugin does not exist.

Note: The getModule() may throw ClassCastException if the expected type is incorrect.

Parameters
key the String complete key of the module, in the form "org.example.plugin:module-key".
Returns

public Collection<ModuleDescriptor<?>> getModuleDescriptors ()

Returns the module descriptors for this plugin

Returns
  • An unmodifiable list of the module descriptors.

public List<ModuleDescriptor<T>> getModuleDescriptorsByModuleClass (Class<T> aClass)

public String getName ()

Returns the non-localised name of this plugin if defined.

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.

Returns
  • the non-localised name of this plugin if defined, or null.

public PluginInformation getPluginInformation ()

public PluginState getPluginState ()

Returns this plugin's current state.

Returns
  • the current state of the plugin.

public int getPluginsVersion ()

Gets the version of the plugins system to handle this plugin

Returns
  • The plugins version. If undefined, assumed to be 1.

public Set<String> getRequiredPlugins ()

@Deprecated public ResourceDescriptor getResourceDescriptor (String type, String name)

This method is deprecated.
No replacement.

Get a ResourceDescriptor of a particular type and name.

Returns
  • the specified resource descriptor if found, null otherwise.

public List<ResourceDescriptor> getResourceDescriptors ()

Get a List of all the descriptors .

Note: since 2.2 this list must be immutable, previously modifying this list could modify the underlying list.

Returns
  • all resource descriptors this object supports.

public List<ResourceDescriptor> getResourceDescriptors (String type)

Get a list of all descriptors of a particular type.

Note: since 2.2 this list must be immutable, previously this list was modifiable but modifications would not be reflected in the underlying list.

Returns
  • all resource descriptors this object supports.

public ResourceLocation getResourceLocation (String type, String name)

Get a ResourceLocation of a particular type and name.

Returns
  • the specified resource location if found, null otherwise.

public final 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 the INSTALLED state. If the plugin is already in the INSTALLED state, nothing will happen.

public boolean isBundledPlugin ()

Whether the plugin is a "bundled" plugin that can't be removed.

Returns
  • true if this plugin is a "bundled" plugin.

@Deprecated public boolean isEnabled ()

Returns
  • true if the plugin has been enabled

public boolean isEnabledByDefault ()

public boolean isSystemPlugin ()

Whether the plugin is a "system" plugin that shouldn't be made visible to the user.

Returns
  • true if this plugin is a "system" plugin.

@Deprecated public void setEnabled (boolean enabled)

Setter for the enabled state of a plugin. If this is set to false then the plugin will not execute.

public void setEnabledByDefault (boolean enabledByDefault)

public void setI18nNameKey (String i18nNameKey)

Sets the i18nKey used to get an internationalised name for this plugin.

Parameters
i18nNameKey the i18n Name Key.

public void setKey (String aPackage)

public void setName (String name)

Sets the non-localised name of this plugin.

Parameters
name the name.

public void setPluginInformation (PluginInformation pluginInformation)

public void setPluginsVersion (int pluginsVersion)

Sets the version of the plugins system

Parameters
pluginsVersion The version

public void setResources (Resourced resources)

public void setSystemPlugin (boolean system)

public String toString ()

public final 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 the UNINSTALLED state. If the plugin is already in the UNINSTALLED state, nothing will happen.

Protected Methods

protected boolean compareAndSetPluginState (PluginState requiredExistingState, PluginState desiredState)

Only sets the plugin state if it is in the expected state.

Parameters
requiredExistingState The expected state
desiredState The desired state
Returns
  • True if the set was successful, false if not in the expected state

protected void disableInternal ()

Perform any internal disabling logic. Subclasses should only throw PluginException.

Throws
PluginException If the plugin could not be disabled

protected PluginState enableInternal ()

Perform any internal enabling logic. Subclasses should only throw PluginException.

Returns
Throws
PluginException If the plugin could not be enabled

protected Logger getLog ()

Returns
  • the logger used internally

protected void installInternal ()

Perform any internal installation logic. Subclasses should only throw PluginException.

Throws
PluginException If the plugin could not be installed

protected void removeModuleDescriptor (String key)

protected void setPluginState (PluginState state)

protected void uninstallInternal ()

Perform any internal uninstallation logic. Subclasses should only throw PluginException.

Throws
PluginException If the plugin could not be uninstalled