Class ConnectorParameter.ConnectorParameterBuilder

java.lang.Object
de.iip_ecosphere.platform.connectors.ConnectorParameter.ConnectorParameterBuilder
Enclosing class:
ConnectorParameter

public static class ConnectorParameter.ConnectorParameterBuilder extends Object
Builds a connector parameter object.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • ConnectorParameterBuilder

      private ConnectorParameterBuilder()
      Prevents external creation.
  • Method Details

    • newBuilder

      public static ConnectorParameter.ConnectorParameterBuilder newBuilder(String host, int port)
      Creates a new connector parameter builder with required basic information. Schema is set to ConnectorParameter.DEFAULT_SCHEMA.
      Parameters:
      host - the host to connect to
      port - the port to connect to
      Returns:
      the connector parameter builder
    • newBuilder

      public static ConnectorParameter.ConnectorParameterBuilder newBuilder(String host, int port, de.iip_ecosphere.platform.support.Schema schema)
      Creates a new connector parameter builder with required basic information.
      Parameters:
      host - the host to connect to
      port - the port to connect to
      schema - protocol schema, usually (ConnectorParameter.DEFAULT_SCHEMA if value is null)
      Returns:
      the connector parameter builder
    • newBuilder

      public static ConnectorParameter.ConnectorParameterBuilder newBuilder(ConnectorParameter params, String host, Integer port, de.iip_ecosphere.platform.support.Schema schema)
      Creates a new connector parameter builder based on the given params.
      Parameters:
      params - the connector params to take information from
      host - the host name to override the value in params, may be null for the value from params.
      port - the port number to override the value in params, may be null for the value from params.
      schema - the schema to override the value in params, may be null for the value from params.
      Returns:
      the connector parameter builder
    • newBuilder

      Creates a new connector parameter builder based on the given params.
      Parameters:
      params - the connector params to take information from
      Returns:
      the connector parameter builder
    • newBuilder

      public static ConnectorParameter.ConnectorParameterBuilder newBuilder(de.iip_ecosphere.platform.support.ServerAddress addr)
      Creates a new connector parameter builder with required basic information.
      Parameters:
      addr - the server address
      Returns:
      the connector parameter builder
    • setService

      public ConnectorParameter.ConnectorParameterBuilder setService(de.iip_ecosphere.platform.support.iip_aas.NameplateSetup.Service service)
      Sets the optional service information to select upon.
      Parameters:
      service - the device service information the connector shall connect to
      Returns:
      this
    • setEndpointPath

      public ConnectorParameter.ConnectorParameterBuilder setEndpointPath(String endpointPath)
      Sets a connector-dependent endpoint path, a URL path. Optional, remains an empty string if not called.
      Parameters:
      endpointPath - the endpoint path
      Returns:
      this
    • setRequestTimeout

      public ConnectorParameter.ConnectorParameterBuilder setRequestTimeout(int requestTimeout)
      Sets the request timeout.
      Parameters:
      requestTimeout - the request timeout. Optional, if not called uses the default value of 5000 ms.
      Returns:
      this
    • setKeepAlive

      public ConnectorParameter.ConnectorParameterBuilder setKeepAlive(int keepAlive)
      Sets the keep alive time for connection heartbeats/reconnects (if supported).
      Parameters:
      keepAlive - the keep alive time. Optional, if not called uses the default value of 2000 ms.
      Returns:
      this
    • setNotificationInterval

      public ConnectorParameter.ConnectorParameterBuilder setNotificationInterval(int notificationInterval)
      Defines the notification interval, i.e., how frequently the connector shall look for new values. This may happen via events, notifications or polling depending on the connector implementation.
      Parameters:
      notificationInterval - the notification interval in ms, disabled if less than 1, default is 1000
      Returns:
      the polling period
    • setApplicationInformation

      public ConnectorParameter.ConnectorParameterBuilder setApplicationInformation(String applicationId, String applicationDescription)
      Sets connector-dependent application information. Optional, if not called both settings will remain empty strings.
      Parameters:
      applicationId - String/URL to identify the application.
      applicationDescription - application description.
      Returns:
      this
    • setAutoApplicationId

      public ConnectorParameter.ConnectorParameterBuilder setAutoApplicationId(boolean autoApplicationId)
      Defines whether the application identification is expected to be unique or shall be made unique upon first connect. May be ignored if not applicable.
      Parameters:
      autoApplicationId - true (default) for make unique, false else
      Returns:
      this
    • setIdentities

      public ConnectorParameter.ConnectorParameterBuilder setIdentities(Map<String,de.iip_ecosphere.platform.support.identities.IdentityToken> identityToken)
      Sets the endpoint identities. Optional, if not called, anonymous identity is assumed.
      Parameters:
      identityToken - the client identity token per endpoint URL (may be null for anonymous), an ConnectorParameter.ANY_ENDPOINT denotes just all endpoints
      Returns:
      this
    • setKeystoreKey

      public ConnectorParameter.ConnectorParameterBuilder setKeystoreKey(String keystoreKey)
      Sets up the optional TLS keystore key to be obtained from IdentityStore.
      Parameters:
      keystoreKey - the (logical) key to access the keystore (null for none)
      Returns:
      this
    • setKeyAlias

      Sets up optional TLS key alias.
      Parameters:
      alias - key alias, may be null for none/first match
      Returns:
      this
    • setHostnameVerification

      public ConnectorParameter.ConnectorParameterBuilder setHostnameVerification(boolean hostnameVerification)
      Defines whether TLS hostname verification shall be performed.
      Parameters:
      hostnameVerification - false for no verification, true else
      Returns:
      this
    • setCacheMode

      Defines the cache mode.
      Parameters:
      cacheMode - the cache mode
      Returns:
      this
    • setSpecificSetting

      public ConnectorParameter.ConnectorParameterBuilder setSpecificSetting(String key, Object value)
      Adds connector specific settings.
      Parameters:
      key - the key of the setting as defined by the connector
      value - the value of the setting
      Returns:
      this (builder style)
    • setSpecificSettingFromResource

      public ConnectorParameter.ConnectorParameterBuilder setSpecificSettingFromResource(String key, String resource, de.iip_ecosphere.platform.support.resources.ResourceResolver... resolver) throws IOException
      Adds connector specific settings by reading the setting value from a given resource.
      Parameters:
      key - the key of the setting as defined by the connector
      resource - the resource to read from
      resolver - optional resource resolver
      Returns:
      this (builder style)
      Throws:
      IOException
    • setSpecificSettingFromResourceSafe

      public ConnectorParameter.ConnectorParameterBuilder setSpecificSettingFromResourceSafe(String key, String resource, de.iip_ecosphere.platform.support.resources.ResourceResolver... resolver)
      Adds connector specific settings by reading the setting value as the contents of a given resource. Emits an error in case of an exception.
      Parameters:
      key - the key of the setting as defined by the connector
      resource - the resource to read from
      resolver - optional resource resolver
      Returns:
      this (builder style)
      See Also:
    • build

      public ConnectorParameter build()
      Creates the instance.
      Returns:
      the created instance