public class SingleConnectionBuilder<T extends ExecutionContext>
extends java.lang.Object
Constructor and Description |
---|
SingleConnectionBuilder() |
Modifier and Type | Method and Description |
---|---|
Connection<T> |
build()
Build a connection using all the values supplied to this builder.
|
SingleConnectionBuilder<T> |
withContextualTask(java.util.function.Consumer<T> task)
Build a connection that includes the given contextual task to be executed synchronously with message execution.
|
SingleConnectionBuilder<T> |
withContextualTasks(java.util.function.Consumer<T>... tasks)
Build a connection that includes the given contextual task to be executed synchronously with message execution.
|
SingleConnectionBuilder<T> |
withContextualTasks(java.lang.Iterable<java.util.function.Consumer<T>> tasks)
Build a connection that includes the given contextual task to be executed synchronously with message execution.
|
SingleConnectionBuilder<T> |
withErrorCallback(java.util.function.BiConsumer<Connection<T>,java.lang.Throwable> callback)
Build a connection with the given error callback function.
|
SingleConnectionBuilder<T> |
withExecutionContext(T context)
Build a connection with the given ExecutionContext.
|
SingleConnectionBuilder<T> |
withInputStream(java.io.InputStream inputStream)
Build a connection with the given InputStream.
|
SingleConnectionBuilder<T> |
withMessageIOFactory(MessageIOFactory factory)
Use the given MessageIOFactory to create MessageReader and MessageWriter instances from Java Input and Output
streams.
|
SingleConnectionBuilder<T> |
withMessageReader(MessageReader reader)
Build a connection with the given InputStream.
|
SingleConnectionBuilder<T> |
withMessageReaderFactory(MessageReaderFactory factory)
Use the specified MessageReaderFactory to build a MessageReader from any InputStreams.
|
SingleConnectionBuilder<T> |
withMessageWriter(MessageWriter writer)
Build a connection with the given OutputStream.
|
SingleConnectionBuilder<T> |
withMessageWriterFactory(MessageWriterFactory factory)
Use the specified MessageWriterFactory to build a MessageWriter from any OutputStreams.
|
SingleConnectionBuilder<T> |
withOutputStream(java.io.OutputStream outputStream)
Build a connection with the given OutputStream.
|
SingleConnectionBuilder<T> |
withShutdownCallback(java.util.function.Consumer<Connection<T>> callback)
Build a connection that will invoke the given consumer when shutting down with itself as a parameter.
|
SingleConnectionBuilder<T> |
withShutdownCallbacks(java.lang.Iterable<java.util.function.Consumer<Connection<T>>> callbacks)
Build a connection that will invoke the given consumers when shutting down with itself as a parameter.
|
SingleConnectionBuilder<T> |
withSocket(java.net.Socket socket)
Construct a new ConnectionBuilder that will establish a connection over the given socket.
|
public Connection<T> build()
public SingleConnectionBuilder<T> withSocket(java.net.Socket socket) throws java.io.IOException
socket
- The socket over which the connection will be made.java.io.IOException
- If there is an exception when creating streams from the given socket.public SingleConnectionBuilder<T> withMessageIOFactory(MessageIOFactory factory)
factory
- The MessageIOFactory.public SingleConnectionBuilder<T> withInputStream(java.io.InputStream inputStream)
inputStream
- The stream the Connection will use to read messages.public SingleConnectionBuilder<T> withOutputStream(java.io.OutputStream outputStream)
outputStream
- The output stream the Connection will use to write messages.public SingleConnectionBuilder<T> withMessageReader(MessageReader reader)
reader
- The stream the Connection will use to read messages.public SingleConnectionBuilder<T> withMessageWriter(MessageWriter writer)
writer
- The output stream the Connection will use to write messages.public SingleConnectionBuilder<T> withExecutionContext(T context)
context
- The context in which the Connection will execute messages.public SingleConnectionBuilder<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 SingleConnectionBuilder<T> withContextualTask(java.util.function.Consumer<T> task)
task
- The task to be executed; a Consumer accepting an ExecutionContext.@SafeVarargs public final SingleConnectionBuilder<T> withContextualTasks(java.util.function.Consumer<T>... tasks)
tasks
- The tasks to be executed; Consumers accepting an ExecutionContext.public SingleConnectionBuilder<T> withContextualTasks(java.lang.Iterable<java.util.function.Consumer<T>> tasks)
tasks
- The tasks to be executed; Consumers accepting an ExecutionContext.public SingleConnectionBuilder<T> withShutdownCallbacks(java.lang.Iterable<java.util.function.Consumer<Connection<T>>> callbacks)
callbacks
- The consumers.public SingleConnectionBuilder<T> withShutdownCallback(java.util.function.Consumer<Connection<T>> callback)
callback
- The consumerpublic SingleConnectionBuilder<T> withMessageReaderFactory(MessageReaderFactory factory)
factory
- The MessageReaderFactory.public SingleConnectionBuilder<T> withMessageWriterFactory(MessageWriterFactory factory)
factory
- The MessageWriterFactory.