@PublicSpi public interface

JiraService

implements ObjectConfigurable Runnable
com.atlassian.jira.service.JiraService
Known Indirect Subclasses

@PublicSpi

This interface is designed for plugins to implement.

Clients of @PublicSpi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicSpi as per each product's API policy (clients should refer to each product's API policy for the exact guarantee -- usually binary compatibility is guaranteed at least across minor versions).

Note: @PublicSpi interfaces and classes are specifically designed to be implemented/extended by clients. Hence, the guarantee of binary compatibility is different to that of @PublicApi elements (if an element is both @PublicApi and @PublicSpi, both guarantees apply).

Class Overview

Classes that are to be run as services within JIRA must implement this interface.

Summary

Fields
public static final Comparator<JiraService> NAME_COMPARATOR Compares two given JiraService objects by their names and returns the result of the comparison.
Public Methods
void destroy()
This method is called when the service is unloaded (usually when the web application or server is being shut down).
String getDescription()
A textual description of the service.
String getName()
A textual name of the service as entered by the user from the web interface.
void init(PropertySet props)
Initialise the service.
boolean isInternal()
Indicates whether administrators can delete this service from within the web interface.
boolean isUnique()
Whether this service class should be unique.
void run()
Perform the action of this service.
void setName(String name)
Used to set the service's name.
[Expand]
Inherited Methods
From interface com.atlassian.configurable.ObjectConfigurable
From interface java.lang.Runnable

Fields

public static final Comparator<JiraService> NAME_COMPARATOR

Compares two given JiraService objects by their names and returns the result of the comparison.

Public Methods

public void destroy ()

This method is called when the service is unloaded (usually when the web application or server is being shut down).

You may wish to remove any connections that you have established, eg. database connections.

public String getDescription ()

A textual description of the service. You can include HTML if required, but do not use tables, or DHTML, as the description may be displayed inside tables / frames.

A good description will describe what this service does, and then explains the parameters required for configuring the service.

If no description is appropriate, return null.

Returns
  • A HTML description of the service

public String getName ()

A textual name of the service as entered by the user from the web interface.

The name should be unique to identify services of the same class.
This is enforced when adding new services via the web interface.

The value of name does not effect the service, hence can be set to null

Returns
  • The name of the service

public void init (PropertySet props)

Initialise the service. This method is guaranteed to be called before the first call to run().

As the parameters are gained from the user's interaction with the website, it is not guaranteed to be called with the correct, or indeed with any parameters.

init() may be called multiple times during the services lifetime.

Parameters
props initialisation parameters
Throws
ObjectConfigurationException in case of an error with initialisation parameters

public boolean isInternal ()

Indicates whether administrators can delete this service from within the web interface.

Generally only Atlassian services should return true from this.

Returns
  • true if this service is internal to JIRA, false otherwise

public boolean isUnique ()

Whether this service class should be unique. Some service are fine to have multiples, and some are not.

Having multiple backup services could be fine - perhaps you want to backup once an hour, and also once a day.

With other services, you may wish to enforce their uniqueness

Returns
  • Whether this service class should be unique.

public void run ()

Perform the action of this service. The caller of this method assumes that no housekeeping has been done, and will call setLastRun() after the run() method.

init() is guaranteed to be called before run(), but the parameters passed to init() are not guaranteed to be correct. Any parameters expected to be set by init() should be checked in this method upon each invocation.

public void setName (String name)

Used to set the service's name. For details on the services name see getName()

Parameters
name service name to set