Adds an afterStart pseudo-event to LoomServer observable by Router implementations #9655
+37
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an
afterStart
"event" in the same spirit as the existingbeforeStart
andafterStop
"events" that are found inServerLifecycle
implementations (but dispatchable only viaRouter
implementations).I am not sure that I have written it correctly and expect it to be discussed thoroughly. My goal with this first pass has been to simply preserve the spirit and style of the preexisting "event" notifications in
LoomServer
, together with preserving design decisions made internally by members of the Helidon team.LoomServer
(package private) has a collection of (package private)ServerListener
instances, indexed by name, that have access toRouter
implementations internally. I found that to preserve the spirit of the existing code I had to provide access to theseRouter
s, since they are currently the only recipients ofbeforeStart
andafterStop
"events", and so, it seemed to me, should be the recipients of (the new)afterStart
"event".Internal discussions said that the notification mechanism should be serial, i.e. not in parallel, so I did not use the
parallel
method to dispatch theafterStart
"event".Currently if an
afterStart
"observer" throws an exception undefined behavior occurs. I believe that there will be many good opinions on what should happen instead.Internal discussions also said that the new "event" payload should be the
WebServer
itself so there is now a bidirectional dependency between, e.g.,Router
andWebServer
. I'm not sure if this was intended to be the case.I also noticed that
Router
is effectively implementing theServerLifecycle
contract, but does not officially implement it, so I didn't add that.I expect that there will be many changes requested, possibly even a completely different architecture for this originally-intended-to-be-small change.