public abstract class AbstractBootstrap<B extends AbstractBootstrap<B,C>,C extends Channel> extends Object implements 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).
Modifier and Type | Method and Description |
---|---|
<T> B |
attr(io.netty.util.AttributeKey<T> key,
T value)
Allow to specify an initial attribute of the newly created
Channel . |
ChannelFuture |
bind()
Create a new
Channel and bind it. |
ChannelFuture |
bind(InetAddress inetHost,
int inetPort)
Create a new
Channel and bind it. |
ChannelFuture |
bind(int inetPort)
Create a new
Channel and bind it. |
ChannelFuture |
bind(SocketAddress localAddress)
Create a new
Channel and bind it. |
ChannelFuture |
bind(String inetHost,
int inetPort)
Create a new
Channel and bind it. |
B |
channel(Class<? extends C> channelClass)
|
B |
channelFactory(ChannelFactory<? extends C> channelFactory)
Deprecated.
Use
channelFactory(io.netty.channel.ChannelFactory) instead. |
B |
channelFactory(ChannelFactory<? extends C> channelFactory)
|
abstract B |
clone()
Returns a deep clone of this bootstrap which has the identical configuration.
|
abstract AbstractBootstrapConfig<B,C> |
config()
Returns the
AbstractBootstrapConfig object that can be used to obtain the current config
of the bootstrap. |
EventLoopGroup |
group()
Deprecated.
Use
config() instead. |
B |
group(EventLoopGroup group)
The
EventLoopGroup which is used to handle all the events for the to-be-created
Channel |
B |
handler(ChannelHandler handler)
the
ChannelHandler to use for serving the requests. |
B |
localAddress(InetAddress inetHost,
int inetPort) |
B |
localAddress(int inetPort) |
B |
localAddress(SocketAddress localAddress)
The
SocketAddress which is used to bind the local "end" to. |
B |
localAddress(String inetHost,
int inetPort) |
<T> B |
option(ChannelOption<T> option,
T value)
Allow to specify a
ChannelOption which is used for the Channel instances once they got
created. |
ChannelFuture |
register()
|
String |
toString() |
B |
validate()
Validate all the parameters.
|
public B group(EventLoopGroup group)
EventLoopGroup
which is used to handle all the events for the to-be-created
Channel
public B channel(Class<? extends C> channelClass)
Class
which is used to create Channel
instances from.
You either use this or channelFactory(io.netty.channel.ChannelFactory)
if your
Channel
implementation has no no-args constructor.@Deprecated public B channelFactory(ChannelFactory<? extends C> channelFactory)
channelFactory(io.netty.channel.ChannelFactory)
instead.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.public B localAddress(SocketAddress localAddress)
SocketAddress
which is used to bind the local "end" to.public B localAddress(int inetPort)
localAddress(SocketAddress)
public B localAddress(String inetHost, int inetPort)
localAddress(SocketAddress)
public B localAddress(InetAddress inetHost, int inetPort)
localAddress(SocketAddress)
public <T> B option(ChannelOption<T> option, T value)
ChannelOption
which is used for the Channel
instances once they got
created. Use a value of null
to remove a previous set ChannelOption
.public <T> B attr(io.netty.util.AttributeKey<T> key, T value)
Channel
. If the value
is
null
, the attribute of the specified key
is removed.public B validate()
public abstract B clone()
Channel
s with similar settings. Please note that this method does not clone the
EventLoopGroup
deeply but shallowly, making the group a shared resource.public ChannelFuture register()
public ChannelFuture bind()
Channel
and bind it.public ChannelFuture bind(int inetPort)
Channel
and bind it.public ChannelFuture bind(String inetHost, int inetPort)
Channel
and bind it.public ChannelFuture bind(InetAddress inetHost, int inetPort)
Channel
and bind it.public ChannelFuture bind(SocketAddress localAddress)
Channel
and bind it.public B handler(ChannelHandler handler)
ChannelHandler
to use for serving the requests.@Deprecated public final EventLoopGroup group()
config()
instead.EventLoopGroup
or null
if non is configured yet.public abstract AbstractBootstrapConfig<B,C> config()
AbstractBootstrapConfig
object that can be used to obtain the current config
of the bootstrap.Copyright © 2008–2023 The Netty Project. All rights reserved.