public abstract class AbstractBootstrap<B extends AbstractBootstrap<?>> extends Object
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.| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractBootstrap.ChannelFactory
|
| Constructor and Description |
|---|
AbstractBootstrap() |
| 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. |
protected Map<io.netty.util.AttributeKey<?>,Object> |
attrs() |
ChannelFuture |
bind()
Create a new
Channel and bind it. |
abstract ChannelFuture |
bind(ChannelFuture future)
Bind the
Channel of the given AbstractBootstrap.ChannelFactory. |
B |
channel(Class<? extends Channel> channelClass)
|
B |
channelFactory(AbstractBootstrap.ChannelFactory factory)
AbstractBootstrap.ChannelFactory which is used to create Channel instances from
when calling bind(). |
protected static boolean |
ensureOpen(ChannelFuture future) |
protected AbstractBootstrap.ChannelFactory |
factory() |
protected EventLoopGroup |
group() |
B |
group(EventLoopGroup group)
The
EventLoopGroup which is used to handle all the events for the to-be-creates
Channel |
protected ChannelHandler |
handler() |
B |
handler(ChannelHandler handler)
the
ChannelHandler to use for serving the requests. |
protected SocketAddress |
localAddress() |
B |
localAddress(InetAddress host,
int port)
|
B |
localAddress(int port)
|
B |
localAddress(SocketAddress localAddress)
The
SocketAddress which is used to bind the local "end" to. |
B |
localAddress(String host,
int port)
|
<T> B |
option(ChannelOption<T> option,
T value)
Allow to specify a
ChannelOption which is used for the Channel instances once they got
created. |
protected Map<ChannelOption<?>,Object> |
options() |
void |
shutdown()
Shutdown the
AbstractBootstrap and the EventLoopGroup which is
used by it. |
protected void |
validate()
Validate all the parameters.
|
protected void |
validate(ChannelFuture future) |
public B group(EventLoopGroup group)
EventLoopGroup which is used to handle all the events for the to-be-creates
Channelpublic B channel(Class<? extends Channel> 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(AbstractBootstrap.ChannelFactory factory)
AbstractBootstrap.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(SocketAddress localAddress)
SocketAddress which is used to bind the local "end" to.public B localAddress(int port)
public B localAddress(InetAddress host, int port)
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 void shutdown()
AbstractBootstrap and the EventLoopGroup which is
used by it. Only call this if you don't share the EventLoopGroup
between different AbstractBootstrap's.protected void validate()
protected final void validate(ChannelFuture future)
public ChannelFuture bind()
Channel and bind it.public B handler(ChannelHandler handler)
ChannelHandler to use for serving the requests.protected static boolean ensureOpen(ChannelFuture future)
public abstract ChannelFuture bind(ChannelFuture future)
Channel of the given AbstractBootstrap.ChannelFactory.protected final SocketAddress localAddress()
protected final AbstractBootstrap.ChannelFactory factory()
protected final ChannelHandler handler()
protected final EventLoopGroup group()
protected final Map<ChannelOption<?>,Object> options()
Copyright © 2008-2012 The Netty Project. All Rights Reserved.