Package com.atlassian.plugin.descriptors
Class AbstractModuleDescriptor<T>
java.lang.Object
com.atlassian.plugin.descriptors.AbstractModuleDescriptor<T>
- All Implemented Interfaces:
ModuleDescriptor<T>,Resourced,ScopeAware,StateAware
- Direct Known Subclasses:
EventListenerModuleDescriptor,UnloadableModuleDescriptor,UnrecognisedModuleDescriptor
public abstract class AbstractModuleDescriptor<T>
extends Object
implements ModuleDescriptor<T>, StateAware
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidassertModuleClassImplements(Class<T> requiredModuleClazz) Check that the module class of this descriptor implements a given interface, or extends a given class.protected final voidThis is a method that module should call (in theirinit method implementationto check that permissions are correctly set on the plugin.voiddestroy()The default implementation disables the module if it's still enabled, and unreference the plugin.voiddisabled()Disables the module descriptor.voidenabled()Enables the descriptor by loading the module class.booleangetKey()abstract Tprotected StringgetName()The set of additionally required permissions.getResourceDescriptor(String type, String name) getResourceLocation(String type, String name) inthashCode()voidbooleanisBroken()booleanGet whether this plugin module is enabled.booleanbooleanprotected voidLoads the module class that this descriptor provides, and will not necessarily be the implementation class.booleanvoidvoidSets the plugin for the ModuleDescriptortoString()protected voidValidates the element has the key attribute present Provides validation for given elementMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.atlassian.plugin.ModuleDescriptor
getDisplayName
-
Field Details
-
plugin
-
key
-
name
-
moduleClassName
-
moduleClass
-
resources
-
moduleFactory
-
-
Constructor Details
-
AbstractModuleDescriptor
-
-
Method Details
-
init
- Specified by:
initin interfaceModuleDescriptor<T>
-
checkPermissions
protected final void checkPermissions()This is a method that module should call (in theirinit method implementationto check that permissions are correctly set on the plugin. Use theRequirePermissionannotation to add permissions to a module, and/orgetRequiredPermissions()if you need more dynamic permissions. If either all permissions are allowed or this is a system module, we don't bother to check permissions- Throws:
ModulePermissionException- if the plugin doesn't require the necessary permissions for the module to work.- Since:
- 3.0
- See Also:
-
getRequiredPermissions
The set of additionally required permissions. This is useful for dynamic permissions depending on module configuration. One might prefer the
RequirePermissionannotation otherwise for 'static' permissions.Default implementation returns an empty set
- Returns:
- the set of additionally required permissions.
- Since:
- 3.0
- See Also:
-
validate
Validates the element has the key attribute present Provides validation for given element- Parameters:
element- The element to validate- Since:
- 7.5.0
-
loadClass
Loads the module class that this descriptor provides, and will not necessarily be the implementation class. Override this for module descriptors whose type cannot be determined via generics.- Parameters:
clazz- The module class name to load- Throws:
IllegalStateException- If the module class cannot be determined and the descriptor doesn't define a module type via generics
-
destroy
public void destroy()The default implementation disables the module if it's still enabled, and unreference the plugin. Override this if your plugin needs to clean up when it's been removed, and call super.destroy(Plugin) before returning.- Specified by:
destroyin interfaceModuleDescriptor<T>
-
isEnabledByDefault
public boolean isEnabledByDefault()- Specified by:
isEnabledByDefaultin interfaceModuleDescriptor<T>
-
isSystemModule
public boolean isSystemModule()- Specified by:
isSystemModulein interfaceModuleDescriptor<T>
-
assertModuleClassImplements
Check that the module class of this descriptor implements a given interface, or extends a given class.- Parameters:
requiredModuleClazz- The class this module's class must implement or extend.- Throws:
PluginParseException- If the module class does not implement or extend the given class.
-
getCompleteKey
- Specified by:
getCompleteKeyin interfaceModuleDescriptor<T>
-
getPluginKey
- Specified by:
getPluginKeyin interfaceModuleDescriptor<T>
-
getKey
- Specified by:
getKeyin interfaceModuleDescriptor<T>
-
getName
- Specified by:
getNamein interfaceModuleDescriptor<T>
-
getModuleClass
- Specified by:
getModuleClassin interfaceModuleDescriptor<T>
-
getModule
- Specified by:
getModulein interfaceModuleDescriptor<T>
-
getScopeKey
- Specified by:
getScopeKeyin interfaceScopeAware
-
getDescription
- Specified by:
getDescriptionin interfaceModuleDescriptor<T>
-
getParams
- Specified by:
getParamsin interfaceModuleDescriptor<T>
-
getI18nNameKey
- Specified by:
getI18nNameKeyin interfaceModuleDescriptor<T>
-
getDescriptionKey
- Specified by:
getDescriptionKeyin interfaceModuleDescriptor<T>
-
getResourceDescriptors
- Specified by:
getResourceDescriptorsin interfaceResourced
-
getResourceLocation
- Specified by:
getResourceLocationin interfaceResourced
-
getResourceDescriptor
- Specified by:
getResourceDescriptorin interfaceResourced
-
getMinJavaVersion
- Specified by:
getMinJavaVersionin interfaceModuleDescriptor<T>
-
satisfiesMinJavaVersion
public boolean satisfiesMinJavaVersion()- Specified by:
satisfiesMinJavaVersionin interfaceModuleDescriptor<T>
-
setPlugin
Sets the plugin for the ModuleDescriptor- Parameters:
plugin- The plugin to set for this descriptor.
-
getPlugin
- Specified by:
getPluginin interfaceModuleDescriptor<T>- Returns:
- The plugin this module descriptor is associated with.
-
equals
- Specified by:
equalsin interfaceModuleDescriptor<T>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceModuleDescriptor<T>- Overrides:
hashCodein classObject
-
toString
-
enabled
public void enabled()Enables the descriptor by loading the module class. Classes overriding this method MUST call super.enabled() before their own enabling code.- Specified by:
enabledin interfaceStateAware- Since:
- 2.1.0
-
disabled
public void disabled()Disables the module descriptor. Classes overriding this method MUST call super.disabled() after their own disabling code.- Specified by:
disabledin interfaceStateAware
-
getModuleClassName
- Returns:
- The defined module class name
- Since:
- 3.0
-
isEnabled
public boolean isEnabled()Get whether this plugin module is enabled.- Specified by:
isEnabledin interfaceModuleDescriptor<T>- Returns:
- If this module is enabled
- Since:
- 3.1
-
setBroken
public void setBroken()- Specified by:
setBrokenin interfaceModuleDescriptor<T>
-
isBroken
public boolean isBroken()- Specified by:
isBrokenin interfaceModuleDescriptor<T>
-