Forums

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

When autowiring - does beans from the current plugin are in priority?

Mihail February 20, 2020

I re-factored some of my JIRA plugins and move some core classes to the separate jar.

But now, when autowiring some interface (from that library), implemented in current plugin (and in other plugins too!) does beans from the current plugin are in priority?

So, for example, in my separate-lib.jar I have some interface A.
Then, while working on plugin, I add an implementation of A, let's call it B. And I know, that in other plugins I have (or would have) other implementations of an interface A.

For now, I suppose, that current plugin beans are in priority while autowiring. Is my guess right?

1 answer

0 votes
Mihail February 26, 2020

Short answer - Yes.

For example, you are creating some your custom endpoint, it is a @Component - your
plugin beans are in priority.

But if, for example, you are creating an admin-panel for your plugin.
You are doing it in a common way - implementing JiraWebActionSupport. Such classes should not be marked as @Scanned or @Component - JIRa inject dependencies itself - as long as you add @Autowired before constructor.

In such case, if some other of you plugins would have the same named class for the same purpose - in this case for admin page - than you would have problems. Context, visible from its constructor would be related to that 'other' plugin - not your current. That can be solved by renaming that implementation class.

If you know other ways to resolve the second case - your comments are very welcome. Because to multiply plugin-dependent named classes is ugly.

Suggest an answer

Log in or Sign up to answer