Forums

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

Listening to Project creation event using annotation

Sadaf
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 21, 2018

Hi All,

I have written a Workflow validator which is working fine, Now I need to attach the validator to the workflow of newly created project by listening to the Project created event. I followed "Jira Event Listener" Link which is outdated so, Not working.
I tried with the annotation as well but that is also not working (not giving error and also not executing the code on project creation). So Plz help me.
Code
import org.springframework.stereotype.Component;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService;
import javax.inject.Inject;
@ExportAsService
@Component
public class ProjectCreatedListener implements InitializingBean, DisposableBean {
private static final Logger log = LoggerFactory.getLogger(ProjectCreatedListener.class);
@ComponentImport
private final EventPublisher eventPublisher;
@Inject
public ProjectCreatedListener(EventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
log.info("started listening");
}
@Override
public void afterPropertiesSet() throws Exception {
eventPublisher.register(this);
}

@Override
public void destroy() throws Exception {
eventPublisher.unregister(this);
}

@EventListener
public void listenForIssueEvent(ProjectCreatedEvent projectCreateEvent) {
log.info("Project Created");
System.out.println("Project Created");
Project createdProject = projectCreateEvent.getProject();
attachValidator(createdProject); // todo
}
}

Will be grateful for any suggestion/help. 

Thanks in advance.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events