@ApiAudience.Public @ApiStability.Unstable public class AergoClientBuilder extends java.lang.Object implements ClientConfiguer<AergoClientBuilder>
Modifier and Type | Field and Description |
---|---|
protected Configuration |
configuration |
protected org.slf4j.Logger |
logger |
protected static java.util.Map<java.lang.Class<?>,Strategy> |
necessaryStrategyMap |
static java.lang.String |
SCOPE |
protected java.util.Map<java.lang.Class<?>,Strategy> |
strategyMap |
Constructor and Description |
---|
AergoClientBuilder() |
Modifier and Type | Method and Description |
---|---|
AergoClientBuilder |
addConfiguration(java.lang.String key,
java.lang.String value)
Add a configuration with
key and value . |
AergoClient |
build()
Build
AergoClient with the current context. |
protected Context |
buildContext() |
AergoClientBuilder |
withBlockingConnect()
Use blocking connection.
|
AergoClientBuilder |
withEndpoint(java.lang.String endpoint)
Provide an endpoint of aergo server.
|
AergoClientBuilder |
withNonBlockingConnect()
Use non-blocking connection.
|
AergoClientBuilder |
withPlainText()
Use plain text on connection.
|
AergoClientBuilder |
withRetry(int count,
long interval,
java.util.concurrent.TimeUnit unit)
If fails with non-connection error, after
interval count times. |
AergoClientBuilder |
withTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Set timeout for each request.
|
AergoClientBuilder |
withTransportSecurity(java.lang.String serverCommonName,
java.io.InputStream serverCertInputStream,
java.io.InputStream clientCertInputStream,
java.io.InputStream clientKeyInputStream)
Use transport security on connection.
|
AergoClientBuilder |
withTransportSecurity(java.lang.String serverCommonName,
java.lang.String serverCertPath,
java.lang.String clientCertPath,
java.lang.String clientKeyPath)
Use transport security on connection.
|
public static final java.lang.String SCOPE
protected static final java.util.Map<java.lang.Class<?>,Strategy> necessaryStrategyMap
protected final org.slf4j.Logger logger
protected final java.util.Map<java.lang.Class<?>,Strategy> strategyMap
protected Configuration configuration
public AergoClientBuilder addConfiguration(java.lang.String key, java.lang.String value)
ClientConfiguer
key
and value
.addConfiguration
in interface ClientConfiguer<AergoClientBuilder>
key
- a keyvalue
- a valuepublic AergoClientBuilder withEndpoint(java.lang.String endpoint)
ClientConfiguer
localhost:7845
withEndpoint
in interface ClientConfiguer<AergoClientBuilder>
endpoint
- aergo chain server endpointpublic AergoClientBuilder withNonBlockingConnect()
ClientConfiguer
ConnectStrategy
is already set, that will be
overridden.withNonBlockingConnect
in interface ClientConfiguer<AergoClientBuilder>
public AergoClientBuilder withBlockingConnect()
ClientConfiguer
ConnectStrategy
is already set, that will be
overridden. This method works for jdk 1.7 or higher.withBlockingConnect
in interface ClientConfiguer<AergoClientBuilder>
public AergoClientBuilder withTimeout(long timeout, java.util.concurrent.TimeUnit unit)
ClientConfiguer
withTimeout
in interface ClientConfiguer<AergoClientBuilder>
timeout
- time to time outunit
- time's unitpublic AergoClientBuilder withRetry(int count, long interval, java.util.concurrent.TimeUnit unit)
ClientConfiguer
interval
count
times. Default retry
count : 0, default retry interval : 5000 milliseconds.withRetry
in interface ClientConfiguer<AergoClientBuilder>
count
- retry count. If it is less than 0, set as 0interval
- interval value. If it's less than 0, set as 0unit
- interval unitpublic AergoClientBuilder withPlainText()
ClientConfiguer
withPlainText
in interface ClientConfiguer<AergoClientBuilder>
public AergoClientBuilder withTransportSecurity(java.lang.String serverCommonName, java.lang.String serverCertPath, java.lang.String clientCertPath, java.lang.String clientKeyPath)
ClientConfiguer
withTransportSecurity
in interface ClientConfiguer<AergoClientBuilder>
serverCommonName
- a server common nameserverCertPath
- a server certification pathclientCertPath
- a client certification pathclientKeyPath
- a client key path. Must be PKCS#8 formatpublic AergoClientBuilder withTransportSecurity(java.lang.String serverCommonName, java.io.InputStream serverCertInputStream, java.io.InputStream clientCertInputStream, java.io.InputStream clientKeyInputStream)
ClientConfiguer
withTransportSecurity
in interface ClientConfiguer<AergoClientBuilder>
serverCommonName
- a server common nameserverCertInputStream
- a server certification streamclientCertInputStream
- a client certification streamclientKeyInputStream
- a client key stream. Must be PKCS#8 formatpublic AergoClient build()
AergoClient
with the current context. If necessary strategy is not provided,fill
necessary strategy.AergoClient
protected Context buildContext()