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).
限定符和类型 | 方法和说明 |
---|---|
<T> B |
attr(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(java.net.InetAddress inetHost,
int inetPort)
Create a new
Channel and bind it. |
ChannelFuture |
bind(int inetPort)
Create a new
Channel and bind it. |
ChannelFuture |
bind(java.net.SocketAddress localAddress)
Create a new
Channel and bind it. |
ChannelFuture |
bind(java.lang.String inetHost,
int inetPort)
Create a new
Channel and bind it. |
B |
channel(java.lang.Class<? extends C> channelClass)
The
Class which is used to create Channel instances from. |
B |
channelFactory(ChannelFactory<? extends C> channelFactory)
|
abstract B |
clone()
Returns a deep clone of this bootstrap which has the identical configuration.
|
EventLoopGroup |
group()
Return the configured
EventLoopGroup or null if non is configured yet. |
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(java.net.InetAddress inetHost,
int inetPort) |
B |
localAddress(int inetPort) |
B |
localAddress(java.net.SocketAddress localAddress)
The
SocketAddress which is used to bind the local "end" to. |
B |
localAddress(java.lang.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()
|
java.lang.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(java.lang.Class<? extends C> channelClass)
Class
which is used to create Channel
instances from.
You either use this or channelFactory(ChannelFactory)
if your
Channel
implementation has no no-args constructor.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)
for
simplify your code.public B localAddress(java.net.SocketAddress localAddress)
SocketAddress
which is used to bind the local "end" to.public B localAddress(int inetPort)
public B localAddress(java.lang.String inetHost, int inetPort)
public B localAddress(java.net.InetAddress inetHost, int inetPort)
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(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.clone
在类中 java.lang.Object
public ChannelFuture register()
public ChannelFuture bind()
Channel
and bind it.public ChannelFuture bind(int inetPort)
Channel
and bind it.public ChannelFuture bind(java.lang.String inetHost, int inetPort)
Channel
and bind it.public ChannelFuture bind(java.net.InetAddress inetHost, int inetPort)
Channel
and bind it.public ChannelFuture bind(java.net.SocketAddress localAddress)
Channel
and bind it.public B handler(ChannelHandler handler)
ChannelHandler
to use for serving the requests.public EventLoopGroup group()
EventLoopGroup
or null
if non is configured yet.public java.lang.String toString()
toString
在类中 java.lang.Object