I’m working on a demo material to present Enterprise OSGi with Java EE and stumbled upon a mental problem where I used OSGi Blueprint that’s easy to use and explain its features, but missed a part about OSGi itself, mostly versioning.
It took me about 2 weeks and a presentation (about Enterprise OSGi and Java EE with Liberty Profile in Riga, Latvia this week) to apply a feature I knew existed, but never used before.
In Chapter 121.6.9 Ranking (page 224 or 232 in the pdf version) of the OSGi Service Platform Enterprise Specification 4.2 there’s this sentence that made my day!
“When registering a service with the service registry, an optional service ranking can be specified that orders service references.”
With this and OSGi Blueprint, I could register two services of the same interface in a single Enterprise Bundle Archive (EBA) for an OSGi application and have them differentiated with the ranking.
It’s easy as it sounds and with IBM WebSphere Application Server V8.5 Liberty Profile Developer Tools V8.5.1 I was pleased with its simplicity.
The demo works now and am on my way to document the findings in an article. Stay tuned.
p.s. I wish there could be a way to list all the services registered in an EBA in Liberty Profile. It could be a nice add-on to the console. Possible? Anyone?