Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use addEventListener(EventListener listener) instead of bespoke listener methods #3966

Merged
merged 35 commits into from
Nov 13, 2019

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Aug 13, 2019

For #2578 (includes #3965 for #3964):

  • Use addEventListener rather than bespoke listener methods.
  • Support getEventListenerBeans at Container level for fast lookup
  • improve javadoc

gregw added 5 commits August 13, 2019 16:35
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Keep a list of EventListeners in the AbstractConnector to make it
more efficient to add and iterate over them.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Use addEventListener rather than bespoke listener methods.
Support getEventListenerBeans at Container level for fast lookup
improve javadoc

Signed-off-by: Greg Wilkins <gregw@webtide.com>
fixed test
more javadoc

Signed-off-by: Greg Wilkins <gregw@webtide.com>
fixed tests

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@joakime
Copy link
Contributor

joakime commented Aug 13, 2019

I don't like this.
The code is needlessly verbose, and a pain to maintain in the future.
Do we have any jmh proof this is even needed?

@sbordet
Copy link
Contributor

sbordet commented Aug 13, 2019

Same as @joakime.

gregw added 6 commits August 14, 2019 08:09
Don't use null for empty lists of listeners

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Resolve differences between eventListeners added as beans and beans
added as EventListeners.   The behaviour should now be the same
regardless of how they listener is added and all listeners are now
beans.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Add only SelectorManager listeners to manager from connector

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Fixed javadoc

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw marked this pull request as ready for review August 14, 2019 03:50
removed old TODO

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw
Copy link
Contributor Author

gregw commented Aug 14, 2019

@joakime @sbordet come on! you've got to give better reviews than "I don't like it"!

What code verbose? I have more lines, but mostly because I've actually added some javadoc?

How is this more difficult to maintain? Previously we have had a managery of different listeners, some EventListeners, some not, some are beans, some are not, some are copied between specific beans and some are not. It's a confusing and already difficult to maintain. Now all EventListeners are beans and all beans that are EventListeners are added as such. We do have some classes called Listener that are not EventListeners, but they probably should have been called Handlers. Now any listener that is-a EventListener can be added with addEventListener rather than sometimes with a bespoke adder.

Why is it "needless"? This clean up avoids several needless iteration over beans and ArrayList creations on every new connection and new HttpChannel (which can be every request in http2). So it is a non-trivial saving of effort.

connector cannot be null

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw added the wip label Aug 14, 2019
@gregw
Copy link
Contributor Author

gregw commented Aug 14, 2019

Doh! I have found an issue with this approach - MBeanListener, which is on every bean if JMX is enabled makes this a non optimal approach. Consider this a draft again until I find a better way.

gregw added 4 commits August 14, 2019 15:16
javadoc

Signed-off-by: Greg Wilkins <gregw@webtide.com>
AbstractConnector keeps a specific list of HttpChannel.Listeners
to avoid Connection.Listeners and MBean listeners being added to
the HttpChannel listener list.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
fixed merge

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw removed the wip label Aug 15, 2019
gregw added 4 commits August 19, 2019 12:32
removed the ability to set/clear context listeners
Instead just remove non-durable ones.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Simplified listener handling by avoiding null connector, previously
only needed for testing.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added 2 commits August 21, 2019 14:45
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
@joakime joakime changed the title Jetty 10.0.x #2578 event listener Issue #2578 - Listener behavior cleanup (Jetty 10.0.x) Aug 21, 2019
@joakime joakime added this to the 10.0.x milestone Aug 21, 2019
gregw added 4 commits August 25, 2019 17:36
…2578-EventListener

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw
Copy link
Contributor Author

gregw commented Aug 28, 2019

@janbartel @joakime re-review please

…2578-EventListener

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw requested review from sbordet and joakime September 4, 2019 22:36
* Fixed tests that scan for "Started" on console

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw requested a review from janbartel September 10, 2019 23:53
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw requested a review from janbartel September 24, 2019 03:06
@joakime joakime removed their request for review September 25, 2019 21:30
@gregw gregw merged commit 46a3368 into jetty-10.0.x Nov 13, 2019
@joakime joakime deleted the jetty-10.0.x-2578-EventListener branch January 10, 2020 00:40
@joakime joakime changed the title Issue #2578 - Listener behavior cleanup (Jetty 10.0.x) Use addEventListener(EventListener listener) instead of bespoke listener methods Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants