Class ClientContext (2.58.0) 
  
  
  
   
  
    
  
  
    
    
    
    
  Version 2.58.0keyboard_arrow_down  
  
 
    
    
    
    
      
  
  
  
    
public   abstract   class  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.
Static Methods
   
  create(ClientSettings settings) 
  
    
public   static   ClientContext   create ( ClientSettings   settings )  
  Instantiates the executor, credentials, and transport context based on the given client
 settings.
create(StubSettings settings) 
  
    
public   static   ClientContext   create ( StubSettings   settings )  
  Instantiates the executor, credentials, and transport context based on the given client
 settings.
newBuilder() 
  
    
public   static   ClientContext . Builder   newBuilder ()  
  Create a new ClientContext with default values
Constructors
   
  ClientContext() 
  
  Methods
   
  getBackgroundResources() 
  
    
public   abstract   List<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.
getClock() 
  
    
public   abstract   ApiClock   getClock ()  
  
  getCredentials() 
  
    
public   abstract   Credentials   getCredentials ()  
  
    
      
        Returns  
      
        Type Description  
      
        com.google.auth.Credentials  
     
  
  getDefaultCallContext() 
  
    
public   abstract   ApiCallContext   getDefaultCallContext ()  
  
  getEndpoint() 
  
    
public   abstract   String   getEndpoint ()  
  
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  getExecutor() 
  
    
public   abstract   ScheduledExecutorService   getExecutor ()  
  Gets the executor to use for running scheduled API call logic (such as retries and long-running
 operations).
getGdchApiAudience() 
  
    
public   abstract   String   getGdchApiAudience ()  
  Gets the API audience used when creating a Client that uses com.google.auth.oauth2.GdchCredentials 
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  
  
  
    
public   abstract   Map<String , String >  getHeaders ()  
  
  
  
  
    
protected   abstract   Map<String , String >  getInternalHeaders ()  
  
  getQuotaProjectId() 
  
    
public   abstract   String   getQuotaProjectId ()  
  
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  getStreamWatchdog() 
  
    
public   abstract   Watchdog   getStreamWatchdog ()  
  
  getStreamWatchdogCheckInterval() 
  
    
public   final   Duration   getStreamWatchdogCheckInterval ()  
  
Obsolete 
Use getStreamWatchdogCheckIntervalDuration() instead 
This feature is stable for usage in this major version, but may be deprecated in a future release.
 
This method is obsolete. Use #getStreamWatchdogCheckIntervalDuration()  instead.
    
      
        Returns  
      
        Type Description  
      
        org.threeten.bp.Duration  
     
  
  getStreamWatchdogCheckIntervalDuration() 
  
    
public   abstract   Duration   getStreamWatchdogCheckIntervalDuration ()  
  
  getTracerFactory() 
  
    
public   abstract   ApiTracerFactory   getTracerFactory ()  
  
Beta 
The surface for tracing is not stable yet and may change in the future. 
This feature is covered by the Pre-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 the ApiTracerFactory  that will be used to generate traces for operations.
getTransportChannel() 
  
    
public   abstract   TransportChannel   getTransportChannel ()  
  
  getUniverseDomain() 
  
    
public   abstract   String   getUniverseDomain ()  
  
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  toBuilder() 
  
    
public   abstract   ClientContext . Builder   toBuilder ()  
  
 
     
    
  
  
  
     
  
    
    
      
       
    
    
  
  
 
  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-10-29 UTC.
 
 
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-29 UTC."],[],[]]