This page last changed on Oct 22, 2009 by rosie@atlassian.com.
The Module Type plugin module described below is available only for OSGi-based plugins in JIRA 4.0 and above.

Purpose of this Module Type

Module Type plugin modules allow you to dynamically add new plugin module types to the plugin framework, generally building on other plugin modules. For example, a plugin developer could create a <dictionary> plugin module that is used to feed a dictionary service used by still other plugins.

Configuration

The root element for the Module Type plugin module is module-type. It allows the following attributes and child elements for configuration:

Attributes

Name Required Description Default
class   The ModuleDescriptor class to instantiate when a new plugin module of this type is found. See the plugin framework guide to creating plugin module instances.  
disabled   Indicate whether the plugin module should be disabled by default (value='true') or enabled by default (value='false'). false
i18n-name-key   The localisation key for the human-readable name of the plugin module.  
key The identifier of the plugin module. This key must be unique within the plugin where it is defined.
Sometimes, in other contexts, you may need to uniquely identify a module. Do this with the complete module key. A module with key fred in a plugin with key com.example.modules will have a complete key of com.example.modules:fred. I.e. the identifier of the module type. This value will be used as the XML element name to match.
N/A
name   The human-readable name of the plugin module.  
system   Indicates whether this plugin module is a system plugin module (value='true') or not (value='false'). Only available for non-OSGi plugins. false

Elements

Name Required Description Default
description   The description of the plugin module. The 'key' attribute can be specified to declare a localisation key for the value instead of text in the element body.  

Example

Here is an example atlassian-plugin.xml file containing a plugin module type:

Our dictionary module descriptor allows plugins to provide dictionaries that get definitions of technical terms and phrases in various languages. We have a Dictionary interface that looks like this:

The Java code for DictionaryModuleDescriptor could look like this:

This will add the new module type 'dictionary' to the plugin framework, allowing other plugins to use the new module type. Here is a plugin that uses the new 'dictionary' module type:

Accessing modules of your dynamic module type can be done using com.atlassian.plugin.PluginAccessor.

Note that it is not advisable to cache the results of calls to com.atlassian.plugin.PluginAccessor's methods, since the return values can change at any time as a result of plugins being installed, uninstalled, enabled, or disabled.

Notes

Some information to be aware of when developing or configuring a Module Type plugin module:

  • Not all dynamic module types will need to use the class attribute on the modules that implement them. For example, if the above dictionary example just used a resource file to translate terms, and not an interface that plugins had to implement, plugins using the dictionary module type might look like this:
  • The plugin that defines a new module type cannot use the module type in the Plugin Framework 2.1, but can in 2.2 or later.
  • If you want to have control over the construction of the ModuleDescriptor, you can skip the 'module-type' module and make public a component registered against the ModuleDescriptorFactory interface:
    Ensure your ModuleDescriptorFactory implements com.atlassian.plugin.osgi.external.ListableModuleDescriptorFactory.
  • By specifying the application attribute in your module type element, you can ensure that a plugin only uses that module type when it is running in a specific application. For example, with the following snippet, the dictionary module type is only used when the plugin is loaded in JIRA:
    The supported values for application are the Product Keys listed in the Atlassian Plugin SDK documentation.
Document generated by Confluence on Mar 27, 2011 18:52