Interface Gateway.Builder

Enclosing interface:
Gateway

public static interface Gateway.Builder
The Gateway Builder interface defines the options that can be configured prior to connection. An instance of builder is created using the static method Gateway.createBuilder(). Every method on the builder object will return a reference to the same builder object allowing them to be chained together in a single line.
  • Method Details

    • networkConfig

      Gateway.Builder networkConfig(Path config) throws IOException
      Specifies the path to the common connection profile.
      Parameters:
      config - The path to the common connection profile.
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
      Throws:
      IOException - if the config file does not exist, or is not JSON or YAML format, or contains invalid information.
    • networkConfig

      Gateway.Builder networkConfig(InputStream config) throws IOException
      Specifies the common connection profile.
      Parameters:
      config - The common connection profile YAML or JSON content.
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
      Throws:
      IOException - if the common connection profile is not JSON or YAML format, or contains invalid information.
    • identity

      Gateway.Builder identity(Wallet wallet, String id) throws IOException
      Specifies the identity that is to be used to connect to the network. All operations under this gateway connection will be performed using this identity.
      Parameters:
      wallet - The wallet object containing the identity.
      id - The name of the identity stored in the wallet.
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
      Throws:
      IOException - if the specified identity can not be loaded from the wallet.
    • identity

      Gateway.Builder identity(Identity identity)
      Specifies the identity that is to be used to connect to the network. All operations under this gateway connection will be performed using this identity.
      Parameters:
      identity - An identity
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
    • commitHandler

      Gateway.Builder commitHandler(CommitHandlerFactory commitHandler)
      Optional - Allows an alternative commit handler to be specified. The commit handler defines how client code should wait to receive commit events from peers following submit of a transaction.

      Default commit handler implementations are defined in DefaultCommitHandlers.

      Parameters:
      commitHandler - A commit handler implementation.
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
    • queryHandler

      Gateway.Builder queryHandler(QueryHandlerFactory queryHandler)
      Optional - Allows an alternative query handler to be specified. The query handler defines the peers that should be used to evaluate transactions.

      Default query handler implementations are defined in DefaultQueryHandlers.

      Parameters:
      queryHandler - A query handler implementation.
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
    • commitTimeout

      Gateway.Builder commitTimeout(long timeout, TimeUnit timeUnit)
      Optional - Set the default maximum time to wait for commit events to be received from peers after submitting a transaction to the orderer.
      Parameters:
      timeout - the maximum time to wait.
      timeUnit - the time unit of the timeout argument.
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
    • discovery

      Gateway.Builder discovery(boolean enabled)
      Optional - Enable or disable service discovery for all transaction submissions for this gateway. Service discovery is disabled by default.
      Parameters:
      enabled - - true to enable service discovery
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
    • forceClose

      Gateway.Builder forceClose(boolean enabled)
      Optional - Enable or disable force immediate shutdown of the network connection. forceClose is enabled by default.
      Parameters:
      enabled - - true to enable force immediate shutdown.
      Returns:
      The builder instance, allowing multiple configuration options to be chained.
    • connect

      Gateway connect()
      Connects to the gateway using the specified options.
      Returns:
      The connected Gateway object.