嵌入式 Jetty 服务器是否保证“做好业务准备”?当对 Server.start() 的调用返回时?
我无法找到有关嵌入式 Jetty 服务器是否保证在对 Server.start() 的调用返回时完全初始化并准备好接收请求的任何信息。
我也无法通过调试找到任何结论。
如果在调用返回时服务器可能仍在初始化自身,是否有任何方法可以注册回调,以便在它确实准备好执行操作时通知我?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,当从
Server.start()
返回时,服务器已准备就绪。您可以使用
Server.addLifeCycleListener(listener)
注册LifeCycle.Listener
来获取启动或关闭事件的通知。如果您查看 Server.start() 的源代码,您会发现它在最后调用了 Listener.lifeCycleStarted() 。Yes, when returning from
Server.start()
the server is ready.You can register a
LifeCycle.Listener
usingServer.addLifeCycleListener(listener)
to get notified of startup or shutdown events. If you look at the source ofServer.start()
you'll see, that it callsListener.lifeCycleStarted()
at the end.不是一个完整的答案,但也许这取决于 servlet 是否“在启动时加载”?
not a complete answer but maybe it depends on whether the servlets may or may not "load on startup"?