Class ServerConfig

java.lang.Object
org.eclipse.hono.config.AbstractConfig
org.eclipse.hono.config.ServerConfig
Direct Known Subclasses:
ServiceConfigProperties

public class ServerConfig extends AbstractConfig
Configuration of properties that are common for components accepting requests/connections on a network socket.
  • Constructor Details

    • ServerConfig

      public ServerConfig()
      Creates new properties using default values.
    • ServerConfig

      public ServerConfig(ServerOptions options)
      Creates a new instance from existing options.
      Parameters:
      options - The options. All of the options are copied to the newly created instance.
  • Method Details

    • isSubstrateVm

      public final boolean isSubstrateVm()
      Checks if the current thread is running on the Graal Substrate VM.
      Returns:
      true if the java.vm.name system property value start with Substrate.
    • getBindAddress

      public final String getBindAddress()
      Gets the host name or literal IP address of the network interface that this server's secure port is configured to be bound to.
      Returns:
      The host name.
    • setBindAddress

      public final void setBindAddress(String address)
      Sets the host name or literal IP address of the network interface that this server's secure port should be bound to.

      The default value of this property is Constants.LOOPBACK_DEVICE_ADDRESS on IPv4 stacks.

      Parameters:
      address - The host name or IP address.
      Throws:
      NullPointerException - if host is null.
    • getPort

      public final int getPort()
      Gets the secure port this server is configured to listen on.
      Returns:
      The port number.
    • getPort

      public final int getPort(int defaultPort)
      Gets the secure port this server is configured to listen on.
      Parameters:
      defaultPort - The port to use if this property has not been set explicitly.
      Returns:
      The configured port number or the defaultPort if port is not set.
      See Also:
    • setPort

      public final void setPort(int port)
      Sets the secure port that this server should listen on.

      If the port is set to 0 (the default value), then this server will bind to an arbitrary free port chosen by the operating system during startup.

      Parameters:
      port - The port number.
      Throws:
      IllegalArgumentException - if port < 0 or port > 65535.
    • isSecurePortEnabled

      public boolean isSecurePortEnabled()
      Checks whether this service should listen to the secure port.

      Subclasses may override this method in order to do more sophisticated checks.

      Returns:
      true if a valid key and certificate have been configured for this service..
    • isNativeTlsRequired

      public final boolean isNativeTlsRequired()
      Checks if this server requires the usage of a native TLS implementation. Native TLS implementations offer in general a better performance but may not be available on all platforms. If true, the server will require the usage of a native TLS implementation. Server will not start if native implementation is not available on the current system. If false, the adapter will try to use a native TLS implementation. If no native implementation is available the default Java platform independent TLS implementation will be used.

      The default value of this property is false.

      Returns:
      true if the server requires native TLS implementation.
    • setNativeTlsRequired

      public final void setNativeTlsRequired(boolean nativeTlsRequired)
      Sets if this server should require the usage of a native TLS implementation. Native TLS implementations offer in general a better performance but may not be available on all platforms. If true, the server will require the usage of a native TLS implementation. Server will not start if native implementation is not available on the current system. If false, the adapter will try to use a native TLS implementation. If no native implementation is available the default Java platform independent TLS implementation will be used.

      The default value of this property is false.

      Parameters:
      nativeTlsRequired - true if the server requires the usage of a native TLS implementation.
    • isInsecurePortEnabled

      public boolean isInsecurePortEnabled()
      Checks whether this service should listen to the insecure port.

      The default value of this property is false.

      Subclasses may override this method in order to do more sophisticated checks.

      Returns:
      true if the insecure port has been enabled explicitly using setInsecurePortEnabled(boolean) or implicitly using setInsecurePort(int).
    • setInsecurePortEnabled

      public final void setInsecurePortEnabled(boolean insecurePortEnabled)
      Sets whether this server should listen on the insecure port.

      The default value of this property is false.

      Parameters:
      insecurePortEnabled - true if the server should listen on the insecure port.
    • getInsecurePortBindAddress

      public final String getInsecurePortBindAddress()
      Gets the host name or literal IP address of the network interface that this server's insecure port is configured to be bound to.
      Returns:
      The host name.
    • setInsecurePortBindAddress

      public final void setInsecurePortBindAddress(String address)
      Sets the host name or literal IP address of the network interface that this server's insecure port should be bound to.

      The default value of this property is Constants.LOOPBACK_DEVICE_ADDRESS on IPv4 stacks.

      Parameters:
      address - The host name or IP address.
      Throws:
      NullPointerException - if address is null.
    • getInsecurePort

      public final int getInsecurePort()
      Gets the insecure port this server is configured to listen on.
      Returns:
      The port number.
    • getInsecurePort

      public final int getInsecurePort(int defaultPort)
      Gets the insecure port this server is configured to listen on.
      Parameters:
      defaultPort - The port to use if this property has not been set explicitly.
      Returns:
      The configured port number or the defaultPort if insecurePort is not set.
      See Also:
    • setInsecurePort

      public final void setInsecurePort(int port)
      Sets the insecure port that this server should listen on.

      If the port is set to 0 (the default value), then this server will bind to an arbitrary free port chosen by the operating system during startup.

      Setting this property also sets the insecurePortEnabled property to true.

      Parameters:
      port - The port number.
      Throws:
      IllegalArgumentException - if port < 0 or port > 65535.
    • setSni

      public final void setSni(boolean sni)
      Sets whether the server should support Server Name Indication for TLS connections.
      Parameters:
      sni - true if the server should support SNI.
    • isSni

      public final boolean isSni()
      Checks if the server supports Server Name Indication for TLS connections.
      Returns:
      true if the server supports SNI.