Class MqttBrokerConfigBuilder


  • public class MqttBrokerConfigBuilder
    extends java.lang.Object
    Simple builder class to simplify the making of an MqttBrokerConfig instance.
    • Constructor Detail

      • MqttBrokerConfigBuilder

        public MqttBrokerConfigBuilder​(java.lang.String address)
        Creates an MqttBrokerConfigBuilder initialized with the specified MQTT broker address.
        Parameters:
        address - the address of the MQTT broker
    • Method Detail

      • willMessage

        public MqttBrokerConfigBuilder willMessage​(java.lang.String topic,
                                                   byte[] applicationMessage,
                                                   QoS qos,
                                                   boolean retain)
        Sets the Will Message on this builder.
        Parameters:
        topic - the topic name
        applicationMessage - the carried Application Message
        qos - the Quality of Service
        retain - the retained flag
        Returns:
        a reference to this object
        Throws:
        java.lang.IllegalArgumentException - in the following cases:
        • the specified qos is null
        • the specified topic is either null or empty
        See Also:
        MqttMessage, MqttBrokerConfig.getWillMessage()
      • keepAlive

        public MqttBrokerConfigBuilder keepAlive​(int keepAlive)
        Sets the keep alive interval expressed in seconds on this builder.
        Parameters:
        keepAlive - the keep alive interval in seconds
        Returns:
        a reference to this object
        See Also:
        MqttBrokerConfig.getKeepAlive()
      • connectionTimeout

        public MqttBrokerConfigBuilder connectionTimeout​(int connectionTimeout)
        Sets the connection timeout expressed in seconds on this builder.
        Parameters:
        connectionTimeout - the connection timeout in seconds
        Returns:
        a reference to this object
        See Also:
        MqttBrokerConfig.getConnectionTimeout()
      • clientIdPrefix

        public MqttBrokerConfigBuilder clientIdPrefix​(java.lang.String clientIdPrefix)
        Sets the ClientId prefix (to be used for shared connection) on this builder.
        Parameters:
        clientIdPrefix - the ClientId prefix
        Returns:
        a reference to this object
        See Also:
        MqttBrokerConfig.getClientIdPrefix()
      • truststorePath

        public MqttBrokerConfigBuilder truststorePath​(java.nio.file.Path truststorePath)
        Sets the absolute path to the JKS truststore on this builder.
        Parameters:
        truststorePath - the absolute to the JKS truststore
        Returns:
        a reference to this object
        See Also:
        SecurityParams.getTruststorePath()
      • truststorePassword

        public MqttBrokerConfigBuilder truststorePassword​(char[] truststorePassword)
        Sets the password for the JKS truststore on this builder.
        Parameters:
        truststorePassword - the password for the JKS truststore
        Returns:
        a reference to this object
        See Also:
        SecurityParams.getTruststorePassword()
      • keystorePath

        public MqttBrokerConfigBuilder keystorePath​(java.nio.file.Path keystorePath)
        Sets the absolute path to the JKS keystore on this builder.
        Parameters:
        keystorePath - the absolute path to the JKS keystore
        Returns:
        a reference to this object
        See Also:
        SecurityParams.getKeystorePath()
      • keystorePassword

        public MqttBrokerConfigBuilder keystorePassword​(char[] keystorePassword)
        Sets the password for the JKS keystore on this builder.
        Parameters:
        keystorePassword - the password for the JKS keystore.
        Returns:
        a reference to this object
        See Also:
        SecurityParams.getKeystorePassword()
      • privateKeyPassword

        public MqttBrokerConfigBuilder privateKeyPassword​(char[] privateKeyPassword)
        Sets the password for the private key (stored into the JSK keystore) on this builder.
        Parameters:
        privateKeyPassword - the password for the private key stored into the JSK keystore
        Returns:
        a reference to this object
        See Also:
        SecurityParams.getPrivateKeyPassword()
      • build

        public MqttBrokerConfig build()
        Returns a new MqttBrokerConfig instance initialized with all parameters provided to this builder.

        Note that the returned MqttBrokerConfig contains a Will Message only if a valid topic has been explicitly provided through willMessage(String, byte[], QoS, boolean).

        Similarly, the MqttBrokerConfig instance contains a SecurityParams object only if at least one of the following parameters has been explicitly provided:

        Returns:
        an MqttBrokerConfig instance