Package org.hyperledger.fabric.gateway
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 Summary
Modifier and TypeMethodDescriptioncommitHandler
(CommitHandlerFactory commitHandler) Optional - Allows an alternative commit handler to be specified.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.connect()
Connects to the gateway using the specified options.discovery
(boolean enabled) Optional - Enable or disable service discovery for all transaction submissions for this gateway.Specifies the identity that is to be used to connect to the network.Specifies the identity that is to be used to connect to the network.networkConfig
(InputStream config) Specifies the common connection profile.networkConfig
(Path config) Specifies the path to the common connection profile.queryHandler
(QueryHandlerFactory queryHandler) Optional - Allows an alternative query handler to be specified.
-
Method Details
-
networkConfig
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
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
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
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
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
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
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
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.
-
connect
Gateway connect()Connects to the gateway using the specified options.- Returns:
- The connected
Gateway
object.
-