Top Description Inners Fields Constructors Methods
io.netty.bootstrap

public abstract Class AbstractBootstrap<B extends AbstractBootstrap<B, C>, C extends Channel>

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
io.netty.bootstrap.Bootstrap, io.netty.bootstrap.ServerBootstrap
Imports
io.netty.channel.Channel, .ChannelFuture, .ChannelFutureListener, .ChannelHandler, .ChannelOption, .ChannelPromise, .DefaultChannelPromise, .EventLoop, .EventLoopGroup, .ReflectiveChannelFactory, io.netty.util.AttributeKey, io.netty.util.concurrent.EventExecutor, .GlobalEventExecutor, io.netty.util.internal.ObjectUtil, .SocketUtils, .StringUtil, io.netty.util.internal.logging.InternalLogger, java.net.InetAddress, .InetSocketAddress, .SocketAddress, java.util.Collection, .Collections, .HashMap, .LinkedHashMap, .Map, java.util.concurrent.ConcurrentHashMap

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 and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Map<AttributeKey<?>, Object>
private volatile ChannelFactory<? extends C>
channelFactory

Deprecated as a consequence of ChannelFactory being deprecated.
private static final Map.Entry<AttributeKey<?>, Object>[]
private static final Map.Entry<ChannelOption<?>, Object>[]
private volatile ClassLoader
pack-priv volatile EventLoopGroup
private volatile ChannelHandler
private volatile SocketAddress
private final Map<ChannelOption<?>, Object>

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public <T> B
attr(AttributeKey<T> key, T value)

Allow to specify an initial attribute of the newly created Channel.

pack-priv final Map<AttributeKey<?>, Object>
pack-priv final Map<AttributeKey<?>, Object>
public ChannelFuture
bind()

Create a new Channel and bind it.

public ChannelFuture
bind(int inetPort)

Create a new Channel and bind it.

public ChannelFuture
bind(String inetHost, int inetPort)

Create a new Channel and bind it.

public ChannelFuture
bind(InetAddress inetHost, int inetPort)

Create a new Channel and bind it.

public ChannelFuture
bind(SocketAddress localAddress)

Create a new Channel and bind it.

public B
channel(Class<? extends C> channelClass)

The Class which is used to create Channel instances from.

public B
channelFactory(ChannelFactory<? extends C> channelFactory)

public B
channelFactory(ChannelFactory<? extends C> channelFactory)

Deprecated as a consequence of ChannelFactory being deprecated.
io.netty.channel.ChannelFactory which is used to create Channel instances from when calling bind().
pack-priv final ChannelFactory<? extends C>
channelFactory()

Deprecated as a consequence of ChannelFactory being deprecated.
public abstract B
clone()

Overrides java.lang.Object.clone.

Returns a deep clone of this bootstrap which has the identical configuration.
public abstract AbstractBootstrapConfig<B, C>
config()

Returns the AbstractBootstrapConfig object that can be used to obtain the current config of the bootstrap.

pack-priv static <K, V> Map<K, V>
copiedMap(Map<K, V> map)

private ChannelFuture
doBind(final SocketAddress localAddress)

private static void
doBind0(final ChannelFuture regFuture, final Channel channel, final SocketAddress localAddress, final ChannelPromise promise)

public B

Returns:

This bootstrap.
extensionsClassLoader
(ClassLoader
The class loader to use for loading ChannelInitializerExtensions.
classLoader
)

Load ChannelInitializerExtensions using the given class loader.

pack-priv Collection<ChannelInitializerExtension>
public B
group(EventLoopGroup group)

The EventLoopGroup which is used to handle all the events for the to-be-created Channel

public final EventLoopGroup
group()

Deprecated Use config() instead.
Returns the configured EventLoopGroup or null if non is configured yet.
public B
handler(ChannelHandler handler)

the ChannelHandler to use for serving the requests.

pack-priv final ChannelHandler
pack-priv abstract void
init(Channel channel)

pack-priv final ChannelFuture
public B
localAddress(SocketAddress localAddress)

The SocketAddress which is used to bind the local "end" to.

public B
localAddress(int inetPort)

public B
localAddress(String inetHost, int inetPort)

public B
localAddress(InetAddress inetHost, int inetPort)

pack-priv final SocketAddress
pack-priv final Map.Entry<AttributeKey<?>, Object>[]
pack-priv static Map.Entry<AttributeKey<?>, Object>[]
pack-priv final Map.Entry<ChannelOption<?>, Object>[]
pack-priv static Map.Entry<ChannelOption<?>, Object>[]
public <T> B
option(ChannelOption<T> option, T value)

Allow to specify a ChannelOption which is used for the Channel instances once they got created.

