public class ServerBuilder<T extends ExecutionContext>
extends java.lang.Object
Constructor and Description |
---|
ServerBuilder() |
Modifier and Type | Method and Description |
---|---|
Server<T> |
build()
Build a Server using the properties supplied to this builder.
|
ServerBuilder<T> |
withConnectionAddedCallbacks(java.util.function.Consumer<Connection<T>>... callbacks)
Build a Server which will execute the given callbacks when a Connection is added.
|
ServerBuilder<T> |
withConnectionAddedCallbacks(java.lang.Iterable<java.util.function.Consumer<Connection<T>>> callbacks)
Build a Server which will execute the given callbacks when a Connection is added.
|
ServerBuilder<T> |
withConnectionRemovedCallbacks(java.util.function.Consumer<Connection<T>>... callbacks)
Build a Server which will execute the given callbacks when a Connection is removed.
|
ServerBuilder<T> |
withConnectionRemovedCallbacks(java.lang.Iterable<java.util.function.Consumer<Connection<T>>> callbacks)
Build a Server which will execute the given callbacks when a Connection is removed.
|
ServerBuilder<T> |
withContextualTasks(java.util.function.BiConsumer<Server,T>... tasks)
Build a Server which will execute the given tasks each time a Connection executes its contextual tasks.
|
ServerBuilder<T> |
withContextualTasks(java.lang.Iterable<java.util.function.BiConsumer<Server,T>> tasks)
Build a Server which will execute the given tasks each time a Connection executes its contextual tasks.
|
ServerBuilder<T> |
withMultiConnectionBuilder(ConnectionBuilder<T> builder)
Build a Server which will use the given ReusableConnectionBuilder to build new connections.
|
ServerBuilder<T> |
withServerSocket(java.net.ServerSocket socket)
Build a Server using the given ServerSocket.
|
ServerBuilder<T> |
withShutdownCallbacks(java.util.function.Consumer<Server<T>>... callbacks)
Build a Server which will execute the given callbacks after shutdown.
|
ServerBuilder<T> |
withShutdownCallbacks(java.lang.Iterable<java.util.function.Consumer<Server<T>>> callbacks)
Build a Server which will execute the given callbacks after shutdown.
|
ServerBuilder<T> |
withStartupCallbacks(java.util.function.Consumer<Server<T>>... callbacks)
Build a Server which will execute the given callbacks after startup.
|
ServerBuilder<T> |
withStartupCallbacks(java.lang.Iterable<java.util.function.Consumer<Server<T>>> callbacks)
Build a Server which will execute the given callbacks after startup.
|
public Server<T> build()
java.lang.IllegalStateException
- If the ServerSocket or ReusableConnectionBuilder are not set.public ServerBuilder<T> withServerSocket(java.net.ServerSocket socket)
socket
- The ServerSocket.java.lang.IllegalStateException
- If the ServerSocket has already been set.public ServerBuilder<T> withMultiConnectionBuilder(ConnectionBuilder<T> builder)
builder
- The ReusableConnectionBuilder.java.lang.IllegalStateException
- If the ReusableConnectionBuilder has already been set.@SafeVarargs public final ServerBuilder<T> withContextualTasks(java.util.function.BiConsumer<Server,T>... tasks)
tasks
- The tasks to be executed with access to this server and an ExecutionContextpublic ServerBuilder<T> withContextualTasks(java.lang.Iterable<java.util.function.BiConsumer<Server,T>> tasks)
tasks
- The tasks to be executed with access to this server and an ExecutionContextpublic ServerBuilder<T> withConnectionAddedCallbacks(java.lang.Iterable<java.util.function.Consumer<Connection<T>>> callbacks)
callbacks
- The callbacks to execute.@SafeVarargs public final ServerBuilder<T> withConnectionAddedCallbacks(java.util.function.Consumer<Connection<T>>... callbacks)
callbacks
- The callbacks to execute.public ServerBuilder<T> withConnectionRemovedCallbacks(java.lang.Iterable<java.util.function.Consumer<Connection<T>>> callbacks)
callbacks
- The callbacks to execute.@SafeVarargs public final ServerBuilder<T> withConnectionRemovedCallbacks(java.util.function.Consumer<Connection<T>>... callbacks)
callbacks
- The callbacks to execute.public ServerBuilder<T> withStartupCallbacks(java.lang.Iterable<java.util.function.Consumer<Server<T>>> callbacks)
callbacks
- The callbacks to execute.@SafeVarargs public final ServerBuilder<T> withStartupCallbacks(java.util.function.Consumer<Server<T>>... callbacks)
callbacks
- The callbacks to execute.public ServerBuilder<T> withShutdownCallbacks(java.lang.Iterable<java.util.function.Consumer<Server<T>>> callbacks)
callbacks
- The callbacks to execute.@SafeVarargs public final ServerBuilder<T> withShutdownCallbacks(java.util.function.Consumer<Server<T>>... callbacks)
callbacks
- The callbacks to execute.