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.

    See Also:
    Service.initialize(ExecutionContext, Configuration), Configurable
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> T getAsJson​(Class<T> configType)
      Returns the configuration as an object of the given type decoded from the underlying JSON.
      <MessageT extends com.google.protobuf.MessageLite>
      MessageT
      getAsMessage​(Class<MessageT> parametersType)
      Returns the configuration parameters as a Protocol Buffers message.
      Properties getAsProperties()
      Returns the configuration as a properties.
      String getAsString()
      Returns the configuration as a plain text string.
      com.exonum.binding.common.messages.Service.ServiceConfiguration.Format getConfigurationFormat()
      Returns the configuration format.
    • Method Detail

      • getAsMessage

        <MessageT extends com.google.protobuf.MessageLite> MessageT getAsMessage​(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:
        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

        com.exonum.binding.common.messages.Service.ServiceConfiguration.Format getConfigurationFormat()
        Returns the configuration format.
        Throws:
        IllegalArgumentException - if the actual type of the configuration is not an instance of Service.ServiceConfiguration
      • getAsString

        String getAsString()
        Returns the configuration as a plain text string.
        Throws:
        IllegalArgumentException - if the actual type of the configuration is not an instance of Service.ServiceConfiguration
      • getAsJson

        <T> T getAsJson​(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:
        IllegalArgumentException - if the actual type of the configuration is not an instance of Service.ServiceConfiguration; or the configuration is not in the JSON format
        com.google.gson.JsonParseException - in case of JSON parse error
      • getAsProperties

        Properties getAsProperties()
        Returns the configuration as a properties.
        Throws:
        IllegalArgumentException - if the actual type of the configuration is not an instance of Service.ServiceConfiguration; or the configuration is not in the properties format; or an error occurs during parsing properties (i.e. malformed properties)