Package com.exonum.binding.core.service
Interface Configuration
public interface Configuration
Configuration parameters of Exonum service.
Network administrators agree on and pass the configuration parameters as a service-specific protobuf message when adding that service instance to the network. After Exonum starts the service, it passes the configuration parameters to the newly created service instance.
Services that have few arguments are encouraged to use the standard protobuf
message Service.ServiceConfiguration
. It supports common text-based configuration formats.
Reconfiguration of a started service may be implemented with a supervisor service
and Configurable
interface.
-
Method Summary
Modifier and Type Method Description <T> T
getAsJson(java.lang.Class<T> configType)
Returns the configuration as an object of the given type decoded from the underlying JSON.<MessageT extends com.google.protobuf.MessageLite>
MessageTgetAsMessage(java.lang.Class<MessageT> parametersType)
Returns the configuration parameters as a Protocol Buffers message.java.util.Properties
getAsProperties()
Returns the configuration as a properties.java.lang.String
getAsString()
Returns the configuration as a plain text string.Service.ServiceConfiguration.Format
getConfigurationFormat()
Returns the configuration format.
-
Method Details
-
getAsMessage
<MessageT extends com.google.protobuf.MessageLite> MessageT getAsMessage(java.lang.Class<MessageT> parametersType)Returns the configuration parameters as a Protocol Buffers message.This method is created for flexibility and if
Service.ServiceConfiguration
is used it is more convenient to some another method corresponding to the configuration format.- Parameters:
parametersType
- the type of a Protocol Buffers message in which the service configuration parameters are recorded in transactions starting the service instance- Throws:
java.lang.IllegalArgumentException
- if the actual type of the configuration parameters does not match the given type. Such mismatch might mean either a configuration error, when administrators pass the wrong parameters; or an error in the service itself- See Also:
StandardSerializers.protobuf(Class)
-
getConfigurationFormat
Service.ServiceConfiguration.Format getConfigurationFormat()Returns the configuration format.- Throws:
java.lang.IllegalArgumentException
- if the actual type of the configuration is not an instance ofService.ServiceConfiguration
-
getAsString
java.lang.String getAsString()Returns the configuration as a plain text string.- Throws:
java.lang.IllegalArgumentException
- if the actual type of the configuration is not an instance ofService.ServiceConfiguration
-
getAsJson
<T> T getAsJson(java.lang.Class<T> configType)Returns the configuration as an object of the given type decoded from the underlying JSON.- Type Parameters:
T
- the type of the configuration object- Parameters:
configType
- the class of T- Throws:
java.lang.IllegalArgumentException
- if the actual type of the configuration is not an instance ofService.ServiceConfiguration
; or the configuration is not in the JSON formatcom.google.gson.JsonParseException
- in case of JSON parse error
-
getAsProperties
java.util.Properties getAsProperties()Returns the configuration as a properties.- Throws:
java.lang.IllegalArgumentException
- if the actual type of the configuration is not an instance ofService.ServiceConfiguration
; or the configuration is not in the properties format; or an error occurs during parsing properties (i.e. malformed properties)
-