celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Broekhuis <a.broekh...@gmail.com>
Subject Re: Celix services and struct inheritance
Date Thu, 26 Jan 2012 12:54:45 GMT

2012/1/26 Marcel Offermans <marcel.offermans@luminis.nl>

> > 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?

This can only work if something like struct inheritance is being used. In
the case of Java, one component can implement multiple services. In Celix,
a service is a struct with service pointers. So there is always a one
(name) to one (struct) relation. To be able to have one component with
multiple services, and still be able to only retrieve one specific service
something like struct inheritance is needed.
Another possibility is to register service - component pairs. This way one
service has a specific struct with function pointers and no struct
inheritance is needed. It is up to the user to always use the correct
service name to retrieve the needed struct.

So when trying to follow the spec, struct inheritance makes more sense. But
there are possibly more drawbacks, when using struct inheritance the first
field has to be the parent struct (not a pointer), this implies that
abstract data types can't be used, exposing the content of a struct to the

As a note, in the Java case, is it acceptable to register service A and B
with one component, and when retrieving service A cast it later to B? In
other words, if a different service is needed, does a user need to do a
getServiceReference/getService again?

> Greetings, Marcel

Met vriendelijke groet,

Alexander Broekhuis

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message