celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Offermans <marcel.offerm...@luminis.nl>
Subject Re: Celix services and struct inheritance
Date Thu, 26 Jan 2012 12:36:34 GMT
On Jan 26, 2012, at 13:19 PM, Pepijn Noltes wrote:

> I have a problem relating to Celix services and inheritance. The
> problem is than under Java it's quite normal to cast retrieved
> services to a derived type, but under C this is not as easy and not
> safe (no RTTI ->no instanceof).

Even though in Java you can (try to) cast a class or interface to a derived type, when you
lookup a service in the OSGi service registry, it is extremely unwise to assume anything other
than the fact that you just got an instance that implements exactly the interface you looked

> [...] But I am not really happy with this solution. It leans to much on the
> assumption service pointer can be cast to derived type and there is no
> way to check if this is correct.


> In my opinion there are 2 alternative to this:
> 1)
> Register multiple services. But than means I am left with the
> challenge how to find the related service.

In Java, you already have the option of registering an instance under multiple service names.
Would doing the same for C solve your issue?

Greetings, Marcel

View raw message