It depends what you mean by “expose”.

You can register an object as a service, yes, but if it’s not implementing an 
interface, what kind of service will it be? You can only register it as its own 
type or as java.lang.Object. This is not very useful except in rare edge-cases.

If you publish it as its own type and clients look it up by that type, then the 
clients are not decoupled from the implementation and you defeat the whole 
purpose of using a service. If you publish as java.lang.Object then how to 
clients know what methods they can call? They would have to use reflection; the 
Gogo shell works like this but it’s very unusual.

Neil


From: Charles Moulliard <ch0...@gmail.com>
Reply: users@felix.apache.org <users@felix.apache.org>>
Date: 24 October 2014 at 18:01:24
To: users@felix.apache.org <users@felix.apache.org>>
Subject:  SCR : Serve a Bean without interface  

Hi,  

Would it be possible using Apache Felix SCR to expose a bean / class as a  
OSGI service ? REMARK : This class does not implement at all an interface.  

Regards,  

--  
Charles Moulliard  
Apache Committer / Architect @RedHat  
Twitter : @cmoulliard | Blog : http://cmoulliard.github.io  

Reply via email to