public final class ServerImpl extends Server
Server
, for creation by transports.
Expected usage (by a theoretical TCP transport):
public class TcpTransportServerFactory {
public static Server newServer(Executor executor, HandlerRegistry registry,
String configuration) {
return new ServerImpl(executor, registry, new TcpTransportServer(configuration));
}
}
Starting the server starts the underlying transport for servicing requests. Stopping the server stops servicing new requests and waits for all connections to terminate.
Constructor and Description |
---|
ServerImpl(Executor executor,
HandlerRegistry registry,
Server transportServer)
Construct a server.
|
Modifier and Type | Method and Description |
---|---|
void |
awaitTerminated()
Waits for the server to become terminated.
|
boolean |
awaitTerminated(long timeout,
TimeUnit unit)
Waits for the server to become terminated, giving up if the timeout is reached.
|
boolean |
isShutdown()
Returns whether the server is shutdown.
|
boolean |
isTerminated()
Returns whether the server is terminated.
|
ServerImpl |
shutdown()
Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected.
|
ServerImpl |
shutdownNow()
Initiates a forceful shutdown in which preexisting and new calls are rejected.
|
ServerImpl |
start()
Bind and start the server.
|
public ServerImpl(Executor executor, HandlerRegistry registry, Server transportServer)
executor
- to call methods on behalf of remote clientsregistry
- of methods to expose to remote clients.public ServerImpl start() throws IOException
this
objectIllegalStateException
- if already startedIOException
- if unable to bindpublic ServerImpl shutdown()
public ServerImpl shutdownNow()
isTerminated()
will likely
return false
immediately after this method returns.
NOT YET IMPLEMENTED. This method currently behaves identically to shutdown().
public boolean isShutdown()
shutdown()
,
isTerminated()
public boolean awaitTerminated(long timeout, TimeUnit unit) throws InterruptedException
isTerminated()
.InterruptedException
public void awaitTerminated() throws InterruptedException
InterruptedException
public boolean isTerminated()
isShutdown()