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).

    • Field Detail

      • EMPTY_OPTION_ARRAY

        private static final java.util.Map.Entry<ChannelOption<?>,​java.lang.Object>[] EMPTY_OPTION_ARRAY
      • EMPTY_ATTRIBUTE_ARRAY

        private static final java.util.Map.Entry<AttributeKey<?>,​java.lang.Object>[] EMPTY_ATTRIBUTE_ARRAY
      • localAddress

        private volatile java.net.SocketAddress localAddress
      • options

        private final java.util.Map<ChannelOption<?>,​java.lang.Object> options
      • attrs

        private final java.util.Map<AttributeKey<?>,​java.lang.Object> attrs
      • extensionsClassLoader

        private volatile java.lang.ClassLoader extensionsClassLoader
    • Constructor Detail

      • AbstractBootstrap

        AbstractBootstrap()
    • Method Detail

      • self

        private B self()
      • 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.
      • doBind

        private ChannelFuture doBind​(java.net.SocketAddress localAddress)
      • init

        abstract void init​(Channel channel)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • newOptionsArray

        final java.util.Map.Entry<ChannelOption<?>,​java.lang.Object>[] newOptionsArray()
      • newOptionsArray

        static java.util.Map.Entry<ChannelOption<?>,​java.lang.Object>[] newOptionsArray​(java.util.Map<ChannelOption<?>,​java.lang.Object> options)
      • newAttributesArray

        final java.util.Map.Entry<AttributeKey<?>,​java.lang.Object>[] newAttributesArray()
      • newAttributesArray

        static java.util.Map.Entry<AttributeKey<?>,​java.lang.Object>[] newAttributesArray​(java.util.Map<AttributeKey<?>,​java.lang.Object> attributes)
      • options0

        final java.util.Map<ChannelOption<?>,​java.lang.Object> options0()
      • attrs0

        final java.util.Map<AttributeKey<?>,​java.lang.Object> attrs0()
      • localAddress

        final java.net.SocketAddress localAddress()
      • options

        final java.util.Map<ChannelOption<?>,​java.lang.Object> options()
      • attrs

        final java.util.Map<AttributeKey<?>,​java.lang.Object> attrs()
      • copiedMap

        static <K,​V> java.util.Map<K,​V> copiedMap​(java.util.Map<K,​V> map)
      • setAttributes

        static void setAttributes​(Channel channel,
                                  java.util.Map.Entry<AttributeKey<?>,​java.lang.Object>[] attrs)
      • toString

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