Package com.kristensoft.kdc
Class Parameters.Builder<T extends Parameters.Builder<T>>
- java.lang.Object
-
- com.kristensoft.kdc.Parameters.Builder<T>
-
- Type Parameters:
T- the concrete builder type.
- Direct Known Subclasses:
ClientParameters.Builder,ServerParameters.Builder
- Enclosing class:
- Parameters
public abstract static class Parameters.Builder<T extends Parameters.Builder<T>> extends Object
Base builder for configuring common KDC communication parameters. Protocol-specific parameter builders extend this class to provide additional configuration and create the corresponding parameter object.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TaddWhiteListEntry(String whitelistEntry)Adds a class or package entry to the deserialization whitelist.abstract Parametersbuild()Builds the parameters using the configuration specified by this builder.<A extends API>
TregisterApi(Class<A> apiClazz, API api)Registers an API implementation for the specified API class.TregisterApi(String apiClazzName, API api)Registers an API implementation using the fully qualified name of the API class.TregisterApis(Map<String,API> apiMap)Registers multiple API implementations with this builder.TwithAutoStart(boolean autoStart)Sets whether the communication entity starts automatically.TwithBindAddress(int port)Sets the local port to which the communication entity binds, using the local loopback address as the bind address.TwithBindAddress(String host, int port)Sets the local host and port to which the communication entity binds.TwithBindAddress(InetSocketAddress bindAddress)Sets the local network address to which the communication entity binds.TwithCompressed(boolean compressed)Sets whether compression is enabled for serialized agent data.TwithConnectionQueuePoolSize(int connectionQueuePoolSize)Sets the number of worker threads in the connection queue thread pool.TwithCrc(boolean crc)Sets whether CRC integrity checking is enabled for serialized agent data.TwithEncryptionKey(com.kristensoft.ko.EncryptionKey key)Sets the encryption key used to encrypt and decrypt serialized agent data.TwithLatencyMode(boolean on)Sets whether latency metrics collection is enabled.TwithLatencyReportingInterval(long interval)Sets the interval at which latency metrics are reported.TwithMaxReceivedBufferSize(int size)Sets the maximum size of the receive buffer, in bytes.TwithMaxSendBufferSize(int size)Sets the maximum size of the send buffer, in bytes.TwithSerializationFormat(com.kristensoft.ko.KristenObjectsSerializer.SerializationFormat serializationFormat)Sets the serialization format used to serialize agent data.TwithWhiteList(List<String> whiteList)Sets additional class and package entries permitted during deserialization.
-
-
-
Method Detail
-
build
public abstract Parameters build()
Builds the parameters using the configuration specified by this builder.- Returns:
- the configured parameters
-
withAutoStart
public T withAutoStart(boolean autoStart)
Sets whether the communication entity starts automatically.- Parameters:
autoStart-trueto enable automatic startup;falseotherwise.- Returns:
- this builder.
-
withBindAddress
public T withBindAddress(InetSocketAddress bindAddress)
Sets the local network address to which the communication entity binds.- Parameters:
bindAddress- the local bind address.- Returns:
- this builder.
-
withBindAddress
public T withBindAddress(String host, int port)
Sets the local host and port to which the communication entity binds.- Parameters:
host- the local host name or IP address.port- the local port.- Returns:
- this builder.
-
withBindAddress
public T withBindAddress(int port)
Sets the local port to which the communication entity binds, using the local loopback address as the bind address. A port of0allows the system to automatically assign an available port.- Parameters:
port- the local port, from 0 through 65535.- Returns:
- this builder.
- Throws:
IllegalArgumentException- if the port is outside the range 0 through 65535.
-
withMaxReceivedBufferSize
public T withMaxReceivedBufferSize(int size)
Sets the maximum size of the receive buffer, in bytes.- Parameters:
size- the maximum receive buffer size, in bytes; must be greater than0.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifsizeis less than or equal to0.
-
withMaxSendBufferSize
public T withMaxSendBufferSize(int size)
Sets the maximum size of the send buffer, in bytes.- Parameters:
size- the maximum send buffer size, in bytes; must be greater than0.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifsizeis less than or equal to0.
-
withCompressed
public T withCompressed(boolean compressed)
Sets whether compression is enabled for serialized agent data.- Parameters:
compressed-trueto enable compression;falseotherwise.- Returns:
- this builder.
-
withEncryptionKey
public T withEncryptionKey(com.kristensoft.ko.EncryptionKey key)
Sets the encryption key used to encrypt and decrypt serialized agent data. A value ofnulldisables encryption.- Parameters:
key- the encryption key, ornullto disable encryption.- Returns:
- this builder.
-
withCrc
public T withCrc(boolean crc)
Sets whether CRC integrity checking is enabled for serialized agent data.- Parameters:
crc-trueto enable CRC integrity checking;falseotherwise.- Returns:
- this builder.
-
withConnectionQueuePoolSize
public T withConnectionQueuePoolSize(int connectionQueuePoolSize)
Sets the number of worker threads in the connection queue thread pool.- Parameters:
connectionQueuePoolSize- the number of worker threads; must be greater than0.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifconnectionQueuePoolSizeis less than or equal to0.- See Also:
Parameters.Defaults.DEFAULT_CONNECTION_QUEUE_POOL_SIZE
-
withWhiteList
public T withWhiteList(List<String> whiteList)
Sets additional class and package entries permitted during deserialization. An entry containing a fully qualified class name permits that class. An entry ending with a period, such as"com.mycompany.", permits classes whose fully qualified names begin with that package prefix. A wildcard entry ("*") permits all classes.- Parameters:
whiteList- the class and package whitelist; must not benulland must not containnullor blank entries.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifwhiteListisnull, or contains anullor blank entry.
-
registerApis
public T registerApis(Map<String,API> apiMap)
Registers multiple API implementations with this builder. The supplied registrations are added to any APIs already registered with the builder.- Parameters:
apiMap- the API registrations to add; must not benulland must not containnullAPI values.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifapiMapisnullor contains anullAPI value.
-
registerApi
public <A extends API> T registerApi(Class<A> apiClazz, API api)
Registers an API implementation for the specified API class.- Type Parameters:
A- the API type.- Parameters:
apiClazz- the API class to register; must not benull.api- the API implementation; must not benull.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifapiClazzorapiisnull.
-
registerApi
public T registerApi(String apiClazzName, API api)
Registers an API implementation using the fully qualified name of the API class.- Parameters:
apiClazzName- the fully qualified API class name; must not benullor blank.api- the API implementation; must not benull.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifapiClazzNameisnullor blank, or ifapiisnull.
-
addWhiteListEntry
public T addWhiteListEntry(String whitelistEntry)
Adds a class or package entry to the deserialization whitelist. An entry containing a fully qualified class name permits that class. An entry ending with a period, such as"com.mycompany.", permits classes whose fully qualified names begin with that package prefix. A wildcard entry ("*") permits all classes. Adding a specific entry removes an existing wildcard entry.- Parameters:
whitelistEntry- the class or package whitelist entry to add; must not benullor blank.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifwhitelistEntryisnullor blank.
-
withLatencyMode
public T withLatencyMode(boolean on)
Sets whether latency metrics collection is enabled.- Parameters:
on-trueto enable latency metrics collection;falseotherwise.- Returns:
- this builder.
-
withLatencyReportingInterval
public T withLatencyReportingInterval(long interval)
Sets the interval at which latency metrics are reported.- Parameters:
interval- the latency reporting interval, in milliseconds; must be greater than0.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifintervalis less than or equal to0.
-
withSerializationFormat
public T withSerializationFormat(com.kristensoft.ko.KristenObjectsSerializer.SerializationFormat serializationFormat)
Sets the serialization format used to serialize agent data.- Parameters:
serializationFormat- the serialization format; must not benull.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifserializationFormatisnull.- See Also:
Parameters.Defaults.DEFAULT_SERIALIZATION_MODE
-
-