- java.lang.Object
-
- io.netty5.bootstrap.AbstractBootstrap<Bootstrap,Channel,ChannelFactory<? extends Channel>>
-
- io.netty5.bootstrap.Bootstrap
-
- All Implemented Interfaces:
Cloneable
public class Bootstrap extends AbstractBootstrap<Bootstrap,Channel,ChannelFactory<? extends Channel>>
ABootstrap
that makes it easy to bootstrap aChannel
to use for clients.The
AbstractBootstrap.bind()
methods are useful in combination with connectionless transports such as datagram (UDP). For regular TCP connections, please use the providedconnect()
methods.
-
-
Constructor Summary
Constructors Constructor Description Bootstrap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bootstrap
channel(Class<? extends Channel> channelClass)
Bootstrap
channelFactory(ChannelFactory<? extends Channel> channelFactory)
ChannelFactory
which is used to createChannel
instances from when callingAbstractBootstrap.bind()
.Bootstrap
clone()
Returns a deep clone of this bootstrap which has the identical configuration.Bootstrap
clone(EventLoopGroup group)
Returns a deep clone of this bootstrap which has the identical configuration except that it uses the givenEventLoopGroup
.BootstrapConfig
config()
Returns theAbstractBootstrapConfig
object that can be used to obtain the current config of the bootstrap.Future<Channel>
connect()
Connect aChannel
to the remote peer.Future<Channel>
connect(String inetHost, int inetPort)
Connect aChannel
to the remote peer.Future<Channel>
connect(InetAddress inetHost, int inetPort)
Connect aChannel
to the remote peer.Future<Channel>
connect(SocketAddress remoteAddress)
Connect aChannel
to the remote peer.Future<Channel>
connect(SocketAddress remoteAddress, SocketAddress localAddress)
Connect aChannel
to the remote peer.Bootstrap
remoteAddress(String inetHost, int inetPort)
Bootstrap
remoteAddress(InetAddress inetHost, int inetPort)
Bootstrap
remoteAddress(SocketAddress remoteAddress)
TheSocketAddress
to connect to once theconnect()
method is called.Bootstrap
resolver(AddressResolverGroup<?> resolver)
Sets theNameResolver
which will resolve the address of the unresolved named address.Bootstrap
validate()
Validate all the parameters.-
Methods inherited from class io.netty5.bootstrap.AbstractBootstrap
attr, bind, bind, bind, bind, bind, createUnregistered, group, group, handler, localAddress, localAddress, localAddress, localAddress, option, register, toString
-
-
-
-
Method Detail
-
resolver
public Bootstrap resolver(AddressResolverGroup<?> resolver)
Sets theNameResolver
which will resolve the address of the unresolved named address.- Parameters:
resolver
- theNameResolver
for thisBootstrap
; may benull
, in which case a default resolver will be used- See Also:
DefaultAddressResolverGroup
-
remoteAddress
public Bootstrap remoteAddress(SocketAddress remoteAddress)
TheSocketAddress
to connect to once theconnect()
method is called.
-
remoteAddress
public Bootstrap remoteAddress(String inetHost, int inetPort)
- See Also:
remoteAddress(SocketAddress)
-
remoteAddress
public Bootstrap remoteAddress(InetAddress inetHost, int inetPort)
- See Also:
remoteAddress(SocketAddress)
-
channel
public Bootstrap channel(Class<? extends Channel> channelClass)
TheClass
which is used to createChannel
instances from. You either use this orchannelFactory(ChannelFactory)
if yourChannel
implementation has no no-args constructor.
-
channelFactory
public Bootstrap channelFactory(ChannelFactory<? extends Channel> channelFactory)
ChannelFactory
which is used to createChannel
instances from when callingAbstractBootstrap.bind()
. This method is usually only used ifchannel(Class)
is not working for you because of some more complex needs. If yourChannel
implementation has a no-args constructor, its highly recommend to just usechannel(Class)
to simplify your code.
-
connect
public Future<Channel> connect(String inetHost, int inetPort)
Connect aChannel
to the remote peer.
-
connect
public Future<Channel> connect(InetAddress inetHost, int inetPort)
Connect aChannel
to the remote peer.
-
connect
public Future<Channel> connect(SocketAddress remoteAddress)
Connect aChannel
to the remote peer.
-
connect
public Future<Channel> connect(SocketAddress remoteAddress, SocketAddress localAddress)
Connect aChannel
to the remote peer.
-
validate
public Bootstrap validate()
Description copied from class:AbstractBootstrap
Validate all the parameters. Sub-classes may override this, but should call the super method in that case.- Overrides:
validate
in classAbstractBootstrap<Bootstrap,Channel,ChannelFactory<? extends Channel>>
-
clone
public Bootstrap clone()
Description copied from class:AbstractBootstrap
Returns a deep clone of this bootstrap which has the identical configuration. This method is useful when making multipleChannel
s with similar settings. Please note that this method does not clone theEventLoopGroup
deeply but shallowly, making the group a shared resource.- Specified by:
clone
in classAbstractBootstrap<Bootstrap,Channel,ChannelFactory<? extends Channel>>
-
clone
public Bootstrap clone(EventLoopGroup group)
Returns a deep clone of this bootstrap which has the identical configuration except that it uses the givenEventLoopGroup
. This method is useful when making multipleChannel
s with similar settings.
-
config
public final BootstrapConfig config()
Description copied from class:AbstractBootstrap
Returns theAbstractBootstrapConfig
object that can be used to obtain the current config of the bootstrap.- Specified by:
config
in classAbstractBootstrap<Bootstrap,Channel,ChannelFactory<? extends Channel>>
-
-