Class AbstractBootstrap<B extends AbstractBootstrap<B,C> , C extends Channel>
java.lang.Object
io.netty.bootstrap.AbstractBootstrap<B,C>
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
Bootstrap, ServerBootstrap
public abstract class AbstractBootstrap<B extends AbstractBootstrap<B,C>, C extends Channel>
extends java.lang.Object
implements java.lang.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 java.util.Map<AttributeKey<?>, java.lang.Object> private ChannelFactory<? extends C> private static final booleanprivate static final java.util.Map.Entry<AttributeKey<?>, java.lang.Object>[]private static final java.util.Map.Entry<ChannelOption<?>, java.lang.Object>[]private java.lang.ClassLoader(package private) EventLoopGroupprivate ChannelHandlerprivate java.net.SocketAddressprivate final java.util.Map<ChannelOption<?>, java.lang.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 java.util.Map<AttributeKey<?>, java.lang.Object> attrs()(package private) final java.util.Map<AttributeKey<?>, java.lang.Object> attrs0()bind()Create a newChanneland bind it.bind(int inetPort) Create a newChanneland bind it.bind(java.lang.String inetHost, int inetPort) Create a newChanneland bind it.bind(java.net.InetAddress inetHost, int inetPort) Create a newChanneland bind it.bind(java.net.SocketAddress localAddress) Create a newChanneland bind it.TheClasswhich is used to createChannelinstances from.(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> java.util.Map <K, V> copiedMap(java.util.Map<K, V> map) private ChannelFuturedoBind(java.net.SocketAddress localAddress) private static voiddoBind0(ChannelFuture regFuture, Channel channel, java.net.SocketAddress localAddress, ChannelPromise promise) extensionsClassLoader(java.lang.ClassLoader classLoader) LoadChannelInitializerExtensions using the given class loader.(package private) java.util.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 java.net.SocketAddresslocalAddress(int inetPort) localAddress(java.lang.String inetHost, int inetPort) localAddress(java.net.InetAddress inetHost, int inetPort) localAddress(java.net.SocketAddress localAddress) TheSocketAddresswhich is used to bind the local "end" to.(package private) final java.util.Map.Entry<AttributeKey<?>, java.lang.Object>[](package private) static java.util.Map.Entry<AttributeKey<?>, java.lang.Object>[]newAttributesArray(java.util.Map<AttributeKey<?>, java.lang.Object> attributes) (package private) final java.util.Map.Entry<ChannelOption<?>, java.lang.Object>[](package private) static java.util.Map.Entry<ChannelOption<?>, java.lang.Object>[]newOptionsArray(java.util.Map<ChannelOption<?>, java.lang.Object> options) <T> Boption(ChannelOption<T> option, T value) Allow to specify aChannelOptionwhich is used for theChannelinstances once they got created.(package private) final java.util.Map<ChannelOption<?>, java.lang.Object> options()(package private) final java.util.Map<ChannelOption<?>, java.lang.Object> options0()register()private Bself()(package private) static voidsetAttributes(Channel channel, java.util.Map.Entry<AttributeKey<?>, java.lang.Object>[] attrs) private static voidsetChannelOption(Channel channel, ChannelOption<?> option, java.lang.Object value, InternalLogger logger) (package private) static voidsetChannelOptions(Channel channel, java.util.Map.Entry<ChannelOption<?>, java.lang.Object>[] options, InternalLogger logger) java.lang.StringtoString()validate()Validate all the parameters.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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
private volatile java.net.SocketAddress localAddress -
options
-
attrs
-
handler
-
extensionsClassLoader
private volatile java.lang.ClassLoader 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
TheClasswhich is used to createChannelinstances from. You either use this orchannelFactory(io.netty.channel.ChannelFactory)if yourChannelimplementation has no no-args constructor. -
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
- See Also:
-
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.- Overrides:
clonein classjava.lang.Object
-
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
- Throws:
java.lang.Throwable
-
getInitializerExtensions
java.util.Collection<ChannelInitializerExtension> getInitializerExtensions() -
doBind0
private static void doBind0(ChannelFuture regFuture, Channel channel, java.net.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
static java.util.Map.Entry<ChannelOption<?>, java.lang.Object>[] newOptionsArray(java.util.Map<ChannelOption<?>, java.lang.Object> options) -
newAttributesArray
-
newAttributesArray
static java.util.Map.Entry<AttributeKey<?>, java.lang.Object>[] newAttributesArray(java.util.Map<AttributeKey<?>, java.lang.Object> attributes) -
options0
-
attrs0
-
localAddress
final java.net.SocketAddress localAddress() -
channelFactory
-
handler
-
options
-
attrs
-
copiedMap
static <K,V> java.util.Map<K,V> copiedMap(java.util.Map<K, V> map) -
setAttributes
static void setAttributes(Channel channel, java.util.Map.Entry<AttributeKey<?>, java.lang.Object>[] attrs) -
setChannelOptions
static void setChannelOptions(Channel channel, java.util.Map.Entry<ChannelOption<?>, java.lang.Object>[] options, InternalLogger logger) throws java.lang.Throwable - Throws:
java.lang.Throwable
-
setChannelOption
private static void setChannelOption(Channel channel, ChannelOption<?> option, java.lang.Object value, InternalLogger logger) throws java.lang.Throwable - Throws:
java.lang.Throwable
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
channelFactory(io.netty.channel.ChannelFactory)instead.