public interface ServerContext extends ListenableAsyncCloseable, GracefulAutoCloseable
Modifier and Type | Method and Description |
---|---|
default void |
awaitShutdown()
Blocks and awaits shutdown of the server this
ServerContext represents. |
default void |
close() |
default void |
closeGracefully()
Used to close/shutdown a resource, similar to
AutoCloseable.close() , but attempts to cleanup state before
abruptly closing. |
ExecutionContext |
executionContext()
Returns
ExecutionContext used by this server. |
java.net.SocketAddress |
listenAddress()
Listen address for the server associated with this context.
|
onClose
closeAsync, closeAsyncGracefully
java.net.SocketAddress listenAddress()
ExecutionContext executionContext()
ExecutionContext
used by this server.ExecutionContext
used by this server.default void awaitShutdown()
ServerContext
represents.
This method will return when ListenableAsyncCloseable.onClose()
terminates either successfully or unsuccessfully.
default void close() throws java.lang.Exception
close
in interface java.lang.AutoCloseable
java.lang.Exception
default void closeGracefully() throws java.lang.Exception
GracefulAutoCloseable
AutoCloseable.close()
, but attempts to cleanup state before
abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in
flight work. This method is implemented on a "best effort" basis and may be equivalent to AutoCloseable.close()
.
Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not
want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a
timeout and force a call to AutoCloseable.close()
.
closeGracefully
in interface GracefulAutoCloseable
java.lang.Exception
- if graceful closure failed.