Restrict non-iPOJO services being installed in OSGI

60 views Asked by At

I am currently trying to find a way to "filter" bundles in OSGI, while installing them. I use Karaf as an OSGI implementation and iPOJO for service resolution. Is there any way I can ensure, that only services provided by iPOJO are allowed to be installed in OSGI?

I already searched the web for methods to see wether the specific service imports OSGI stuff(like BundleContext etc.), but that doesnt seem to be working easily.

Thank you :)

2

There are 2 answers

0
Daniel.T On BEST ANSWER

I got a solution to my problem... I kind of did it like erosb was suggesting. Every IPOJO service reference owns the property "name", so i just created a LDAP-filter for the @Bind method, which accepts all values for the name-property(filter = "(instance.name=*). Services, that were not created with iPOJO, don't have that field, so in that way i can filter any iPOJO-service.

Thanks alot :)

5
erosb On

Probably no, and I don't recommend doing it. The way how a service is published is better to consider as an implementation-specific detail. If you want to search for the services provided by your library, then it is better to add a custom key-value property to your services (don't know how to do that with iPOJO) and use that key in your LDAP filter.

edit: the provided services' only externally visible characteristics are the classname and the key-value service properties, so if you can't find any reasonable information there about iPOJO, then you don't have too much chance