This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 32714 - Make removal of all listeners possible
Summary: Make removal of all listeners possible
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-08 13:51 UTC by tsturm
Modified: 2003-06-29 14:50 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tsturm 2003-04-08 13:51:12 UTC
Sometimes I need to remove all active listeners
for a certain element without them individually
(e.g. for supressing the deployment of change
events during loading, see the thread "Disabling
Events" on mdr-dev for details).

This is a very important feature that is available
in most of the common event/listener
architectures. It also helps to raise the
performance of mdr and to avoid memory leaks.

I'm thinking of some kind of removeAllListeners()
either on the MDRObject itself or on the
repository with the MDRObject to remove listeners
from being provided as parameter.
Comment 1 Martin Matula 2003-04-09 15:29:44 UTC
Hi Thorsten. Let me better understand the requirements. Do you want to
remove all the listeners? Are there any listeners that someone else
registered (3rd party plugins) that also need to be removed? Does the
removal need to be conditional/parametrizable in any way (remove only
events related to associations, instances but keep listeners on
transaction events, etc.)? Should there be a method that registers
back all the listeners previously removed by removeAll method, or you
don't care?
Comment 2 tsturm 2003-04-17 09:08:18 UTC
Hi Martin,

initially, we need a removeAll that removes all listeners from listening to anything in the 
repository, no matter where they got registered from (I already added that as a very dirty 
hack to our local version of MDR).

In addition to that, parameterized versions of removeAll based on objects/types from the 
repository or on event types can be very useful and convenient. It would give us more 
control and flexibility.

Holding and readding the listeners is something that can be very convenient, but it is 
nothing we currently care about.
Comment 3 Martin Matula 2003-06-29 14:50:32 UTC
Hi Thorsten,
I have solved the issue using a little bit different approach -
hopefully it will be sufficient for you.
The functionality that I have added to MDR allows you to turn off
events (instead of removing all the listeners) - this way the
registered listeners still stay registered (i.e. they do not need to
be re-added) and there should be a performance boost because the event
objects are not even created.
The events are turned off only for the currently opened transaction
(i.e. they will be turned on automatically after the transaction is
commited or rolled back). To turn off the events, the only thing you
need to do is to call ((NBMDRepositoryImpl)
repository).disableEvents() immediately (or later) after you start a
transaction. Note that you have to re-cast the repository object to
NBMDRepositoryImpl, as I haven't made this method part of the official
API.