Class ClientContext


  • public abstract class ClientContext
    extends java.lang.Object
    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.

    • Constructor Detail

      • ClientContext

        public ClientContext()
    • Method Detail

      • getBackgroundResources

        public abstract java.util.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.
      • getExecutor

        public abstract java.util.concurrent.ScheduledExecutorService getExecutor()
        Gets the executor to use for running scheduled API call logic (such as retries and long-running operations).
      • getCredentials

        @Nullable
        public abstract com.google.auth.Credentials getCredentials()
      • getTransportChannel

        @Nullable
        public abstract TransportChannel getTransportChannel()
      • getHeaders

        public abstract java.util.Map<java.lang.String,​java.lang.String> getHeaders()
      • getInternalHeaders

        protected abstract java.util.Map<java.lang.String,​java.lang.String> getInternalHeaders()
      • getClock

        public abstract com.google.api.core.ApiClock getClock()
      • getDefaultCallContext

        public abstract ApiCallContext getDefaultCallContext()
      • getStreamWatchdog

        @Nullable
        public abstract Watchdog getStreamWatchdog()
      • getStreamWatchdogCheckInterval

        @Nonnull
        public abstract org.threeten.bp.Duration getStreamWatchdogCheckInterval()
      • getEndpoint

        @Nullable
        public abstract java.lang.String getEndpoint()
      • getQuotaProjectId

        @Nullable
        public abstract java.lang.String getQuotaProjectId()
      • getTracerFactory

        @BetaApi("The surface for tracing is not stable yet and may change in the future.")
        @Nonnull
        public abstract ApiTracerFactory getTracerFactory()
        Gets the ApiTracerFactory that will be used to generate traces for operations.
      • create

        public static ClientContext create​(ClientSettings settings)
                                    throws java.io.IOException
        Instantiates the executor, credentials, and transport context based on the given client settings.
        Throws:
        java.io.IOException
      • create

        public static ClientContext create​(StubSettings settings)
                                    throws java.io.IOException
        Instantiates the executor, credentials, and transport context based on the given client settings.
        Throws:
        java.io.IOException