Available: | Confluence 1.4 and later |
Servlet plugin modules let you deploy Java Servlets as part of your plugins.
The root element for the Servlet plugin module is servlet
. To configure it, use following attributes and child elements.
Name* | Description |
---|---|
class* | The Servlet Java class. Must be a subclass of See the plugin framework guide to creating plugin module instances. |
state
| Indicate whether the plugin module should be disabled by default (value='disabled') or enabled by default (value='enabled'). Default: enabled. |
i18n-name-key | The localization key for the human-readable name of the plugin module. |
key* | 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.
I.e. the identifier of the servlet. |
name | The human-readable name of the plugin module. i.e. the human-readable name of the Servlet. Default: 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. Default: false. |
Attributes marked with * are required.
Name* | Description |
---|---|
description | The description of the plugin module. The 'key' attribute can be specified to declare a localization key for the value instead of text in the element body. i.e. the description of the Servlet module. |
init-param
| Initialization parameters for the servlet, specified using just as in |
resource | A resource for this plugin module. This element may be repeated. A 'resource' is a non-Java file that a plugin may need to operate. Refer to Adding resources to your project for details on defining a resource. |
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:
Examples
|
name | The human-readable name of the plugin module. i.e. the human-readable name of the Servlet. Default: 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. Default: false. |
Elements marked with * are required.
Here is an sample atlassian-plugin.xml
file containing a single Servlet module:
1 2<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>
You can access your Servlet in 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 is deployed at
yourserver/jira, then you can access your servlet at
yourserver/jira/plugins/servlet/helloworld.
Here is some information you need to know when developing or configuring a Servlet plugin module:
init()
method is not called on web application start as for a normal servlet. Instead,
this method is called the first time your servlet is accessed after each time plugin module 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-created and its init()
method is called again./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.Rate this page: