com.atlassian.plugin.descriptors
Class AbstractModuleDescriptor<T>

java.lang.Object
  extended by com.atlassian.plugin.descriptors.AbstractModuleDescriptor<T>
All Implemented Interfaces:
ModuleDescriptor<T>, Resourced, StateAware
Direct Known Subclasses:
AbstractWebFragmentModuleDescriptor, BaseServletModuleDescriptor, ResourcedModuleDescriptor, ServletContextListenerModuleDescriptor, ServletContextParamModuleDescriptor, UnloadableModuleDescriptor, UnrecognisedModuleDescriptor, WebResourceModuleDescriptor

public abstract class AbstractModuleDescriptor<T>
extends java.lang.Object
implements ModuleDescriptor<T>, StateAware


Field Summary
protected  Plugin plugin
           
protected  Resources resources
           
protected  boolean singleton
           
 
Constructor Summary
AbstractModuleDescriptor()
           
 
Method Summary
protected  void assertModuleClassImplements(java.lang.Class requiredModuleClazz)
          Check that the module class of this descriptor implements a given interface, or extends a given class.
 void destroy(Plugin plugin)
          Override this if your plugin needs to clean up when it's been removed.
 void disabled()
          Disables the module descriptor
 void enabled()
          Enables the descriptor by loading the module class
 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.
 java.lang.String getName()
          A simple string name for this descriptor.
 java.util.Map getParams()
           
 Plugin getPlugin()
           
 java.lang.String getPluginKey()
          The plugin key for this module, derived from the complete key
 ResourceDescriptor getResourceDescriptor(java.lang.String type, java.lang.String name)
          Deprecated.  
 java.util.List<ResourceDescriptor> getResourceDescriptors()
           
 java.util.List<ResourceDescriptor> getResourceDescriptors(java.lang.String type)
           
 ResourceLocation getResourceLocation(java.lang.String type, java.lang.String name)
           
 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()
           
protected  boolean isSingletonByDefault()
          Override this method if you want your module descriptor to be or not be a singleton by default.
 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)
          Override this for module descriptors which don't expect to be able to load a class successfully
 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

plugin

protected Plugin plugin

singleton

protected boolean singleton

resources

protected Resources resources
Constructor Detail

AbstractModuleDescriptor

public AbstractModuleDescriptor()
Method Detail

init

public void init(Plugin plugin,
                 org.dom4j.Element element)
          throws PluginParseException
Description copied from interface: ModuleDescriptor
Initialise a module given it's parent plugin and the XML element representing the module.

Specified by:
init in interface ModuleDescriptor<T>
Throws:
PluginParseException

loadClass

protected void loadClass(Plugin plugin,
                         org.dom4j.Element element)
                  throws PluginParseException
Deprecated. Since 2.1.0, use loadClass(Plugin,String) instead

Override this for module descriptors which don't expect to be able to load a class successfully

Parameters:
plugin -
element -
Throws:
PluginParseException

loadClass

protected void loadClass(Plugin plugin,
                         java.lang.String clazz)
                  throws PluginParseException
Override this for module descriptors which don't expect to be able to load a class successfully

Parameters:
plugin -
clazz - The module class name to load
Throws:
PluginParseException
Since:
2.1.0

destroy

public void destroy(Plugin plugin)
Override this if your plugin needs to clean up when it's been removed.

Specified by:
destroy in interface ModuleDescriptor<T>

isEnabledByDefault

public boolean isEnabledByDefault()
Description copied from interface: ModuleDescriptor
Whether or not this plugin module is enabled by default.

Specified by:
isEnabledByDefault in interface ModuleDescriptor<T>
Returns:

isSystemModule

public boolean isSystemModule()
Description copied from interface: ModuleDescriptor
Whether or not this plugin module is a "system" plugin that shouldn't be made visible/disableable to the user

Specified by:
isSystemModule in interface ModuleDescriptor<T>
Returns:

isSingleton

public boolean isSingleton()

isSingletonByDefault

protected boolean isSingletonByDefault()
Override this method if you want your module descriptor to be or not be a singleton by default.

