Class AbstractBootstrap<B extends AbstractBootstrap<B,​C>,​C extends Channel>

  • All Implemented Interfaces:
    java.lang.Cloneable
    Direct Known Subclasses:
    Bootstrap, ServerBootstrap

    public abstract class AbstractBootstrap<B extends AbstractBootstrap<B,​C>,​C extends Channel>
    extends java.lang.Object
    implements java.lang.Cloneable
    AbstractBootstrap is a helper class that makes it easy to bootstrap a Channel. It support method-chaining to provide an easy way to configure the AbstractBootstrap.

    When not used in a ServerBootstrap context, the bind() methods are useful for connectionless transports such as datagram (UDP).

    • Method Detail

      • channelFactory

        public B channelFactory​(ChannelFactory<? extends C> channelFactory)
        ChannelFactory which is used to create Channel instances from when calling bind(). This method is usually only used if channel(Class) is not working for you because of some more complex needs. If your Channel implementation has a no-args constructor, its highly recommend to just use channel(Class) to simplify your code.
      • localAddress

        public B localAddress​(java.net.SocketAddress localAddress)
        The SocketAddress which is used to bind the local "end" to.
      • attr

        public <T> B attr​(AttributeKey<T> key,
                          T value)
        Allow to specify an initial attribute of the newly created Channel. If the value is null, the attribute of the specified key is removed.
      • extensionsClassLoader

        public B extensionsClassLoader​(java.lang.ClassLoader classLoader)
        Load ChannelInitializerExtensions using the given class loader.

        By default, the extensions will be loaded by the same class loader that loaded this bootstrap class.

        Parameters:
        classLoader - The class loader to use for loading ChannelInitializerExtensions.
        Returns:
        This bootstrap.
      • validate

        public B validate()
        Validate all the parameters. Sub-classes may override this, but should call the super method in that case.
      • clone

        public abstract B clone()
        Returns a deep clone of this bootstrap which has the identical configuration. This method is useful when making multiple Channels with similar settings. Please note that this method does not clone the EventLoopGroup deeply but shallowly, making the group a shared resource.
        Overrides:
        clone in class java.lang.Object
      • bind

        public ChannelFuture bind​(java.lang.String inetHost,
                                  int inetPort)
        Create a new Channel and bind it.
      • bind

        public ChannelFuture bind​(java.net.InetAddress inetHost,
                                  int inetPort)
        Create a new Channel and bind it.
      • bind

        public ChannelFuture bind​(java.net.SocketAddress localAddress)
        Create a new Channel and bind it.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object