Quantcast
Channel: Adobe Community : Popular Discussions - CQ5 (read only)
Viewing all articles
Browse latest Browse all 12476

Retrieving OSGi Services by Interface

$
0
0

I may be trying something incorrect in OSGi terms, so if I am, please tell me.  I'm trying to create a generic "IPlugin" interface that will likely have multiple implementation classes, all as separate OSGi services.  In another service, PluginManager, I want to be able to retrieve all active instances of IPlugin (regardless of implementation class) so that I can loop through and call the one method on that interface for each one.  The goal is to set up a framework wherby I can just add/remove services that implement IPlugin as I see fit and as requirements evolve.

 

I'm struggling to figure out how to do this.  Should I be using the @Reference annotation somehow?  If not, should I be using the ComponentContext of PluginManager to retrieve the services manually somehow?  I feel like I'm missing something here.  I wondered if anyone had some advice or has implemented something like this before using Apache Felix.  Thanks in advance!

 

P.S.

I'm not doing this on a huge scale.  For the purpose of this discussion I used very generic class/interface names.  This is not something I'm trying to use as some central, global plugin controller for an entire app.  That would probably not be a good thing.  Just thought I'd throw that in there, in case anyone considered that a concern.


Viewing all articles
Browse latest Browse all 12476

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>