pack-priv final Map<ChannelOption<?>, Object>
pack-priv final Map<ChannelOption<?>, Object>
public ChannelFuture
register()

Create a new Channel and register it with an EventLoop.

private B
self()

pack-priv static void
private static void
setChannelOption(Channel channel, ChannelOption<?> option, Object value, InternalLogger logger)

pack-priv static void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public B
validate()

Validate all the parameters.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attrsback to summary
private final Map<AttributeKey<?>, Object> attrs
channelFactoryback to summary
private volatile ChannelFactory<? extends C> channelFactory

Deprecated

as a consequence of ChannelFactory being deprecated. See corresponding docs for further information.

Annotations
@SuppressWarnings:deprecation
EMPTY_ATTRIBUTE_ARRAYback to summary
private static final Map.Entry<AttributeKey<?>, Object>[] EMPTY_ATTRIBUTE_ARRAY
Annotations
@SuppressWarnings:unchecked
EMPTY_OPTION_ARRAYback to summary
private static final Map.Entry<ChannelOption<?>, Object>[] EMPTY_OPTION_ARRAY
Annotations
@SuppressWarnings:unchecked
extensionsClassLoaderback to summary
private volatile ClassLoader extensionsClassLoader
groupback to summary
pack-priv volatile EventLoopGroup group
handlerback to summary
private volatile ChannelHandler handler
localAddressback to summary
private volatile SocketAddress localAddress
optionsback to summary
private final Map<ChannelOption<?>, Object> options

Constructor Detail

AbstractBootstrapback to summary
pack-priv AbstractBootstrap()
AbstractBootstrapback to summary
pack-priv AbstractBootstrap(AbstractBootstrap<B, C> bootstrap)

Method Detail

attrback to summary
public <T> B attr(AttributeKey<T> key, T value)

Allow to specify an initial attribute of the newly created Channel. If the value is null, the attribute of the specified key is removed.

attrsback to summary
pack-priv final Map<AttributeKey<?>, Object> attrs()
attrs0back to summary
pack-priv final Map<AttributeKey<?>, Object> attrs0()
bindback to summary
public ChannelFuture bind()

Create a new Channel and bind it.

bindback to summary
public ChannelFuture bind(int inetPort)

Create a new Channel and bind it.

bindback to summary
public ChannelFuture bind(String inetHost, int inetPort)

Create a new Channel and bind it.

bindback to summary
public ChannelFuture bind(InetAddress inetHost, int inetPort)

Create a new Channel and bind it.

bindback to summary
public ChannelFuture bind(SocketAddress localAddress)

Create a new Channel and bind it.

channelback to summary
public B channel(Class<? extends C> channelClass)

The Class which is used to create Channel instances from. You either use this or channelFactory(io.netty.channel.ChannelFactory) if your Channel implementation has no no-args constructor.

channelFactoryback to summary
public B channelFactory(ChannelFactory<? extends C> channelFactory)
Annotations
@Deprecated
channelFactoryback to summary
public B channelFactory(ChannelFactory<? extends C> channelFactory)

Deprecated

as a consequence of ChannelFactory being deprecated. See corresponding docs for further information.

io.netty.channel.ChannelFactory which is used to create Channel instances from when calling bind(). This method is usually only used if channel(Class) is not working for you because of some more complex needs. If your Channel implementation has a no-args constructor, its highly recommend to just use channel(Class) to simplify your code.

Annotations
@SuppressWarnings:unchecked, deprecation
channelFactoryback to summary
pack-priv final ChannelFactory<? extends C> channelFactory()

Deprecated

as a consequence of ChannelFactory being deprecated. See corresponding docs for further information.

Annotations
@SuppressWarnings:deprecation
cloneback to summary
public abstract B clone()

Overrides java.lang.Object.clone.

Returns a deep clone of this bootstrap which has the identical configuration. This method is useful when making multiple Channels with similar settings. Please note that this method does not clone the EventLoopGroup deeply but shallowly, making the group a shared resource.

Returns:B

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
@SuppressWarnings:CloneDoesntDeclareCloneNotSupportedException
configback to summary
public abstract AbstractBootstrapConfig<B, C> config()

Returns the AbstractBootstrapConfig object that can be used to obtain the current config of the bootstrap.

copiedMapback to summary
pack-priv static <K, V> Map<K, V> copiedMap(Map<K, V> map)
doBindback to summary
private ChannelFuture doBind(final SocketAddress localAddress)
doBind0back to summary
private static void doBind0(final ChannelFuture regFuture, final Channel channel, final SocketAddress localAddress, final ChannelPromise promise)
extensionsClassLoaderback to summary
public B extensionsClassLoader(ClassLoader classLoader)

Load ChannelInitializerExtensions using the given class loader.

