Class NettyHttpServer

  • All Implemented Interfaces:
    io.micronaut.context.ApplicationContextLifeCycle<io.micronaut.runtime.server.EmbeddedServer>, io.micronaut.context.ApplicationContextProvider, io.micronaut.context.event.ApplicationEventListener<io.micronaut.runtime.context.scope.refresh.RefreshEvent>, io.micronaut.context.LifeCycle, io.micronaut.core.order.Ordered, io.micronaut.http.netty.channel.ChannelPipelineCustomizer, io.micronaut.http.netty.websocket.WebSocketSessionRepository, NettyEmbeddedServer, NettyServerCustomizer.Registry, io.micronaut.runtime.context.scope.refresh.RefreshEventListener, io.micronaut.runtime.EmbeddedApplication<io.micronaut.runtime.server.EmbeddedServer>, io.micronaut.runtime.server.EmbeddedServer, java.io.Closeable, java.lang.AutoCloseable, java.util.EventListener

    @Internal
    public class NettyHttpServer
    extends java.lang.Object
    implements NettyEmbeddedServer
    Implements the bootstrap and configuration logic for the Netty implementation of EmbeddedServer.
    Since:
    1.0
    See Also:
    RoutingInBoundHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String OUTBOUND_KEY  
      • Fields inherited from interface io.micronaut.http.netty.channel.ChannelPipelineCustomizer

        HANDLER_ACCESS_LOGGER, HANDLER_CONNECT_TTL, HANDLER_FLOW_CONTROL, HANDLER_HTTP_AGGREGATOR, HANDLER_HTTP_CHUNK, HANDLER_HTTP_CLIENT_CODEC, HANDLER_HTTP_CLIENT_INIT, HANDLER_HTTP_COMPRESSOR, HANDLER_HTTP_DECODER, HANDLER_HTTP_DECOMPRESSOR, HANDLER_HTTP_KEEP_ALIVE, HANDLER_HTTP_PROXY, HANDLER_HTTP_SERVER_CODEC, HANDLER_HTTP_STREAM, HANDLER_HTTP_TO_HTTPS_REDIRECT, HANDLER_HTTP2_CONNECTION, HANDLER_HTTP2_PROTOCOL_NEGOTIATOR, HANDLER_HTTP2_SETTINGS, HANDLER_HTTP2_UPGRADE_REQUEST, HANDLER_IDLE_STATE, HANDLER_MICRONAUT_FULL_HTTP_RESPONSE, HANDLER_MICRONAUT_HTTP_RESPONSE_FULL, HANDLER_MICRONAUT_HTTP_RESPONSE_STREAM, HANDLER_MICRONAUT_INBOUND, HANDLER_MICRONAUT_SSE_CONTENT, HANDLER_MICRONAUT_SSE_EVENT_STREAM, HANDLER_MICRONAUT_WEBSOCKET_CLIENT, HANDLER_READ_TIMEOUT, HANDLER_SOCKS_5_PROXY, HANDLER_SSL, HANDLER_WEBSOCKET_UPGRADE
      • Fields inherited from interface io.micronaut.core.order.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
      • Fields inherited from interface io.micronaut.runtime.context.scope.refresh.RefreshEventListener

        DEFAULT_POSITION
    • Method Detail

      • isKeepAlive

        public boolean isKeepAlive()
        Specified by:
        isKeepAlive in interface io.micronaut.runtime.server.EmbeddedServer
      • isRunning

        public boolean isRunning()
        Specified by:
        isRunning in interface io.micronaut.context.LifeCycle
      • start

        public NettyEmbeddedServer start()
        Specified by:
        start in interface io.micronaut.context.ApplicationContextLifeCycle<io.micronaut.runtime.server.EmbeddedServer>
        Specified by:
        start in interface io.micronaut.context.LifeCycle
        Specified by:
        start in interface NettyEmbeddedServer
      • stop

        public NettyEmbeddedServer stop()
        Specified by:
        stop in interface io.micronaut.context.ApplicationContextLifeCycle<io.micronaut.runtime.server.EmbeddedServer>
        Specified by:
        stop in interface io.micronaut.context.LifeCycle
        Specified by:
        stop in interface NettyEmbeddedServer
      • getPort

        public int getPort()
        Specified by:
        getPort in interface io.micronaut.runtime.server.EmbeddedServer
      • getHost

        public java.lang.String getHost()
        Specified by:
        getHost in interface io.micronaut.runtime.server.EmbeddedServer
      • getScheme

        public java.lang.String getScheme()
        Specified by:
        getScheme in interface io.micronaut.runtime.server.EmbeddedServer
      • getURL

        public java.net.URL getURL()
        Specified by:
        getURL in interface io.micronaut.runtime.server.EmbeddedServer
      • getURI

        public java.net.URI getURI()
        Specified by:
        getURI in interface io.micronaut.runtime.server.EmbeddedServer
      • getApplicationContext

        public io.micronaut.context.ApplicationContext getApplicationContext()
        Specified by:
        getApplicationContext in interface io.micronaut.context.ApplicationContextProvider
        Specified by:
        getApplicationContext in interface io.micronaut.runtime.EmbeddedApplication<io.micronaut.runtime.server.EmbeddedServer>
      • getApplicationConfiguration

        public io.micronaut.runtime.ApplicationConfiguration getApplicationConfiguration()
        Specified by:
        getApplicationConfiguration in interface io.micronaut.runtime.EmbeddedApplication<io.micronaut.runtime.server.EmbeddedServer>
      • createParentEventLoopGroup

        protected io.netty.channel.EventLoopGroup createParentEventLoopGroup()
        Returns:
        The parent event loop group
      • createWorkerEventLoopGroup

        protected io.netty.channel.EventLoopGroup createWorkerEventLoopGroup​(@Nullable
                                                                             io.micronaut.http.netty.channel.EventLoopGroupConfiguration workerConfig)
        Parameters:
        workerConfig - The worker configuration
        Returns:
        The worker event loop group
      • createServerBootstrap

        protected io.netty.bootstrap.ServerBootstrap createServerBootstrap()
        Returns:
        The Netty server bootstrap
      • addChannel

        public void addChannel​(io.netty.channel.Channel channel)
        Specified by:
        addChannel in interface io.micronaut.http.netty.websocket.WebSocketSessionRepository
      • removeChannel

        public void removeChannel​(io.netty.channel.Channel channel)
        Specified by:
        removeChannel in interface io.micronaut.http.netty.websocket.WebSocketSessionRepository
      • getChannelGroup

        public io.netty.channel.group.ChannelGroup getChannelGroup()
        Specified by:
        getChannelGroup in interface io.micronaut.http.netty.websocket.WebSocketSessionRepository
      • getWebSocketSessionRepository

        public io.micronaut.http.netty.websocket.WebSocketSessionRepository getWebSocketSessionRepository()
        Returns:
        NettyHttpServer which implements WebSocketSessionRepository
      • isClientChannel

        public boolean isClientChannel()
        Specified by:
        isClientChannel in interface io.micronaut.http.netty.channel.ChannelPipelineCustomizer
      • doOnConnect

        public void doOnConnect​(@NonNull
                                io.micronaut.http.netty.channel.ChannelPipelineListener listener)
        Specified by:
        doOnConnect in interface io.micronaut.http.netty.channel.ChannelPipelineCustomizer
      • getObservedConfigurationPrefixes

        public java.util.Set<java.lang.String> getObservedConfigurationPrefixes()
        Specified by:
        getObservedConfigurationPrefixes in interface io.micronaut.runtime.context.scope.refresh.RefreshEventListener
      • onApplicationEvent

        public void onApplicationEvent​(io.micronaut.runtime.context.scope.refresh.RefreshEvent event)
        Specified by:
        onApplicationEvent in interface io.micronaut.context.event.ApplicationEventListener<io.micronaut.runtime.context.scope.refresh.RefreshEvent>
      • buildEmbeddedChannel

        @Internal
        public io.netty.channel.embedded.EmbeddedChannel buildEmbeddedChannel​(boolean ssl)
        Builds Embedded Channel.
        Parameters:
        ssl - SSL
        Returns:
        Embedded Channel