I have already used the PluginScheduler in previous plugins with older JIRAs before and I wanted to adapt some code to JIRA 7 and the SchedulerService. In order to schedule my job, I thought I'd use a LifeCycleAware component that would register the JobRunner and schedule a job with it, similar as what Chris Fuller's example does, but I haven't been able to have the component instantiated so far.
UPM installs the plugin without a fuss and I do not see any error in the spring debug logs.
Is it a lack of explicit dependency import in the maven JIRA plugin ? A wrong scope for some dependencies ? Missing annotations ? Any hints would be greatly appreciated.
Regards,
Sebastien Delcoigne
Community moderators have prevented the ability to post new answers.
Is the component you need marked with @ComponentImport
or @Inject
? Is the class marked with @Scanned
? I understand that @Scanned
will go away at some point, but maybe that hasn't happened yet. I haven't used the scanner much myself as yet.
I have finally solved this. You need to add @ExportAsService annotation in addition to @Component annotation
@Component @ExportAsService(LifecycleAware.class)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Deniz,
sorry but can you please explain a little how you solved this problem using LifecycleAware with Atlassian Spring Scanner?
Can you please share your class which is implementing LifecycleAware?
I have a same problem and here is my class:
@Named("myClassLauncher") @ExportAsService(LifecycleAware.class) public class MyClassLauncher implements LifecycleAware, InitializingBean, DisposableBean { private static final Logger LOGGER = LoggerFactory.getLogger(MyClassLauncher.class); private final MyClassScheduleManager myClassScheduleManager; @Inject public MyClassLauncher(MyClassScheduleManager myClassScheduleManager) { this.myClassScheduleManager = myClassScheduleManager; } @Override public void onStart() { LOGGER.info("LifecycleAware - onStart"); } @Override public void onStop() { LOGGER.info("LifecycleAware - onStop"); } @Override public void destroy() throws Exception { LOGGER.info("unregisterListeners"); LOGGER.info("unregisterJobRunner"); } @Override public void afterPropertiesSet() throws Exception { LOGGER.info("AFTER_PROPERTIES_SET"); } /** * This is received from the plugin system after the plugin is fully initialized. */ @EventListener public void onPluginEnabled(PluginEnabledEvent event) { LOGGER.info("PLUGIN_ENABLED"); }
Now, I get "AFTER_PROPERTIES_SET" and "PLUGIN_ENABLED", but I can not get "LifecycleAware - onStart" in log, meaning that I failed initializing this properly.
Is this:
@Component @ExportAsService(LifecycleAware.class)
instead of:
@Named("myClassLauncher") @ExportAsService(LifecycleAware.class)
enough?
Do I need some other related changes in atlassian-plugin.xml or pom.xml?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @vvasic75
I know it's been a while since you've asked, but just to let this be registered here...
you can use something like
public void afterPropertiesSet() throws Exception {
registerListener();
onLifecycleEvent(LifecycleEvent.AFTER_PROPERTIES_SET);
if (lifecycleManager.isApplicationSetUp())
onLifecycleEvent(LifecycleEvent.LIFECYCLE_AWARE_ON_START);
}
... so you trigger the AWARE_ON_START event even on simple deploy - if LifecycleManager informs you that the ApplicationsSetUp().
Hope this helps someone ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have the same problem. I'm using spring scanner 1.2.13. Everything was fine until I need to use PluginScheduler. My component is annotated with @Component and implements LifecycleAware. onStart method is never triggered although component is instantiated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.