@PublicSpi public interface

MessageHandler

com.atlassian.jira.service.util.handler.MessageHandler

@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

An interface representing a message handler. A handler handles messages. Implementers may extend AbstractMessageHandler (provided by JIRA Mail Plugin) to inherit standard functionality such mail loop detection etc.

As of JIRA 5.0 MessageHandler implementations provided by plugins are created using dependency injection, so injecting your dependencies instead of calling them statically is the prefered way to go.

Summary

Public Methods
boolean handleMessage(Message message, MessageHandlerContext context)
Perform the specific work of this handler for the given message.
void init(Map<StringString> params, MessageHandlerErrorCollector errorCollector)
Will be called before any messages are to be handled.

Public Methods

public boolean handleMessage (Message message, MessageHandlerContext context)

Perform the specific work of this handler for the given message.

Return true to indicate that the message was successfully processed and can be deleted. Return false to indicate that the message was not processed. If the message is invalid and cannot be processed you should call markMessageForDeletion(java.lang.String). Calling this method will mark the message for deletion, but will also attempt to forward the email on to the admin with the given error message if such a forwarding address has been configured.

Parameters
message the message to check for handling.
context user-friendly message handler should utilize this interface to create issue, comments, users and provide feedback information about messages being processed and problems being encountered. While MessageHandler-s are run from UI (in TEST / dry-run mode) such invocations are not mutative (they do not create any JIRA entities) and information provided by the handler is displayed back to the user as a summary of the dry-run.
Returns
  • true if the message was successfully processed.
Throws
MessagingException if anything went wrong.

public void init (Map<StringString> params, MessageHandlerErrorCollector errorCollector)

Will be called before any messages are to be handled.

Parameters
params configuration.
errorCollector potential problems encountered during initialization of the handler should be reported here. Depending on the run mode it may be e.g. displayed back to the user (when handler is tested from UI) or logged to the file .