java.lang.Object
stincmale.server.AbstractServer
- All Implemented Interfaces:
Server
- Direct Known Subclasses:
NettyServer
@ThreadSafe public abstract class AbstractServer extends Object implements Server
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractServer()
-
Method Summary
Modifier and Type Method Description protected abstract void
doStart(CompletableFuture<Void> futureStop)
This method is called fromstart()
only when it is required, so it does not need to care if the server was already started/stopped.protected abstract void
doStop(CompletableFuture<Void> futureStop)
This method is called fromstop()
only when it is required, so it does not need to care if the server was already started/stopped.CompletableFuture<Void>
start()
Enables theServer
to perform I/O operations untilServer.stop()
is invoked or until an implementation decided to cease all operations.void
stop()
-
Constructor Details
-
AbstractServer
protected AbstractServer()
-
-
Method Details
-
doStart
This method is called fromstart()
only when it is required, so it does not need to care if the server was already started/stopped.- Parameters:
futureStop
- The sameCompletableFuture
methodstart()
returns.
-
doStop
This method is called fromstop()
only when it is required, so it does not need to care if the server was already started/stopped.- Parameters:
futureStop
- The sameCompletableFuture
methodstart()
returns.
-
start
Description copied from interface:Server
Enables theServer
to perform I/O operations untilServer.stop()
is invoked or until an implementation decided to cease all operations. This method is allowed to be called multiple times.- Specified by:
start
in interfaceServer
- Returns:
CompletionStage
that may be used to get notified when the server stops operating, or if the server fails to start.- See Also:
Server.start()
,Server.stop()
-
stop
Description copied from interface:Server
Disables theServer
so it does not perform I/O and any other operations anymore if theServer
wasstarted
, otherwise does nothing. This method is allowed to be called multiple times.- Specified by:
stop
in interfaceServer
- Throws:
InterruptedException
- See Also:
Server.start()
-