ComponentLocator is discussed at https://developer.atlassian.com/display/DOCS/SAL+Services and said to be available in every Atlassian application.
It seems that accessing a ComponentLocator should be as simple as, in atlassian-plugin.xml:
<component-import key="componentLocator" interface="com.atlassian.sal.api.component.ComponentLocator"/>
...and using constructor dependency injection to get a reference to the ComponentLocator.
When I try this in JIRA 6.0.1, my plugin fails to deploy with:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.sal.api.component.ComponentLocator] is defined: Unsatisfied dependency of type [class com.atlassian.sal.api.component.ComponentLocator]: expected at least 1 matching bean
I've searched and have not been able to find anyone successfully using the SAL component locator from a JIRA plugin.
I did find http://www.j-tricks.com/1/post/2013/07/component-import-gotchas-nosuchbeandefinitionexception.html which refers to the non-SAL ComponentLocator and talks about confusion between component vs component-import.
Can anyone confirm it as working in JIRA 6, and if so, what's the correct way to get a handle to it?
Community moderators have prevented the ability to post new answers.
What I was missing is that ComponentLocator's methods are static, so there is no need to import an instance. That's also why I couldn't find a reference to ComponentLocator in anyone's atlassian-plugin.xml.
So, the answer is: yes it works, just call the static methods, nothing is required in atlassian-plugin.xml.
Glad to know it works now, please let me know if you have any questions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please see the version matrix https://developer.atlassian.com/display/DOCS/SAL+Version+Matrix, so it should support jira 6
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also please make sure you have deployed the dependency, and please refer to the version number according to https://developer.atlassian.com/display/DOCS/SAL+Version+Matrix
<
dependency
>
<
groupId
>com.atlassian.sal</
groupId
>
<
artifactId
>sal-api</
artifactId
>
<
version
>*</
version
>
<
scope
>provided</
scope
>
<!-- Uses the application's SAL instead of bundling it into the plugin. -->
</
dependency
>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do have sal-api in my pom.xml as shown here, although my understanding is that it is not expected to actually deploy anything due to the <scope>provided</scope>.
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.