Class ClientContext (2.54.1)

publicabstractclass ClientContext

Encapsulates client state, including executor, credentials, and transport channel.

Unlike ClientSettings which allows users to configure the client, ClientContext is intended to be used in generated code. Most users will not need to use it.

Inheritance

java.lang.Object > ClientContext

Static Methods

create(ClientSettings settings)

publicstaticClientContextcreate(ClientSettingssettings)

Instantiates the executor, credentials, and transport context based on the given client settings.

Parameter
Name Description
settings ClientSettings
Returns
Type Description
ClientContext
Exceptions
Type Description
IOException

create(StubSettings settings)

publicstaticClientContextcreate(StubSettingssettings)

Instantiates the executor, credentials, and transport context based on the given client settings.

Parameter
Name Description
settings StubSettings
Returns
Type Description
ClientContext
Exceptions
Type Description
IOException

newBuilder()

publicstaticClientContext.BuildernewBuilder()

Create a new ClientContext with default values

Returns
Type Description
ClientContext.Builder

Constructors

ClientContext()

publicClientContext()

Methods

getBackgroundResources()

publicabstractList<BackgroundResource>getBackgroundResources()

The objects that need to be closed in order to clean up the resources created in the process of creating this ClientContext. This will include the closeables from the transport context.

Returns
Type Description
List<BackgroundResource>

getClock()

publicabstractApiClockgetClock()
Returns
Type Description
ApiClock

getCredentials()

publicabstractCredentialsgetCredentials()
Returns
Type Description
com.google.auth.Credentials

getDefaultCallContext()

publicabstractApiCallContextgetDefaultCallContext()
Returns
Type Description
ApiCallContext

getEndpoint()

publicabstractStringgetEndpoint()
Returns
Type Description
String

getExecutor()

publicabstractScheduledExecutorServicegetExecutor()

Gets the executor to use for running scheduled API call logic (such as retries and long-running operations).

Returns
Type Description
ScheduledExecutorService

getGdchApiAudience()

publicabstractStringgetGdchApiAudience()

Gets the API audience used when creating a Client that uses com.google.auth.oauth2.GdchCredentials

Returns
Type Description
String

getHeaders()

publicabstractMap<String,String>getHeaders()
Returns
Type Description
Map<String,String>

getInternalHeaders()

protectedabstractMap<String,String>getInternalHeaders()
Returns
Type Description
Map<String,String>

getQuotaProjectId()

publicabstractStringgetQuotaProjectId()
Returns
Type Description
String

getStreamWatchdog()

publicabstractWatchdoggetStreamWatchdog()
Returns
Type Description
Watchdog

getStreamWatchdogCheckInterval()

publicfinalDurationgetStreamWatchdogCheckInterval()

This method is obsolete. Use #getStreamWatchdogCheckIntervalDuration() instead.

Returns
Type Description
org.threeten.bp.Duration

getStreamWatchdogCheckIntervalDuration()

publicabstractDurationgetStreamWatchdogCheckIntervalDuration()
Returns
Type Description
Duration

getTracerFactory()

publicabstractApiTracerFactorygetTracerFactory()

Gets the ApiTracerFactory that will be used to generate traces for operations.

Returns
Type Description
ApiTracerFactory

getTransportChannel()

publicabstractTransportChannelgetTransportChannel()
Returns
Type Description
TransportChannel

getUniverseDomain()

publicabstractStringgetUniverseDomain()
Returns
Type Description
String

toBuilder()

publicabstractClientContext.BuildertoBuilder()
Returns
Type Description
ClientContext.Builder

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年11月19日 UTC.