You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Matthew Aguirre <ma...@gmail.com> on 2015/05/11 18:01:46 UTC

[lang] Check for Duplicate Event Listener

I would like to add support to check for a duplicate event listener to the
org.apache.commons.lang3.event.EventListenerSupport class.
This would save me (and possibly others) from then checking the listeners
before adding.

   1. Should I just submit a ticket or should I implement a change within
   GitHub?
   2. Since I doubt that a global change would be appreciated, what would
   an acceptable method for signaling duplicate detection be?
      1. Flag in the constructor?
      2. Flag in the addListener method?

Thanks!
--
Matt

Re: [lang] Check for Duplicate Event Listener

Posted by James Carman <ja...@carmanconsulting.com>.
On Mon, May 11, 2015 at 12:43 PM James Carman <ja...@carmanconsulting.com>
wrote:

>
> Great ideas!  I would think the non-duplicate part would be a global thing
> for that particular EventListenerSupport object, so it should probably be
> part of the constructor.  That would change the serialization of the
> objects, which is somewhat problematic, but we do control that ourselves
> (without version numbers, unfortunately), so we could always default the
> flag to false if the data's not there.  I doubt folks are storing event
> listeners in long-term storage, though.
>

Actually, after having sent that, the "support" object probably doesn't
care about duplicates itself, really.  It's the particular listener that
cares whether or not its logic will be called multiple time.  So, maybe it
is better to put it on the "add" method.  This would avoid the issue with
serialization, also. :)  Go for it!

Re: [lang] Check for Duplicate Event Listener

Posted by James Carman <ja...@carmanconsulting.com>.
On Mon, May 11, 2015 at 12:02 PM Matthew Aguirre <ma...@gmail.com>
wrote:

> I would like to add support to check for a duplicate event listener to the
> org.apache.commons.lang3.event.EventListenerSupport class.
> This would save me (and possibly others) from then checking the listeners
> before adding.
>
>    1. Should I just submit a ticket or should I implement a change within
>    GitHub?
>    2. Since I doubt that a global change would be appreciated, what would
>    an acceptable method for signaling duplicate detection be?
>       1. Flag in the constructor?
>       2. Flag in the addListener method?
>
>
Great ideas!  I would think the non-duplicate part would be a global thing
for that particular EventListenerSupport object, so it should probably be
part of the constructor.  That would change the serialization of the
objects, which is somewhat problematic, but we do control that ourselves
(without version numbers, unfortunately), so we could always default the
flag to false if the data's not there.  I doubt folks are storing event
listeners in long-term storage, though.

Re: [lang] Check for Duplicate Event Listener

Posted by Benedikt Ritter <br...@apache.org>.
Hello Matthew,

2015-05-11 18:01 GMT+02:00 Matthew Aguirre <ma...@gmail.com>:

> I would like to add support to check for a duplicate event listener to the
> org.apache.commons.lang3.event.EventListenerSupport class.
> This would save me (and possibly others) from then checking the listeners
> before adding.
>
>    1. Should I just submit a ticket or should I implement a change within
>    GitHub?
>

If you're planning to contribute via GitHub, I recommend reading the
CONTRIBUTING.md [1] in the repository. It should have alle the information
you need.


>    2. Since I doubt that a global change would be appreciated, what would
>    an acceptable method for signaling duplicate detection be?
>       1. Flag in the constructor?
>       2. Flag in the addListener method?
>

I agree with James' latest message. It should go to e specific add method.
Please don't modify the existing method signatures, but add an overload
since we would otherwise break binary compatibility.

Thank you!
Benedikt

[1] https://github.com/apache/commons-lang/blob/master/CONTRIBUTING.md


>
> Thanks!
> --
> Matt
>



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter