Module io.netty5.transport
Package io.netty5.bootstrap
Class AbstractBootstrap<B extends AbstractBootstrap<B,C,F>,C extends Channel,F>
- java.lang.Object
-
- io.netty5.bootstrap.AbstractBootstrap<B,C,F>
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
Bootstrap,ServerBootstrap
public abstract class AbstractBootstrap<B extends AbstractBootstrap<B,C,F>,C extends Channel,F> extends Object implements Cloneable
AbstractBootstrapis a helper class that makes it easy to bootstrap aChannel. It support method-chaining to provide an easy way to configure theAbstractBootstrap.When not used in a
ServerBootstrapcontext, thebind()methods are useful for connectionless transports such as datagram (UDP).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> Battr(AttributeKey<T> key, T value)Allow to specify an initial attribute of the newly createdChannel.Future<Channel>bind()Create a newChanneland bind it.Future<Channel>bind(int inetPort)Create a newChanneland bind it.Future<Channel>bind(String inetHost, int inetPort)Create a newChanneland bind it.Future<Channel>bind(InetAddress inetHost, int inetPort)Create a newChanneland bind it.Future<Channel>bind(SocketAddress localAddress)Create a newChanneland bind it.abstract Bclone()Returns a deep clone of this bootstrap which has the identical configuration.abstract AbstractBootstrapConfig<B,C,F>config()Returns theAbstractBootstrapConfigobject that can be used to obtain the current config of the bootstrap.ChannelcreateUnregistered()Create a new unregistered channel.EventLoopGroupgroup()Deprecated.Useconfig()instead.Bgroup(EventLoopGroup group)TheEventLoopGroupwhich is used to handle all the events for the to-be-createdChannelBhandler(ChannelHandler handler)theChannelHandlerto use for serving the requests.BlocalAddress(int inetPort)BlocalAddress(String inetHost, int inetPort)BlocalAddress(InetAddress inetHost, int inetPort)BlocalAddress(SocketAddress localAddress)TheSocketAddresswhich is used to bind the local "end" to.<T> Boption(ChannelOption<T> option, T value)Allow to specify aChannelOptionwhich is used for theChannelinstances once they got created.Future<Channel>register()StringtoString()Bvalidate()Validate all the parameters.
-
-
-
Method Detail
-
group
public B group(EventLoopGroup group)
TheEventLoopGroupwhich is used to handle all the events for the to-be-createdChannel
-
localAddress
public B localAddress(SocketAddress localAddress)
TheSocketAddresswhich is used to bind the local "end" to.
-
localAddress
public B localAddress(int inetPort)
- See Also:
localAddress(SocketAddress)
-
localAddress
public B localAddress(String inetHost, int inetPort)
- See Also:
localAddress(SocketAddress)
-
localAddress
public B localAddress(InetAddress inetHost, int inetPort)
- See Also:
localAddress(SocketAddress)
-
option
public <T> B option(ChannelOption<T> option, T value)
Allow to specify aChannelOptionwhich is used for theChannelinstances once they got created. Use a value ofnullto remove a previous setChannelOption.
-
attr
public <T> B attr(AttributeKey<T> key, T value)
Allow to specify an initial attribute of the newly createdChannel. If thevalueisnull, the attribute of the specifiedkeyis removed.
-
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 multipleChannels with similar settings. Please note that this method does not clone theEventLoopGroupdeeply but shallowly, making the group a shared resource.
-
createUnregistered
public Channel createUnregistered() throws Exception
Create a new unregistered channel.The channel must then be registered separately.
- Returns:
- A new unregistered channel.
- Throws:
Exception- If the channel cannot be created.
-
bind
public Future<Channel> bind(InetAddress inetHost, int inetPort)
Create a newChanneland bind it.
-
bind
public Future<Channel> bind(SocketAddress localAddress)
Create a newChanneland bind it.
-
handler
public B handler(ChannelHandler handler)
theChannelHandlerto use for serving the requests.
-
group
@Deprecated public final EventLoopGroup group()
Deprecated.Useconfig()instead.Returns the configuredEventLoopGroupornullif non is configured yet.
-
config
public abstract AbstractBootstrapConfig<B,C,F> config()
Returns theAbstractBootstrapConfigobject that can be used to obtain the current config of the bootstrap.
-
-