Class EConfigure.ServerBuilder

  • Enclosing class:
    EConfigure

    public static final class EConfigure.ServerBuilder
    extends EConfigure.AbstractBuilder<EConfigure.ServerBuilder>
    Constructs an EConfigure.Service instance based on the parameters set via this builder's API. The minimally allowed configuration is the service name, connection type and port. The remaining parameters are set to the following defaults:
    • connection type: EConfigure.ConnectionType.TCP - plain text TCP connection.
    • address filter: null - no address filter applied.
    • input buffer size: zero - use system default buffer size.
    • output buffer size: zero - use system default buffer size.
    • byte order: little-endian.
    • maximum message queue size: zero - unlimited queue size.
    • service selector thread: AsyncChannel.defaultSelector.
    • accepted connection select thread: AsyncChannel.defaultSelector.
    • heartbeat millisecond delay: zero - heartbeating off.
    • heartbeat millisecond reply delay: zero - wait indefinitely for a reply.

    If either the service name or port are not set, then build() will throw an exception.

    Example building an EServer

    final AddressFilter filter = ...;
    final SSLContext secureContext = ...;
    final EConfigure.ServerBuilder builder = EConfigure.serverBuilder();
    
    EServer.openServer(builder.name("AppServer")
                              .port(6789)
                              .connectionType(EConfigure.ConnectionType.SECURE_TCP)
                              .sslContext(secureContext)
                              .addressFilter(filter)
                              .inputBufferSize(1_024)
                              .outputBufferSize(1_024)
                              .byteOrder(ByteOrder.BIG_ENDIAN)
                              .messageQueueSize(10_000)
                              .serviceSelector("svcSelector")
                              .connectionSelector("connSelector")
                              .heartbeatDelay(60_000L)
                              .heartbeatReplyDelay(30_000L)
                              .build());
    Author:
    Charles W. Rapp
    See Also:
    EConfigure.ConnectionBuilder
    • Method Detail

      • configuration

        public EConfigure.ServerBuilder configuration​(EConfigure.Service config)
        Copies in the settings from config to this builder. This method is provided for making changes to an existing configuration since EConfigure.Service is immutable.

        if config is null, then nothing is done and the builder remains unchanged.

        Parameters:
        config - copy settings from this configuration.
        Returns:
        this service builder.
      • port

        public EConfigure.ServerBuilder port​(int port)
        Sets the service TCP port.
        Parameters:
        port - service TCP port.
        Returns:
        this service builder.
        Throws:
        com.typesafe.config.ConfigException - if port is not a valid TCP port.
      • addressFilter

        public EConfigure.ServerBuilder addressFilter​(AddressFilter filter)
        Sets the optional service address filter.
        Parameters:
        filter - the optional address filter. May be null.
        Returns:
        this service builder.
      • serviceSelector

        public EConfigure.ServerBuilder serviceSelector​(String selector)
        Sets the selector used for the service connection.
        Parameters:
        selector - eBus selector name.
        Returns:
        this service builder.
        Throws:
        com.typesafe.config.ConfigException - if name is null or empty or is not a known selector.
      • connectionSelector

        public EConfigure.ServerBuilder connectionSelector​(String selector)
        Sets the selector used for accepted TCP connections.
        Parameters:
        selector - eBus selector name.
        Returns:
        this service builder.
        Throws:
        com.typesafe.config.ConfigException - if name is null or empty or not a known selector.
      • build

        public EConfigure.Service build()
        Returns the eBus service configuration built from the previously set parameters.
        Returns:
        an eBus service configuration.
        Throws:
        com.typesafe.config.ConfigException - if any service name or service port is not set.
      • validate

        protected Validator validate​(Validator problems)
        Validates the builder parameters. This validation is "fail slow" meaning that a single validation call will determine all configuration errors.
        Overrides:
        validate in class EConfigure.AbstractBuilder<EConfigure.ServerBuilder>
        Parameters:
        problems - record configuration problems in this list.
        Returns:
        problems so validate calls may be chained together.