Documentation for JIRA 5.0. Documentation for other versions of JIRA is available too.

リスナーはJIRAで固有であり、拡張するのにとても強力な方法です。

JIRA has a complete event subsystem which fires events whenever anything happens inside the application. For example an ISSUE_CREATED event is fired whenever an issue is created.

A Listener is a class that implements one of the Listener interfaces. It is then called whenever events occur in JIRA. Using those events, you can then perform any action you want. For example the email sent by JIRA is driven by the MailListener.

リスナーは、JIRA内で発生するイベントから外部システムに影響を与えたいときに最も便利です。

On this page:

(warning) The information on this page does not apply to JIRA OnDemand.

Listener Interfaces

JIRA には次のような(基本の JiraListener を拡張した)具体的なリスナーがあります。

com.atlassian.jira.event.JiraListener

The base interface which all other JIRA listener interfaces extend. Covers core listener properties like uniqueness, description, parameters etc.
API doc

com.atlassian.jira.event.issue.IssueEventListener

The main listener interface in JIRA, used whenever anything happens to an issue.
API doc

com.atlassian.jira.event.user.UserEventListener

This listener is called whenever anything happens to a user within JIRA.
API doc

Example Listeners

The examples provided may be freely used and modified for use in your own environment. The source of all examples is available and should give you good overview of how simple it is to write your own listeners. Both example listeners are included with JIRA 2.1, and both implement UserEventListener and IssueEventListener.

  • DebugListener (source) — This is a very simple listener that prints events and their content to System.out whenever they are received. To test this listener, add a listener with the class com.atlassian.jira.event.listeners.DebugListener .
  • MailListener (source) — This listener is how mail notifications are currently sent from within JIRA, and a good example of a more complex listener. It basically listens for events, and turns them into email notifications using Velocity templates to generate the mail bodies.
    This listener is usually always turned on in JIRA — see Email Notifications for more details. If you want to write more complex or more specific notifications, you can disable the internal MailListener and add your own.

リスナーで実現できるその他の便利なタスクの例:

  • SMS または IM 通知を送信する — リスナーは SMS または インスタント メッセンジャー(例、ICQ または AIM)、メッセージを送信する Java ライブラリを介して様々なイベントの通知を容易に送ることができます。
  • グループ通知 — リスナーは課題の内容によって、信頼できるグループに課題の変更を通知することができます。例えば、環境に "windows" が含まれている課題は "windows-開発者" グループに通知することができます。

Registering a Listener

(info) For custom-written listener classes, make sure your listener class is in the classpath where JIRA can see it — the best locations are usually the <jira-application-dir>/WEB-INF/classes or <jira-application-dir>/WEB-INF/lib subdirectories within of your JIRA Installation Directory (as JAR files).

リスナーを登録するには、次の手順に従います。

  1. Log in as a user with the 'JIRA System Administrators' global permission.
  2. Select 'Administration' > 'System' > 'Advanced' > 'Listeners' (tab) to open the 'Listeners' page.
    (tick) Keyboard shortcut: 'g' + 'g' + type 'lis'
  3. ページの下部にある 「リスナーの追加」 フォームで、次のフィールドの入力を完了します。
    • 名前 — リスナーを適切に説明する名前
    • 'Class' — the fully-qualified class name of your listener.

      (info) To use one of JIRA's built-in listener classes, first click the 'Built-in Listeners' link to expand the list of listener classes and then click the name of the specific class in the list. The fully-qualified class name of the built-in listener will be added to the 'Class' field.
  4. 追加ボタンをクリックすると、リスナーが上部のリスナー一覧に追加されます。

Editing Listener Properties

リスナーがパラメータまたはプロパティを受け入れる場合、JIRA の管理エリアのリスナー ページにある、対象のリスナーに関連する編集リンクをクリックすることで変更することができます。

When defining your own Listener, there is a method getAcceptedParams to overload for defining the parameter names, pass as an array of String objects. The DebugParamListener class is an example of doing this.

Removing a Listener

リスナーを削除するには、JIRA の管理エリアのリスナー ページにある、対象のリスナーに関連する削除リンクをクリックします。

Custom Events

With the ability to add custom events to JIRA, the Listener must be updated to deal with the event as appropriate. This is possible by providing an implementation for the method customEvent(IssueEvent event) in the Listener. For example, the MailListener implementation passes the custom event on for notification processing. The DebugListener logs that the custom event has been fired.

参考情報