Class ConfigurationLoader
-
- All Implemented Interfaces:
-
java.lang.Runnable
public final class ConfigurationLoader extends HandlerThread
The main entry point, responsible for configuration retrieval, provider processing, retries, input and error callbacks. It attempts to retrieve configuration data from the queue of providers and returns the configuration data from the first successful provider.
By default, the initial queue contents are:
- MANAGED_CONFIGURATION_PROVIDER
- FILE_CONFIGURATION_PROVIDER
- DISCOVERY_SERVICE_CONFIGURATION_PROVIDER
- JSONServiceConfigurationProvider
During execution of loadConfiguration, each provider is queried for configuration data. If data is successfully retrieved, it is persisted using the specified persistConfiguration method and the onCompletion handler is called with the provider-id and success. The first provider encountered that requires input will cause the ConfigurationLoader to build a list of all of the providers that expect input and call the onInputRequired handler. Input is returned to the loader by calling processRequestedInputs and will be provided to the associated provider. The provider will then return the successful configuration data retrieved or call the onError handler (allowing new input processing). If an empty or null input is provided, all providers that expect input will be skipped. Therefore, if none of the remaining non-input expected providers successfully retrieve configuration data, the ConfigurationLoader will call the onCompletion handler with a null provider id and unsuccessful.
Users can override the default queue of providers by creating a ConfigurationLoader and adding the provider(s) of interest. Custom providers provide extensibility
-
-
Field Summary
Fields Modifier and Type Field Description public final ConfigurationLoaderCallback
callback
public final ConfigurationPersister
persistenceMethod
public final static int
MAX_PRIORITY
public final static int
MIN_PRIORITY
public final static int
NORM_PRIORITY
-
Constructor Summary
Constructors Constructor Description ConfigurationLoader(Context context, ConfigurationLoaderCallback callback)
Create the loader and assign the Notification callbacks. ConfigurationLoader(Context context, String applicationId, ConfigurationLoaderCallback callback)
Create the loader and assign the Notification callbacks. ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, UserInputs userInputs)
Create the loader and assign the Notification callbacks. ConfigurationLoader(Context context, String applicationId, ConfigurationLoaderCallback callback, UserInputs userInputs)
Create the loader and assign the Notification callbacks. ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, Array<ConfigurationProvider> providers)
Create the loader, assign the Notification callback handlers and override the default provider queue. ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, Array<ConfigurationProvider> providers, UserInputs userInputs)
Create the loader, assign the Notification callback handlers and override the default provider queue. ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, ConfigurationPersister persistenceMethod)
Create the loader, assign the Notification callback handlers and assign the method responsible for persisting the configuration data. ConfigurationLoader(Context context, String applicationId, ConfigurationLoaderCallback callback, ConfigurationPersister persistenceMethod)
Create the loader, assign the Notification callback handlers and assign the method responsible for persisting the configuration data. ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, ConfigurationPersister persistenceMethod, UserInputs userInputs)
Create the loader, assign the Notification callback handlers and assign the method responsible for persisting the configuration data. ConfigurationLoader(Context context, String applicationId, ConfigurationLoaderCallback callback, ConfigurationPersister persistenceMethod, UserInputs userInputs)
Create the loader, assign the Notification callback handlers and assign the method responsible for persisting the configuration data. ConfigurationLoader(ConfigurationLoaderCallback callback, Array<ConfigurationProvider> providers, ConfigurationPersister persistenceMethod)
Create the loader, assign the Notification callback, override the default provider queue and assign the method responsible for persisting the configuration data ConfigurationLoader(ConfigurationLoaderCallback callback, Array<ConfigurationProvider> providers, ConfigurationPersister persistenceMethod, UserInputs userInputs)
Create the loader, assign the Notification callback, override the default provider queue and assign the method responsible for persisting the configuration data
-
Method Summary
Modifier and Type Method Description ConfigurationLoaderCallback
getCallback()
Retrieve the Notification callback ConfigurationPersister
getPersistenceMethod()
Retrieve the Output handler callback Array<ProviderIdentifier>
getProviders()
Retrieve the provider queue, represented as an array of Provider Identifiers. boolean
loadConfiguration()
Starts a thread which will attempt to retrieve the configuration data from the queue of providers and store it using the designated persistence method. boolean
processRequestedInputs(@NonNull() UserInputs requestedInputs)
Provides user inputs to the load configuration thread so that it can continue processing. -
Methods inherited from class android.os.HandlerThread
getLooper, getThreadId, quit, quitSafely, run
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, start, stop, suspend, toString, yield
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ConfigurationLoader
ConfigurationLoader(Context context, ConfigurationLoaderCallback callback)
Create the loader and assign the Notification callbacks.- Parameters:
context
- An android Context providing access to the resourcescallback
- com.sap.cloud.mobile.foundation.configurationprovider.ConfigurationLoaderCallback
-
ConfigurationLoader
ConfigurationLoader(Context context, String applicationId, ConfigurationLoaderCallback callback)
Create the loader and assign the Notification callbacks.- Parameters:
context
- An android Context providing access to the resourcesapplicationId
- An Application Id to be used by the Discovery Service Provider.callback
- com.sap.cloud.mobile.foundation.configurationprovider.ConfigurationLoaderCallback
-
ConfigurationLoader
ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, UserInputs userInputs)
Create the loader and assign the Notification callbacks.- Parameters:
context
- An android Context providing access to the resourcescallback
- com.sap.cloud.mobile.foundation.configurationprovider.ConfigurationLoaderCallbackuserInputs
- Provide an initial set of UserInput values
-
ConfigurationLoader
ConfigurationLoader(Context context, String applicationId, ConfigurationLoaderCallback callback, UserInputs userInputs)
Create the loader and assign the Notification callbacks.- Parameters:
context
- An android Context providing access to the resourcesapplicationId
- An Application Id to be used by the Discovery Service Provider.callback
- com.sap.cloud.mobile.foundation.configurationprovider.ConfigurationLoaderCallbackuserInputs
- Provide an initial set of UserInput values
-
ConfigurationLoader
ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, Array<ConfigurationProvider> providers)
Create the loader, assign the Notification callback handlers and override the default provider queue.- Parameters:
context
- An android Context providing access to the resourcescallback
- A notification .ConfigurationLoaderCallback callbackproviders
- An array of .ConfigurationProvider ConfigurationProviders
-
ConfigurationLoader
ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, Array<ConfigurationProvider> providers, UserInputs userInputs)
Create the loader, assign the Notification callback handlers and override the default provider queue.- Parameters:
context
- An android Context providing access to the resourcescallback
- A notification .ConfigurationLoaderCallback callbackproviders
- An array of .ConfigurationProvider ConfigurationProvidersuserInputs
- Provide an initial set of userInput values
-
ConfigurationLoader
ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, ConfigurationPersister persistenceMethod)
Create the loader, assign the Notification callback handlers and assign the method responsible for persisting the configuration data.- Parameters:
context
- An android Context providing access to the resourcescallback
- A notification .ConfigurationLoaderCallback callbackpersistenceMethod
- A persistenceMethod that stores the configuration data
-
ConfigurationLoader
ConfigurationLoader(Context context, String applicationId, ConfigurationLoaderCallback callback, ConfigurationPersister persistenceMethod)
Create the loader, assign the Notification callback handlers and assign the method responsible for persisting the configuration data.- Parameters:
context
- An android Context providing access to the resourcesapplicationId
- An Application Id to be used by the Discovery Service Provider.callback
- A notification .ConfigurationLoaderCallback callbackpersistenceMethod
- A persistenceMethod that stores the configuration data
-
ConfigurationLoader
ConfigurationLoader(Context context, ConfigurationLoaderCallback callback, ConfigurationPersister persistenceMethod, UserInputs userInputs)
Create the loader, assign the Notification callback handlers and assign the method responsible for persisting the configuration data.- Parameters:
context
- An android Context providing access to the resourcescallback
- A notification .ConfigurationLoaderCallback callbackpersistenceMethod
- A persistenceMethod that stores the configuration datauserInputs
- Provide an initial set of UserInput values
-
ConfigurationLoader
ConfigurationLoader(Context context, String applicationId, ConfigurationLoaderCallback callback, ConfigurationPersister persistenceMethod, UserInputs userInputs)
Create the loader, assign the Notification callback handlers and assign the method responsible for persisting the configuration data.- Parameters:
context
- An android Context providing access to the resourcesapplicationId
- An Application Id to be used by the Discovery Service Provider.callback
- A notification .ConfigurationLoaderCallback callbackpersistenceMethod
- A persistenceMethod that stores the configuration datauserInputs
- Provide an initial set of UserInput values
-
ConfigurationLoader
ConfigurationLoader(ConfigurationLoaderCallback callback, Array<ConfigurationProvider> providers, ConfigurationPersister persistenceMethod)
Create the loader, assign the Notification callback, override the default provider queue and assign the method responsible for persisting the configuration data- Parameters:
callback
- A .ConfigurationLoaderCallback callbackproviders
- An array of .ConfigurationProvider ConfigurationProviderspersistenceMethod
- A persistenceMethod that stores the configuration data
-
ConfigurationLoader
ConfigurationLoader(ConfigurationLoaderCallback callback, Array<ConfigurationProvider> providers, ConfigurationPersister persistenceMethod, UserInputs userInputs)
Create the loader, assign the Notification callback, override the default provider queue and assign the method responsible for persisting the configuration data- Parameters:
callback
- A .ConfigurationLoaderCallback callbackproviders
- An array of .ConfigurationProvider ConfigurationProviderspersistenceMethod
- A persistenceMethod that stores the configuration datauserInputs
- Provide an initial set of UserInput values
-
-
Method Detail
-
getCallback
@NonNull() ConfigurationLoaderCallback getCallback()
Retrieve the Notification callback
- Returns:
The notification callback
-
getPersistenceMethod
@NonNull() ConfigurationPersister getPersistenceMethod()
Retrieve the Output handler callback
- Returns:
-
getProviders
@NonNull() Array<ProviderIdentifier> getProviders()
Retrieve the provider queue, represented as an array of Provider Identifiers.
- Returns:
The current queue of ProviderIdentifier
-
loadConfiguration
boolean loadConfiguration()
Starts a thread which will attempt to retrieve the configuration data from the queue of providers and store it using the designated persistence method. The returned configuration data will be from the first queries provider that returns data. If no provider is successful, then the thread terminates with failure. The OnCompletion callback will be invoked, indicating success or failure immediately before the thread terminates. The other callbacks, onInputRequired and onError, will be invoked when the first provider that needs input is tried and when an input required provider encounters an error, respectively.
- Returns:
true if the thread was started and false if the thread was already running.
-
processRequestedInputs
boolean processRequestedInputs(@NonNull() UserInputs requestedInputs)
Provides user inputs to the load configuration thread so that it can continue processing. This method must be called in response to the onInputRequired and onError callback method invocations. If this is not called after either of these methods are invoked, the loadConfiguration method will not complete and the load configuration thread will run indefinitely.
- Parameters:
requestedInputs
- A UserInputs object.- Returns:
true if the load configuration thread is running and the inputs were successfully handed to it, false otherwise. Will return false if loadConfiguration() was not called prior to this or has already completed or if the message could not be queued.
-
-
-
-