public static final class EConfigure.ConnectionBuilder extends EConfigure.AbstractBuilder<EConfigure.ConnectionBuilder>
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, mCanPause, mHbDelay, mHbReplyDelay, mInputBufferSize, mLoaderFlag, mMsgQueueSize, mName, mOutputBufferSize, mPauseConfig, 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 |
configuration(EConfigure.RemoteConnection config)
Copies in the settings from
config to this
builder. |
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.
|
protected void |
validate()
Validates the builder parameters.
|
byteOrder, byteOrder, canPause, canPause, configuration, connectionType, connectionType, heartbeatDelay, heartbeatDelay, heartbeatReplyDelay, heartbeatReplyDelay, inputBufferSize, inputBufferSize, loaderFlag, messageQueueSize, messageQueueSize, name, name, outputBufferSize, outputBufferSize, pauseConfig, pauseConfig, sslContext, 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 configuration(EConfigure.RemoteConnection config)
config to this
builder. This method is provided for making changes to
an existing configuration since
EConfigure.RemoteConnection is immutable.
if config is null, then nothing is
done and the builder remains unchanged.
config - copy settings from this configuration.this connection builder.public EConfigure.ConnectionBuilder address(InetSocketAddress address)
address - connection address.this connection builder.com.typesafe.config.ConfigException - 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.com.typesafe.config.ConfigException - if port is either <
ENetConfigure.ANY_PORT or >
ENetConfigure.MAX_PORT.public EConfigure.ConnectionBuilder selector(String selector)
selector - eBus selector name.this connection builder.com.typesafe.config.ConfigException - if name is null, 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.com.typesafe.config.ConfigException - if time < zero.reconnect(boolean)public EConfigure.RemoteConnection build()
com.typesafe.config.ConfigException - if either connection name or address is not set or if
reconnect flag is set to true but the
reconnect delay is not set.protected void validate()
validate in class EConfigure.AbstractBuilder<EConfigure.ConnectionBuilder>com.typesafe.config.ConfigException - if a required parameter is not set or if a parameter
is not set to a valid value with respect to another
parameter.Copyright © 2019. All rights reserved.