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 booleanprivate static final Map.Entry<AttributeKey<?>, Object>[]private static final Map.Entry<ChannelOption<?>, Object>[]private ClassLoader(package private) EventLoopGroupprivate ChannelHandlerprivate SocketAddressprivate final Map<ChannelOption<?>, Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Battr(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 newChanneland bind it.bind(int inetPort) Create a newChanneland bind it.Create a newChanneland bind it.bind(InetAddress inetHost, int inetPort) Create a newChanneland bind it.bind(SocketAddress localAddress) Create a newChanneland bind it.(package private) final ChannelFactory<? extends C> channelFactory(ChannelFactory<? extends C> channelFactory) Deprecated.channelFactory(ChannelFactory<? extends C> channelFactory) abstract Bclone()Returns a deep clone of this bootstrap which has the identical configuration.abstract AbstractBootstrapConfig<B, C> config()Returns theAbstractBootstrapConfigobject that can be used to obtain the current config of the bootstrap.(package private) static <K,V> Map <K, V> private ChannelFuturedoBind(SocketAddress localAddress) private static voiddoBind0(ChannelFuture regFuture, Channel channel, SocketAddress localAddress, ChannelPromise promise) extensionsClassLoader(ClassLoader classLoader) LoadChannelInitializerExtensions using the given class loader.(package private) Collection<ChannelInitializerExtension> final EventLoopGroupgroup()Deprecated.Useconfig()instead.group(EventLoopGroup group) TheEventLoopGroupwhich is used to handle all the events for the to-be-createdChannel(package private) final ChannelHandlerhandler()handler(ChannelHandler handler) theChannelHandlerto use for serving the requests.(package private) abstract void(package private) final ChannelFuture(package private) final SocketAddresslocalAddress(int inetPort) localAddress(String inetHost, int inetPort) localAddress(InetAddress inetHost, int inetPort) localAddress(SocketAddress localAddress) TheSocketAddresswhich 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> Boption(ChannelOption<T> option, T value) Allow to specify aChannelOptionwhich is used for theChannelinstances once they got created.(package private) final Map<ChannelOption<?>, Object> options()(package private) final Map<ChannelOption<?>, Object> options0()register()private Bself()(package private) static voidsetAttributes(Channel channel, Map.Entry<AttributeKey<?>, Object>[] attrs) private static voidsetChannelOption(Channel channel, ChannelOption<?> option, Object value, InternalLogger logger) (package private) static voidsetChannelOptions(Channel channel, Map.Entry<ChannelOption<?>, Object>[] options, InternalLogger logger) toString()validate()Validate all the parameters.
-
Field Details
-
CLOSE_ON_SET_OPTION_FAILURE
private static final boolean CLOSE_ON_SET_OPTION_FAILURE -
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
TheEventLoopGroupwhich is used to handle all the events for the to-be-createdChannel -
self
-
channel
-
channelFactory
Deprecated.UsechannelFactory(io.netty.channel.ChannelFactory)instead. -
channelFactory
ChannelFactorywhich is used to createChannelinstances from when callingbind(). This method is usually only used ifchannel(Class)is not working for you because of some more complex needs. If yourChannelimplementation has a no-args constructor, its highly recommend to just usechannel(Class)to simplify your code. -
localAddress
TheSocketAddresswhich is used to bind the local "end" to. -
localAddress
- See Also:
-
localAddress
-
localAddress
- See Also:
-
option
Allow to specify aChannelOptionwhich is used for theChannelinstances once they got created. Use a value ofnullto remove a previous setChannelOption. -
attr
Allow to specify an initial attribute of the newly createdChannel. If thevalueisnull, the attribute of the specifiedkeyis removed. -
extensionsClassLoader
LoadChannelInitializerExtensions 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 loadingChannelInitializerExtensions.- 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 multipleChannels with similar settings. Please note that this method does not clone theEventLoopGroupdeeply but shallowly, making the group a shared resource. -
register
-
bind
Create a newChanneland bind it. -
bind
Create a newChanneland bind it. -
bind
Create a newChanneland bind it. -
bind
Create a newChanneland bind it. -
bind
Create a newChanneland bind it. -
doBind
-
initAndRegister
-
init
-
getInitializerExtensions
Collection<ChannelInitializerExtension> getInitializerExtensions() -
doBind0
private static void doBind0(ChannelFuture regFuture, Channel channel, SocketAddress localAddress, ChannelPromise promise) -
handler
theChannelHandlerto use for serving the requests. -
group
Deprecated.Useconfig()instead.Returns the configuredEventLoopGroupornullif non is configured yet. -
config
Returns theAbstractBootstrapConfigobject 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) throws Throwable - Throws:
Throwable
-
setChannelOption
private static void setChannelOption(Channel channel, ChannelOption<?> option, Object value, InternalLogger logger) throws Throwable - Throws:
Throwable
-
toString
-
channelFactory(io.netty.channel.ChannelFactory)instead.