felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Konstantinos N. Ntermitzoglou" <kos...@inaccessnetworks.com>
Subject EventDispatcher buggy filter update
Date Tue, 03 Jul 2007 09:24:18 GMT
Hi all,
I have been facing some trouble with the DeviceManager. It looked like 
it would not receive registration and unregistration events of Devices 
and Drivers. Looking closer at DM's and Felix's source code, I have 
reached the following conclusion:
According to the spec for the addServiceListener method (6.1.6.3, core 
spec) :
"
...
If the context bundle’s list of listeners already contains a listener l 
such that
(l==listener), then this method replaces that listener’s filter (which 
may be
null) with the specified one (which may be null).
...
"
Felix attempts this within updateListener method of EventDispatcher 
class. There, at some point there is the following code to decide if the 
filter should be replaced or not:

"
if ( l instanceof FrameworkListener )
{
// The spec says to ignore this case.
}
else if ( l instanceof BundleListener) )
{
// The spec says to ignore this case.
}
else if ( l instanceof ServiceListener )
{
// The spec says to update the filter in this case.
System.out.println("EventDispatcher: Updating Filter");
listeners[i + LISTENER_FILTER_OFFSET] = filter;
}
"

Now, the problem I see is the following:
DeviceManager implements ServiceListener and FrameworkListener (among 
others ). When there is a need for the the filter to be updated (using 
addServiceListner provided "this" and a filter, for a second time ), the 
preceding code will assume that this update has to do with a 
FrameworkListener and will not do the filter update.
I believe that the update should take place in that case right ?
If so, I have modified the code a little and looks ok so far:

if ( (l instanceof FrameworkListener) &&
(clazz == FrameworkListener.class) )
{
// The spec says to ignore this case.
}
else if ( (l instanceof BundleListener) &&
(clazz == BundleListener.class))
{
// The spec says to ignore this case.
}
else if ( (l instanceof ServiceListener) &&
(clazz == ServiceListener.class))
{
// The spec says to update the filter in this case.
System.out.println("EventDispatcher: Updating Filter");
listeners[i + LISTENER_FILTER_OFFSET] = filter;
}
It should also be working only by using clazz == aListener.class ...

Thank you for your time and sorry for the long message,

Regards,
kostas

Mime
View raw message