Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConnectionParams

Contains connection parameters to connect to external services. They are used together with credential parameters, but usually stored separately from more protected sensitive values.

Configuration parameters

  • discovery_key: key to retrieve parameters from discovery service
  • protocol: connection protocol like http, https, tcp, udp
  • host: host name or IP address
  • port: port number
  • uri: resource URI or connection string with all parameters in it

In addition to standard parameters ConnectionParams may contain any number of custom parameters

see

ConfigParams

see

CredentialParams

see

ConnectionResolver

see

IDiscovery

Example

Example ConnectionParams object usage:

let connection = ConnectionParams.fromTuples(
    "protocol", "http",
    "host", "10.1.1.100",
    "port", "8080",
    "cluster", "mycluster"
);

let host = connection.getHost();                             // Result: "10.1.1.100"
let port = connection.getPort();                             // Result: 8080
let cluster = connection.getAsNullableString("cluster");     // Result: "mycluster"

Hierarchy

  • ConfigParams
    • ConnectionParams

Index

Constructors

constructor

  • Creates a new connection parameters and fills it with values.

    Parameters

    • Default value values: any = null

      (optional) an object to be converted into key-value pairs to initialize this connection.

    Returns ConnectionParams

Methods

addSection

  • addSection(section: string, sectionParams: ConfigParams): void
  • Adds 'sectionParams' to this ConfigParams object under the section named 'section'.

    Parameters

    • section: string

      name of the section, under which 'sectionParams' is to be added. The keys of 'sectionParams' will be renamed to "(section).<key's name>", when added to this ConfigParams object.

    • sectionParams: ConfigParams

      ConfigParams that are to be added under the section named 'section'.

    Returns void

append

  • append(map: any): void
  • Parameters

    • map: any

      map of items to append to this StringValueMap.

    Returns void

clear

  • clear(): any
  • Removes all values from this StringValueMap.

    Returns any

clone

  • clone(): any
  • Returns any

    a clone of this object.

get

  • get(key: string): string
  • Parameters

    • key: string

      key of the item to retrieve from this StringValueMap.

    Returns string

    the item stored by the given key.

