Hello, we need to develop a plugin which has to be aware about all currently logged in users and for that we are trying to import an instance of the class JiraUserSessionTracker through a component import annotation:
@Named("balancedAssignmentComponent")
public class BalancedAssignmentComponent {
...
@ComponentImport
private final JiraUserSessionTracker jiraUserSessionTracker;
...
@Inject
public BalancedAssignmentComponent(final JiraUserSessionTracker jiraUserSessionTracker,
final UserManager userManager, final GroupManager groupManager, final ProjectRoleManager projectRoleManager,
final ProjectManager projectManager, ...) {
this.jiraUserSessionTracker = jiraUserSessionTracker;
this.userManager = userManager;
this.groupManager = groupManager;
this.projectRoleManager = projectRoleManager;
this.projectManager = projectManager;
...
}
...
}
When installing the plugin, it fails and throws this error, which does not help us at all to solve the problem:
2016-05-23 12:43:14,141 UpmAsynchronousTaskManager:thread-2 ERROR admin 618x331x2 1v7s77t 0:0:0:0:0:0:0:1 /rest/plugins/1.0/available/featured [c.a.p.osgi.factory.OsgiPlugin] Plugin 'com.xeridia.jira.sigdjira7plugin.SigdJira7plugin' never resolved service '&jiraUserSessionTracker' with filter '(&(objectClass=com.atlassian.jira.web.session.currentusers.JiraUserSessionTracker)(objectClass=com.atlassian.jira.web.session.currentusers.JiraUserSessionTracker))' 2016-05-23 12:43:14,144 UpmAsynchronousTaskManager:thread-2 DEBUG admin 618x331x2 1v7s77t 0:0:0:0:0:0:0:1 /rest/plugins/1.0/available/featured [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] onPluginDisabledEvent removing delegate for [com.xeridia.jira.sigdjira7plugin.SigdJira7plugin] 2016-05-23 12:43:14,146 UpmAsynchronousTaskManager:thread-2 ERROR admin 618x331x2 1v7s77t 0:0:0:0:0:0:0:1 /rest/plugins/1.0/available/featured [c.a.plugin.manager.PluginEnabler] Unable to start the following plugins due to timeout while waiting for plugin to enable: com.xeridia.jira.sigdjira7plugin.SigdJira7plugin
What does that mean? I think it is absolutely senseless.
The JiraUserSessionTracker is not part of the JIRA API. It is only available by using jira-core, and you cannot get it injected to a plugin, because it is not intended for third-party use.
There is probably something in jira-api that does what you need. However, if there is not, then the only way you can use this is:
jira-coreComponentAccessor.getComponent(JiraUserSessionTracker.class)Any use of jira-core is, however, not covered by the Java API Policy for JIRA. It may break at any time, even in a bugfix release.
Thank you for your fast response. Respecting to the jira-core usage I am aware of what you are stating. I were already able to use that service by adding this line of code to my class:
private final JiraUserSessionTracker jiraUserSessionTracker = JiraUserSessionTracker.getInstance();
It is only an instance attribute and initializing it this way is working for me. I suppose that using the component accessor would work the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It would turn up the same result. That's actually what getInstance() calls internally:
public static JiraUserSessionTracker getInstance() {
return ComponentAccessor.getComponentOfType(JiraUserSessionTracker.class);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, a quick search of the API turned up... nothing. There doesn't seem to be an API-safe way to find out who is logged in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.