felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Nodet <gno...@gmail.com>
Subject Re: Corner case where ServiceListener do not receive events for matching services
Date Thu, 07 May 2009 11:49:48 GMT
On Thu, May 7, 2009 at 13:41, Felix Meschberger <fmeschbe@gmail.com> wrote:
> Hi,
> I am bit confused, too ;-)
> Guillaume Nodet schrieb:
>> I've just finished debugging a corner case in karaf  where a
>> ServiceListener did not receive events when a matching service was
>> registered.
>> The problem is not very simple:
>>   * the service is exposed via a ServiceFactory
> So, the ServiceFactory must create objects implementing the service
> interface, right ?
>>   * the service factory does not belong to the same classloader as
>> the interface of the exposed service
> No problem. In case the factory and service interface are in different
> bundles, this is expected.
>>   * the bundle exporting the service does not have a direct import on
>> the interface exposed
> You mean, the bundle registering the ServiceFactory ?
> In this case, I would assume, this is an invalid service registration,
> since the registering bundle does not know about the service interface,
> unless the service interface is contained in the same bundle as the
> ServiceFactory implementation.
> This leads to the suspicion, that there are two actual service interface
> class objects: The public one used by the listener and another one
> (exported or not) used by the ServiceFactory implementation.
> Or are there three bundles ? (1) exporting the service interface, (2)
> exporting the service implementation and (3) registering the
> ServiceFactory as a service for the service interface defined by (1) and
> creating implementations located in (2) ?
> Or, maybe, I am completely wrong ....

In my case, the bundle exporting the service defines a class that
indirectly implement the required interface by inheriting a class from
another package.
So I have 3 bundles:
  * bundle A defines an interface R and a class S in different
packages, whith S implementing R
  * bundle B defines a class T extending S, it has an import statement
on S package, but not on R package
  * bundle C defines a ServiceFactory that export T service without
any import on any package from R, S, T
Maybe the service registration is invalid because bundle B does not
import R package, but the service actually implement the right

> Regards
> Felix
>> This leads to the service listener not being invoked because
>> Util.isServiceAssignable() returns false.
>> I think it's a problem, but I've no idea how to solve it.  The only
>> way I can think about is to actually check the service class returned
>> by the factory instead of the factory, but it may cause side effects,
>> not sure.
>> Thoughts?
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com

Guillaume Nodet
Blog: http://gnodet.blogspot.com/
Open Source SOA

View raw message