public abstract class AbstractModuleDescriptor<T> extends Object implements ModuleDescriptor<T>, StateAware
| Modifier and Type | Field and Description |
|---|---|
protected String |
key |
protected Class<T> |
moduleClass |
protected String |
moduleClassName |
protected ModuleFactory |
moduleFactory |
protected String |
name |
protected Plugin |
plugin |
protected Resources |
resources |
| Constructor and Description |
|---|
AbstractModuleDescriptor(ModuleFactory moduleFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertModuleClassImplements(Class<T> requiredModuleClazz)
Check that the module class of this descriptor implements a given
interface, or extends a given class.
|
protected void |
checkPermissions()
This is a method that module should call (in their
init method implementation to
check that permissions are correctly set on the plugin. |
void |
destroy()
The default implementation disables the module if it's still enabled, and unreference the plugin.
|
void |
disabled()
Disables the module descriptor.
|
void |
enabled()
Enables the descriptor by loading the module class.
|
boolean |
equals(Object obj) |
String |
getCompleteKey() |
String |
getDescription() |
String |
getDescriptionKey() |
String |
getI18nNameKey() |
String |
getKey() |
Float |
getMinJavaVersion() |
abstract T |
getModule() |
Class<T> |
getModuleClass() |
protected String |
getModuleClassName() |
String |
getName() |
Map<String,String> |
getParams() |
Plugin |
getPlugin() |
String |
getPluginKey() |
protected Set<String> |
getRequiredPermissions()
The set of additionally required permissions.
|
ResourceDescriptor |
getResourceDescriptor(String type,
String name) |
List<ResourceDescriptor> |
getResourceDescriptors() |
ResourceLocation |
getResourceLocation(String type,
String name) |
Optional<String> |
getScopeKey() |
int |
hashCode() |
void |
init(Plugin plugin,
org.dom4j.Element element) |
boolean |
isBroken() |
boolean |
isEnabled()
Get whether this plugin module is enabled.
|
boolean |
isEnabledByDefault() |
boolean |
isSystemModule() |
protected void |
loadClass(Plugin plugin,
String clazz)
Loads the module class that this descriptor provides, and will not
necessarily be the implementation class.
|
protected void |
provideValidationRules(ValidationPattern pattern)
Provides validation rules for the pattern
|
boolean |
satisfiesMinJavaVersion() |
void |
setBroken() |
void |
setPlugin(Plugin plugin)
Sets the plugin for the ModuleDescriptor
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetDisplayNameprotected Plugin plugin
protected String key
protected String name
protected String moduleClassName
protected Resources resources
protected final ModuleFactory moduleFactory
public AbstractModuleDescriptor(ModuleFactory moduleFactory)
public void init(@Nonnull Plugin plugin, @Nonnull org.dom4j.Element element) throws PluginParseException
init in interface ModuleDescriptor<T>PluginParseExceptionprotected final void checkPermissions()
throws ModulePermissionException
init method implementation to
check that permissions are correctly set on the plugin. Use the RequirePermission annotation to add
permissions to a module, and/or getRequiredPermissions() if you need more dynamic permissions.
If either all permissions are allowed or this is a system module, we don't bother to check permissionsModulePermissionException - if the plugin doesn't require the necessary permissions for the module to work.RequirePermission,
getRequiredPermissions()protected Set<String> getRequiredPermissions()
The set of additionally required permissions. This is useful for dynamic permissions depending on module
configuration. One might prefer the RequirePermission annotation otherwise for 'static' permissions.
Default implementation returns an empty set
RequirePermission,
checkPermissions()protected void provideValidationRules(ValidationPattern pattern)
pattern - The validation patternprotected void loadClass(Plugin plugin, String clazz) throws PluginParseException
clazz - The module class name to loadIllegalStateException - If the module class cannot be determined
and the descriptor doesn't define a module type via genericsPluginParseExceptionpublic void destroy()
destroy in interface ModuleDescriptor<T>public boolean isEnabledByDefault()
isEnabledByDefault in interface ModuleDescriptor<T>public boolean isSystemModule()
isSystemModule in interface ModuleDescriptor<T>protected final void assertModuleClassImplements(Class<T> requiredModuleClazz) throws PluginParseException
requiredModuleClazz - The class this module's class must implement
or extend.PluginParseException - If the module class does not implement or
extend the given class.public String getCompleteKey()
getCompleteKey in interface ModuleDescriptor<T>public String getPluginKey()
getPluginKey in interface ModuleDescriptor<T>public String getKey()
getKey in interface ModuleDescriptor<T>public String getName()
getName in interface ModuleDescriptor<T>public Class<T> getModuleClass()
getModuleClass in interface ModuleDescriptor<T>public abstract T getModule()
getModule in interface ModuleDescriptor<T>public Optional<String> getScopeKey()
getScopeKey in interface ScopeAwarepublic String getDescription()
getDescription in interface ModuleDescriptor<T>public Map<String,String> getParams()
getParams in interface ModuleDescriptor<T>public String getI18nNameKey()
getI18nNameKey in interface ModuleDescriptor<T>public String getDescriptionKey()
getDescriptionKey in interface ModuleDescriptor<T>public List<ResourceDescriptor> getResourceDescriptors()
getResourceDescriptors in interface Resourcedpublic ResourceLocation getResourceLocation(String type, String name)
getResourceLocation in interface Resourcedpublic ResourceDescriptor getResourceDescriptor(String type, String name)
getResourceDescriptor in interface Resourcedpublic Float getMinJavaVersion()
getMinJavaVersion in interface ModuleDescriptor<T>public boolean satisfiesMinJavaVersion()
satisfiesMinJavaVersion in interface ModuleDescriptor<T>public void setPlugin(Plugin plugin)
plugin - The plugin to set for this descriptor.public Plugin getPlugin()
getPlugin in interface ModuleDescriptor<T>public boolean equals(Object obj)
equals in interface ModuleDescriptor<T>equals in class Objectpublic int hashCode()
hashCode in interface ModuleDescriptor<T>hashCode in class Objectpublic void enabled()
enabled in interface StateAwarepublic void disabled()
disabled in interface StateAwareprotected String getModuleClassName()
public boolean isEnabled()
isEnabled in interface ModuleDescriptor<T>public void setBroken()
setBroken in interface ModuleDescriptor<T>public boolean isBroken()
isBroken in interface ModuleDescriptor<T>Copyright © 2020 Atlassian. All rights reserved.