Class NettyOptionSettingChannelInitializer

java.lang.Object
io.netty5.channel.ChannelInitializer<io.netty5.channel.Channel>
eu.cloudnetservice.driver.impl.network.netty.NettyOptionSettingChannelInitializer
All Implemented Interfaces:
io.netty5.channel.ChannelHandler
Direct Known Subclasses:
NettyNetworkClientInitializer, NettyNetworkServerInitializer

public class NettyOptionSettingChannelInitializer extends io.netty5.channel.ChannelInitializer<io.netty5.channel.Channel>
A custom channel initializer implementation which activates option in the given channel during the initialization if they are supported by the implementation.
Since:
4.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Map<io.netty5.channel.ChannelOption<?>, Object>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doInitChannel(@NonNull io.netty5.channel.Channel channel)
    Method that gets called when the actual channel initialization finished and all requested channel options were activated in the channel.
    protected void
    initChannel(@NonNull io.netty5.channel.Channel channel)
    option(@NonNull io.netty5.channel.ChannelOption<T> option, T value)
    Adds an option which should be activated in channels initialized by this initializer if it is supported.

    Methods inherited from class io.netty5.channel.ChannelInitializer

    channelExceptionCaught, handlerAdded, isSharable

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty5.channel.ChannelHandler

    bind, channelActive, channelInactive, channelInboundEvent, channelRead, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerRemoved, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown, write
  • Field Details

    • options

      private final Map<io.netty5.channel.ChannelOption<?>, Object> options
  • Constructor Details

    • NettyOptionSettingChannelInitializer

      public NettyOptionSettingChannelInitializer()
  • Method Details

    • initChannel

      protected void initChannel(@NonNull @NonNull io.netty5.channel.Channel channel) throws Exception
      Specified by:
      initChannel in class io.netty5.channel.ChannelInitializer<io.netty5.channel.Channel>
      Throws:
      Exception
    • option

      @NonNull public <T> @NonNull NettyOptionSettingChannelInitializer option(@NonNull @NonNull io.netty5.channel.ChannelOption<T> option, @NonNull T value)
      Adds an option which should be activated in channels initialized by this initializer if it is supported.
      Type Parameters:
      T - the type of the option value.
      Parameters:
      option - the option to activate if supported.
      value - the value of the option.
      Returns:
      this initializer instance, for chaining.
      Throws:
      NullPointerException - if the given option or value is null.
    • doInitChannel

      protected void doInitChannel(@NonNull @NonNull io.netty5.channel.Channel channel) throws Exception
      Method that gets called when the actual channel initialization finished and all requested channel options were activated in the channel. This channel removes the need for overriding classes to call super.initChannel in order to get all channel options activated.
      Parameters:
      channel - the channel to initialize.
      Throws:
      Exception - thrown if an error occurs during initialization.