I have a problem with dependency injection while writing a bitbucket rest plugin.
1) I followed this tutorial https://developer.atlassian.com/server/framework/atlassian-sdk/developing-a-rest-service-plugin/
2) Then I tried adding PullRequestService:
package com.atlassian.plugins.tutorial.impl;
import com.atlassian.bitbucket.pull.PullRequestService;
import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.sal.api.ApplicationProperties;
import com.atlassian.plugins.tutorial.api.MyPluginComponent;
import javax.inject.Inject;
import javax.inject.Named;
@ExportAsService ({MyPluginComponent.class})
@Named ("myPluginComponent")
public class MyPluginComponentImpl implements MyPluginComponent
{
@ComponentImport
private final ApplicationProperties applicationProperties;
@ComponentImport
private final PullRequestService pullRequestService;
@Inject
public MyPluginComponentImpl(final ApplicationProperties applicationProperties,
final PullRequestService pullRequestService)
{
this.applicationProperties = applicationProperties;
this.pullRequestService = pullRequestService;
}
public String getName()
{
if(null != applicationProperties)
{
return "myComponent:" + applicationProperties.getDisplayName();
}
return "myComponent";
}
}
But then after atlas-clean and atlas-run I get:
[INFO] [talledLocalContainer] WARN - 08:15:45,080 - ni.blueprint.extender.internal.support.ExtenderConfiguration - [FelixStartLevel] - Gemini Blueprint extensions bundle not present, annotation processing disabled.
[INFO] [talledLocalContainer] ERROR - 08:15:54,242 - com.atlassian.plugin.osgi.factory.OsgiPluginInstalledHelper - [localhost-startStop-1] - Cannot determine required plugins, cannot resolve bundle 'com.atlassian.plugins.tutorial.Message'
[INFO] [talledLocalContainer] ERROR - 08:15:54,247 - com.atlassian.plugin.osgi.factory.OsgiPluginInstalledHelper - [localhost-startStop-1] - Cannot determine required plugins, cannot resolve bundle 'com.atlassian.plugins.tutorial.Message-tests'
[INFO] [talledLocalContainer] ERROR - 08:15:55,109 - com.atlassian.plugin.osgi.factory.OsgiPlugin - [localhost-startStop-1] - Detected an error (BundleException) enabling the plugin 'com.atlassian.plugins.tutorial.Message' : Unable to resolve com.atlassian
.plugins.tutorial.Message [58](R 58.0): missing requirement [com.atlassian.plugins.tutorial.Message [58](R 58.0)] osgi.wiring.package; (osgi.wiring.package=com.atlassian.bitbucket.pull) Unresolved requirements: [[com.atlassian.plugins.tutorial.Message [58](R 58.0)] osgi.w
iring.package; (osgi.wiring.package=com.atlassian.bitbucket.pull)]. This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or
there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN