Class ClientContext


  • public class ClientContext
    extends java.lang.Object
    Configuration information provided by the LDClient when creating components.

    The getter methods in this class provide information about the initial configuration of the client, as well as its current state. This includes properties from LDConfig, and also values that are computed during initialization. It is preferable for components to copy properties from this class rather than to retain a reference to the entire LDConfig object.

    The actual implementation class may contain other properties that are only relevant to the built-in SDK components and are therefore not part of this base class; this allows the SDK to add its own context information as needed without disturbing the public API.

    Since:
    3.3.0
    • Method Detail

      • getBaseLogger

        public LDLogger getBaseLogger()
        The base logger for the SDK.
        Returns:
        a logger instance
      • getConfig

        public LDConfig getConfig()
        Returns the full configuration object. THIS IS A TEMPORARY METHOD that will be removed prior to release-- the goal is to NOT retain the full LDConfig in these components, but until we have moved more of the config properties into subconfiguration builders, this is necessary.
        Returns:
        the configuration object
      • getEnvironmentName

        public java.lang.String getEnvironmentName()
        Returns the configured environment name.
        Returns:
        the environment name
      • isEvaluationReasons

        public boolean isEvaluationReasons()
        Returns true if evaluation reasons are enabled.
        Returns:
        true if evaluation reasons are enabled
      • getHttp

        public HttpConfiguration getHttp()
        Returns the HTTP configuration.
        Returns:
        the HTTP configuration
      • getEvaluationContext

        public LDContext getEvaluationContext()
        Returns the current evaluation context as of the time that this component was created.
        Returns:
        the current evaluation context
      • isInBackground

        public boolean isInBackground()
        Returns true if the application was in the background at the time that this component was created.
        Returns:
        true if in the background
      • getMobileKey

        public java.lang.String getMobileKey()
        Returns the configured mobile key.

        In multi-environment mode, there is a separate ClientContext for each environment, corresponding to the LDClient instance for that environment.

        Returns:
        the mobile key
      • getPreviouslyInBackground

        public java.lang.Boolean getPreviouslyInBackground()
        Returns the previous background state.

        This is initially null when the SDK is initialized. It is set to true or false when the SDK is restarting the data source due to a state change, in case the data source might need to have different behavior depending on whether the state change included a change in foreground/background state.

        Returns:
        true if the application was in the background before the time that this component was created; false if it was in the foreground; or null if this is the first time the component is being created during the lifetime of the SDK
      • getServiceEndpoints

        public ServiceEndpoints getServiceEndpoints()
        Returns the base service URIs used by SDK components.
        Returns:
        the service endpoint URIs
      • isSetOffline

        public boolean isSetOffline()
        Returns true if the application has specified that the SDK should be offline.
        Returns:
        true if set to be offline