Class ClientContext (2.72.2)

publicabstractclassClientContext

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

UnlikeClientSettings 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
NameDescription
settingsClientSettings
Returns
TypeDescription
ClientContext
Exceptions
TypeDescription
IOException

create(StubSettings settings)

publicstaticClientContextcreate(StubSettingssettings)

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

Parameter
NameDescription
settingsStubSettings
Returns
TypeDescription
ClientContext
Exceptions
TypeDescription
IOException

newBuilder()

publicstaticClientContext.BuildernewBuilder()

Create a new ClientContext with default values

Returns
TypeDescription
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
TypeDescription
List<BackgroundResource>

getClock()

publicabstractApiClockgetClock()
Returns
TypeDescription
ApiClock

getCredentials()

publicabstractCredentialsgetCredentials()
Returns
TypeDescription
com.google.auth.Credentials

getDefaultCallContext()

publicabstractApiCallContextgetDefaultCallContext()
Returns
TypeDescription
ApiCallContext

getEndpoint()

publicabstractStringgetEndpoint()
Returns
TypeDescription
String

getExecutor()

publicabstractScheduledExecutorServicegetExecutor()

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

Returns
TypeDescription
ScheduledExecutorService

getGdchApiAudience()

publicabstractStringgetGdchApiAudience()

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

Returns
TypeDescription
String

getHeaders()

publicabstractMap<String,String>getHeaders()
Returns
TypeDescription
Map<String,String>

getInternalHeaders()

protectedabstractMap<String,String>getInternalHeaders()
Returns
TypeDescription
Map<String,String>

getQuotaProjectId()

publicabstractStringgetQuotaProjectId()
Returns
TypeDescription
String

getStreamWatchdog()

publicabstractWatchdoggetStreamWatchdog()
Returns
TypeDescription
Watchdog

getStreamWatchdogCheckInterval()

publicfinalDurationgetStreamWatchdogCheckInterval()
Returns
TypeDescription
org.threeten.bp.Duration

getStreamWatchdogCheckIntervalDuration()

publicabstractDurationgetStreamWatchdogCheckIntervalDuration()
Returns
TypeDescription
Duration

getTracerFactory()

publicabstractApiTracerFactorygetTracerFactory()

Beta

The surface for tracing is not stable yet and may change in the future.

This feature is covered by thePre-GA Offerings Terms of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

Gets theApiTracerFactory that will be used to generate traces for operations.

Returns
TypeDescription
ApiTracerFactory

getTransportChannel()

publicabstractTransportChannelgetTransportChannel()
Returns
TypeDescription
TransportChannel

getUniverseDomain()

publicabstractStringgetUniverseDomain()
Returns
TypeDescription
String

toBuilder()

publicabstractClientContext.BuildertoBuilder()
Returns
TypeDescription
ClientContext.Builder

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

Last updated 2025-12-17 UTC.