Class QUICBabelChannelBuilder

All Implemented Interfaces:
BabelChannelBuilder

public class QUICBabelChannelBuilder extends AbstractIPBabelChannelBuilder<QUICBabelChannelBuilder>
Builder for QUICBabelChannel instances.

Configures channel parameters such as the local binding address, event loop group, number of streams, TLS trust manager, and identity keys prior to building the channel via the Babel runtime. Example usage:

QUICBabelChannelBuilder builder = QUICBabelChannel.builder()
        .setBindingAddress(new InetSocketAddress("0.0.0.0", 7000))
        .setNumberOfStreams(4)
        .setNumberOfConnections(100)
        .setTrustManagerFactory(new PeerIdentityTrustManagerFactory());

When registered with Babel via Babel.builder().registerProtocol(protocol, holderFactory, builder), build(Babel, NodeStore, BabelNode, BabelProtocol) is invoked for each registering protocol. The underlying QUICBabelChannel is created on the first invocation and shared, returning a dedicated QUICBabelChannelProtocolWrapper for each registering protocol.

  • Method Details

    • setNumberOfStreams

      public QUICBabelChannelBuilder setNumberOfStreams(int numberOfStreams)
      Sets the maximum number of concurrent unidirectional streams per connection. Also ensures the trust manager is initialized to InsecureTrustManagerFactory.INSTANCE if not already customized.
      Parameters:
      numberOfStreams - the number of unidirectional streams to configure
      Returns:
      this builder instance for method chaining
    • setTrustManagerFactory

      public QUICBabelChannelBuilder setTrustManagerFactory(TrustManagerFactory trustManager)
      Sets the TrustManagerFactory used to validate peer TLS certificates during the QUIC handshake.
      Parameters:
      trustManager - the trust manager factory to use
      Returns:
      this builder instance for method chaining
    • setTrustManager

      public QUICBabelChannelBuilder setTrustManager(TrustManager trustManager)
      Sets the TrustManager used to validate peer TLS certificates during the QUIC handshake.
      Parameters:
      trustManager - the trust manager to use
      Returns:
      this builder instance for method chaining
    • setKeyMaterial

      public QUICBabelChannelBuilder setKeyMaterial(CertGenerator.KeyMaterial keyMaterial)
      Sets pre-generated CertGenerator.KeyMaterial containing the ephemeral key and certificate.
      Parameters:
      keyMaterial - the key material to use
      Returns:
      this builder instance for method chaining
    • setComparator

      public QUICBabelChannelBuilder setComparator(Comparator<? extends BabelNode> comparator)
      Sets the comparator used to resolve simultaneous-connection conflicts.
      Parameters:
      comparator - the comparator to use for tie-breaking
      Returns:
      this builder instance for method chaining
    • build

      public BabelChannel build(Babel runtime, NodeStore store, BabelNode identity, BabelProtocol protocol)
      Builds the channel or returns a protocol-specific wrapper if the underlying channel has already been constructed.
      Parameters:
      runtime - the Babel runtime instance
      store - the node store containing peer components
      identity - the local node's identity
      protocol - the Babel protocol registering with the channel
      Returns:
      a BabelChannel wrapper bound to the registering protocol
      Throws:
      IllegalArgumentException - if numberOfStreams has not been set (equals 0)