Package dev.relism.flash.transport
Class ServerLifecycle
java.lang.Object
dev.relism.flash.transport.ServerLifecycle
- All Implemented Interfaces:
ServerHandle
Owns the server's lifecycle: the accept threads (one per listener ×
TransportTuning.ACCEPT_THREADS), the active-socket registry, and the two-stage
shutdownDrainTimeoutMs (during which Http1Connection forces
Connection: close on the next response once it observes isStopped()), then
force-close whatever remains.
Implements ServerHandle directly — its three methods already match that contract
exactly, so no separate wrapper class is needed.
-
Constructor Summary
ConstructorsConstructorDescriptionServerLifecycle(List<BoundListener> listeners, ConnectionRunner runner, FlashConfiguration configuration, ExecutorService executorService, Set<Socket> activeSockets) -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the server has begun shutting down.intport()Port of the first bound listener.ports()Ports of every bound listener, in configuration order.voidstart()Starts the accept loop on a background platform thread.voidStarts the accept loop and blocks the calling thread until the server is stopped.stop()Gracefully stops the server, draining active connections.
-
Constructor Details
-
ServerLifecycle
public ServerLifecycle(List<BoundListener> listeners, ConnectionRunner runner, FlashConfiguration configuration, ExecutorService executorService, Set<Socket> activeSockets)
-
-
Method Details
-
port
public int port()Description copied from interface:ServerHandlePort of the first bound listener. Valid as soon as the handle exists — listeners are bound at construction, not atServerHandle.start()— so configuring with port0and reading the OS-assigned port back is a supported pattern.- Specified by:
portin interfaceServerHandle
-
ports
Description copied from interface:ServerHandlePorts of every bound listener, in configuration order.- Specified by:
portsin interfaceServerHandle
-
isStopped
public boolean isStopped()Whether the server has begun shutting down. Passed down to every connection as aBooleanSupplierso in-flight request loops can drain promptly instead of waiting for their next keep-alive request. -
start
public void start()Description copied from interface:ServerHandleStarts the accept loop on a background platform thread. Returns immediately.- Specified by:
startin interfaceServerHandle
-
startAndBlock
public void startAndBlock()Description copied from interface:ServerHandleStarts the accept loop and blocks the calling thread until the server is stopped. Suitable for use inmain()when no other work is needed after startup.- Specified by:
startAndBlockin interfaceServerHandle
-
stop
Description copied from interface:ServerHandleGracefully stops the server, draining active connections.- Specified by:
stopin interfaceServerHandle
-