getAsArray

  • getAsArray(key: string): AnyValueArray
  • see

    [[AnyValueArray]]

    see

    [[AnyValueArray.fromValue]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValueArray

    the item with the given key as an AnyValueArray object.

getAsArrayWithDefault

  • getAsArrayWithDefault(key: string, defaultValue: AnyValueArray): AnyValueArray
  • see

    [[AnyValueArray]]

    see

    getAsNullableArray

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: AnyValueArray

      value to use if the item with the given key cannot be converted into an AnyValueArray.

    Returns AnyValueArray

    the item with the given key as an AnyValueArray object or 'defaultValue', if conversion is not possible.

getAsBoolean

  • getAsBoolean(key: string): boolean
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns boolean

    the item with the given key as a boolean (or false as the default).

getAsBooleanWithDefault

  • getAsBooleanWithDefault(key: string, defaultValue: boolean): boolean
  • see

    [[BooleanConverter.toBooleanWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: boolean

      value to return if conversion is not possible.

    Returns boolean

    the item with the given key as a boolean or the defaultValue (if conversion is not possible).

getAsDateTime

  • getAsDateTime(key: string): Date
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns Date

    the item with the given key as a Datetime (or null as the default).

getAsDateTimeWithDefault

  • getAsDateTimeWithDefault(key: string, defaultValue: Date): Date
  • see

    [[DateTimeConverter.toDateTimeWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: Date

      value to return if conversion is not possible.

    Returns Date

    the item with the given key as a Datetime or the defaultValue (if conversion is not possible).

getAsDouble

  • getAsDouble(key: string): number
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a double (or 0 as the default).

getAsDoubleWithDefault

  • getAsDoubleWithDefault(key: string, defaultValue: number): number
  • see

    [[DoubleConverter.toDoubleWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: number

      value to return if conversion is not possible.

    Returns number

    the item with the given key as a double or the defaultValue (if conversion is not possible).

getAsFloat

  • getAsFloat(key: string): number
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a float (or 0 as the default).

getAsFloatWithDefault

  • getAsFloatWithDefault(key: string, defaultValue: number): number
  • see

    [[FloatConverter.toFloatWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: number

      value to return if conversion is not possible.

    Returns number

    the item with the given key as a float or the defaultValue (if conversion is not possible).

getAsInteger

  • getAsInteger(key: string): number
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as an integer (or 0 as the default).

getAsIntegerWithDefault

  • getAsIntegerWithDefault(key: string, defaultValue: number): number
  • see

    [[IntegerConverter.toIntegerWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: number

      value to return if conversion is not possible.

    Returns number

    the item with the given key as an integer or the defaultValue (if conversion is not possible).

getAsLong

  • getAsLong(key: string): number
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a long (or 0 as the default).

getAsLongWithDefault

  • getAsLongWithDefault(key: string, defaultValue: number): number
  • see

    [[LongConverter.toLongWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: number

      value to return if conversion is not possible.

    Returns number

    the item with the given key as a long or the defaultValue (if conversion is not possible).

getAsMap

  • getAsMap(key: string): AnyValueMap
  • see

    fromValue

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValueMap

    the item with the given key as an AnyValueMap object.

getAsMapWithDefault

  • getAsMapWithDefault(key: string, defaultValue: AnyValueMap): AnyValueMap
  • Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: AnyValueMap

      value to use if the item with the given key cannot be converted into an AnyValueMap.

    Returns AnyValueMap

    the item with the given key as an AnyValueMap object or 'defaultValue', if conversion is not possible.

getAsNullableArray

  • getAsNullableArray(key: string): AnyValueArray
  • see

    [[AnyValueArray]]

    see

    [[AnyValueArray.fromValue]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValueArray

    the item with the given key as a nullable AnyValueArray object (returns null if the item with the given key is null).

getAsNullableBoolean

  • getAsNullableBoolean(key: string): boolean
  • see

    [[BooleanConverter.toNullableBoolean]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns boolean

    the item with the given key as a nullable boolean.

getAsNullableDateTime

  • getAsNullableDateTime(key: string): Date
  • see

    [[DateTimeConverter.toNullableDateTime]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns Date

    the item with the given key as a nullable Datetime.

getAsNullableDouble

  • getAsNullableDouble(key: string): number
  • see

    [[DoubleConverter.toNullableDouble]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a nullable double.

getAsNullableFloat

  • getAsNullableFloat(key: string): number
  • see

    [[FloatConverter.toNullableFloat]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a nullable float.

getAsNullableInteger

  • getAsNullableInteger(key: string): number
  • see

    [[IntegerConverter.toNullableInteger]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a nullable integer.

getAsNullableLong

  • getAsNullableLong(key: string): number
  • see

    [[LongConverter.toNullableLong]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a nullable long.

getAsNullableMap

  • getAsNullableMap(key: string): AnyValueMap
  • see

    fromValue

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValueMap

    the item with the given key as a nullable AnyValueMap object (returns null if the item with the given key is null).

getAsNullableString

  • getAsNullableString(key: string): string
  • see

    [[StringConverter.toNullableString]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns string

    the item with the given key as a nullable string.

getAsNullableType

  • getAsNullableType<T>(type: TypeCode, key: string): T
  • Converts the item with the given key into a nullable object of type 'type' using [[TypeConverter.toNullableType]] and returns it.

    see

    [[TypeConverter.toNullableType]]

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode to be used in TypeConverter.toNullableType(TypeCode, value);

    • key: string

      key of the item to retrieve.

    Returns T

    the item with the given key as a nullable object of type 'type'.

getAsObject

  • getAsObject(key?: string): any
  • Parameters

    • Optional key: string

      key of the item to retrieve.

    Returns any

    the item with the given key without any conversions or all items (if 'key' is undefined or omitted).

getAsString

  • getAsString(key: string): string
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns string

    the item with the given key as a string (or null as the default).

getAsStringWithDefault

  • getAsStringWithDefault(key: string, defaultValue: string): string
  • see

    [[StringConverter.toStringWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: string

      value to return if conversion is not possible.

    Returns string

    the item with the given key as a string or the defaultValue (if conversion is not possible).

getAsType

  • getAsType<T>(type: TypeCode, key: string): T
  • Converts the item with the given key into an object of type 'type' using [[TypeConverter.toTypeWithDefault]] and returns it.

    see

    getAsTypeWithDefault

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode to be used in TypeConverter.toTypeWithDefault(TypeCode, value, null);

    • key: string

      key of the item to retrieve.

    Returns T

    the item with the given key as an object of type 'type' (or null as the default).

getAsTypeWithDefault

  • getAsTypeWithDefault<T>(type: TypeCode, key: string, defaultValue: T): T
  • Converts the item with the given key into an object of type 'type' using [[TypeConverter.toTypeWithDefault]] and returns it.

    see

    [[TypeConverter.toTypeWithDefault]]

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode to be used in TypeConverter.toTypeWithDefault(TypeCode, value, defaultValue);

    • key: string
    • defaultValue: T

      value to return if conversion is not possible.

    Returns T

    the item with the given key as an object of type 'type' or the defaultValue, if conversion is not possible.

getAsValue

  • getAsValue(key: string): AnyValue
  • see

    [[AnyValue]]

    see

    [[AnyValue.constructor]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValue

    the item with the given key as an AnyValue object.

getDiscoveryKey

  • getDiscoveryKey(): string
  • Gets the key to retrieve this connection from [[DiscoveryService]]. If this key is null, than all parameters are already present.

    see

    useDiscovery

    Returns string

    the discovery key to retrieve connection.

getHost

  • getHost(): string

getKeys

  • getKeys(): string[]
  • Returns string[]

    all of the keys that are contained in this StringValueMap as a list of strings.

getPort

  • getPort(): number

getProtocol

  • getProtocol(defaultValue?: string): string
  • Gets the connection protocol.

    Parameters

    • Default value defaultValue: string = null

      (optional) the default protocol

    Returns string

    the connection protocol or the default value if it's not set.

getSection

  • getSection(section: string): ConfigParams
  • Parameters

    • section: string

      name of the section to retrieve configuration parameters from.

    Returns ConfigParams

    all configuration parameters that belong to the section named 'section'.

    Example key "Section-1.Subsection-1-1.Key-1-1-1" contains the section named "Section-1". Calling getSection("Section-1") would return a ConfigParams object containing the key "Subsection-1-1.Key-1-1-1"

getSectionNames

  • getSectionNames(): string[]
  • Returns string[]

    the names of all sections that are present in this object's complex keys.

    Example key "Section-1.Subsection-1-1.Key-1-1-1" contains the section named "Section-1".

getUri

  • getUri(): string
  • Gets the resource URI or connection string. Usually it includes all connection parameters in it.

    Returns string

    the resource URI or connection string.

length

  • length(): number
  • Returns number

    the number of key-value pairs stored in this StringValueMap.

override

  • override(configParams: ConfigParams): ConfigParams
  • Overrides the configuration parameters stored in this object with the ones in 'configParams'. If a configuration is already set in this ConfigParams object, it will be overwritten by the value in 'configParams' with the same key.

    see

    setDefaults

    Parameters

    • configParams: ConfigParams

      configuration parameters to override the parameters of this object with.

    Returns ConfigParams

    ConfigParams object with overridden parameters.

put

  • put(key: string, value: any): any
  • Parameters

    • key: string

      the key by which to insert the given value.

    • value: any

      the value to insert into this StringValueMap by the given key.

    Returns any

remove

  • remove(key: string): void
  • Parameters

    • key: string

      key of the item to remove.

    Returns void

setAsObject

  • setAsObject(key: any, value?: any): void
  • see

    [[MapConverter.toMap]]

    Parameters

    • key: any

      the key by which to set the 'value' passed.

    • Optional value: any

      the value to set in this StringValueMap with the given 'key'. If 'key' is omitted, then this StringValueMap will be set (cleared and filled anew) using 'value'. In this case 'value' will be converted to a map using "MapConverter.toMap(value)" and set to this StringValueMap.

    Returns void

setDefaults

  • setDefaults(defaultConfigParams: ConfigParams): ConfigParams
  • Sets the default configurations for this ConfigParams object, based on the default configuration parameters passed in 'defaultConfigParams'. If a configuration is already set in this ConfigParams object, it will not be overwritten by the default value in 'defaultConfigParams' with the same key.

    see

    override

    Parameters

    • defaultConfigParams: ConfigParams

      the default configuration parameters to use.

    Returns ConfigParams

    this ConfigParams object with the newly set defaults.

setDiscoveryKey

  • setDiscoveryKey(value: string): void
  • Sets the key to retrieve these parameters from [[DiscoveryService]].

    Parameters

    • value: string

      a new key to retrieve connection.

    Returns void

setHost

  • setHost(value: string): void

setPort

  • setPort(value: number): void

setProtocol

  • setProtocol(value: string): void

setUri

  • setUri(value: string): void
  • Sets the resource URI or connection string.

    Parameters

    • value: string

      a new resource URI or connection string.

    Returns void

toString

  • toString(): string
  • Returns string

    this StringValueMap as a semicolon-separated values string.

    Example: "key1=value1;key2;key3=value3".

useDiscovery

  • useDiscovery(): boolean
  • Checks if these connection parameters shall be retrieved from [[DiscoveryService]]. The connection parameters are redirected to [[DiscoveryService]] when discovery_key parameter is set.

    see

    getDiscoveryKey

    Returns boolean

    true if connection shall be retrieved from [[DiscoveryService]]

Static fromConfig

  • Retrieves a single ConnectionParams from configuration parameters from "connection" section. If "connections" section is present instead, then is returns only the first connection element.

    see

    manyFromConfig

    Parameters

    • config: ConfigParams

      ConnectionParams, containing a section named "connection(s)".

    Returns ConnectionParams

    the generated ConnectionParams object.

Static fromMaps

  • fromMaps(...maps: any[]): StringValueMap
  • Static method for creating a StringValueMap using the maps passed as parameters.

    Parameters

    • Rest ...maps: any[]

      the maps passed to this method to create a StringValueMap with.

    Returns StringValueMap

    the StringValueMap created.

Static fromString

  • Creates a new ConnectionParams object filled with key-value pairs serialized as a string.

    see

    [[StringValueMap.fromString]]

    Parameters

    • line: string

      a string with serialized key-value pairs as "key1=value1;key2=value2;..." Example: "Key1=123;Key2=ABC;Key3=2016-09-16T00:00:00.00Z"

    Returns ConnectionParams

    a new ConnectionParams object.

Static fromTuples

  • Creates a new ConnectionParams object filled with provided key-value pairs called tuples. Tuples parameters contain a sequence of key1, value1, key2, value2, ... pairs.

    Parameters

    • Rest ...tuples: any[]

      the tuples to fill a new ConnectionParams object.

    Returns ConnectionParams

    a new ConnectionParams object.

Static fromTuplesArray

  • fromTuplesArray(tuples: any[]): StringValueMap
  • Static method for creating a StringValueMap from an array of tuples.

    Parameters

    • tuples: any[]

      the key-value tuples array to initialize the new StringValueMap with.

    Returns StringValueMap

    the StringValueMap created and filled by the 'tuples' array provided.

Static fromValue

  • fromValue(value: any): ConfigParams
  • Static method that creates a ConfigParams object based on the values that are stored in the 'value' object's properties.

    see

    [[RecursiveObjectReader.getProperties]]

    Parameters

    • value: any

      configuration parameters in the form of an object with properties.

    Returns ConfigParams

    generated ConfigParams.

Static manyFromConfig

  • Retrieves all ConnectionParams from configuration parameters from "connections" section. If "connection" section is present instead, than it returns a list with only one ConnectionParams.

    Parameters

    • config: ConfigParams

      a configuration parameters to retrieve connections

    Returns ConnectionParams[]

    a list of retrieved ConnectionParams

Static mergeConfigs

  • mergeConfigs(...configs: ConfigParams[]): ConfigParams
  • Static method that can merge two or more ConfigParams into one.

    see

    [[StringValueMap.fromMaps]]

    Parameters

    • Rest ...configs: ConfigParams[]

      the ConfigParams that are to be merged into one ConfigParams object. The order in which the ConfigParams are passed to this method is important, as it regulates which values to keep in the case of identical complex keys (the ConfigParams passed later/last override the values of other ConfigParams with the same key).

    Returns ConfigParams

    merged ConfigParams.

Generated using TypeDoc