|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.plugin.descriptors.AbstractModuleDescriptor<T>
public abstract class AbstractModuleDescriptor<T>
| Field Summary | |
|---|---|
protected java.lang.String |
key
|
protected java.lang.Class<T> |
moduleClass
|
protected java.lang.String |
moduleClassName
|
protected ModuleFactory |
moduleFactory
|
protected java.lang.String |
name
|
protected Plugin |
plugin
|
protected Resources |
resources
|
protected boolean |
singleton
Deprecated. since 2.2.0 |
| Constructor Summary | |
|---|---|
AbstractModuleDescriptor(ModuleFactory moduleFactory)
|
|
| Method Summary | |
|---|---|
protected void |
assertModuleClassImplements(java.lang.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(Plugin plugin)
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(java.lang.Object obj)
Compares the specified object with this module descriptor for equality. |
java.lang.String |
getCompleteKey()
The complete key for this module, including the plugin key. |
java.lang.String |
getDescription()
A simple description of this descriptor. |
java.lang.String |
getDescriptionKey()
Key used to override ModuleDescriptor.getDescription() when using
internationalisation. |
java.lang.String |
getI18nNameKey()
Key used to override ModuleDescriptor.getName() when using internationalisation. |
java.lang.String |
getKey()
The key for this module, unique within the plugin. |
java.lang.Float |
getMinJavaVersion()
|
abstract T |
getModule()
The particular module object created by this plugin. |
java.lang.Class<T> |
getModuleClass()
The class of the module this descriptor creates. |
protected java.lang.String |
getModuleClassName()
|
java.lang.String |
getName()
A simple string name for this descriptor. |
java.util.Map<java.lang.String,java.lang.String> |
getParams()
|
Plugin |
getPlugin()
|
java.lang.String |
getPluginKey()
The plugin key for this module, derived from the complete key. |
protected java.util.Set<java.lang.String> |
getRequiredPermissions()
The set of additionally required permissions. |
ResourceDescriptor |
getResourceDescriptor(java.lang.String type,
java.lang.String name)
Get a ResourceDescriptor of a particular type and name. |
java.util.List<ResourceDescriptor> |
getResourceDescriptors()
Get a List of all the descriptors
. |
java.util.List<ResourceDescriptor> |
getResourceDescriptors(java.lang.String type)
Get a list of all descriptors of a particular
type. |
ResourceLocation |
getResourceLocation(java.lang.String type,
java.lang.String name)
Get a ResourceLocation of a particular type and name. |
int |
hashCode()
Returns the hash code value for this module descriptor. |
void |
init(Plugin plugin,
org.dom4j.Element element)
Initialise a module given it's parent plugin and the XML element representing the module. |
boolean |
isEnabledByDefault()
Whether or not this plugin module is enabled by default. |
boolean |
isSingleton()
Deprecated. Since 2.2.0 |
protected boolean |
isSingletonByDefault()
Deprecated. Since 2.2.0 |
boolean |
isSystemModule()
Whether or not this plugin module is a "system" plugin that shouldn't be made visible/disableable to the user. |
protected void |
loadClass(Plugin plugin,
org.dom4j.Element element)
Deprecated. Since 2.1.0, use loadClass(Plugin,String) instead |
protected void |
loadClass(Plugin plugin,
java.lang.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()
If a min java version has been specified this will return true if the running jvm is >= to the specified version. |
void |
setPlugin(Plugin plugin)
Sets the plugin for the ModuleDescriptor |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Plugin plugin
protected java.lang.String key
protected java.lang.String name
protected java.lang.String moduleClassName
protected java.lang.Class<T> moduleClass
@Deprecated protected boolean singleton
protected Resources resources
protected final ModuleFactory moduleFactory
| Constructor Detail |
|---|
public AbstractModuleDescriptor(ModuleFactory moduleFactory)
| Method Detail |
|---|
public void init(@NotNull
Plugin plugin,
@NotNull
org.dom4j.Element element)
throws PluginParseException
ModuleDescriptor
Since atlassian-plugins v2.2, you can no longer load classes from the
plugin in this method, because the OSGi bundle that they will live in is
not built yet. Load classes in the
enabled()
method instead.
init in interface ModuleDescriptor<T>plugin - The plugin that the module belongs to. Must not be null.element - XML element representing the module. Must not be null.
PluginParseException - Can be thrown if an error occurs while
parsing the XML element.
protected 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.
ModulePermissionException - if the plugin doesn't require the necessary permissions for the module to work.RequirePermission,
getRequiredPermissions()protected java.util.Set<java.lang.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 pattern
@Deprecated
protected void loadClass(Plugin plugin,
org.dom4j.Element element)
throws PluginParseException
loadClass(Plugin,String) instead
plugin - element -
PluginParseException
protected void loadClass(Plugin plugin,
java.lang.String clazz)
throws PluginParseException
clazz - The module class name to load
java.lang.IllegalStateException - If the module class cannot be determined
and the descriptor doesn't define a module type via generics
PluginParseExceptionpublic void destroy(Plugin plugin)
destroy in interface ModuleDescriptor<T>plugin - TODO: The plugin parameter is redundant. The
ModuleDescriptor must know its parent plugin in order to
implement getPlugin()public boolean isEnabledByDefault()
ModuleDescriptor
isEnabledByDefault in interface ModuleDescriptor<T>true if this plugin module is enabled by default.public boolean isSystemModule()
ModuleDescriptor
isSystemModule in interface ModuleDescriptor<T>true if this plugin module is a "system" plugin that
shouldn't be made visible/disableable to the user.@Deprecated public boolean isSingleton()
@Deprecated protected boolean isSingletonByDefault()
protected final void assertModuleClassImplements(java.lang.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 java.lang.String getCompleteKey()
ModuleDescriptorFormat is plugin.key:module.key
getCompleteKey in interface ModuleDescriptor<T>ModuleDescriptor.getKey(),
ModuleDescriptor.getPluginKey()public java.lang.String getPluginKey()
ModuleDescriptor
getPluginKey in interface ModuleDescriptor<T>ModuleDescriptor.getKey(),
ModuleDescriptor.getCompleteKey()public java.lang.String getKey()
ModuleDescriptor
getKey in interface ModuleDescriptor<T>ModuleDescriptor.getCompleteKey(),
ModuleDescriptor.getPluginKey()public java.lang.String getName()
ModuleDescriptor
getName in interface ModuleDescriptor<T>public java.lang.Class<T> getModuleClass()
ModuleDescriptor
getModuleClass in interface ModuleDescriptor<T>ModuleDescriptor.getModule()public abstract T getModule()
ModuleDescriptor
getModule in interface ModuleDescriptor<T>ModuleDescriptor.getModuleClass()public java.lang.String getDescription()
ModuleDescriptor
getDescription in interface ModuleDescriptor<T>public java.util.Map<java.lang.String,java.lang.String> getParams()
getParams in interface ModuleDescriptor<T>public java.lang.String getI18nNameKey()
ModuleDescriptorModuleDescriptor.getName() when using internationalisation.
getI18nNameKey in interface ModuleDescriptor<T>public java.lang.String getDescriptionKey()
ModuleDescriptorModuleDescriptor.getDescription() when using
internationalisation.
getDescriptionKey in interface ModuleDescriptor<T>public java.util.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 java.util.List<ResourceDescriptor> getResourceDescriptors(java.lang.String type)
Resourceddescriptors 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.
getResourceDescriptors in interface Resourced
public ResourceLocation getResourceLocation(java.lang.String type,
java.lang.String name)
ResourcedResourceLocation of a particular type and name.
getResourceLocation in interface Resourced
public ResourceDescriptor getResourceDescriptor(java.lang.String type,
java.lang.String name)
ResourcedResourceDescriptor of a particular type and name.
getResourceDescriptor in interface Resourcedpublic java.lang.Float getMinJavaVersion()
getMinJavaVersion in interface ModuleDescriptor<T>public boolean satisfiesMinJavaVersion()
ModuleDescriptor
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(java.lang.Object obj)
ModuleDescriptorCompares the specified object with this module descriptor for equality.
Returns true if the given object is also a module descriptor and the two descriptors have the same
"complete key" as determined by ModuleDescriptor.getCompleteKey().
equals in interface ModuleDescriptor<T>equals in class java.lang.Objectobj - object to be compared for equality with this module descriptor.
public int hashCode()
ModuleDescriptor
getCompleteKey() == null ? 0 : getCompleteKey().hashCode()
This ensures that d1.equals(d2) implies that
d1.hashCode()==d2.hashCode() for any two Module Descriptors
d1 and d2, as required by the general
contract of Object.hashCode.
hashCode in interface ModuleDescriptor<T>hashCode in class java.lang.ObjectObject.hashCode(),
Object.equals(Object),
ModuleDescriptor.equals(Object)public java.lang.String toString()
toString in class java.lang.Objectpublic void enabled()
enabled in interface StateAwarepublic void disabled()
disabled in interface StateAwareprotected java.lang.String getModuleClassName()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||