Top Description Fields Constructors Methods
io.netty5.bootstrap

public abstract Class AbstractBootstrap<B extends io.netty5.bootstrap.AbstractBootstrap<B, C, F>, C extends io.netty5.channel.Channel, F>

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
io.netty5.bootstrap.Bootstrap, io.netty5.bootstrap.ServerBootstrap
Imports
io.netty5.channel.Channel, .ChannelFutureListeners, .ChannelHandler, .ChannelOption, .EventLoop, .EventLoopGroup, io.netty5.util.AttributeKey, io.netty5.util.concurrent.Future, .Promise, io.netty5.util.internal.SocketUtils, .StringUtil, io.netty5.util.internal.logging.InternalLogger, java.net.InetAddress, .InetSocketAddress, .SocketAddress, java.util.Collections, .LinkedHashMap, .Map, java.util.concurrent.ConcurrentHashMap

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 Summary

Modifier and TypeField and Description
private final Map<AttributeKey<?>, Object>
private static final Map.Entry<AttributeKey<?>, Object>[]
private static final Map.Entry<ChannelOption<?>, Object>[]
pack-priv volatile EventLoopGroup
private volatile ChannelHandler
private volatile SocketAddress
private final Map<ChannelOption<?>, Object>

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public <T> B
attr(AttributeKey<T> key, T value)

Allow to specify an initial attribute of the newly created Channel.

pack-priv final Map<AttributeKey<?>, Object>
public Future<Channel>
bind()

Create a new Channel and bind it.

public Future<Channel>
bind(int inetPort)

Create a new Channel and bind it.

public Future<Channel>
bind(String inetHost, int inetPort)

Create a new Channel and bind it.

public Future<Channel>
bind(InetAddress inetHost, int inetPort)

Create a new Channel and bind it.

public Future<Channel>
bind(SocketAddress localAddress)

Create a new Channel and bind it.

public abstract B
clone()

Overrides java.lang.Object.clone.

Returns a deep clone of this bootstrap which has the identical configuration.
public abstract AbstractBootstrapConfig<B, C, F>
config()

Returns the AbstractBootstrapConfig object that can be used to obtain the current config of the bootstrap.

pack-priv static <K, V> Map<K, V>
copiedMap(Map<K, V> map)

public Channel

Returns:

A new unregistered channel.
createUnregistered
()

Create a new unregistered channel.

private Future<Channel>
doBind(final SocketAddress localAddress)

private static void
doBind0(final Future<Channel> regFuture, final Channel channel, final SocketAddress localAddress, final Promise<Void> promise)

public B
group(EventLoopGroup group)

The EventLoopGroup which is used to handle all the events for the to-be-created Channel

public final EventLoopGroup
group()

Deprecated Use config() instead.
Returns the configured EventLoopGroup or null if non is configured yet.
public B
handler(ChannelHandler handler)

the ChannelHandler to use for serving the requests.

pack-priv final ChannelHandler
pack-priv abstract Future<Channel>
init(Channel channel)

pack-priv final Future<Channel>
pack-priv final Channel
public B
localAddress(SocketAddress localAddress)

The SocketAddress which is used to bind the local "end" to.

public B
localAddress(int inetPort)

public B
localAddress(String inetHost, int inetPort)

public B
localAddress(InetAddress inetHost, int inetPort)

pack-priv final SocketAddress
pack-priv final Map.Entry<AttributeKey<?>, Object>[]
pack-priv static Map.Entry<AttributeKey<?>, Object>[]
pack-priv abstract C
pack-priv final Map.Entry<ChannelOption<?>, Object>[]
pack-priv static Map.Entry<ChannelOption<?>, Object>[]
public <T> B
option(ChannelOption<T> option, T value)

Allow to specify a ChannelOption which is used for the Channel instances once they got created.

pack-priv final Map<ChannelOption<?>, Object>
public Future<Channel>
register()

Create a new Channel and register it with an EventLoop.

private B
self()

pack-priv static void
private static void
setChannelOption(Channel channel, ChannelOption<?> option, Object value, InternalLogger logger)

pack-priv static void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public B
validate()

Validate all the parameters.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attrsback to summary
private final Map<AttributeKey<?>, Object> attrs
EMPTY_ATTRIBUTE_ARRAYback to summary
private static final Map.Entry<AttributeKey<?>, Object>[] EMPTY_ATTRIBUTE_ARRAY
Annotations
@SuppressWarnings:unchecked
EMPTY_OPTION_ARRAYback to summary
private static final Map.Entry<ChannelOption<?>, Object>[] EMPTY_OPTION_ARRAY
Annotations
@SuppressWarnings:unchecked
groupback to summary
pack-priv volatile EventLoopGroup group
handlerback to summary
private volatile ChannelHandler handler
localAddressback to summary
private volatile SocketAddress localAddress
optionsback to summary
private final Map<ChannelOption<?>, Object> options

