Rate this page:
Confluence 2.10 and later
Using Servlet Filter plugin modules you can deploy Java Servlet filters as a part of your plugin, specifying the location and ordering of your filter. In this way you can build filters that can tackle tasks like profiling, monitoring, and content generation.
The root element for the Servlet Filter plugin module is . To configure it, use the following attributes and child elements.
The class which implements this plugin module. The class you need to provide depends on the module type. For example, Confluence theme, layout and colour-scheme modules can use classes already provided in Confluence. So you can write a theme-plugin without any Java code. But for macro and listener modules you need to write your own implementing class and include it in your plugin. See the plugin framework guide to creating plugin module instances.
The servlet filter Java class must implement .
Indicate whether the plugin module should be disabled (value='disabled') or enabled by default (value='enabled').
|The localization key for the human-readable name of the plugin module.|
I.e. the identifier of the servlet filter.
The position of the filter in the application filter chain.
If two plugins provide filters at the same position, the 'weight' attribute (see later) is evaluated.
The human-readable name of the plugin module.
i.e. the human-readable name of the filter.
Default: the plugin key.
Indicates whether this plugin module is a system plugin module (value='true') or not (value='false'). Only available for non-OSGi plugins.
The weight of the filter, used to decide in which order to place the filter in the chain of filters that have the same 'location' attribute specified (see previously).
The higher weight, the lower the filter's position.Default: 100.
Attributes marked with * are required.
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 filter.
Initialization parameters for the filter, specified using and sub-elements, just as in .
This element and its child elements may be repeated.
|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 Resources to your Project for details on defining a resource.|
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:
Determines when the filter is triggered. You can include multiple elements.
Note: This element is only available in Plugin Framework 2.5 and later.
Default: filter will be triggered only for requests from the client.
Elements marked with * are required.
Here is a sample file containing a single Servlet Filter:
<atlassian-plugin name="Hello World Filter" key="example.plugin.helloworld" plugins-version="2"> <plugin-info> <description>A basic Servlet filter module test - says "Hello World!</description> <vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/> <version>1.0</version> </plugin-info> <servlet-filter name="Hello World Servlet" key="helloWorld" class="com.example.myplugins.helloworld.HelloWorldFilter" location="before-dispatch" weight="200"> <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> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </servlet-filter> </atlassian-plugin>
You can access your servlet in the Atlassian web application via each you specify. But, unlike the Servlet plugin module, the is relative to the root of the web application.
For example, if you specify a of as previously, and your Atlassian application is deployed at yourserver/contextpath -- then your servlet filter would be accessed at yourserver/contextpath/helloworld.
Here is some information you need to know when developing or configuring a Servlet Filter plugin module:
Rate this page: