Jira: Access Plugin Singleton from scheduled Service

Pascal Müller January 9, 2012

Hi all

I have a question. Plugins themselves are sperated by default from Jira and from other plugins. As far as I understand, only the plugin can access to Jira or to Plugins which are explicitly imported.

Now, i have this singleton in my plugin. This plugins contains a list of elements, which shall be consumed by a scheduled service. But i can't get this singleton instance which has already been created by the plugin. The service creates its own instance, which is... not good (from my view)

Does anybody have any hint how to work around this case, or just make this singleton accessible for the Scheduler? I don't want to implement my own Scheduler, since there could appear other problems when disabling the plugins or stuff.

Anybody?

Thx a lot!!

cheers muealle

1 answer

1 accepted

1 vote
Answer accepted
NielsJ
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.
January 9, 2012

If you write a V1 plugin, all plugins and JIRA live in the same "world" from a ClassLoader's point of view. You can access classes as you wish then.

When using a V2 plugin, all plugins are enclosed in an OSGi bundle that shields the plugin from other plugins. Using singletons is generally a bad idea but may work as a quick solution.

I would suggest to:

  • implement a Component
  • make this Component public
  • find the Component by using ComponentManager.getOSGiComponentInstanceOfType() in the service.
Pascal Müller January 12, 2012

Yeah, it's actually a V2 plugin. But there was another problem apparently. The good news is, it works know. Don't know really why. The acces from scheduler to the plugin is now possible without a hassle.

Thanks for your reply anyway!

Suggest an answer

Log in or Sign up to answer