Default is "true" - ie all plugin modules are singletons by default.


assertModuleClassImplements

protected final void assertModuleClassImplements(java.lang.Class requiredModuleClazz)
                                          throws PluginParseException
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

public java.lang.String getCompleteKey()
Description copied from interface: ModuleDescriptor
The complete key for this module, including the plugin key.

Format is plugin.key:module.key

Specified by:
getCompleteKey in interface ModuleDescriptor<T>

getPluginKey

public java.lang.String getPluginKey()
Description copied from interface: ModuleDescriptor
The plugin key for this module, derived from the complete key

Specified by:
getPluginKey in interface ModuleDescriptor<T>

getKey

public java.lang.String getKey()
Description copied from interface: ModuleDescriptor
The key for this module, unique within the plugin.

Specified by:
getKey in interface ModuleDescriptor<T>

getName

public java.lang.String getName()
Description copied from interface: ModuleDescriptor
A simple string name for this descriptor.

Specified by:
getName in interface ModuleDescriptor<T>

getModuleClass

public java.lang.Class<T> getModuleClass()
Description copied from interface: ModuleDescriptor
The class of the module this descriptor creates.

Specified by:
getModuleClass in interface ModuleDescriptor<T>

getModule

public abstract T getModule()
Description copied from interface: ModuleDescriptor
The particular module object created by this plugin.

Specified by:
getModule in interface ModuleDescriptor<T>

getDescription

public java.lang.String getDescription()
Description copied from interface: ModuleDescriptor
A simple description of this descriptor.

Specified by:
getDescription in interface ModuleDescriptor<T>

getParams

public java.util.Map getParams()
Specified by:
getParams in interface ModuleDescriptor<T>

getI18nNameKey

public java.lang.String getI18nNameKey()
Description copied from interface: ModuleDescriptor
Key used to override ModuleDescriptor.getName() when using internationalisation.

Specified by:
getI18nNameKey in interface ModuleDescriptor<T>
Returns:
the i18n key. May be null.

getDescriptionKey

public java.lang.String getDescriptionKey()
Description copied from interface: ModuleDescriptor
Key used to override ModuleDescriptor.getDescription() when using internationalisation.

Specified by:
getDescriptionKey in interface ModuleDescriptor<T>
Returns:
the i18n key. May be null.

getResourceDescriptors

public java.util.List<ResourceDescriptor> getResourceDescriptors()
Specified by:
getResourceDescriptors in interface Resourced

getResourceDescriptors

public java.util.List<ResourceDescriptor> getResourceDescriptors(java.lang.String type)
Specified by:
getResourceDescriptors in interface Resourced

getResourceLocation

public ResourceLocation getResourceLocation(java.lang.String type,
                                            java.lang.String name)
Specified by:
getResourceLocation in interface Resourced

getResourceDescriptor

public ResourceDescriptor getResourceDescriptor(java.lang.String type,
                                                java.lang.String name)
Deprecated. 

Specified by:
getResourceDescriptor in interface Resourced

getMinJavaVersion

public java.lang.Float getMinJavaVersion()
Specified by:
getMinJavaVersion in interface ModuleDescriptor<T>

satisfiesMinJavaVersion

public boolean satisfiesMinJavaVersion()
Description copied from interface: ModuleDescriptor
If a min java version has been specified this will return true if the running jvm is >= to the specified version. If this is not set then it is treated as not having a preference.

Specified by:
satisfiesMinJavaVersion in interface ModuleDescriptor<T>
Returns:
true if satisfied, false otherwise.

setPlugin

public void setPlugin(Plugin plugin)
Sets the plugin for the ModuleDescriptor


getPlugin

public Plugin getPlugin()
Specified by:
getPlugin in interface ModuleDescriptor<T>
Returns:
The plugin this module descriptor is associated with

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

enabled

public void enabled()
Enables the descriptor by loading the module class

Specified by:
enabled in interface StateAware
Since:
2.1.0

disabled

public void disabled()
Disables the module descriptor

Specified by:
disabled in interface StateAware


Copyright © 2008 Atlassian Pty Ltd. All Rights Reserved.