Package com.seeq.link.sdk.interfaces
Interface ConfigService
- All Known Implementing Classes:
DefaultConfigService
public interface ConfigService
Provides methods to load and save configuration objects. The location of the data store is abstracted from the caller
at this level: Behind the scenes, the ConfigService may be retrieving configuration from Appserver and/or from the
local file system using
ConfigObjectProvider
. But that is not exposed to the agents/connectors.
This is the interface that agents/connectors will use to retrieve configuration data.-
Method Summary
Modifier and TypeMethodDescriptiongetGlobalArgument
(String argumentName) Deprecated.void
initialize
(FileConfigObjectProvider fileConfigObjectProvider, RemoteConfigObjectProvider remoteConfigObjectProvider) Initializes the service with itsFileConfigObjectProvider
(used to retrieve configuration from disk) and itsRemoteConfigObjectProvider
(used to retrieve the remote configuration).loadConfigObject
(String name, ConfigObject[] supportedConfigObjects) Loads a configuration Object from the config data store.void
registerChangeCallback
(String name, Consumer<String> callback) Registers a callback for when the configuration has changed.void
saveConfigObject
(String name, Object configObject) Saves a configuration Object to the config data store.void
Unregisters a callback previously registered.
-
Method Details
-
initialize
void initialize(FileConfigObjectProvider fileConfigObjectProvider, RemoteConfigObjectProvider remoteConfigObjectProvider) Initializes the service with itsFileConfigObjectProvider
(used to retrieve configuration from disk) and itsRemoteConfigObjectProvider
(used to retrieve the remote configuration).- Parameters:
fileConfigObjectProvider
- Interface used to retrieve configuration from disk.remoteConfigObjectProvider
- Interface used to retrieve remote configuration.
-
loadConfigObject
ConfigObject loadConfigObject(String name, ConfigObject[] supportedConfigObjects) throws IOException Loads a configuration Object from the config data store. This function requires an array of config objects to use as a means of discovering what Object type is encoded in the store.- Parameters:
name
- The name of configuration store, which will normally be the connector name.supportedConfigObjects
- An array of ConfigObject instances that represent the possible Object types that can be successfully retrieved from the store. If the persisted Object type does not match anything in the list, then the first item in the array is passed back (being effectively a means to have a 'default' config).- Returns:
- The configuration Object, which must be cast to a ConfigObject-derived class.
- Throws:
IOException
- Thrown if JSON file could not be successfully deserialized.
-
saveConfigObject
Saves a configuration Object to the config data store. The config object's type will be encoded in 'Version' field in the data store.- Parameters:
name
- The name of configuration store, which will normally be the connector name.configObject
- The configuration Object to serialize to the store.
-
getGlobalArgument
Deprecated.Deprecated: All configuration should now come from configuration files. Retrieves an argument that was passed in on the process's command line. These can be used to override saved configuration data, usually for testing purposes.- Parameters:
argumentName
- Name of the command line argument to retrieve.- Returns:
- Value of the command line argument.
-
registerChangeCallback
Registers a callback for when the configuration has changed.- Parameters:
name
- Name of the configuration object you're interested in.callback
- Callback function that takes the name as its only parameter.
-
unregisterChangeCallback
Unregisters a callback previously registered.- Parameters:
name
- Name of the configuration object you're interested in.
-