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 port 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") .port(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, mSSLContext
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)Sets the service TCP port.EConfigure.ServerBuilderserviceSelector(String selector)Sets the selector used for the service connection.protected voidvalidate()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, 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)
Sets the service TCP port.- Parameters:
port- service TCP port.- Returns:
thisservice builder.- Throws:
com.typesafe.config.ConfigException- ifportis not a valid TCP port.
-
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 port is not set.
-
validate
protected void validate()
Validates the builder parameters. Called for effect only.- Overrides:
validatein classEConfigure.AbstractBuilder<EConfigure.ServerBuilder>- Throws:
com.typesafe.config.ConfigException- if a required parameter is not set or is not set to a valid value with respect to another parameter.
-
-