Hi
can anyone help on this below issue,
We are replacing felix annotations with OSGI DS annotations. We have come across with a challenge please find below
Felix annotation :
@Reference(policyOption = ReferencePolicyOption.GREEDY)
protected UserConnector userConnector;
OSGI Annotation I tried :
protected UserConnector userConnector;
@Reference(policyOption = ReferencePolicyOption.GREEDY)
public void bindUserConnector(UserConnector userConnector) {
this.userConnector = userConnector;
}
public void unbindUserConnector(UserConnector userConnector) {
this.userConnector = userConnector;
}
But there is an error in eclipse where “The attribute policyOption is undefined for the annotation type Reference”.
Can you please tell me whether policyOption is deprecated in OSGi annotations.
Please let me know how to use policyOption = ReferencePolicyOption.Greedy in @Reference OSGI annotation.
Much Appreciated in advance.
Thanks
Vijay
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
It is working fine for me, successfully built the project. Please check API docs?
https://osgi.org/javadoc/r6/residential/org/osgi/service/component/annotations/Reference.html
Views
Replies
Total Likes
The syntax is not a 1-1 match between felix and DS annotations.
Here is the reference for a DS annotation that will help...
https://osgi.org/javadoc/r4v43/cmpn/org/osgi/service/component/annotations/Reference.html
You can see the applicable values for policyOption.
Hope this helps...
Views
Replies
Total Likes
Hi,
It is working fine for me, successfully built the project. Please check API docs?
https://osgi.org/javadoc/r6/residential/org/osgi/service/component/annotations/Reference.html
Views
Replies
Total Likes
Nice response Arun - great to see that you were able to build this.
Views
Replies
Total Likes
On a related note - for those reading this thread and wanting to know more about DS Annotations - read this from Nate Yolles - a great article:
Views
Replies
Total Likes
Hi Arun,
It's not working for me @Reference(policyOption = ReferencePolicyOption.GREEDY) and I'm getting this error in eclipse where “The attribute policyOption is undefined for the annotation type Reference”. if I use the below dependency in my pom.xml,
<dependency>
<groupId>biz.aQute</groupId>
<artifactId>bndlib</artifactId>
<version>1.50.0</version>
<scope>provided</scope>
</dependency>
Eclipse allow me to use GREEDY if I use the below dependency and i Just changed the version and build is success. But when I install the bundle, in /system/console/components/ I'm getting unsatisfied (reference) error and it is not active. The version number I got it from MAVEN central repo. FYI
<dependency>
<groupId>biz.aQute</groupId>
<artifactId>bndlib</artifactId>
<version>2.0.0.20130123-133441</version>
<scope>provided</scope>
</dependency>
Can you help me to resolve this? Also I could see in your earlier post that you were able to use GREEDY, what is the exact dependency & import you have used? can you share that.
Thanks,
Vijay
Views
Replies
Total Likes
Hi,
I am using osgi annotations
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferencePolicyOption;
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
Views
Replies
Total Likes
Using the same Imports & dependency Arun but doesn't work . any clue like if I did anyother mistake?
Thanks,
Vijay
Views
Replies
Total Likes
Hi,
Do you have multiple imports ?
Check below osgi Annotation
https://osgi.org/javadoc/r6/residential/org/osgi/service/component/annotations/Reference.html
In Eclipse, can you click on Policy, PolicyOption or ReferencePolicyOption and press F4 to check from where reference is used.You can see the jar name in status bar
@Reference(policyOption=ReferencePolicyOption.GREEDY)
Hi Arun,
As you said I found at the issue with my jar. @Reference is pointing out out to this JAR maven\repository\biz\aQute\bndlib\1.50.0\bndlib-1.50.0.jar and if I see the Reference interface inside the jar policyOption is not available and that's why I'm unable to use policyOption.
Now I should pointing to this maven\repository\org\osgi\osgi.cmpn\6.0.0.jar. Inside the jar I'm having Reference interface where I can see the policyOption(). how can I change the reference now? can you guide me on the same.
Thanks.,
Vijay
Hi Arun,
Fixed the issue. Changed the order of dependencies and now its pointing to osgi.cmpn. but still I'm getting unsatisfied reference issue.Any Idea?
Thanks,
vijay
Views
Replies
Total Likes
Hi,
For my test service, it is in satisfied state.
your issue could be due to dependancy code or something but not sure.
Views
Replies
Total Likes
Hi Arun,
Do you have any idea about No services bound? If you see my above screenshot for the unsatisfied service It shows No Services bound.
Also I have used policyOption:Greedy for three references Where it is satisfied for HybrisConnection and unsatisfied for HybrisFactory & ImportHandler.
Thanks,
Vijay
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies