org.hyperledger.fabric.gateway

## 接口 Gateway.Builder

- 封闭接口:
    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.

- - ### 方法概要

    所有方法 实例方法 抽象方法
    限定符和类型 | 方法和说明
    --- | ---
    `Gateway.Builder` | `commitHandler(CommitHandlerFactory commitHandler)` Optional - Allows an alternative commit handler to be specified.
    `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.
    `Gateway` | `connect()` Connects to the gateway using the specified options.
    `Gateway.Builder` | `discovery(boolean enabled)` Optional - Enable or disable service discovery for all transaction submissions for this gateway.
    `Gateway.Builder` | `identity(Identity identity)` Specifies the identity that is to be used to connect to the network.
    `Gateway.Builder` | `identity(Wallet wallet, String id)` Specifies the identity that is to be used to connect to the network.
    `Gateway.Builder` | `networkConfig(InputStream config)` Specifies the common connection profile.
    `Gateway.Builder` | `networkConfig(Path config)` Specifies the path to the common connection profile.
    `Gateway.Builder` | `queryHandler(QueryHandlerFactory queryHandler)` Optional - Allows an alternative query handler to be specified.

- - ### 方法详细资料

    - #### networkConfig

          Gateway.Builder networkConfig(Path config)
                                 throws IOException

      Specifies the path to the common connection profile.
      参数:
        `config` - The path to the common connection profile.
      返回:
        The builder instance, allowing multiple configuration options to be chained.
      抛出:
        `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.
      参数:
        `config` - The common connection profile YAML or JSON content.
      返回:
        The builder instance, allowing multiple configuration options to be chained.
      抛出:
        `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.
      参数:
        `wallet` - The wallet object containing the identity.
        `id` - The name of the identity stored in the wallet.
      返回:
        The builder instance, allowing multiple configuration options to be chained.
      抛出:
        `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.
      参数:
        `identity` - An identity
      返回:
        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`.

      参数:
        `commitHandler` - A commit handler implementation.
      返回:
        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`.

      参数:
        `queryHandler` - A query handler implementation.
      返回:
        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.
      参数:
        `timeout` - the maximum time to wait.
        `timeUnit` - the time unit of the timeout argument.
      返回:
        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.
      参数:
        `enabled` - - true to enable service discovery
      返回:
        The builder instance, allowing multiple configuration options to be chained.

    - #### connect

          Gateway connect()

      Connects to the gateway using the specified options.
      返回:
        The connected `Gateway` object.

Copyright © 2023. All rights reserved.