Package net.sf.eBus.config
Class EConfigure.AbstractBuilder<T extends EConfigure.AbstractBuilder>
- java.lang.Object
-
- net.sf.eBus.config.EConfigure.AbstractBuilder<T>
-
- Type Parameters:
T- builder subclass.
- Direct Known Subclasses:
EConfigure.ConnectionBuilder,EConfigure.ServerBuilder
- Enclosing class:
- EConfigure
public abstract static class EConfigure.AbstractBuilder<T extends EConfigure.AbstractBuilder> extends Object
Base class forEConfigure.ServerBuilderandEConfigure.ConnectionBuilder, containing the properties common to both.- Author:
- Charles W. Rapp
-
-
Field Summary
Fields Modifier and Type Field Description protected ByteOrdermByteOrderCode and decode messages in this byte order.protected booleanmCanPauseSet totrueif remote connections may be paused.protected DurationmHbDelaySend a heartbeat message after this many milliseconds of inbound message inactivity.protected DurationmHbReplyDelayThe number of milliseconds the far-end has to respond to a heartbeat.protected intmInputBufferSizeMaximum input buffer size.protected booleanmLoaderFlagSet totrueif this builder is used when loading a configuration.protected intmMsgQueueSizeMaximum eBus message outbound queue size for remote connections.protected StringmNameUnique service or connection name.protected intmOutputBufferSizeMaximum output buffer size.protected EConfigure.PauseConfigmPauseConfigContains the pause parameters.protected DurationmRetransmitDelayRe-transmit application message over reliable UDP after waiting this long for an application message receipt.protected intmRetransmitLimitRe-transmit application message at most this many times before declaring reliable UDP connection lost.protected SSLContextmSSLContextThe SSL/TLS context used for a secure TCP connection.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractBuilder()Creates a new abstract configuration builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TbyteOrder(ByteOrder byteOrder)Sets the byte order used by the connection.TcanPause(boolean flag)Sets a flag specifying whether accepted connections may be paused (true) or not.protected Tconfiguration(EConfigure.AbstractConfig config)Copies the values found inconfigto this configuration.TconnectionType(EConfigure.ConnectionType connType)Sets the underlying channel type.TheartbeatDelay(Duration delay)Sets the heartbeat delay used for the connection.TheartbeatReplyDelay(Duration delay)Sets the heartbeat reply delay used for the connection.TinputBufferSize(int size)Sets the input buffer size for the connection.protected TloaderFlag(boolean flag)Sets the loader flag to the given value.TmessageQueueSize(int size)Sets the maximum queue size for the connection.Tname(String name)Sets the service/connection name.ToutputBufferSize(int size)Sets the output buffer size for the connection.TpauseConfig(EConfigure.PauseConfig pc)Sets the pause configuration for the connection.TretransmitDelay(Duration delay)Sets reliable UDP application message re-transmit delay.TretransmitLimit(int limit)Sets reliable UDP application message re-transmit limit.TsslContext(SSLContext context)Sets the SSL/TLS context used by a secure location.protected Validatorvalidate(Validator problems)Validates builder arguments are correctly set, listing validation errors inproblemslist.
-
-
-
Field Detail
-
mName
protected String mName
Unique service or connection name.
-
mInputBufferSize
protected int mInputBufferSize
Maximum input buffer size. May be overridden bySSLSession.getApplicationBufferSize()when using a secure TCP connection.
-
mOutputBufferSize
protected int mOutputBufferSize
Maximum output buffer size. May be override bySSLSession.getPacketBufferSize()when using a secure TCP connection.
-
mByteOrder
protected ByteOrder mByteOrder
Code and decode messages in this byte order.
-
mMsgQueueSize
protected int mMsgQueueSize
Maximum eBus message outbound queue size for remote connections. When the queue outbound message count exceeds this size, the remote connection is automatically closed and the outbound messages discarded.
-
mHbDelay
protected Duration mHbDelay
Send a heartbeat message after this many milliseconds of inbound message inactivity.
-
mHbReplyDelay
protected Duration mHbReplyDelay
The number of milliseconds the far-end has to respond to a heartbeat. If the response is not received after this many milliseconds, the remote connection is automatically closed.
-
mSSLContext
protected SSLContext mSSLContext
The SSL/TLS context used for a secure TCP connection.
-
mCanPause
protected boolean mCanPause
Set totrueif remote connections may be paused.
-
mPauseConfig
protected EConfigure.PauseConfig mPauseConfig
-
mLoaderFlag
protected boolean mLoaderFlag
Set totrueif this builder is used when loading a configuration. This flag is used to detect when a secure TCP session is defined in a configuration as opposed to built by an application. If so, then the session definition is not required to define the SSL context.
-
mRetransmitDelay
protected Duration mRetransmitDelay
Re-transmit application message over reliable UDP after waiting this long for an application message receipt.This configuration only applies to a reliable UDP connection.
-
mRetransmitLimit
protected int mRetransmitLimit
Re-transmit application message at most this many times before declaring reliable UDP connection lost. Does not apply to initial transmit.This configuration only applies to a reliable UDP connection.
-
-
Method Detail
-
name
public final T name(String name)
Sets the service/connection name.- Parameters:
name- service/connection name.- Returns:
thisservice/connection builder.- Throws:
com.typesafe.config.ConfigException- ifnameisnullor empty.
-
connectionType
public final T connectionType(EConfigure.ConnectionType connType)
Sets the underlying channel type.- Parameters:
connType- channel type.- Returns:
thisservice/connection builder.- Throws:
com.typesafe.config.ConfigException- ifconnTypeisnull.
-
inputBufferSize
public final T inputBufferSize(int size)
Sets the input buffer size for the connection. Ifsizeis zero, then the default input buffer size is used.- Parameters:
size- connection input buffer size.- Returns:
thisservice/connection builder.- Throws:
com.typesafe.config.ConfigException- ifsize< zero.
-
outputBufferSize
public final T outputBufferSize(int size)
Sets the output buffer size for the connection. Ifsizeis zero, then the default output buffer size is used.- Parameters:
size- connection output buffer size.- Returns:
thisservice/connection builder.- Throws:
com.typesafe.config.ConfigException- ifsize< zero.
-
byteOrder
public final T byteOrder(ByteOrder byteOrder)
Sets the byte order used by the connection.- Parameters:
byteOrder- connection serialize and de-serialize messages using this byte order.- Returns:
thisservice/connection builder.- Throws:
com.typesafe.config.ConfigException- ifbyteOrderisnuill.
-
messageQueueSize
public final T messageQueueSize(int size)
Sets the maximum queue size for the connection. When the message queue size reaches this maximum, the connection is automatically closed. If zero, then the default maximum queue size is used.- Parameters:
size- message queue maximum size.- Returns:
thisservice/connection builder.- Throws:
com.typesafe.config.ConfigException- ifsize< zero.
-
heartbeatDelay
public final T heartbeatDelay(Duration delay)
Sets the heartbeat delay used for the connection. If no message is received afterdelaymilliseconds, then a heartbeat is sent. Ifdelayis zero, then heartbeating is turned off.- Parameters:
delay- millisecond heartbeat rate.- Returns:
thisservice/connection builder.- Throws:
com.typesafe.config.ConfigException- ifdelay< zero.
-
heartbeatReplyDelay
public final T heartbeatReplyDelay(Duration delay)
Sets the heartbeat reply delay used for the connection. The remote eBus application has this many milliseconds to reply to a heartbeat. If no reply is received afterdelaymilliseconds, the connection is closed. This value is ignored if the heartbeat delay is zero.- Parameters:
delay- millisecond heartbeat reply delay.- Returns:
thisservice/connection builder.- Throws:
com.typesafe.config.ConfigException- ifdelayisnullor < zero.
-
sslContext
public final T sslContext(SSLContext context)
Sets the SSL/TLS context used by a secure location. This should be called only if the connection type is set toEConfigure.ConnectionType.SECURE_TCP.- Parameters:
context- secure TCP context.- Returns:
thisserver/connection builder.- Throws:
com.typesafe.config.ConfigException- ifcontextisnull.
-
canPause
public final T canPause(boolean flag)
Sets a flag specifying whether accepted connections may be paused (true) or not.- Parameters:
flag- pause-able connection flag.- Returns:
thisconnection builder.
-
pauseConfig
public final T pauseConfig(EConfigure.PauseConfig pc)
Sets the pause configuration for the connection.canPause(boolean)must be set totruebefore setting the pause configuration.- Parameters:
pc- pause configuration- Returns:
thisserver/connection builder.- Throws:
com.typesafe.config.ConfigException- ifcanPause(boolean)returnsfalse(meaning the connection cannot be pause) or ifpcisnull.
-
retransmitDelay
public final T retransmitDelay(Duration delay)
Sets reliable UDP application message re-transmit delay.- Parameters:
delay- application message re-transmit delay.- Returns:
thisserver/connection builder.- Throws:
com.typesafe.config.ConfigException- ifdelayis eithernullor a negative value.
-
retransmitLimit
public final T retransmitLimit(int limit)
Sets reliable UDP application message re-transmit limit. This limit does not include the initial message transmit.- Parameters:
limit- maximum number of times an application message may be sent before declaring a reliable UDP connection lost.- Returns:
thisserver/connection builder.- Throws:
com.typesafe.config.ConfigException- iflimitis ≤ zero.
-
configuration
protected T configuration(EConfigure.AbstractConfig config)
Copies the values found inconfigto this configuration. This method is used to modify an existing immutable configuration.- Parameters:
config- copy this configuration's values.- Returns:
thisserver/connection builder.
-
loaderFlag
protected final T loaderFlag(boolean flag)
Sets the loader flag to the given value.- Parameters:
flag- loader flag value.- Returns:
thisserver/connection builder.
-
validate
protected Validator validate(Validator problems)
Validates builder arguments are correctly set, listing validation errors inproblemslist. This validation is "fail slow" meaning that a single validation call will determine all configuration errors.- Parameters:
problems- record configuration problems in this list.- Returns:
problemssovalidatecalls may be chained together.
-
-