Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is an embedded Jetty Server guaranteed to be "ready for business" when the call to Server.start() returns?

I am having trouble finding any information about whether an embedded Jetty Server is guaranteed to be fully initialized and ready to receive requests when the call to Server.start() returns.

Nor have I been able to find anything conclusive by debugging.

If the server might still be initializing itself when the call returns, is there any way to register a callback so that I can be notified when it is indeed ready for action?

like image 714
svjson Avatar asked Jan 01 '26 01:01

svjson


1 Answers

Yes, when returning from Server.start() the server is ready.

You can register a LifeCycle.Listener using Server.addLifeCycleListener(listener) to get notified of startup or shutdown events. If you look at the source of Server.start() you'll see, that it calls Listener.lifeCycleStarted() at the end.

like image 80
the.duckman Avatar answered Jan 02 '26 15:01

the.duckman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!