In my JIRA Server plugin I developed a service that takes a IssueEvent and automates status transitions. I want to be able to call this service in selected projects of my JIRA instance, and the solution we came up with was with a Groovy script: we should be able to load our service in the script and call its methods specifying that the script should only load in certain projects.
We wrote our whole project with dependency injection provided by Spring (@Components and @Autowires) and our service is resolved the same way: the method is provided by an interface, the implementation is annotated with @Component and in the constructor both JIRA API and internal dependencies are @Autowired.
If we implemented the service as a Listener, things would go smoothly, but within the Groovy script we're unable to instantiate the service. We tried:
If loaded with ComponentAccessor OSGi resolver, the service class is resolved but the object is not. Otherwise, all attempts to just instantiate an object without explicitly calling the constructor (or using an empty constructor) will fail because the inner service field is not instantiated.
What am I doing wrong? There must be something obvious I'm missing, but I can't find it online.