代碼示例:
public class TestEventListener extends AbstractIssueEventListener implements InitializingBean, DisposableBean {
private final EventPublisher eventPublisher;
public TestEventListener(
EventPublisher eventPublisher
) {
this.eventPublisher = eventPublisher;
}
@EventListener
public void onIssueEvent(IssueEvent issueEvent) throws JiraException, IOException, URISyntaxException {
}
/**
* Called when the plugin has been enabled.
*
* @throws Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
// register ourselves with the EventPublisher
eventPublisher.register(this);
}
/**
* Called when the plugin is being disabled or removed.
*
* @throws Exception
*/
@Override
public void destroy() throws Exception {
// unregister ourselves with the EventPublisher
eventPublisher.unregister(this);
}
}
是的,我已經改寫自己的代碼來擴展'AbstractIssueEventListener' - _instead_實施豆類。我猜,Atlassian的教程是陳舊的 - 因爲基於bean的類沒有被JIRA使用。 –
我試過這個,但可以讓它工作。它總是打印異常加載類:[Class'... Listener'可從OSGi加載,但沒有啓用的插件可以自動裝載實例。]。' – kravemir