issue event listener

Hi,

when i implement my class from IssueEventListener and impement its methods not happening on issue events. how i can listen to issue events in my class ?

dose my class called even if issue events occures in another page?in the other hand how i can use issue listener to run my class on issue events?

thanks a lot

tis is my simple class code:



package com.atlassian.jira.event.listeners;

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.event.JiraEvent;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.issue.IssueEventListener;
import com.atlassian.jira.event.user.UserEvent;
import com.atlassian.jira.event.user.UserEventListener;

import org.ofbiz.core.entity.GenericEntityException;
import org.ofbiz.core.entity.GenericValue;

import java.util.Iterator;
import java.util.List;
import java.util.Map;


public class my class extends IssueActionSupport implements IssueEventListener
{

...

public void customEvent(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueAssigned(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueClosed(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueCommented(IssueEvent arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.getIssue().getKey() +"comment");


}
public void issueCreated(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueDeleted(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueGenericEvent(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueMoved(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueReopened(IssueEvent arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.getIssue().getKey() +"reopen");


}
public void issueResolved(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueStarted(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueStopped(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void issueUpdated(IssueEvent arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.getChangeLog().modified +"updated");

}
public void issueWorkLogged(IssueEvent arg0) {
// TODO Auto-generated method stub

}
public void workflowEvent(IssueEvent arg0) {
// TODO Auto-generated method stub

}


...

}

4 answers

1 accepted

0 votes
Accepted answer

Hi Mehran,

Go to JIRA Administration >> Listeners >> Add fully qualified name of your listener class

OR

in below code you did not required to add listener class explicitly.

public class MyEventListenerClass  implements InitializingBean,DisposableBean 
{
	public MyEventListenerClass()
	{
	}
	public void afterPropertiesSet() throws Exception 
	{
		eventPublisher.register(this);
	}
	public void destroy() throws Exception 
	{		
		eventPublisher.unregister(this);
	}
	@EventListener
	public void onIssueEvent(IssueEvent issueEvent) throws Exception 
	{
		Long eventTypeId = issueEvent.getEventTypeId();
		log.debug("On Issue Event against issue "+issueEvent.getIssue().getKey());
		if(eventTypeId.equals(EventType.ISSUE_CREATED_ID))
		{
				// do stuff on issue created event
		}		
	}
}

atlassian-plugin.xml

<component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher"/>

			<component key="eventListener" class="com.ora.sm.MyEventListener">

		    <description>Class that processes the incoming JIRA issue events.</description>

	 </component>

Regards

Onkar Ahire

thanks onkar , it works when i added my listener :)

2 votes

The basics of writing a listener, explaining how you get the information about the change that fired the event (including issue) is all at https://developer.atlassian.com/display/JIRADEV/Writing+JIRA+Event+Listeners+with+the+atlassian-event+Library

This was the JIRA4.x way of doing things, see the tutorial Nic linked (and /or clarify your JIRA version)

My jira version is 3.7.2 Andy

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,752 views 18 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you