public class MultiConnectionBuilder<T extends ExecutionContext>
extends java.lang.Object
Constructor and Description |
---|
MultiConnectionBuilder() |
Modifier and Type | Method and Description |
---|---|
Connection<T> |
build(java.net.Socket socket)
Build a connection using the given socket.
|
MultiConnectionBuilder<T> |
withContextualTask(java.util.function.Consumer<T> task)
Build a connection that includes the given contextual task to be executed synchronously with message execution.
|
MultiConnectionBuilder<T> |
withContextualTasks(java.util.Collection<java.util.function.Consumer<T>> tasks)
Build a connection that includes the given contextual task to be executed synchronously with message execution.
|
MultiConnectionBuilder<T> |
withContextualTasks(java.util.function.Consumer<T>... tasks)
Build a connection that includes the given contextual task to be executed synchronously with message execution.
|
MultiConnectionBuilder<T> |
withErrorCallback(java.util.function.BiConsumer<Connection<T>,java.lang.Throwable> callback)
Build a connection with the given error callback function.
|
MultiConnectionBuilder<T> |
withExecutionContextFactory(ExecutionContextFactory<T> context)
Build a connection with the given ExecutionContext.
|
MultiConnectionBuilder<T> |
withMessageIOFactory(MessageIOFactory factory)
Use the given MessageIOFactory to create MessageReader and MessageWriter instances from Java Input and Output
streams.
|
MultiConnectionBuilder<T> |
withShutdownCallback(java.util.function.Consumer<Connection<T>> callback)
Build a connection that will execute the given callback on shutdown.
|
public Connection<T> build(java.net.Socket socket) throws java.io.IOException
socket
- The socket.java.io.IOException
- If there is an exception when building the connection.public MultiConnectionBuilder<T> withErrorCallback(java.util.function.BiConsumer<Connection<T>,java.lang.Throwable> callback)
callback
- The Consumer (accepting a Connection and Throwable) that will be invoked when an error is
encountered.public MultiConnectionBuilder<T> withMessageIOFactory(MessageIOFactory factory)
factory
- The MessageIOFactory.public MultiConnectionBuilder<T> withExecutionContextFactory(ExecutionContextFactory<T> context)
context
- The context in which the Connection will execute messages.public MultiConnectionBuilder<T> withContextualTask(java.util.function.Consumer<T> task)
task
- The task to be executed; a Consumer accepting an ExecutionContext.@SafeVarargs public final MultiConnectionBuilder<T> withContextualTasks(java.util.function.Consumer<T>... tasks)
tasks
- The tasks to be executed; Consumers accepting an ExecutionContext.public MultiConnectionBuilder<T> withContextualTasks(java.util.Collection<java.util.function.Consumer<T>> tasks)
tasks
- The tasks to be executed; Consumers accepting an ExecutionContext.public MultiConnectionBuilder<T> withShutdownCallback(java.util.function.Consumer<Connection<T>> callback)
callback
- The callback to be invoked.