Package net.sf.eBus.config
Class EConfigure.ServerBuilder
- java.lang.Object
-
- net.sf.eBus.config.EConfigure.AbstractBuilder<EConfigure.ServerBuilder>
-
- net.sf.eBus.config.EConfigure.ServerBuilder
-
- Enclosing class:
- EConfigure
public static final class EConfigure.ServerBuilder extends EConfigure.AbstractBuilder<EConfigure.ServerBuilder>
Constructs anEConfigure.Serviceinstance based on the parameters set via this builder's API. The minimally allowed configuration is the service name, connection type and port. The remaining parameters are set to the following defaults:-
connection type:
EConfigure.ConnectionType.TCP- plain text TCP connection. -
address filter:
null- no address filter applied. - input buffer size: zero - use system default buffer size.
- output buffer size: zero - use system default buffer size.
- byte order: little-endian.
- maximum message queue size: zero - unlimited queue size.
-
service selector thread:
AsyncChannel.defaultSelector. -
accepted connection select thread:
AsyncChannel.defaultSelector. - heartbeat millisecond delay: zero - heartbeating off.
- heartbeat millisecond reply delay: zero - wait indefinitely for a reply.
If either the service name or address are not set, then
build()will throw an exception.Example building an
EServerfinal AddressFilter filter = ...; final SSLContext secureContext = ...; final EConfigure.ServerBuilder builder = EConfigure.serverBuilder(); EServer.openServer(builder.name("AppServer") .address(6789) .connectionType(EConfigure.ConnectionType.SECURE_TCP) .sslContext(secureContext) .addressFilter(filter) .inputBufferSize(1_024) .outputBufferSize(1_024) .byteOrder(ByteOrder.BIG_ENDIAN) .messageQueueSize(10_000) .serviceSelector("svcSelector") .connectionSelector("connSelector") .heartbeatDelay(60_000L) .heartbeatReplyDelay(30_000L) .build());- Author:
- Charles W. Rapp
- See Also:
EConfigure.ConnectionBuilder
-
-
Field Summary
-
Fields inherited from class net.sf.eBus.config.EConfigure.AbstractBuilder
mByteOrder, mCanPause, mHbDelay, mHbReplyDelay, mInputBufferSize, mLoaderFlag, mMsgQueueSize, mName, mOutputBufferSize, mPauseConfig, mRetransmitDelay, mRetransmitLimit, mSSLContext
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EConfigure.ServerBuilderaddress(InetSocketAddress address)Sets the service TCP host and address.EConfigure.ServerBuilderaddressFilter(AddressFilter filter)Sets the optional service address filter.EConfigure.Servicebuild()Returns the eBus service configuration built from the previously set parameters.EConfigure.ServerBuilderconfiguration(EConfigure.Service config)Copies in the settings fromconfigto this builder.EConfigure.ServerBuilderconnectionSelector(String selector)Sets the selector used for accepted TCP connections.EConfigure.ServerBuilderport(int port)Set service TCP to given port and local wildcard address.EConfigure.ServerBuilderserviceSelector(String selector)Sets the selector used for the service connection.protected Validatorvalidate(Validator problems)Validates the builder parameters.-
Methods inherited from class net.sf.eBus.config.EConfigure.AbstractBuilder
byteOrder, canPause, configuration, connectionType, heartbeatDelay, heartbeatReplyDelay, inputBufferSize, loaderFlag, messageQueueSize, name, outputBufferSize, pauseConfig, retransmitDelay, retransmitLimit, sslContext
-
-
-
-
Method Detail
-
configuration
public EConfigure.ServerBuilder configuration(EConfigure.Service config)
Copies in the settings fromconfigto this builder. This method is provided for making changes to an existing configuration sinceEConfigure.Serviceis immutable.if
configisnull, then nothing is done and the builder remains unchanged.- Parameters:
config- copy settings from this configuration.- Returns:
thisservice builder.
-
port
public EConfigure.ServerBuilder port(int port)
Set service TCP to given port and local wildcard address.- Parameters:
port- service TCP port.- Returns:
thisservice builder.- Throws:
com.typesafe.config.ConfigException- ifportis not a valid TCP port.
-
address
public EConfigure.ServerBuilder address(InetSocketAddress address)
Sets the service TCP host and address.- Parameters:
address- service TCP host and address.- Returns:
thisservice builder.- Throws:
com.typesafe.config.ConfigException- ifaddressisnull.
-
addressFilter
public EConfigure.ServerBuilder addressFilter(AddressFilter filter)
Sets the optional service address filter.- Parameters:
filter- the optional address filter. May benull.- Returns:
thisservice builder.
-
serviceSelector
public EConfigure.ServerBuilder serviceSelector(String selector)
Sets the selector used for the service connection.- Parameters:
selector- eBus selector name.- Returns:
thisservice builder.- Throws:
com.typesafe.config.ConfigException- ifnameisnullor empty or is not a known selector.
-
connectionSelector
public EConfigure.ServerBuilder connectionSelector(String selector)
Sets the selector used for accepted TCP connections.- Parameters:
selector- eBus selector name.- Returns:
thisservice builder.- Throws:
com.typesafe.config.ConfigException- ifnameisnullor empty or not a known selector.
-
build
public EConfigure.Service build()
Returns the eBus service configuration built from the previously set parameters.- Returns:
- an eBus service configuration.
- Throws:
com.typesafe.config.ConfigException- if any service name or service address is not set.
-
validate
protected Validator validate(Validator problems)
Validates the builder parameters. This validation is "fail slow" meaning that a single validation call will determine all configuration errors.- Overrides:
validatein classEConfigure.AbstractBuilder<EConfigure.ServerBuilder>- Parameters:
problems- record configuration problems in this list.- Returns:
problemssovalidatecalls may be chained together.
-
-