bundle.stop is not firing a bundle change event to a listener plugin [message #530473] |
Thu, 29 April 2010 17:53 |
|
Hi,
I have two plugins A and B. B is set to lazy start. A implements
IStartup to guarantee that A moves to an Activated state so it can listen
to BundleChange events for B.
This works and is verifiable using the OSGi console command "ss".
A now creates a BundleListener to listen for B bundle state changes.
When I open a view in B, it moves to the Activated state and A gets
the BundleEvent in its listener:
<snippet>
@Override
public void bundleChanged(BundleEvent event) {
</snippet>
When I invoke bundle.stop() in B, A does not get the event. Why is that?
I stepped through the stop() code in Eclipse and in this section
of code in org.eclipse.osgi.framework.eventmgr.EventManager found
that the listenerObject at one point is set to my A plugin. I stepped
through for a while and mistakenly stepped out.
<snippet>
static void dispatchEvent(Set/*<Map.Entry<Object,Object>>*/
listeners, EventDispatcher dispatcher, int eventAction, Object
eventObject) {
for (Iterator iter = listeners.iterator(); iter.hasNext
();) { /* iterate over the list of listeners */
Map.Entry listener = (Map.Entry) iter.next();
Object eventListener = listener.getKey();
Object listenerObject = listener.getValue();
try {
/* Call the EventDispatcher to complete
the delivery of the event. */
dispatcher.dispatchEvent(eventListener,
listenerObject, eventAction, eventObject);
} catch (Throwable t) {
</snippet>
Any ideas why bundle.stop() is not firing any bundle events to the
listener?
Thanks,
Dilton
|
|
|
Re: bundle.stop is not firing a bundle change event to a listener plugin [message #530498 is a reply to message #530473] |
Thu, 29 April 2010 20:08 |
|
On Thu, 29 Apr 2010 17:53:15 +0000, Dilton wrote:
> Any ideas why bundle.stop() is not firing any bundle events to the
> listener?
I debugged this down a little further into ListenerQueue. In the
following method the "put" operation is skipped when the listener
is my A BundleListener plugin from the OP:
public synchronized void queueListeners(Set/
*<Map.Entry<Object,Object>>*/listeners, EventDispatcher dispatcher) {
if (readOnly) {
throw new IllegalStateException();
}
if (listeners.size() != 0) {
queue.put(listeners, dispatcher); // enqueue the
list and its dispatcher
}
}
Is this a bug?
Dilton
|
|
|
Powered by
FUDForum. Page generated in 0.03369 seconds