@PublicSpi public abstract class

AbstractService

extends Object
implements JiraService
java.lang.Object
   ↳ com.atlassian.jira.service.AbstractService
Known Direct Subclasses
Known Indirect Subclasses

@PublicSpi

This class 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

A convenience class - if you extend this class, all that needs to be implemented is run()

Summary

Constants
String SERVICE_EVENT
Fields
protected Logger log
protected String name
[Expand]
Inherited Fields
From interface com.atlassian.jira.service.JiraService
Public Constructors
AbstractService()
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 getDefaultProperty(String propertyKey)
Returns the default property value for a key
String getDescription()
A textual description of the service.
String getKey()
Return the key of this object
Long getLongProperty(String propertyKey)
Returns a property of this object with the specified key as a long
String getName()
A textual name of the service as entered by the user from the web interface.
PropertySet getProperties()
Retrieve all the specified Properties for this object
String getProperty(String propertyKey)
Returns a property of this object with the specified key
String getTextProperty(String propertyKey)
Returns a property of this object with the specified key, the property is of type text
boolean hasProperty(String propertyKey)
Checks if this object has a particular property
void init(PropertySet props)
Initialise the service.
boolean isInternal()
By default, returns false.
boolean isUnique()
By default, services are not unique.
abstract void run()
This method must be implemented in a subclass, and performs the functionality that the service performs.
void setName(String name)
Used to set the service's name.
Protected Methods
ObjectConfiguration getObjectConfiguration(String id, String xmlfile, Map<StringString[]> params)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.configurable.ObjectConfigurable
From interface com.atlassian.jira.service.JiraService
From interface java.lang.Runnable

Constants

public static final String SERVICE_EVENT

Constant Value: "ServiceEvent"

Fields

protected Logger log

protected String name

Public Constructors

public AbstractService ()

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 getDefaultProperty (String propertyKey)

Returns the default property value for a key

Parameters
propertyKey String key used to retrieve the properties default value
Returns
  • Default property key

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 getKey ()

Return the key of this object

Returns
  • Key of object

public Long getLongProperty (String propertyKey)

Returns a property of this object with the specified key as a long

Parameters
propertyKey String key used to retrieve the property value
Returns
  • Property value

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 PropertySet getProperties ()

Retrieve all the specified Properties for this object

Returns
  • Set of properties for this object

public String getProperty (String propertyKey)

Returns a property of this object with the specified key

Parameters
propertyKey String key used to retrieve the property value
Returns
  • Property value

public String getTextProperty (String propertyKey)

Returns a property of this object with the specified key, the property is of type text

Parameters
propertyKey String key used to retrieve the property value
Returns
  • Property value

public boolean hasProperty (String propertyKey)

Checks if this object has a particular property

Parameters
propertyKey to look for
Returns
  • true If there is a value

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

public boolean isInternal ()

By default, returns false.

Returns
  • false

public boolean isUnique ()

By default, services are not unique.

Returns
  • false.

public abstract void run ()

This method must be implemented in a subclass, and performs the functionality that the service performs. This method is called after the duration specified through the administration web interface.

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

Protected Methods

protected ObjectConfiguration getObjectConfiguration (String id, String xmlfile, Map<StringString[]> params)