Package io.netty.bootstrap
Class AbstractBootstrap<B extends AbstractBootstrap<B,C>,C extends Channel>
java.lang.Object
io.netty.bootstrap.AbstractBootstrap<B,C>
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
Bootstrap
,ServerBootstrap
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).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<AttributeKey<?>, Object> private ChannelFactory
<? extends C> private static final Map.Entry<AttributeKey<?>,
Object>[] private static final Map.Entry<ChannelOption<?>,
Object>[] private ClassLoader
(package private) EventLoopGroup
private ChannelHandler
private SocketAddress
private final Map
<ChannelOption<?>, Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> B
attr
(AttributeKey<T> key, T value) Allow to specify an initial attribute of the newly createdChannel
.(package private) final Map
<AttributeKey<?>, Object> attrs()
(package private) final Map
<AttributeKey<?>, Object> attrs0()
bind()
Create a newChannel
and bind it.bind
(int inetPort) Create a newChannel
and bind it.Create a newChannel
and bind it.bind
(InetAddress inetHost, int inetPort) Create a newChannel
and bind it.bind
(SocketAddress localAddress) Create a newChannel
and bind it.(package private) final ChannelFactory
<? extends C> channelFactory
(ChannelFactory<? extends C> channelFactory) Deprecated.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 theAbstractBootstrapConfig
object that can be used to obtain the current config of the bootstrap.(package private) static <K,
V> Map <K, V> private ChannelFuture
doBind
(SocketAddress localAddress) private static void
doBind0
(ChannelFuture regFuture, Channel channel, SocketAddress localAddress, ChannelPromise promise) extensionsClassLoader
(ClassLoader classLoader) LoadChannelInitializerExtension
s using the given class loader.(package private) Collection
<ChannelInitializerExtension> final EventLoopGroup
group()
Deprecated.Useconfig()
instead.group
(EventLoopGroup group) TheEventLoopGroup
which is used to handle all the events for the to-be-createdChannel
(package private) final ChannelHandler
handler()
handler
(ChannelHandler handler) theChannelHandler
to use for serving the requests.(package private) abstract void
(package private) final ChannelFuture
(package private) final SocketAddress
localAddress
(int inetPort) localAddress
(String inetHost, int inetPort) localAddress
(InetAddress inetHost, int inetPort) localAddress
(SocketAddress localAddress) TheSocketAddress
which is used to bind the local "end" to.(package private) final Map.Entry<AttributeKey<?>,
Object>[] (package private) static Map.Entry<AttributeKey<?>,
Object>[] newAttributesArray
(Map<AttributeKey<?>, Object> attributes) (package private) final Map.Entry<ChannelOption<?>,
Object>[] (package private) static Map.Entry<ChannelOption<?>,
Object>[] newOptionsArray
(Map<ChannelOption<?>, Object> options) <T> B
option
(ChannelOption<T> option, T value) Allow to specify aChannelOption
which is used for theChannel
instances once they got created.(package private) final Map
<ChannelOption<?>, Object> options()
(package private) final Map
<ChannelOption<?>, Object> options0()
register()
private B
self()
(package private) static void
setAttributes
(Channel channel, Map.Entry<AttributeKey<?>, Object>[] attrs) private static void
setChannelOption
(Channel channel, ChannelOption<?> option, Object value, InternalLogger logger) (package private) static void
setChannelOptions
(Channel channel, Map.Entry<ChannelOption<?>, Object>[] options, InternalLogger logger) toString()
validate()
Validate all the parameters.
-
Field Details
-
EMPTY_OPTION_ARRAY
-
EMPTY_ATTRIBUTE_ARRAY
-
group
-
channelFactory
-
localAddress
-
options
-
attrs
-
handler
-
extensionsClassLoader
-
-
Constructor Details
-
AbstractBootstrap
AbstractBootstrap() -
AbstractBootstrap
AbstractBootstrap(AbstractBootstrap<B, C> bootstrap)
-
-
Method Details
-
group
TheEventLoopGroup
which is used to handle all the events for the to-be-createdChannel
-
self
-
channel
TheClass
which is used to createChannel
instances from. You either use this orchannelFactory(io.netty.channel.ChannelFactory)
if yourChannel
implementation has no no-args constructor. -
channelFactory
Deprecated.UsechannelFactory(io.netty.channel.ChannelFactory)
instead. -
channelFactory
ChannelFactory
which is used to createChannel
instances from when callingbind()
. 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. -
localAddress
TheSocketAddress
which is used to bind the local "end" to. -
localAddress
- See Also:
-
localAddress
- See Also:
-
localAddress
- See Also:
-
option
Allow to specify aChannelOption
which is used for theChannel
instances once they got created. Use a value ofnull
to remove a previous setChannelOption
. -
attr
Allow to specify an initial attribute of the newly createdChannel
. If thevalue
isnull
, the attribute of the specifiedkey
is removed. -
extensionsClassLoader
LoadChannelInitializerExtension
s using the given class loader.By default, the extensions will be loaded by the same class loader that loaded this bootstrap class.
- Parameters:
classLoader
- The class loader to use for loadingChannelInitializerExtension
s.- Returns:
- This bootstrap.
-
validate
Validate all the parameters. Sub-classes may override this, but should call the super method in that case. -
clone
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. -
register
-
bind
Create a newChannel
and bind it. -
bind
Create a newChannel
and bind it. -
bind
Create a newChannel
and bind it. -
bind
Create a newChannel
and bind it. -
bind
Create a newChannel
and bind it. -
doBind
-
initAndRegister
-
init
- Throws:
Exception
-
getInitializerExtensions
Collection<ChannelInitializerExtension> getInitializerExtensions() -
doBind0
private static void doBind0(ChannelFuture regFuture, Channel channel, SocketAddress localAddress, ChannelPromise promise) -
handler
theChannelHandler
to use for serving the requests. -
group
Deprecated.Useconfig()
instead.Returns the configuredEventLoopGroup
ornull
if non is configured yet. -
config
Returns theAbstractBootstrapConfig
object that can be used to obtain the current config of the bootstrap. -
newOptionsArray
-
newOptionsArray
-
newAttributesArray
-
newAttributesArray
static Map.Entry<AttributeKey<?>,Object>[] newAttributesArray(Map<AttributeKey<?>, Object> attributes) -
options0
-
attrs0
-
localAddress
-
channelFactory
-
handler
-
options
-
attrs
-
copiedMap
-
setAttributes
-
setChannelOptions
static void setChannelOptions(Channel channel, Map.Entry<ChannelOption<?>, Object>[] options, InternalLogger logger) -
setChannelOption
private static void setChannelOption(Channel channel, ChannelOption<?> option, Object value, InternalLogger logger) -
toString
-
channelFactory(io.netty.channel.ChannelFactory)
instead.