Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Crerate plugin listener

Dmitry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 18, 2022

Hi all

The new plugin development version baffles me
It was be easier early

I can't specify components and their imports in atlassian-plugin.xml - and must use annotations. OK
I create a class


@Component
public class MyListener implements InitializingBean, DisposableBean {
private static final Logger log = LoggerFactory.getLogger(CreateListener.class);

@ComponentImport
private final EventPublisher eventPublisher;

@Inject
public MyListener (EventPublisher eventPublisher) {
    log.info("***************" + eventPublisher);
    this.eventPublisher = eventPublisher;
}

@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
    log.info("onIssueEvent");

}

@Override
public void afterPropertiesSet() throws Exception {
log.info("Enabling plugin");
eventPublisher.register(this);
}

@Override
public void destroy() throws Exception {
log.info("Disabling plugin");
eventPublisher.unregister(this);
}


And nothing happens, even the module of listener doesn't appear in list modules of plugin.
Ok - I'm adding to atlassian-plugin.xml


<listener name="Listener 1" key="issueListener1" class="....MyListener">
<description>Will listen events1.</description>
</listener>


The module in the plugin appears - but still nothing happens
Added path to package to <Export-Package> in atlassian-plugin.xml

Added com.atlassian.jira.* to <Import-Package> in atlassian-plugin.xml

Nothing happens.

Please help me start

1 answer

1 accepted

3 votes
Answer accepted
Aron Gombas _Midori_
Community Champion
June 18, 2022

I think you're mixing the old way (declaring the listener in the plugin XML) and the new way (using annotations).

You should be using annotation and not declared the thing in the XML. Here is an article with a Hello World listener you can use as sample: https://developer.atlassian.com/server/jira/platform/writing-jira-event-listeners-with-the-atlassian-event-library/

Dmitry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 18, 2022

Hi @Aron Gombas _Midori_ 

I'm so stipid :)

I did try this sample also - but i always before start patched logging and didn't see minimal log level is WARN

Now i did try clear example and understand my mistake - thank you

Like Aron Gombas _Midori_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events