Forums

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

What is @Scanned annotation in Atlassian SDK

Junseok Lee November 1, 2020

As we develop the Atlasian plug-in, You will encounter the corresponding @Scanned annotations.

But, I don't know what @Scanned annotation does.

Does anyone know any documents to explain or refer to?

2 answers

1 accepted

2 votes
Answer accepted
Nir Haimov
Community Champion
November 1, 2020

Hi @Junseok Lee 

I found the following answer from an Atlassian Team member in another post:

@Scanned says, consider this class as part of something that the spring-scanner build time should consider (like @Component / @Inject but without any other side effects).

For the record "rest modules" are magic in that they do not need to make themselves known to Spring and yet are "wired" for you by the Atlassian plugin system.  But @Scanned is needed here to make the spring-scanner build time take it into consideration.

 

In my own experience, i use @Scanned in classes that i extends other classes, for example:

@Scanned
public class SettingsServlet extends HttpServlet

or

@Scanned
@Named
public class IsPluginLicensedCondition extends AbstractWebCondition

In cases when you use @Scanned annotation to your class, you should use @Inject annotation to your constructor.

In other cases, when you use @Component, like:

@Component
public class CreateProjectRestResources

or

@Component
public class Utils

you should use @Autowired annotation to your constructor.

Junseok Lee November 2, 2020

Wow! , Thank you so much.

0 votes
Giorgia Fineschi January 15, 2021

Hi Everyone,

my situation is slightly different.

I have

@Named
@ExportAsService
public class ENGSLAService extends AbstractService {

@JiraImport
private JqlQueryParser jqlQueryParser;

@JiraImport
private SearchService searchService;

private InsightReader insightReader;

@Inject
public ENGSLAService(JqlQueryParser jqlQueryParser, SearchService searchService) {

this.jqlQueryParser = jqlQueryParser;
this.searchService = searchService;
this.insightReader = ComponentAccessor.getOSGiComponentInstanceOfType(InsightReader.class);
log.warn("insightReader is " + insightReader);
}
}


@JiraComponent
public class InsightReader {

@JiraImport
private ObjectFacade objectFacade;
@JiraImport
private IQLFacade iqlFacade;

}

but insightReader object is null after initialization in ENGSLAService's construction? What am I doing wrong? Did I mess up with the annotations?

Thanks for helping!

Suggest an answer

Log in or Sign up to answer