Forums

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

How do you access a Component from another Plugin in ScriptRunner?

Jack [AppFox]
Atlassian Partner
June 20, 2016

I am trying to access a Component from another plugin.

The plugin's atlassian-plugin.xml contains the following definition:

<component key="xxx-dao-service" name="DAO Service" class="com.xxx.jira.plugins.xxx.service.xxxDAOServiceImpl" public="true">
<interface>com.xxx.jira.plugins.xxx.service.xxxDAOService</interface>
</component>

It is a third-party, published plugin that was bought from the Atlassian Marketplace.

ComponentManager componentManager = ComponentManager.getInstance();
PluginAccessor pluginAccessor = componentManager.getPluginAccessor();
Class daoSvcClass = pluginAccessor.getClassLoader().findClass("com.xxx.jira.plugins.xxx.service.xxxDAOService");
def serviceDao = componentManager.getOSGiComponentInstanceOfType(daoSvcClass);
log.debug(serviceDao.method(xxx,xxx,xxx))

So how do you access another plugins' components and use the methods therein?

3 answers

1 accepted

0 votes
Answer accepted
JamieA
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.
June 21, 2016

You don't have to include it in your plugin - in fact doing so is not going to work if there are components etc. As Ash said, you should be able to use @WithPlugin and @PluginModule to get access to the services.

1 vote
Vasiliy Zverev
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.
June 20, 2016

If you need to use third-party component you shoul include it into your plugin jar. To do this you should to spesify this into dependences section with scope <compile>. It means that this jar will be included into your jar. And then you can get any class with componentManager.getOSGiComponentInstanceOfType(daoSvcClass.class)

0 votes
Ashraful Hasan [Adaptavist]
Contributor
June 20, 2016

Hi,

Please check this link for more detail: ScriptRunner Scripting Other Plugin

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events