Class ClientContext
- java.lang.Object
-
- com.launchdarkly.sdk.android.subsystems.ClientContext
-
public class ClientContext extends java.lang.Object
Configuration information provided by theLDClient
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 entireLDConfig
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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClientContext(ClientContext copy)
ClientContext(java.lang.String mobileKey, IEnvironmentReporter environmentReporter, LDLogger baseLogger, LDConfig config, DataSourceUpdateSink dataSourceUpdateSink, java.lang.String environmentName, boolean evaluationReasons, LDContext evaluationContext, HttpConfiguration http, boolean inBackground, java.lang.Boolean previouslyInBackground, ServiceEndpoints serviceEndpoints, boolean setOffline)
Constructs an instance, specifying all properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LDLogger
getBaseLogger()
The base logger for the SDK.LDConfig
getConfig()
Returns the full configuration object.DataSourceUpdateSink
getDataSourceUpdateSink()
java.lang.String
getEnvironmentName()
Returns the configured environment name.IEnvironmentReporter
getEnvironmentReporter()
LDContext
getEvaluationContext()
Returns the current evaluation context as of the time that this component was created.HttpConfiguration
getHttp()
Returns the HTTP configuration.java.lang.String
getMobileKey()
Returns the configured mobile key.java.lang.Boolean
getPreviouslyInBackground()
Returns the previous background state.ServiceEndpoints
getServiceEndpoints()
Returns the base service URIs used by SDK components.boolean
isEvaluationReasons()
Returns true if evaluation reasons are enabled.boolean
isInBackground()
Returns true if the application was in the background at the time that this component was created.boolean
isSetOffline()
Returns true if the application has specified that the SDK should be offline.
-
-
-
Constructor Detail
-
ClientContext
public ClientContext(java.lang.String mobileKey, IEnvironmentReporter environmentReporter, LDLogger baseLogger, LDConfig config, DataSourceUpdateSink dataSourceUpdateSink, java.lang.String environmentName, boolean evaluationReasons, LDContext evaluationContext, HttpConfiguration http, boolean inBackground, java.lang.Boolean previouslyInBackground, ServiceEndpoints serviceEndpoints, boolean setOffline)
Constructs an instance, specifying all properties.- Parameters:
mobileKey
- seegetMobileKey()
environmentReporter
- seegetEnvironmentReporter()
baseLogger
- seegetBaseLogger()
config
- seegetConfig()
dataSourceUpdateSink
- seegetDataSourceUpdateSink()
environmentName
- seegetEnvironmentName()
evaluationReasons
- seeisEvaluationReasons()
evaluationContext
- seegetEvaluationContext()
http
- seegetHttp()
inBackground
- seeisInBackground()
previouslyInBackground
- seegetPreviouslyInBackground()
serviceEndpoints
- seegetServiceEndpoints()
setOffline
- seeisSetOffline()
-
ClientContext
protected ClientContext(ClientContext copy)
-
-
Method Detail
-
getEnvironmentReporter
public IEnvironmentReporter getEnvironmentReporter()
- Returns:
- the
IEnvironmentReporter
for this client context
-
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
-
getDataSourceUpdateSink
public DataSourceUpdateSink getDataSourceUpdateSink()
-
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 theLDClient
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
orfalse
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; ornull
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
-
-