public class ConnectionBuilder<T extends Client<Connection<T>>>
extends java.lang.Object
ConnectionHandler responsible to manage all incoming connections.| Constructor and Description |
|---|
ConnectionBuilder() |
| Modifier and Type | Method and Description |
|---|---|
ConnectionBuilder<T> |
bufferDefaultSize(int bufferSize)
Sets the size limit of the data buffer sent/received.
|
ConnectionBuilder<T> |
bufferLargePoolSize(int bufferPoolSize)
Sets the maximum amount of buffer with large size that can be holder on the BufferPool.
|
ConnectionBuilder<T> |
bufferLargeSize(int bufferSize)
Sets the large size of the data buffer sent/received.
|
ConnectionBuilder<T> |
bufferMediumPoolSize(int bufferPoolSize)
Sets the maximum amount of buffer with medium size that can be holder on the BufferPool.
|
ConnectionBuilder<T> |
bufferMediumSize(int bufferSize)
Sets the medium size of the data buffer sent/received.
|
ConnectionBuilder<T> |
bufferPoolSize(int bufferPoolSize)
Sets the maximum amount of buffer with default size that can be holder on the BufferPool.
|
ConnectionBuilder<T> |
bufferSmallPoolSize(int bufferPoolSize)
Sets the maximum amount of buffer with small size that can be holder on the BufferPool.
|
ConnectionBuilder<T> |
bufferSmallSize(int bufferSize)
Sets the small size of the data buffer sent/received.
|
ConnectionHandler<T> |
build()
Builds a new ConnectionHandler based on the options configured.
|
ConnectionBuilder<T> |
byteOrder(java.nio.ByteOrder order)
Sets the byte order used to send and receive packets.
|
static <T extends Client<Connection<T>>> |
create(java.net.InetSocketAddress address,
ClientFactory<T> clientFactory,
PacketHandler<T> packetHandler,
PacketExecutor<T> executor)
Creates a ConnectionBuilder holding the minimum requirements to create a ConnectionHandler.
|
ConnectionBuilder<T> |
filter(ConnectionFilter filter)
Sets a filter to be used on incoming connections.
|
ConnectionBuilder<T> |
shutdownWaitTime(long waitTime)
Sets the shutdown wait time in milliseconds.
|
ConnectionBuilder<T> |
threadPoolSize(int size)
Set the size of the threadPool used to manage the connections and data sending.
|
ConnectionBuilder<T> |
useNagle(boolean useNagle)
Defines if small outgoing packets must be combined to be sent all at once.
|
public static <T extends Client<Connection<T>>> ConnectionBuilder<T> create(java.net.InetSocketAddress address, ClientFactory<T> clientFactory, PacketHandler<T> packetHandler, PacketExecutor<T> executor)
T - - The Type of client that ConnectionBuilder will handle.address - - The socket address to listen the incoming connections.clientFactory - - The factory responsible to create a new Client when a new connection is accepted.packetHandler - - The handle responsible to convert the data received into a ReadablePacketexecutor - - The responsible to execute the incoming packets.public ConnectionBuilder<T> filter(ConnectionFilter filter)
filter - - the ConnectionFilter to be set.public ConnectionBuilder<T> threadPoolSize(int size)
Short.MAX_VALUE then a cachedThreadPool is used.
Otherwise a FixedThreadPool with the size set is used.
The default value is the quantity of available processors minus 2.size - - the size to be Setpublic ConnectionBuilder<T> useNagle(boolean useNagle)
useNagle - - true if the Nagle's algorithm must be used.public ConnectionBuilder<T> shutdownWaitTime(long waitTime)
waitTime - - the wait time to close all connections resources after a ConnectionHandler.shutdown() is called.public ConnectionBuilder<T> bufferDefaultSize(int bufferSize)
bufferSize - - the buffer size to be setpublic ConnectionBuilder<T> bufferSmallSize(int bufferSize)
bufferSize - - the buffer size to be setpublic ConnectionBuilder<T> bufferLargeSize(int bufferSize)
bufferSize - - the buffer size to be setpublic ConnectionBuilder<T> bufferMediumSize(int bufferSize)
bufferSize - - the buffer size to be setpublic ConnectionBuilder<T> bufferPoolSize(int bufferPoolSize)
bufferPoolSize - - the size of the buffer pool size.public ConnectionBuilder<T> bufferSmallPoolSize(int bufferPoolSize)
bufferPoolSize - - the size of the buffer pool size.public ConnectionBuilder<T> bufferMediumPoolSize(int bufferPoolSize)
bufferPoolSize - - the size of the buffer pool size.public ConnectionBuilder<T> bufferLargePoolSize(int bufferPoolSize)
bufferPoolSize - - the size of the buffer pool size.public ConnectionBuilder<T> byteOrder(java.nio.ByteOrder order)
ByteOrder.LITTLE_ENDIANorder - - the order to be used.public ConnectionHandler<T> build() throws java.io.IOException
java.io.IOException - - If the Socket Address configured can't be used.