当对Server.start()的调用返回时,嵌入式Jetty服务器是否保证"为业务做好准备"?

svj*_*son 3 java jetty embedding

我无法找到有关嵌入式Jetty服务器是否保证完全初始化并准备好在Server.start()调用返回时接收请求的任何信息.

我也没有通过调试找到任何结论.

如果服务器在调用返回时可能仍在初始化自己,是否有任何方法可以注册回调,以便在确实准备好执行操作时通知我?

the*_*man 5

是的,从Server.start()服务器返回时已准备就绪.

您可以注册LifeCycle.Listener使用Server.addLifeCycleListener(listener)以获得启动或关闭事件的通知.如果你看一下Server.start()你会看到的来源,它会Listener.lifeCycleStarted()在最后调用.