Class InstantiatingHttpJsonChannelProvider (2.42.0)

public final class InstantiatingHttpJsonChannelProvider implements TransportChannelProvider

InstantiatingHttpJsonChannelProvider is a TransportChannelProvider which constructs a ManagedHttpJsonChannel with a number of configured inputs every time getChannel(...) is called. These inputs include a port, a service address, and credentials.

The credentials can either be supplied directly (by providing a FixedCredentialsProvider to Builder.setCredentialsProvider()) or acquired implicitly from Application Default Credentials (by providing a GoogleCredentialsProvider to Builder.setCredentialsProvider()).

The client lib header and generator header values are used to form a value that goes into the http header of requests to the service.

Inheritance

java.lang.Object > InstantiatingHttpJsonChannelProvider

Static Methods

newBuilder()

public static InstantiatingHttpJsonChannelProvider.Builder newBuilder()
Returns
TypeDescription
InstantiatingHttpJsonChannelProvider.Builder

Methods

acceptsPoolSize() (deprecated)

public boolean acceptsPoolSize()

Deprecated. REST transport channel doesn't support channel pooling

Reports whether this provider allows pool size customization.

Returns
TypeDescription
boolean

getEndpoint()

public String getEndpoint()

The endpoint to be used for the channel.

Returns
TypeDescription
String

getTransportChannel()

public HttpJsonTransportChannel getTransportChannel()

Provides a Transport, which could either be a new instance for every call, or the same instance, depending on the implementation.

If #needsExecutor() is true, then #withExecutor(Executor) needs to be called first to provide an executor.

If #needsHeaders() is true, then #withHeaders(Map) needs to be called first to provide headers.

if #needsEndpoint() is true, then #withEndpoint(String) needs to be called first to provide an endpoint.

Returns
TypeDescription
HttpJsonTransportChannel
Exceptions
TypeDescription
IOException

getTransportName()

public String getTransportName()

The name of the transport.

This string can be used for identifying transports for switching logic.

Returns
TypeDescription
String

needsCredentials()

public boolean needsCredentials()

True if credentials are needed before channel creation.

Returns
TypeDescription
boolean

needsEndpoint()

public boolean needsEndpoint()

True if the TransportProvider has no endpoint set.

Returns
TypeDescription
boolean

needsExecutor() (deprecated)

public boolean needsExecutor()

Deprecated. If executor is not set, this channel provider will create channels with default executor defined in ManagedHttpJsonChannel.

True if the TransportProvider needs an executor.

Returns
TypeDescription
boolean

needsHeaders()

public boolean needsHeaders()

True if the TransportProvider has no headers provided.

Returns
TypeDescription
boolean

shouldAutoClose()

public boolean shouldAutoClose()

Indicates whether the TransportChannel should be closed by the containing client class.

Returns
TypeDescription
boolean

toBuilder()

public InstantiatingHttpJsonChannelProvider.Builder toBuilder()
Returns
TypeDescription
InstantiatingHttpJsonChannelProvider.Builder

withCredentials(Credentials credentials)

public TransportChannelProvider withCredentials(Credentials credentials)

Sets the credentials that will be applied before channel creation.

Parameter
NameDescription
credentialscom.google.auth.Credentials
Returns
TypeDescription
TransportChannelProvider

withEndpoint(String endpoint)

public TransportChannelProvider withEndpoint(String endpoint)

Sets the endpoint to use when constructing a new TransportChannel.

This method should only be called if #needsEndpoint() returns true.

Parameter
NameDescription
endpointString
Returns
TypeDescription
TransportChannelProvider

withExecutor(Executor executor)

public TransportChannelProvider withExecutor(Executor executor)

Sets the executor to use when constructing a new TransportChannel.

Parameter
NameDescription
executorExecutor
Returns
TypeDescription
TransportChannelProvider

withExecutor(ScheduledExecutorService executor) (deprecated)

public TransportChannelProvider withExecutor(ScheduledExecutorService executor)
Parameter
NameDescription
executorScheduledExecutorService
Returns
TypeDescription
TransportChannelProvider

withHeaders(Map<String,String> headers)

public TransportChannelProvider withHeaders(Map<String,String> headers)

Sets the headers to use when constructing a new TransportChannel.

This method should only be called if #needsHeaders() returns true.

Parameter
NameDescription
headersMap<String,String>
Returns
TypeDescription
TransportChannelProvider

withPoolSize(int size) (deprecated)

public TransportChannelProvider withPoolSize(int size)

Deprecated. REST transport channel doesn't support channel pooling

Number of underlying transport channels to open. Calls will be load balanced across them.

Parameter
NameDescription
sizeint
Returns
TypeDescription
TransportChannelProvider