Class ServerBuilder<T extends ServerBuilder<T>>

  • Type Parameters:
    T - the concrete server builder.
    Direct Known Subclasses:
    DlmsServer.TcpServerBuilder

    public abstract class ServerBuilder<T extends ServerBuilder<T>>
    extends java.lang.Object
    Builder class to build a DLMS Server.
    • Constructor Detail

      • ServerBuilder

        public ServerBuilder()
    • Method Detail

      • build

        public abstract DlmsServer build()
                                  throws java.io.IOException
        Builds a new server and starts it, with the provided settings.
        Returns:
        the new Server.
        Throws:
        java.io.IOException - if an I/O exception occurs while starting the server.
      • registerLogicalDevice

        public final T registerLogicalDevice​(LogicalDevice... logicalDevice)
        Register one or more logical devices to the server.
        Parameters:
        logicalDevice - a logical device.
        Returns:
        the self reference of the connection builder.
      • registerLogicalDevice

        public T registerLogicalDevice​(java.util.List<LogicalDevice> newlogicalDevices)
        Register list of logical devices to the server.
        Parameters:
        newlogicalDevices - a list of logical devices.
        Returns:
        the self reference of the connection builder.
      • setMaxClients

        public T setMaxClients​(int maxClients)
        Restrict the maximum number of connected clients.

        A value of zero imposes no restriction.

        Parameters:
        maxClients - positive integer, restricting the maximum number of connected clients.
        Returns:
        the self reference of the connection builder.
        Throws:
        java.lang.IllegalArgumentException - if the maxClients < 0.
      • setInactivityTimeout

        public T setInactivityTimeout​(int inactivityTimeout)
        Sets the inactivity timeout. If a client doesn't send a request within that time, the server closes the connection.

        The timeout must be greater than 0. A timeout of values 0 implies that the option is disabled (i.e., timeout of infinity).

        The default value is 0.

        Parameters:
        inactivityTimeout - the timeout value.
        Returns:
        the self reference of the connection builder.
        Throws:
        java.lang.IllegalArgumentException - if the inactivityTimeout < 0.
      • setReferencingMethod

        public T setReferencingMethod​(ReferencingMethod referencingMethod)
        Set the Referencing Method. Default value is LOGICAL.
        Parameters:
        referencingMethod - the referencing method.
        Returns:
        the self reference of the connection builder.
      • setResponseTimeout

        public T setResponseTimeout​(int responseTimeout)
        The max time a server waits for a response from the client, after sending a request to the client.

        The timeout must be greater than 0. A timeout of values 0 implies that the option is disabled (i.e., timeout of infinity).

        The default value is 0.

        Parameters:
        responseTimeout - the timeout value.
        Returns:
        the self reference of the connection builder.
        Throws:
        java.lang.IllegalArgumentException - if the responseTimeout < 0.
      • parseLogicalDevices

        protected final DataDirectory parseLogicalDevices()