Constructor Detail

AbstractBootstrapback to summary
pack-priv AbstractBootstrap()
AbstractBootstrapback to summary
pack-priv AbstractBootstrap(AbstractBootstrap<B, C, F> bootstrap)

Method Detail

attrback to summary
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.

attrsback to summary
pack-priv final Map<AttributeKey<?>, Object> attrs()
bindback to summary
public Future<Channel> bind()

Create a new Channel and bind it.

bindback to summary
public Future<Channel> bind(int inetPort)

Create a new Channel and bind it.

bindback to summary
public Future<Channel> bind(String inetHost, int inetPort)

Create a new Channel and bind it.

bindback to summary
public Future<Channel> bind(InetAddress inetHost, int inetPort)

Create a new Channel and bind it.

bindback to summary
public Future<Channel> bind(SocketAddress localAddress)

Create a new Channel and bind it.

cloneback to summary
public abstract B clone()

Overrides java.lang.Object.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.

Returns:B

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
@SuppressWarnings:CloneDoesntDeclareCloneNotSupportedException
configback to summary
public abstract AbstractBootstrapConfig<B, C, F> config()

Returns the AbstractBootstrapConfig object that can be used to obtain the current config of the bootstrap.

copiedMapback to summary
pack-priv static <K, V> Map<K, V> copiedMap(Map<K, V> map)
createUnregisteredback to summary
public Channel createUnregistered() throws Exception

Create a new unregistered channel.

The channel must then be registered separately.

Returns:Channel

A new unregistered channel.

Exceptions
Exception:
If the channel cannot be created.
doBindback to summary
private Future<Channel> doBind(final SocketAddress localAddress)
doBind0back to summary
private static void doBind0(final Future<Channel> regFuture, final Channel channel, final SocketAddress localAddress, final Promise<Void> promise)
groupback to summary
public B group(EventLoopGroup group)

The EventLoopGroup which is used to handle all the events for the to-be-created Channel

groupback to summary
public final EventLoopGroup group()

Deprecated

Use config() instead.

Returns the configured EventLoopGroup or null if non is configured yet.

Annotations
@Deprecated
handlerback to summary
public B handler(ChannelHandler handler)

the ChannelHandler to use for serving the requests.

handlerback to summary
pack-priv final ChannelHandler handler()
initback to summary
pack-priv abstract Future<Channel> init(Channel channel)
initAndRegisterback to summary
pack-priv final Future<Channel> initAndRegister(EventLoop loop)
initWithoutRegisterback to summary
pack-priv final Channel initWithoutRegister() throws Exception
localAddressback to summary
public B localAddress(SocketAddress localAddress)

The SocketAddress which is used to bind the local "end" to.

localAddressback to summary
public B localAddress(int inetPort)
See Also
localAddress(SocketAddress)
localAddressback to summary
public B localAddress(String inetHost, int inetPort)
See Also
localAddress(SocketAddress)
localAddressback to summary
public B localAddress(InetAddress inetHost, int inetPort)
See Also
localAddress(SocketAddress)
localAddressback to summary
pack-priv final SocketAddress localAddress()
newAttributesArrayback to summary
pack-priv final Map.Entry<AttributeKey<?>, Object>[] newAttributesArray()
newAttributesArrayback to summary
pack-priv static Map.Entry<AttributeKey<?>, Object>[] newAttributesArray(Map<AttributeKey<?>, Object> attributes)
newChannelback to summary
pack-priv abstract C newChannel(EventLoop loop) throws Exception
newOptionsArrayback to summary
pack-priv final Map.Entry<ChannelOption<?>, Object>[] newOptionsArray()
newOptionsArrayback to summary
pack-priv static Map.Entry<ChannelOption<?>, Object>[] newOptionsArray(Map<ChannelOption<?>, Object> options)
optionback to summary
public <T> B option(ChannelOption<T> option, T value)

Allow to specify a ChannelOption which is used for the Channel instances once they got created. Use a value of null to remove a previous set ChannelOption.

optionsback to summary
pack-priv final Map<ChannelOption<?>, Object> options()
registerback to summary
public Future<Channel> register()

Create a new Channel and register it with an EventLoop.

selfback to summary
private B self()
Annotations
@SuppressWarnings:unchecked
setAttributesback to summary
pack-priv static void setAttributes(Channel channel, Map.Entry<AttributeKey<?>, Object>[] attrs)
setChannelOptionback to summary
private static void setChannelOption(Channel channel, ChannelOption<?> option, Object value, InternalLogger logger)
Annotations
@SuppressWarnings:unchecked
setChannelOptionsback to summary
pack-priv static void setChannelOptions(Channel channel, Map.Entry<ChannelOption<?>, Object>[] options, InternalLogger logger)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
validateback to summary
public B validate()

Validate all the parameters. Sub-classes may override this, but should call the super method in that case.