public static final class EConfigure.ConnectionBuilder extends EConfigure.AbstractBuilder
EConfigure.RemoteConnection instance
based on the parameters set via the builder's API. The
minimally allowed configuration is the connection name and
address. The remaining parameters are set to the following
defaults:
EConfigure.ConnectionType.TCP - plain
text TCP connection.
ERemoteApp.ANY_PORT.
AsyncChannel.defaultSelector.
ERemoteAppfinal InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 12345);
final SSLContext secureContext = ...;
final EConfigure.ConnectionBuilder builder = EConfigure.connectionBuilder();
ERemoteApp.openConnection(builder.name("Conn0")
.address(address)
.bindPort(0)
.connectionType(EConfigure.ConnectionType.SECURE_TCP)
.sslContext(secureContext)
.inputBufferSize(4_996)
.outputBufferSize(8_192)
.byteOrder(ByteOrder.BIG_ENDIAN)
.messageQueueSize(0)
.selector("connSelector")
.reconnect(true)
.reconnectDelay(500L)
.heartbeatDelay(0L)
.heartbeatReplyDelay(0L)
.build());EConfigure.ServerBuildermByteOrder, mHbDelay, mHbReplyDelay, mInputBufferSize, mMsgQueueSize, mName, mOutputBufferSize, mSSLContext| Modifier and Type | Method and Description |
|---|---|
InetSocketAddress |
address()
Returns the configured Internet address and port.
|
EConfigure.ConnectionBuilder |
address(InetSocketAddress address)
Set the connection address.
|
int |
bindPort()
Returns the configured bind port.
|
EConfigure.ConnectionBuilder |
bindPort(int port)
Bind the connection local port to this value.
|
EConfigure.RemoteConnection |
build()
Returns the eBus connection configuration built from
the previously set parameters.
|
EConfigure.ConnectionBuilder |
byteOrder(ByteOrder byteOrder)
Sets the connection byte order.
|
EConfigure.ConnectionBuilder |
connectionType(EConfigure.ConnectionType connType)
Sets the underlying channel type.
|
EConfigure.ConnectionBuilder |
heartbeatDelay(long delay)
Sets the heartbeat delay used for the connection.
|
EConfigure.ConnectionBuilder |
heartbeatReplyDelay(long delay)
Sets the heartbeat reply delay used for the
connection.
|
EConfigure.ConnectionBuilder |
inputBufferSize(int size)
Sets the connection input buffer size.
|
EConfigure.ConnectionBuilder |
messageQueueSize(int size)
Sets the connection maximum queue size.
|
EConfigure.ConnectionBuilder |
name(String name)
Sets the connection name.
|
EConfigure.ConnectionBuilder |
outputBufferSize(int size)
Sets the connection output buffer size.
|
boolean |
reconnect()
Returns
true if the connection is configured
to re-establish a lost connect. |
EConfigure.ConnectionBuilder |
reconnect(boolean flag)
Sets the reconnect flag to the given value.
|
long |
reconnectDelay()
Returns the configured millisecond reconnect delay.
|
EConfigure.ConnectionBuilder |
reconnectDelay(long time)
Sets the reconnect delay to the given value.
|
String |
selector()
Returns the configured network selector information.
|
EConfigure.ConnectionBuilder |
selector(String selector)
Sets the selector used for the connection.
|
EConfigure.ConnectionBuilder |
sslContext(SSLContext context)
Sets the SSL/TLS context used by a secure location.
|
protected void |
validate()
Validates the builder parameters.
|
byteOrder, connectionType, heartbeatDelay, heartbeatReplyDelay, inputBufferSize, messageQueueSize, name, outputBufferSize, setByteOrder, setConnectionType, setHeartbeatDelay, setHeartbeatReplyDelay, setInputBufferSize, setMessageQueueSize, setName, setOutputBufferSize, setSSLContext, sslContextpublic InetSocketAddress address()
null if the address is not set.public int bindPort()
public String selector()
public boolean reconnect()
true if the connection is configured
to re-establish a lost connect.public long reconnectDelay()
public EConfigure.ConnectionBuilder name(String name)
name - connection name.this connection builder.NullPointerException - if name is null.IllegalArgumentException - if name is empty.public EConfigure.ConnectionBuilder connectionType(EConfigure.ConnectionType connType)
connType - channel type.this service builder.NullPointerException - if connType is null.public EConfigure.ConnectionBuilder address(InetSocketAddress address)
address - connection address.this connection builder.NullPointerException - if address is null.public EConfigure.ConnectionBuilder bindPort(int port)
port is set to ENetConfigure.ANY_PORT,
then the connection local port is set to any available
value.port - connection local bind port.this connection builder.IllegalArgumentException - if port is either <
ENetConfigure.ANY_PORT or >
ENetConfigure.MAX_PORT.public EConfigure.ConnectionBuilder inputBufferSize(int size)
size
is zero, then the default input buffer size is used.size - accepted connection input buffer size.this service builder.IllegalArgumentException - if size < zero.public EConfigure.ConnectionBuilder outputBufferSize(int size)
size is zero, then the default output buffer
size is used.size - connection output buffer size.this connection builder.IllegalArgumentException - if size < zero.public EConfigure.ConnectionBuilder byteOrder(ByteOrder byteOrder)
byteOrder - connection serializes and
de-serializes messages using this byte order.this connection builder.NullPointerException - if byteOrder is nuill.public EConfigure.ConnectionBuilder messageQueueSize(int size)
size - message queue maximum size.this connection builder.IllegalArgumentException - if size < zero.public EConfigure.ConnectionBuilder selector(String selector)
selector - eBus selector name.this connection builder.NullPointerException - if name is null.IllegalArgumentException - if name is an empty string or not a known
selector.public EConfigure.ConnectionBuilder reconnect(boolean flag)
true means the connection will be
re-established if lost; false means a lost
connection is left down.flag - establish lost connection flag.this connection builder.reconnectDelay(long)public EConfigure.ConnectionBuilder reconnectDelay(long time)
true.time - reconnect a lost connect after this
millisecond delay.this connection builder.reconnect(boolean)public EConfigure.ConnectionBuilder heartbeatDelay(long delay)
delay
milliseconds, then a heartbeat is sent. If
delay is zero, then heartbeating is turned
off.delay - millisecond heartbeat rate.this connection builder.IllegalArgumentException - if delay < zero.public EConfigure.ConnectionBuilder heartbeatReplyDelay(long delay)
delay milliseconds, the
connection is closed. This value is ignored if the
heartbeat delay is zero (heartbeating is off).delay - millisecond heartbeat reply delay.this connection builder.IllegalArgumentException - if delay < zero.public EConfigure.ConnectionBuilder sslContext(SSLContext context)
EConfigure.ConnectionType.SECURE_TCP.context - secure TCP context.this connection builder.NullPointerException - if context is null.public EConfigure.RemoteConnection build()
NullPointerException - if either connection name or address is not set.IllegalStateException - if reconnect flag is set to true but the
reconnect delay is not set.protected void validate()
validate in class EConfigure.AbstractBuilderNullPointerException - if a required parameter is not set.IllegalArgumentException - if a parameter is not set to a valid value with
respect to another parameter.Copyright © 2019. All rights reserved.