This page last changed on Dec 02, 2008 by smaddox.

On this page:

Error formatting macro: toc: java.lang.NullPointerException

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.  
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 you will need to uniquely identify a module. Do this with the module complete 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.  
singleton   Indicates whether this plugin module should only have one instance of its class (value='true') or may have more than one instance (value='false').
Support for this attribute varies between applications (JIRA, Confluence, etc).
false
system   Indicates whether this plugin module is a system plugin module (value='true') or not (value='false'). 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.  
param   Parameters for the plugin module. Use the 'key' attribute to declare the parameter key, then specify the value in either the 'value' attribute or the element body. This element may be repeated. An example is the configuration link described in Adding a Configuration UI for your Plugin. N/A
resource   A resource for this plugin module. This element may be repeated. A 'resource' is a non-Java file that a plugin may need in order to operate. Refer to Adding Plugin and Module Resources for details on defining a resource. N/A

Example

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

<atlassian-plugin name="Hello World" key="example.plugin.helloworld" pluginsVersion="2">
    <plugin-info>
        <description>A dictionary module type test</description>
        <vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/>
        <version>1.0</version>
    </plugin-info>

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

The Java code for DictionaryModuleDescriptor could look like this:

public class DictionaryModuleDescriptor extends AbstractModuleDescriptor<Dictionary>
{
    private String language;
    
    @Override
    public void init(Plugin plugin, Element element) throws PluginParseException
    {
        super.init(plugin, element);
        language = element.attributeValue("lang");
    }

    public Dictionary getModule()
    {
         return (Dictionary)((AutowireCapablePlugin)plugin).autowire(getModuleClass());
    }

    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" pluginsVersion="2">
    <plugin-info>
        <description>An english dictionary</description>
        <vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/>
        <version>1.0</version>
    </plugin-info>

    <dictionary key="english" class="example.plugin.english.MyDictionary" />
</atlassian-plugin>

Notes

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

  • The plugin that defines a new module type cannot use the module type.
  • 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">
      <interface>com.atlassian.plugin.ModuleDescriptorFactory</interface>
    </component>
    
RELATED TOPICS

Writing Confluence Plugins
Installing and Configuring Plugins Manually

Document generated by Confluence on Dec 03, 2008 15:14