Module Type Plugin Module


The Module Type plugin module is available only for OSGi-based plugins in JIRA 4.0 and later.

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.


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





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.


Indicate whether the plugin module should be disabled by default (value='disabled') or enabled by default (value='enabled').

Default: enabled.


The localisation key for the human-readable name of the plugin module.


The unique identifier of the plugin module. You refer to this key to use the resource from other contexts in your plugin, such as from the plugin Java code or JavaScript resources.

<component-import key="appProps" interface="com.atlassian.sal.api.ApplicationProperties"/>

In the example, appProps is the key for this particular module declaration, for component-import, in this case.


I.e. the identifier of the module type. This value will be used as the XML element name to match.


The human-readable name of the plugin module.


Indicates whether this plugin module is a system plugin module (value='true') or not (value='false'). Only available for non-OSGi plugins.

Default: false.

*key attribute is required.


  • 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.


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

<atlassian-plugin name="Hello World" key="example.plugin.helloworld" plugins-version="2">
        <description>A dictionary module type test</description>
        <vendor name="Atlassian Software Systems" url=""/>

    <module-type key="dictionary" class="example.plugin.DictionaryModuleDescriptor" />

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:

public interface Dictionary
    String getDefinition(String text);

The Java code for DictionaryModuleDescriptor could look like this:

public class DictionaryModuleDescriptor extends AbstractModuleDescriptor<Dictionary>
    private String language;

    public DictionaryModuleDescriptor(ModuleFactory moduleFactory)

    public void init(Plugin plugin, Element element) throws PluginParseException
        super.init(plugin, element);
        language = element.attributeValue("lang");

    public Dictionary getModule()
         return moduleFactory.createModule(moduleClassName, this);

    public String getLanguage()
        return language;

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:

<atlassian-plugin name="Hello World" key="example.plugin.helloworld" plugins-version="2">
        <description>An english dictionary</description>
        <vendor name="Atlassian Software Systems" url=""/>

    <dictionary key="myEnglishDictionary" lang="english" class="example.plugin.english.MyDictionary" />

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

// To get all the enabled modules of this module descriptor
List<DictionaryModuleDescriptor> dictionaryModuleDescriptors =
// Now we'll use each one to get a map of languages to translations of the word "OSGi"
Map<String, String> results = new HashMap<String, String>();
for (DictionaryModuleDescriptor dictionaryModuleDescriptor : dictionaryModuleDescriptors)

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.


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:

    <dictionary key="myEnglishDictionary" lang="english" resource="example/plugin/english/" />
  • 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:

    <component key="dictionaryFactory" class="example.plugin.DictionaryModuleDescriptorFactory" public="true">

    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:

    <dictionary key="myEnglishDictionary" lang="english" class="example.plugin.english.MyDictionary" application="jira" />

    The supported values for application are the Product Keys listed in the Atlassian Plugin SDK documentation.

Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport