I am migrating some SCR annotations based code base to OSGi R6.
The current code uses scr annotations and fields which are not available in R6.
For example: @references and referenceInterface are not supported in R6
@Component
@References({
@Reference(
referenceInterface = SomeFactory.class,
policy = ReferencePolicy.DYNAMIC,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE)
})
@Service
public class SomeResolverImpl implements SomeResolver { }
Solved! Go to Solution.
Hi Rahul,
We dont have @References with r6. Also, @Reference interface doesnt support 'referenceInterace' anymore (Refer this - https://osgi.org/javadoc/r6/residential/org/osgi/service/component/annotations/Reference.html )
You may have to declare individual references within the class or if you are looking at referring interface, then you may also see if @Designate annotation works.
The best way to proceed here is to rebuild your project using Maven 12 Archetype. This project uses R6 annotations by default.
Creating an Adobe Experience Manager 6.3 Project using Adobe Maven Archetype 12
Notice in this article the use of 6.3 UBER JAR.
Views
Replies
Total Likes
Hi Rahul,
As Scott stated, the best way to learn how to use R6 annotations from the article: Creating an Adobe Experience Manager 6.3 Project using Adobe Maven Archetype 12
Make sure you include Uber Jar in POM xml file.
Thanks,
Ratna Kumar.
Views
Replies
Total Likes
Also -- here is a good overview of R6 - Official OSGi Declarative Services Annotations in AEM - Adobe Experience Manager | AEM/CQ | Apache S...
Views
Replies
Total Likes
Thanks for the reply. I have already checked articles you guys suggested.
However, I am not able to find suitable annotations and field which were available in scr.
Can you answer my specific question?
@references and referenceInterface are not supported in R6. How do I re implement it in R6?
Views
Replies
Total Likes
In R6 - you can use @Reference. The fully qualified package is
//DS Annotations
import
org.osgi.service.component.annotations.Component;
import
org.osgi.service.component.annotations.Reference;
This works the same way - it injects an AEM Service. That way, you can use a service like DataSourcePool:
@Reference
private
DataSourcePool source;
The other one you mention not in R6.
https://osgi.org/javadoc/r4v43/cmpn/org/osgi/service/component/annotations/package-summary.html
To see a step by step articel that uses @Reference - see this AEM 6.4 one that uses DataSourcePool
In fact - most of our AEM 6.4 articles use R6 annotations.
Hope this helps....
Views
Replies
Total Likes
If you see my example, I need to use @reference at class level. (Which was possible in SCR)
I am able to use it at field level i.e. injecting OSGi service using @reference on a field.
Views
Replies
Total Likes
Read here too - talks about @Refenence:
Using OSGi R6 annotations (>= AEM6.2) - Experience Delivers
Here is a good piece of information that should help you --
It talks migrating from SRC annotations to R6.
Looks like @References is not supported in R6.
Views
Replies
Total Likes
Hi Rahul,
We dont have @References with r6. Also, @Reference interface doesnt support 'referenceInterace' anymore (Refer this - https://osgi.org/javadoc/r6/residential/org/osgi/service/component/annotations/Reference.html )
You may have to declare individual references within the class or if you are looking at referring interface, then you may also see if @Designate annotation works.