This page last changed on Jul 30, 2009 by smaddox.

On this page:

Purpose of this Module Type

Servlet plugin modules enable you to deploy Java servlets as a part of your plugins.

Configuration

The root element for the Servlet plugin module is servlet. It allows the following attributes and child elements for configuration:

Attributes

Name Required Description Default
class The servlet Java class. Must be a subclass of javax.servlet.http.HttpServlet.  
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 servlet.
N/A
name   The human-readable name of the plugin module. I.e. the human-readable name of the servlet. The plugin key.
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. I.e. the description of the servlet.  
init-param   Initialisation parameters for the servlet, specified using param-name and param-value sub-elements, just as in web.xml. This element and its child elements may be repeated. 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
url-pattern The pattern of the URL to match. This element may be repeated.

The URL pattern format is used in Atlassian plugin types to map them to URLs. On the whole, the pattern rules are consistent with those defined in the Servlet 2.3 API. The following wildcards are supported:

  • * matches zero or many characters, including directory slashes
  • ? matches zero or one character
Examples
  • /mydir/* matches /mydir/myfile.xml
  • /*/admin/*.??ml matches /mydir/otherdir/admin/myfile.html
N/A

Example

Here is an example atlassian-plugin.xml file containing a single servlet:

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

    <servlet name="Hello World Servlet" key="helloWorld" class="com.example.myplugins.helloworld.HelloWorldServlet">
        <description>Says Hello World, Australia or your name.</description>
        <url-pattern>/helloworld</url-pattern>
        <init-param>
            <param-name>defaultName</param-name>
            <param-value>Australia</param-value>
        </init-param>
    </servlet>
</atlassian-plugin>

Accessing your Servlet

Your servlet will be accessible within the Atlassian web application via each url-pattern you specify, beneath the /plugins/servlet parent path.

For example, if you specify a url-pattern of /helloworld as above, and your Atlassian application was deployed at http://yourserver/jira — then your servlet would be accessed at http://yourserver/jira/plugins/servlet/helloworld .

Notes

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

  • Your servlet's init() method will not be called on web application startup, as for a normal servlet. Instead, this method will be called the first time your servlet is accessed after each time it is enabled. This means that if you disable a plugin containing a servlet, or a single servlet module, and re-enable it again, the servlet is re-instantiated and its init() method will be called again.
  • Because all servlet modules are deployed beneath a common /plugins/servlet root, be careful when choosing each url-pattern under which your servlet is deployed. It is recommended to use a value that will always be unique to the world!
RELATED TOPICS

Developing Plugins for Crowd

Information sourced from Plugin Framework documentation

Document generated by Confluence on Jul 30, 2009 01:30