public abstract class AbstractPlugin extends Object implements PluginInternal, Comparable<Plugin>
p1.equals(p2) == true will give p1.compareTo(p2) == 0 but the opposite is not guaranteed because we keep a map of plugins versus loaders in the DefaultPluginManager .
A plugin with the same key and version may well be loaded from multiple loaders (in fact with UPM it's almost guaranteed) so we CANNOT override equals.
| Modifier and Type | Field and Description |
|---|---|
protected PluginArtifact |
pluginArtifact |
| Constructor and Description |
|---|
AbstractPlugin(PluginArtifact pluginArtifact) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addDynamicModuleDescriptor(ModuleDescriptor<?> module)
Add a module descriptor.
|
void |
addModuleDescriptor(ModuleDescriptor<?> moduleDescriptor) |
static String |
cleanVersionString(String version) |
void |
close() |
protected boolean |
compareAndSetPluginState(PluginState requiredExistingState,
PluginState desiredState)
Only sets the plugin state if it is in the expected state.
|
int |
compareTo(Plugin otherPlugin)
Compares this Plugin to another Plugin for order.
|
boolean |
containsSystemModule() |
void |
disable()
Disables the plugin.
|
protected void |
disableInternal()
Perform any internal disabling logic.
|
void |
enable()
Enables the plugin.
|
protected PluginState |
enableInternal()
Perform any internal enabling logic.
|
Set<String> |
getActivePermissions() |
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.
|
Iterable<ModuleDescriptor<?>> |
getDynamicModuleDescriptors() |
String |
getI18nNameKey()
Returns the i18nKey used to get an internationalised name for this plugin.
|
InstallationMode |
getInstallationMode()
Gets the installation mode
|
String |
getKey() |
protected org.slf4j.Logger |
getLog() |
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)
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
|
Set<String> |
getRequiredPlugins() |
ResourceDescriptor |
getResourceDescriptor(String type,
String name)
Get a
ResourceDescriptor of a particular type and name. |
List<ResourceDescriptor> |
getResourceDescriptors()
Get a
List of all the descriptors
. |
ResourceLocation |
getResourceLocation(String type,
String name)
Get a
ResourceLocation of a particular type and name. |
Optional<String> |
getScopeKey() |
boolean |
hasAllPermissions() |
void |
install()
Installs the plugin into any internal, managing container.
|
protected void |
installInternal()
Perform any internal installation logic.
|
boolean |
isBundledPlugin()
Whether the plugin is a "bundled" plugin that can't be removed.
|
boolean |
isEnabledByDefault() |
boolean |
isSystemPlugin()
Whether the plugin is a "system" plugin that shouldn't be made visible to the user.
|
boolean |
removeDynamicModuleDescriptor(ModuleDescriptor<?> module)
Remove a module descriptor.
|
protected void |
removeModuleDescriptor(String key) |
void |
resolve()
Perform any required resolution.
|
void |
setBundledPlugin(boolean bundledPlugin)
Alters whether the plugin is a "bundled" plugin that can't be removed.
|
void |
setEnabledByDefault(boolean enabledByDefault) |
void |
setI18nNameKey(String i18nNameKey)
Sets the i18nKey used to get an internationalised name for this plugin.
|
void |
setKey(String key) |
void |
setName(String name)
Sets the non-localised name of this plugin.
|
void |
setPluginInformation(PluginInformation pluginInformation) |
protected void |
setPluginState(PluginState state) |
void |
setPluginsVersion(int pluginsVersion)
Sets the version of the plugins system
|
void |
setResources(Resourced resources) |
void |
setSystemPlugin(boolean system) |
String |
toString() |
void |
uninstall()
Uninstalls the plugin from any internal container.
|
protected void |
uninstallInternal()
Perform any internal uninstallation logic.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetClassLoader, getResource, getResourceAsStream, isDeleteable, isDynamicallyLoaded, isUninstallable, loadClassprotected final PluginArtifact pluginArtifact
public AbstractPlugin(PluginArtifact pluginArtifact)
public String getName()
Plugin 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.
getName in interface PluginPlugin.getI18nNameKey()public void setName(String name)
PluginsetName in interface Pluginname - the name.Plugin.getName()protected org.slf4j.Logger getLog()
public String getI18nNameKey()
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.
getI18nNameKey in interface PluginPlugin.getName()public void setI18nNameKey(String i18nNameKey)
PluginsetI18nNameKey in interface Plugini18nNameKey - the i18n Name Key.Plugin.getI18nNameKey()public void addModuleDescriptor(ModuleDescriptor<?> moduleDescriptor)
addModuleDescriptor in interface Pluginprotected void removeModuleDescriptor(String key)
public Collection<ModuleDescriptor<?>> getModuleDescriptors()
getModuleDescriptors in interface Pluginpublic ModuleDescriptor<?> getModuleDescriptor(String key)
PluginModuleDescriptor 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.
getModuleDescriptor in interface Pluginkey - the String complete key of the module, in the form "org.example.plugin:module-key".ModuleDescriptor of the expected type.public <T> List<ModuleDescriptor<T>> getModuleDescriptorsByModuleClass(Class<T> aClass)
Plugindescriptors 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.
getModuleDescriptorsByModuleClass in interface PluginT - The expected module type of the returned descriptors.aClass - the super class the descriptors return.List of descriptors of the expected type.public PluginState getPluginState()
PlugingetPluginState in interface Pluginprotected void setPluginState(PluginState state)
protected boolean compareAndSetPluginState(PluginState requiredExistingState, PluginState desiredState)
requiredExistingState - The expected statedesiredState - The desired statepublic boolean isEnabledByDefault()
isEnabledByDefault in interface Pluginpublic void setEnabledByDefault(boolean enabledByDefault)
setEnabledByDefault in interface Pluginpublic int getPluginsVersion()
PlugingetPluginsVersion in interface Pluginpublic void setPluginsVersion(int pluginsVersion)
PluginsetPluginsVersion in interface PluginpluginsVersion - The versionpublic PluginInformation getPluginInformation()
getPluginInformation in interface Pluginpublic void setPluginInformation(PluginInformation pluginInformation)
setPluginInformation in interface Pluginpublic void setResources(Resourced resources)
setResources in interface Pluginpublic List<ResourceDescriptor> getResourceDescriptors()
ResourcedList of all the descriptors
.
Note: since 2.2 this list must be immutable, previously modifying this list could modify the underlying list.
getResourceDescriptors in interface Resourcedpublic ResourceLocation getResourceLocation(String type, String name)
ResourcedResourceLocation of a particular type and name.getResourceLocation in interface Resourcedpublic ResourceDescriptor getResourceDescriptor(String type, String name)
ResourcedResourceDescriptor of a particular type and name.getResourceDescriptor in interface Resourcedpublic void enable()
PluginPluginState.ENABLING or PluginState.ENABLED state. If the plugin is already in the
PluginState.ENABLING or PluginState.ENABLED state, nothing will happen.protected PluginState enableInternal() throws PluginException
PluginState.PENDING is returned, it will be passed to setPluginState(PluginState). If a subclass
returns PluginState.PENDING, no state is set, and it is assumed the subclass has taken responsibility for
transitioning state via direct calls to setPluginState(PluginState).
Subclasses should only throw PluginException.PluginState.ENABLED, PluginState.ENABLING, or PluginState.PENDINGPluginException - If the plugin could not be enabledpublic final void disable()
PluginPluginState.DISABLED
state. If the plugin is already in the PluginState.DISABLED state, nothing will happen.protected void disableInternal()
throws PluginException
PluginException.PluginException - If the plugin could not be disabled@Nonnull public PluginDependencies getDependencies()
PlugingetDependencies in interface Pluginpublic final Set<String> getActivePermissions()
getActivePermissions in interface Pluginpublic final boolean hasAllPermissions()
hasAllPermissions in interface Plugintrue if the plugin has all the permissionspublic InstallationMode getInstallationMode()
PlugingetInstallationMode in interface Pluginpublic void close()
public final void install()
PluginPluginState.INSTALLED state. If the plugin is already
in the PluginState.INSTALLED state, nothing will happen.protected void installInternal()
throws PluginException
PluginException.PluginException - If the plugin could not be installedpublic final void uninstall()
PluginPluginState.UNINSTALLED state. If the plugin is already
in the PluginState.UNINSTALLED state, nothing will happen.protected void uninstallInternal()
throws PluginException
PluginException.PluginException - If the plugin could not be uninstalledpublic boolean isSystemPlugin()
PluginisSystemPlugin in interface Plugintrue if this plugin is a "system" plugin.public boolean containsSystemModule()
containsSystemModule in interface Pluginpublic void setSystemPlugin(boolean system)
setSystemPlugin in interface Pluginsystem - whether the plugin is a "system" plugin that shouldn't be made visible to the user.public void resolve()
Pluginpublic Date getDateLoaded()
PlugingetDateLoaded in interface Pluginpublic Date getDateInstalled()
PlugingetDateInstalled in interface Plugin@ExperimentalApi public Date getDateEnabling()
PlugingetDateEnabling in interface PluginPluginState.ENABLING.@ExperimentalApi public Date getDateEnabled()
PlugingetDateEnabled in interface PluginPluginState.ENABLED,
if this was not before the most recent PluginState.ENABLING, otherwise null.public boolean isBundledPlugin()
PluginisBundledPlugin in interface Plugintrue if this plugin is a "bundled" plugin.public void setBundledPlugin(boolean bundledPlugin)
PluginInternalsetBundledPlugin in interface PluginInternalbundledPlugin - true if this plugin is a "bundled" plugin.public PluginArtifact getPluginArtifact()
PluginPluginArtifact 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.
getPluginArtifact in interface Pluginpublic Optional<String> getScopeKey()
getScopeKey in interface ScopeAwareOptional.empty() if not definedpublic Iterable<ModuleDescriptor<?>> getDynamicModuleDescriptors()
getDynamicModuleDescriptors in interface PluginInternalpublic boolean addDynamicModuleDescriptor(ModuleDescriptor<?> module)
PluginInternaladdDynamicModuleDescriptor in interface PluginInternalmodule - to addpublic boolean removeDynamicModuleDescriptor(ModuleDescriptor<?> module)
PluginInternalremoveDynamicModuleDescriptor in interface PluginInternalmodule - to removepublic int compareTo(@Nonnull Plugin otherPlugin)
compareTo in interface Comparable<Plugin>otherPlugin - The plugin to be compared.VersionStringComparator,
Comparable.compareTo(T)Copyright © 2019 Atlassian. All rights reserved.