Package io.micronaut.http.server.netty
Class DefaultNettyEmbeddedServerFactory
- java.lang.Object
-
- io.micronaut.http.server.netty.DefaultNettyEmbeddedServerFactory
-
- All Implemented Interfaces:
NettyEmbeddedServerFactory,NettyEmbeddedServices
@Factory @Internal @Bean(typed={NettyEmbeddedServerFactory.class,DefaultNettyEmbeddedServerFactory.class}) public class DefaultNettyEmbeddedServerFactory extends java.lang.Object implements NettyEmbeddedServerFactory, NettyEmbeddedServicesDefault implementation ofNettyEmbeddedServerFactory.- Since:
- 3.1.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultNettyEmbeddedServerFactory(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.http.server.RouteExecutor routeExecutor, io.micronaut.http.codec.MediaTypeCodecRegistry mediaTypeCodecRegistry, io.micronaut.web.router.resource.StaticResourceResolver staticResourceResolver, java.util.concurrent.ThreadFactory nettyThreadFactory, HttpCompressionStrategy httpCompressionStrategy, io.micronaut.http.netty.channel.EventLoopGroupFactory eventLoopGroupFactory, io.micronaut.http.netty.channel.EventLoopGroupRegistry eventLoopGroupRegistry)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NettyEmbeddedServerbuild(NettyHttpServerConfiguration configuration)Builds aNettyEmbeddedServerfor the given configuration.NettyEmbeddedServerbuild(NettyHttpServerConfiguration configuration, io.micronaut.http.ssl.ServerSslConfiguration sslConfiguration)Builds aNettyEmbeddedServerfor the given configuration.protected NettyEmbeddedServerbuildDefaultServer(NettyHttpServerConfiguration configuration)Builds the default server configuration.io.netty.channel.EventLoopGroupcreateEventLoopGroup(int numThreads, java.util.concurrent.ExecutorService executorService, java.lang.Integer ioRatio)Creates the event loop group configuration.io.netty.channel.EventLoopGroupcreateEventLoopGroup(io.micronaut.http.netty.channel.EventLoopGroupConfiguration config)Creates the event loop group configuration.io.micronaut.context.ApplicationContextgetApplicationContext()io.micronaut.http.netty.channel.converters.ChannelOptionFactorygetChannelOptionFactory()io.netty.channel.ServerChannelgetDomainServerChannelInstance(io.micronaut.http.netty.channel.EventLoopGroupConfiguration workerConfig)Gets the domain server socket channel instance.io.micronaut.http.netty.channel.EventLoopGroupRegistrygetEventLoopGroupRegistry()<E> io.micronaut.context.event.ApplicationEventPublisher<E>getEventPublisher(java.lang.Class<E> eventClass)Get an event publisher for the server for the given type.io.micronaut.scheduling.executor.ExecutorSelectorgetExecutorSelector()HttpCompressionStrategygetHttpCompressionStrategy()io.micronaut.http.codec.MediaTypeCodecRegistrygetMediaTypeCodecRegistry()java.util.List<io.netty.channel.ChannelOutboundHandler>getOutboundHandlers()io.micronaut.http.server.binding.RequestArgumentSatisfiergetRequestArgumentSatisfier()io.micronaut.http.server.RouteExecutorgetRouteExecutor()io.netty.channel.socket.ServerSocketChannelgetServerSocketChannelInstance(io.micronaut.http.netty.channel.EventLoopGroupConfiguration workerConfig)Gets the server socket channel instance.ServerSslBuildergetServerSslBuilder()io.micronaut.web.router.resource.StaticResourceResolvergetStaticResourceResolver()io.micronaut.websocket.context.WebSocketBeanRegistrygetWebSocketBeanRegistry()protected voidsetChannelOptionFactory(io.micronaut.http.netty.channel.converters.ChannelOptionFactory channelOptionFactory)Configures the channel option factory.protected voidsetOutboundHandlers(java.util.List<io.netty.channel.ChannelOutboundHandler> outboundHandlers)Sets the outbound handlers.protected voidsetServerSslBuilder(ServerSslBuilder serverSslBuilder)Configures theServerSslBuilderthe server ssl builder.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.http.server.netty.NettyEmbeddedServices
getRouter
-
-
-
-
Constructor Detail
-
DefaultNettyEmbeddedServerFactory
protected DefaultNettyEmbeddedServerFactory(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.http.server.RouteExecutor routeExecutor, io.micronaut.http.codec.MediaTypeCodecRegistry mediaTypeCodecRegistry, io.micronaut.web.router.resource.StaticResourceResolver staticResourceResolver, @Named("netty") java.util.concurrent.ThreadFactory nettyThreadFactory, HttpCompressionStrategy httpCompressionStrategy, io.micronaut.http.netty.channel.EventLoopGroupFactory eventLoopGroupFactory, io.micronaut.http.netty.channel.EventLoopGroupRegistry eventLoopGroupRegistry)Default constructor.- Parameters:
applicationContext- The app ctxrouteExecutor- The route executormediaTypeCodecRegistry- The media type codecstaticResourceResolver- The static resource resolvernettyThreadFactory- The netty thread factoryhttpCompressionStrategy- The http compression strategyeventLoopGroupFactory- The event loop group factoryeventLoopGroupRegistry- The event loop group registry
-
-
Method Detail
-
build
@NonNull public NettyEmbeddedServer build(@NonNull NettyHttpServerConfiguration configuration)
Description copied from interface:NettyEmbeddedServerFactoryBuilds aNettyEmbeddedServerfor the given configuration.Note that the returned server instance should be closed gracefully by calling the
NettyEmbeddedServer.stop()method.- Specified by:
buildin interfaceNettyEmbeddedServerFactory- Parameters:
configuration- The configuration, nevernull- Returns:
- A
NettyEmbeddedServerinstance
-
build
@NonNull public NettyEmbeddedServer build(@NonNull NettyHttpServerConfiguration configuration, @Nullable io.micronaut.http.ssl.ServerSslConfiguration sslConfiguration)
Description copied from interface:NettyEmbeddedServerFactoryBuilds aNettyEmbeddedServerfor the given configuration.Note that the returned server instance should be closed gracefully by calling the
NettyEmbeddedServer.stop()method.- Specified by:
buildin interfaceNettyEmbeddedServerFactory- Parameters:
configuration- The configuration, nevernullsslConfiguration- The SSL configuration, can benullif SSL is not required- Returns:
- A
NettyEmbeddedServerinstance
-
buildDefaultServer
@Singleton @Primary @NonNull protected NettyEmbeddedServer buildDefaultServer(@NonNull NettyHttpServerConfiguration configuration)
Builds the default server configuration.- Parameters:
configuration- The server configuration- Returns:
- The
NettyEmbeddedServerinstance
-
getOutboundHandlers
public java.util.List<io.netty.channel.ChannelOutboundHandler> getOutboundHandlers()
- Specified by:
getOutboundHandlersin interfaceNettyEmbeddedServices- Returns:
- The channel outbound handlers
-
getApplicationContext
public io.micronaut.context.ApplicationContext getApplicationContext()
- Specified by:
getApplicationContextin interfaceNettyEmbeddedServices- Returns:
- The application context
-
getRequestArgumentSatisfier
public io.micronaut.http.server.binding.RequestArgumentSatisfier getRequestArgumentSatisfier()
- Specified by:
getRequestArgumentSatisfierin interfaceNettyEmbeddedServices- Returns:
- The request argument satisfier
- See Also:
RequestArgumentSatisfier
-
getRouteExecutor
public io.micronaut.http.server.RouteExecutor getRouteExecutor()
- Specified by:
getRouteExecutorin interfaceNettyEmbeddedServices- Returns:
- The route executor
- See Also:
RouteExecutor
-
getMediaTypeCodecRegistry
public io.micronaut.http.codec.MediaTypeCodecRegistry getMediaTypeCodecRegistry()
- Specified by:
getMediaTypeCodecRegistryin interfaceNettyEmbeddedServices- Returns:
- The media type code registry
- See Also:
MediaTypeCodecRegistry
-
getStaticResourceResolver
public io.micronaut.web.router.resource.StaticResourceResolver getStaticResourceResolver()
- Specified by:
getStaticResourceResolverin interfaceNettyEmbeddedServices- Returns:
- The static resource resolver
- See Also:
StaticResourceResolver
-
getExecutorSelector
public io.micronaut.scheduling.executor.ExecutorSelector getExecutorSelector()
- Specified by:
getExecutorSelectorin interfaceNettyEmbeddedServices- Returns:
- The executor resolver
-
getServerSslBuilder
public ServerSslBuilder getServerSslBuilder()
- Specified by:
getServerSslBuilderin interfaceNettyEmbeddedServices- Returns:
- The server SSL builder or
nullif none is configured - See Also:
CertificateProvidedSslBuilder
-
getChannelOptionFactory
public io.micronaut.http.netty.channel.converters.ChannelOptionFactory getChannelOptionFactory()
- Specified by:
getChannelOptionFactoryin interfaceNettyEmbeddedServices- Returns:
- The channel option factory
-
getHttpCompressionStrategy
public HttpCompressionStrategy getHttpCompressionStrategy()
- Specified by:
getHttpCompressionStrategyin interfaceNettyEmbeddedServices- Returns:
- The http compression strategy
-
getWebSocketBeanRegistry
public io.micronaut.websocket.context.WebSocketBeanRegistry getWebSocketBeanRegistry()
- Specified by:
getWebSocketBeanRegistryin interfaceNettyEmbeddedServices- Returns:
- The websocket bean registry
-
getEventLoopGroupRegistry
public io.micronaut.http.netty.channel.EventLoopGroupRegistry getEventLoopGroupRegistry()
- Specified by:
getEventLoopGroupRegistryin interfaceNettyEmbeddedServices- Returns:
- The event loop group registry.
-
createEventLoopGroup
public io.netty.channel.EventLoopGroup createEventLoopGroup(io.micronaut.http.netty.channel.EventLoopGroupConfiguration config)
Description copied from interface:NettyEmbeddedServicesCreates the event loop group configuration.- Specified by:
createEventLoopGroupin interfaceNettyEmbeddedServices- Parameters:
config- The config- Returns:
- The event loop group config
-
getServerSocketChannelInstance
public io.netty.channel.socket.ServerSocketChannel getServerSocketChannelInstance(io.micronaut.http.netty.channel.EventLoopGroupConfiguration workerConfig)
Description copied from interface:NettyEmbeddedServicesGets the server socket channel instance.- Specified by:
getServerSocketChannelInstancein interfaceNettyEmbeddedServices- Parameters:
workerConfig- The worker config- Returns:
- The
ServerSocketChannel
-
getDomainServerChannelInstance
public io.netty.channel.ServerChannel getDomainServerChannelInstance(io.micronaut.http.netty.channel.EventLoopGroupConfiguration workerConfig)
Description copied from interface:NettyEmbeddedServicesGets the domain server socket channel instance.- Specified by:
getDomainServerChannelInstancein interfaceNettyEmbeddedServices- Parameters:
workerConfig- The worker config- Returns:
- The
DomainSocketChannel
-
getEventPublisher
public <E> io.micronaut.context.event.ApplicationEventPublisher<E> getEventPublisher(java.lang.Class<E> eventClass)
Description copied from interface:NettyEmbeddedServicesGet an event publisher for the server for the given type.- Specified by:
getEventPublisherin interfaceNettyEmbeddedServices- Type Parameters:
E- The event generic type- Parameters:
eventClass- The event publisher- Returns:
- The event publisher
-
createEventLoopGroup
@NonNull public io.netty.channel.EventLoopGroup createEventLoopGroup(int numThreads, @NonNull java.util.concurrent.ExecutorService executorService, java.lang.Integer ioRatio)Description copied from interface:NettyEmbeddedServicesCreates the event loop group configuration.- Specified by:
createEventLoopGroupin interfaceNettyEmbeddedServices- Parameters:
numThreads- The number of threadsexecutorService- The executor serviceioRatio- The I/O ratio- Returns:
- The event loop group
-
setChannelOptionFactory
@Inject protected void setChannelOptionFactory(@Nullable io.micronaut.http.netty.channel.converters.ChannelOptionFactory channelOptionFactory)Configures the channel option factory.- Parameters:
channelOptionFactory- The channel option factory.
-
setServerSslBuilder
@Inject protected void setServerSslBuilder(@Nullable ServerSslBuilder serverSslBuilder)Configures theServerSslBuilderthe server ssl builder.- Parameters:
serverSslBuilder- The builder
-
setOutboundHandlers
@Inject protected void setOutboundHandlers(java.util.List<io.netty.channel.ChannelOutboundHandler> outboundHandlers)
Sets the outbound handlers.- Parameters:
outboundHandlers- TheChannelOutboundHandlerinstances
-
-