Package com.atlassian.plugin.impl
Class AbstractPlugin
java.lang.Object
com.atlassian.plugin.impl.AbstractPlugin
- All Implemented Interfaces:
Plugin,PluginInternal,Resourced,ScopeAware,Comparable<Plugin>
- Direct Known Subclasses:
DefaultDynamicPlugin,StaticPlugin,XmlDynamicPlugin
Represents the base class for all plugins. Note: This class has a natural ordering that is inconsistent with equals.
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddDynamicModuleDescriptor(ModuleDescriptor<?> module) Add a module descriptor.voidaddModuleDescriptor(ModuleDescriptor<?> moduleDescriptor) static StringcleanVersionString(String version) voidclose()protected booleancompareAndSetPluginState(PluginState requiredExistingState, PluginState desiredState) Only sets the plugin state if it is in the expected state.intCompares this Plugin to another Plugin for order.booleanfinal voiddisable()protected voidPerform any internal disabling logic.voidenable()protected PluginStatePerform any internal enabling logic.getKey()protected org.slf4j.LoggergetLog()Returns the module descriptors for this plugin<T> List<ModuleDescriptor<T>>getModuleDescriptorsByModuleClass(Class<T> aClass) getName()intgetResourceDescriptor(String type, String name) getResourceLocation(String type, String name) final booleanfinal voidinstall()protected voidPerform any internal installation logic.booleanbooleanbooleanbooleanremoveDynamicModuleDescriptor(ModuleDescriptor<?> module) Remove a module descriptor.protected voidvoidresolve()voidsetBundledPlugin(boolean bundledPlugin) Alters whether the plugin is a "bundled" plugin that can't be removed.voidsetEnabledByDefault(boolean enabledByDefault) voidsetI18nNameKey(String i18nNameKey) voidvoidvoidsetPluginInformation(PluginInformation pluginInformation) protected voidsetPluginState(PluginState state) voidsetPluginsVersion(int pluginsVersion) voidsetResources(Resourced resources) voidsetSystemPlugin(boolean system) toString()final voidprotected voidPerform any internal uninstallation logic.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.atlassian.plugin.Plugin
getClassLoader, getResource, getResourceAsStream, isDeleteable, isDynamicallyLoaded, isUninstallable, loadClass
-
Field Details
-
pluginArtifact
-
-
Constructor Details
-
AbstractPlugin
-
-
Method Details
-
getName
-
setName
-
getLog
protected org.slf4j.Logger getLog()- Returns:
- the logger used internally
-
getI18nNameKey
- Specified by:
getI18nNameKeyin interfacePlugin
-
setI18nNameKey
- Specified by:
setI18nNameKeyin interfacePlugin
-
getKey
-
setKey
-
addModuleDescriptor
- Specified by:
addModuleDescriptorin interfacePlugin
-
removeModuleDescriptor
-
getModuleDescriptors
Returns the module descriptors for this plugin- Specified by:
getModuleDescriptorsin interfacePlugin- Returns:
- An unmodifiable list of the module descriptors.
-
getModuleDescriptor
- Specified by:
getModuleDescriptorin interfacePlugin
-
getModuleDescriptorsByModuleClass
- Specified by:
getModuleDescriptorsByModuleClassin interfacePlugin
-
getPluginState
- Specified by:
getPluginStatein interfacePlugin
-
setPluginState
-
compareAndSetPluginState
protected boolean compareAndSetPluginState(PluginState requiredExistingState, PluginState desiredState) Only sets the plugin state if it is in the expected state.- Parameters:
requiredExistingState- The expected statedesiredState- The desired state- Returns:
- True if the set was successful, false if not in the expected state
- Since:
- 2.4
-
isEnabledByDefault
public boolean isEnabledByDefault()- Specified by:
isEnabledByDefaultin interfacePlugin
-
setEnabledByDefault
public void setEnabledByDefault(boolean enabledByDefault) - Specified by:
setEnabledByDefaultin interfacePlugin
-
getPluginsVersion
public int getPluginsVersion()- Specified by:
getPluginsVersionin interfacePlugin
-
setPluginsVersion
public void setPluginsVersion(int pluginsVersion) - Specified by:
setPluginsVersionin interfacePlugin
-
getPluginInformation
- Specified by:
getPluginInformationin interfacePlugin
-
setPluginInformation
- Specified by:
setPluginInformationin interfacePlugin
-
setResources
- Specified by:
setResourcesin interfacePlugin
-
getResourceDescriptors
- Specified by:
getResourceDescriptorsin interfaceResourced
-
getResourceLocation
- Specified by:
getResourceLocationin interfaceResourced
-
getResourceDescriptor
- Specified by:
getResourceDescriptorin interfaceResourced
-
enable
public void enable() -
enableInternal
Perform any internal enabling logic. This method is called by enable to allow subclasses to customize enable behaviour. If a PluginState other thanPluginState.PENDINGis returned, it will be passed tosetPluginState(PluginState). If a subclass returnsPluginState.PENDING, no state is set, and it is assumed the subclass has taken responsibility for transitioning state via direct calls tosetPluginState(PluginState). Subclasses should only throwPluginException.- Returns:
- One of
PluginState.ENABLED,PluginState.ENABLING, orPluginState.PENDING - Throws:
PluginException- If the plugin could not be enabled- Since:
- 2.2.0
-
disable
public final void disable() -
disableInternal
protected void disableInternal()Perform any internal disabling logic. Subclasses should only throwPluginException.- Throws:
PluginException- If the plugin could not be disabled- Since:
- 2.2.0
-
getRequiredPlugins
-
getDependencies
- Specified by:
getDependenciesin interfacePlugin
-
getActivePermissions
- Specified by:
getActivePermissionsin interfacePlugin
-
hasAllPermissions
public final boolean hasAllPermissions()- Specified by:
hasAllPermissionsin interfacePlugin
-
getInstallationMode
- Specified by:
getInstallationModein interfacePlugin
-
close
public void close() -
install
public final void install() -
installInternal
protected void installInternal()Perform any internal installation logic. Subclasses should only throwPluginException.- Throws:
PluginException- If the plugin could not be installed- Since:
- 2.2.0
-
uninstall
public final void uninstall() -
uninstallInternal
protected void uninstallInternal()Perform any internal uninstallation logic. Subclasses should only throwPluginException.- Throws:
PluginException- If the plugin could not be uninstalled- Since:
- 2.2.0
-
isSystemPlugin
public boolean isSystemPlugin()- Specified by:
isSystemPluginin interfacePlugin
-
containsSystemModule
public boolean containsSystemModule()- Specified by:
containsSystemModulein interfacePlugin
-
setSystemPlugin
public void setSystemPlugin(boolean system) - Specified by:
setSystemPluginin interfacePlugin
-
resolve
public void resolve() -
getDateLoaded
- Specified by:
getDateLoadedin interfacePlugin
-
getDateInstalled
- Specified by:
getDateInstalledin interfacePlugin
-
getDateEnabling
- Specified by:
getDateEnablingin interfacePlugin
-
getDateEnabled
- Specified by:
getDateEnabledin interfacePlugin
-
isBundledPlugin
public boolean isBundledPlugin()- Specified by:
isBundledPluginin interfacePlugin
-
setBundledPlugin
public void setBundledPlugin(boolean bundledPlugin) Description copied from interface:PluginInternalAlters whether the plugin is a "bundled" plugin that can't be removed.- Specified by:
setBundledPluginin interfacePluginInternal- Parameters:
bundledPlugin-trueif this plugin is a "bundled" plugin.
-
getPluginArtifact
- Specified by:
getPluginArtifactin interfacePlugin
-
getScopeKey
- Specified by:
getScopeKeyin interfaceScopeAware
-
getDynamicModuleDescriptors
- Specified by:
getDynamicModuleDescriptorsin interfacePluginInternal- Returns:
- current set of dynamic module descriptors.
-
addDynamicModuleDescriptor
Description copied from interface:PluginInternalAdd a module descriptor.- Specified by:
addDynamicModuleDescriptorin interfacePluginInternal- Parameters:
module- to add- Returns:
- true if added, false if already present
-
removeDynamicModuleDescriptor
Description copied from interface:PluginInternalRemove a module descriptor.- Specified by:
removeDynamicModuleDescriptorin interfacePluginInternal- Parameters:
module- to remove- Returns:
- true if removed, false if not present
-
compareTo
Compares this Plugin to another Plugin for order. The primary sort field is the key, and the secondary field is the version number.- Specified by:
compareToin interfaceComparable<Plugin>- 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.
- See Also:
-
cleanVersionString
-
toString
-