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:08:28 GMT
Well, in my case, the line 426 of ServiceRegistrationImpl is executed:

                        allow =
getServiceRegistration().isClassAccessible(requestClass);

which looks like:

    protected boolean isClassAccessible(Class clazz)
    {
        try
        {
            // Try to load from the service object or service factory class.
            Class sourceClass = (m_factory != null)
                ? m_factory.getClass() : m_svcObj.getClass();
            Class targetClass = Util.loadClassUsingClass(sourceClass,
clazz.getName());
            return (targetClass == clazz);
        }
        catch (Exception ex)
        {
            // Ignore this and return false.
        }
        return false;
    }

So felix checks if the classloader used to load the factory can also
load the interface, which is not the case in my example.
So isClassAccessible returns false and the event is not dispatched to
the service listener.

On Thu, May 7, 2009 at 12:51, Stuart McCulloch <mcculls@gmail.com> wrote:
> 2009/5/7 Guillaume Nodet <gnodet@gmail.com>
>
>> 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
>>   * the service factory does not belong to the same classloader as
>> the interface of the exposed service
>>   * the bundle exporting the service does not have a direct import on
>> the interface exposed
>>
>> 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?
>>
>
> not sure I quite understand where ServiceFactory comes into it...
>
> IIUIC "isAssignableTo()" checks the packages listed under the "objectClass"
> property and sees if there's any conflict between the wires for the
> registering
> bundle compared to the client bundle.
>
> so I would expect a normal instance and service factory to behave the same,
> as long as they provided the same set of packages as their "objectClass"
>
> are there a different set of packages in "objectClass" for the factory case?
>
> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>
>
>
> --
> Cheers, Stuart
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Mime
View raw message