Enum Class NettyTransport
- All Implemented Interfaces:
Serializable, Comparable<NettyTransport>, Constable
Holds all supported transport types and functionality to retrieve model instances for servers/clients construction.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final io.netty5.channel.ChannelFactory<? extends io.netty5.channel.Channel> private final Supplier<io.netty5.channel.IoHandlerFactory> private final Stringprivate final booleanprivate final io.netty5.channel.ServerChannelFactory<? extends io.netty5.channel.ServerChannel> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNettyTransport(@NonNull String name, boolean available, boolean nativeTransport, @NonNull Supplier<io.netty5.channel.IoHandlerFactory> ioHandlerFactory, @NonNull io.netty5.channel.ChannelFactory<? extends io.netty5.channel.Channel> clientChannelFactory, @NonNull io.netty5.channel.ServerChannelFactory<? extends io.netty5.channel.ServerChannel> serverChannelFactory) Constructs a new netty transport instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull NettyTransportavailableTransport(boolean noNative) Selects and returns the first available transport.@NonNull io.netty5.channel.ChannelFactory<? extends io.netty5.channel.Channel> Get the factory for client channels of this transport.@NonNull io.netty5.channel.EventLoopGroupcreateEventLoopGroup(int threads, @Nullable ThreadFactory threadFactory) Creates a new event loop group of the current selected transport with the supplied amount of threads.Get the display name of the transport.booleanGet if this transport type is native.@NonNull io.netty5.channel.ServerChannelFactory<? extends io.netty5.channel.ServerChannel> Get the factory for server channels of this transport.static NettyTransportReturns the enum constant of this class with the specified name.static NettyTransport[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
EPOLL
-
KQUEUE
-
NIO
-
-
Field Details
-
name
-
available
private final boolean available -
nativeTransport
private final boolean nativeTransport -
ioHandlerFactory
-
clientChannelFactory
private final io.netty5.channel.ChannelFactory<? extends io.netty5.channel.Channel> clientChannelFactory -
serverChannelFactory
private final io.netty5.channel.ServerChannelFactory<? extends io.netty5.channel.ServerChannel> serverChannelFactory
-
-
Constructor Details
-
NettyTransport
private NettyTransport(@NonNull @NonNull String name, boolean available, boolean nativeTransport, @NonNull @NonNull Supplier<io.netty5.channel.IoHandlerFactory> ioHandlerFactory, @NonNull @NonNull io.netty5.channel.ChannelFactory<? extends io.netty5.channel.Channel> clientChannelFactory, @NonNull @NonNull io.netty5.channel.ServerChannelFactory<? extends io.netty5.channel.ServerChannel> serverChannelFactory) Constructs a new netty transport instance.- Parameters:
name- the display name of the transport.available- if the transport is available.nativeTransport- if the transport is native.ioHandlerFactory- the factory for io handlers.clientChannelFactory- the factory for client channels.serverChannelFactory- the factory for server channels.- Throws:
NullPointerException- if one of the given parameters is null.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
availableTransport
Selects and returns the first available transport. If this method should not return native transports, it currently only returns nio.- Parameters:
noNative- if no native transport should get included into the selection.- Returns:
- the first available transport.
- Throws:
IllegalStateException- if no transport is available, should normally never happen.
-
createEventLoopGroup
@NonNull public @NonNull io.netty5.channel.EventLoopGroup createEventLoopGroup(int threads, @Nullable @Nullable ThreadFactory threadFactory) Creates a new event loop group of the current selected transport with the supplied amount of threads.- Parameters:
threads- the amount of threads.threadFactory- the thread factory to use for event loop threads, null to use the default factory.- Returns:
- a new event loop group for this transport.
- Throws:
IllegalArgumentException- if the given number of threads is negative.
-
displayName
-
nativeTransport
public boolean nativeTransport()Get if this transport type is native.- Returns:
- if this transport type is native.
-
clientChannelFactory
-
serverChannelFactory
-