By default, the extensions will be loaded by the same class loader that loaded this bootstrap class.

Parameters
classLoader:ClassLoader

The class loader to use for loading ChannelInitializerExtensions.

Returns:B

This bootstrap.

getInitializerExtensionsback to summary
pack-priv Collection<ChannelInitializerExtension> getInitializerExtensions()
groupback to summary
public B group(EventLoopGroup group)

The EventLoopGroup which is used to handle all the events for the to-be-created Channel

groupback to summary
public final EventLoopGroup group()

Deprecated

Use config() instead.

Returns the configured EventLoopGroup or null if non is configured yet.

Annotations
@Deprecated
handlerback to summary
public B handler(ChannelHandler handler)

the ChannelHandler to use for serving the requests.

handlerback to summary
pack-priv final ChannelHandler handler()
initback to summary
pack-priv abstract void init(Channel channel) throws Exception
initAndRegisterback to summary
pack-priv final ChannelFuture initAndRegister()
localAddressback to summary
public B localAddress(SocketAddress localAddress)

The SocketAddress which is used to bind the local "end" to.

localAddressback to summary
public B localAddress(int inetPort)
See Also
localAddress(SocketAddress)
localAddressback to summary
public B localAddress(String inetHost, int inetPort)
See Also
localAddress(SocketAddress)
localAddressback to summary
public B localAddress(InetAddress inetHost, int inetPort)
See Also
localAddress(SocketAddress)
localAddressback to summary
pack-priv final SocketAddress localAddress()
newAttributesArrayback to summary
pack-priv final Map.Entry<AttributeKey<?>, Object>[] newAttributesArray()
newAttributesArrayback to summary
pack-priv static Map.Entry<AttributeKey<?>, Object>[] newAttributesArray(Map<AttributeKey<?>, Object> attributes)
newOptionsArrayback to summary
pack-priv final Map.Entry<ChannelOption<?>, Object>[] newOptionsArray()
newOptionsArrayback to summary
pack-priv static Map.Entry<ChannelOption<?>, Object>[] newOptionsArray(Map<ChannelOption<?>, Object> options)
optionback to summary
public <T> B option(ChannelOption<T> option, T value)

Allow to specify a ChannelOption which is used for the Channel instances once they got created. Use a value of null to remove a previous set ChannelOption.

optionsback to summary
pack-priv final Map<ChannelOption<?>, Object> options()
options0back to summary
pack-priv final Map<ChannelOption<?>, Object> options0()
registerback to summary
public ChannelFuture register()

Create a new Channel and register it with an EventLoop.

selfback to summary
private B self()
Annotations
@SuppressWarnings:unchecked
setAttributesback to summary
pack-priv static void setAttributes(Channel channel, Map.Entry<AttributeKey<?>, Object>[] attrs)
setChannelOptionback to summary
private static void setChannelOption(Channel channel, ChannelOption<?> option, Object value, InternalLogger logger)
Annotations
@SuppressWarnings:unchecked
setChannelOptionsback to summary
pack-priv static void setChannelOptions(Channel channel, Map.Entry<ChannelOption<?>, Object>[] options, InternalLogger logger)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
validateback to summary
public B validate()

Validate all the parameters. Sub-classes may override this, but should call the super method in that case.

io.netty.bootstrap back to summary

pack-priv final Class AbstractBootstrap.PendingRegistrationPromise

extends DefaultChannelPromise
Class Inheritance

Field Summary

Modifier and TypeField and Description
private volatile boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected EventExecutor
executor()

Overrides io.netty.channel.DefaultChannelPromise.executor.

Get the executor used to notify listeners when this promise is complete.
pack-priv void
Inherited from io.netty.channel.DefaultChannelPromise:
addListeneraddListenersawaitawaitUninterruptiblychannelcheckDeadLockflushCheckpointflushCheckpointisVoidpromiseremoveListenerremoveListenerssetFailuresetSuccesssetSuccesssyncsyncUninterruptiblytrySuccessunvoid

Field Detail

registeredback to summary
private volatile boolean registered

Constructor Detail

PendingRegistrationPromiseback to summary
pack-priv PendingRegistrationPromise(Channel channel)

Method Detail

executorback to summary
protected EventExecutor executor()

Overrides io.netty.channel.DefaultChannelPromise.executor.

Doc from io.netty.util.concurrent.DefaultPromise.executor.

Get the executor used to notify listeners when this promise is complete.

It is assumed this executor will protect against StackOverflowError exceptions. The executor may be used to avoid StackOverflowError by executing a Runnable if the stack depth exceeds a threshold.

Returns:EventExecutor

The executor used to notify listeners when this promise is complete.

Annotations
@Override
registeredback to summary
pack-priv void registered()