Is it possible to setup Grizzly for graceful shutdown?

lit*_*ium 7 java nio jersey grizzly

I have a Jersey application running on embedded Grizzly, that is initialized like the following:

HttpServer httpServer = GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
Run Code Online (Sandbox Code Playgroud)

What i want to achieve is let the running requests finish when shutting down, but not let new requests in. I couldn't find a way to achieve this through public methods of HttpServer, or not even with private methods and such (although it is not nice, a solution by accessing private stuff through reflection is also ok)

Does anyone know how this is possible?

odi*_*apc 3

使用 Grizzly 2.3.4 是可以的;请参阅有关优雅终止 Grizzly Transport的帖子。简而言之,在特定于实现的传输机制(例如、或)上实现使用Transport.addShutdownListener()注册的GracefulShutdownListenerNIOTransportTCPNIOTransportUDPNIOTransport