Package io.micronaut.http.server.netty
Class NettyHttpServer
- java.lang.Object
-
- io.micronaut.http.server.netty.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,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 ofEmbeddedServer.- Since:
- 1.0
- See Also:
RoutingInBoundHandler
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringOUTBOUND_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
-
-
Constructor Summary
Constructors Constructor Description NettyHttpServer(NettyHttpServerConfiguration serverConfiguration, NettyEmbeddedServices nettyEmbeddedServices, NettyCustomizableResponseTypeHandlerRegistry handlerRegistry, boolean isDefault)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChannel(io.netty.channel.Channel channel)io.netty.channel.embedded.EmbeddedChannelbuildEmbeddedChannel(boolean ssl)Builds Embedded Channel.protected io.netty.channel.EventLoopGroupcreateParentEventLoopGroup()protected io.netty.bootstrap.ServerBootstrapcreateServerBootstrap()protected io.netty.channel.EventLoopGroupcreateWorkerEventLoopGroup(io.micronaut.http.netty.channel.EventLoopGroupConfiguration workerConfig)voiddoOnConnect(io.micronaut.http.netty.channel.ChannelPipelineListener listener)io.micronaut.runtime.ApplicationConfigurationgetApplicationConfiguration()io.micronaut.context.ApplicationContextgetApplicationContext()java.util.Set<java.lang.Integer>getBoundPorts()Gets the set of all ports this Netty server is bound to.io.netty.channel.group.ChannelGroupgetChannelGroup()java.lang.StringgetHost()java.util.Set<java.lang.String>getObservedConfigurationPrefixes()intgetPort()java.lang.StringgetScheme()NettyHttpServerConfigurationgetServerConfiguration()java.net.URIgetURI()java.net.URLgetURL()io.micronaut.http.netty.websocket.WebSocketSessionRepositorygetWebSocketSessionRepository()booleanisClientChannel()booleanisKeepAlive()booleanisRunning()voidonApplicationEvent(io.micronaut.runtime.context.scope.refresh.RefreshEvent event)voidremoveChannel(io.netty.channel.Channel channel)NettyEmbeddedServerstart()NettyEmbeddedServerstop()-
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.netty.channel.ChannelPipelineCustomizer
isServerChannel
-
-
-
-
Field Detail
-
OUTBOUND_KEY
public static final java.lang.String OUTBOUND_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NettyHttpServer
public NettyHttpServer(NettyHttpServerConfiguration serverConfiguration, NettyEmbeddedServices nettyEmbeddedServices, NettyCustomizableResponseTypeHandlerRegistry handlerRegistry, boolean isDefault)
- Parameters:
serverConfiguration- The Netty HTTP server configurationnettyEmbeddedServices- The embedded server contexthandlerRegistry- The handler registryisDefault- Is this the default server
-
-
Method Detail
-
isKeepAlive
public boolean isKeepAlive()
- Specified by:
isKeepAlivein interfaceio.micronaut.runtime.server.EmbeddedServer
-
getServerConfiguration
public NettyHttpServerConfiguration getServerConfiguration()
- Returns:
- The configuration for the server
-
isRunning
public boolean isRunning()
- Specified by:
isRunningin interfaceio.micronaut.context.LifeCycle
-
start
public NettyEmbeddedServer start()
- Specified by:
startin interfaceio.micronaut.context.ApplicationContextLifeCycle<io.micronaut.runtime.server.EmbeddedServer>- Specified by:
startin interfaceio.micronaut.context.LifeCycle- Specified by:
startin interfaceNettyEmbeddedServer
-
stop
public NettyEmbeddedServer stop()
- Specified by:
stopin interfaceio.micronaut.context.ApplicationContextLifeCycle<io.micronaut.runtime.server.EmbeddedServer>- Specified by:
stopin interfaceio.micronaut.context.LifeCycle- Specified by:
stopin interfaceNettyEmbeddedServer
-
getPort
public int getPort()
- Specified by:
getPortin interfaceio.micronaut.runtime.server.EmbeddedServer
-
getHost
public java.lang.String getHost()
- Specified by:
getHostin interfaceio.micronaut.runtime.server.EmbeddedServer
-
getScheme
public java.lang.String getScheme()
- Specified by:
getSchemein interfaceio.micronaut.runtime.server.EmbeddedServer
-
getURL
public java.net.URL getURL()
- Specified by:
getURLin interfaceio.micronaut.runtime.server.EmbeddedServer
-
getURI
public java.net.URI getURI()
- Specified by:
getURIin interfaceio.micronaut.runtime.server.EmbeddedServer
-
getApplicationContext
public io.micronaut.context.ApplicationContext getApplicationContext()
- Specified by:
getApplicationContextin interfaceio.micronaut.context.ApplicationContextProvider- Specified by:
getApplicationContextin interfaceio.micronaut.runtime.EmbeddedApplication<io.micronaut.runtime.server.EmbeddedServer>
-
getApplicationConfiguration
public io.micronaut.runtime.ApplicationConfiguration getApplicationConfiguration()
- Specified by:
getApplicationConfigurationin interfaceio.micronaut.runtime.EmbeddedApplication<io.micronaut.runtime.server.EmbeddedServer>
-
getBoundPorts
public final java.util.Set<java.lang.Integer> getBoundPorts()
Description copied from interface:NettyEmbeddedServerGets the set of all ports this Netty server is bound to.- Specified by:
getBoundPortsin interfaceNettyEmbeddedServer- Returns:
- An immutable set of bound ports if the server has been started with
NettyEmbeddedServer.start()an empty set otherwise.
-
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:
addChannelin interfaceio.micronaut.http.netty.websocket.WebSocketSessionRepository
-
removeChannel
public void removeChannel(io.netty.channel.Channel channel)
- Specified by:
removeChannelin interfaceio.micronaut.http.netty.websocket.WebSocketSessionRepository
-
getChannelGroup
public io.netty.channel.group.ChannelGroup getChannelGroup()
- Specified by:
getChannelGroupin interfaceio.micronaut.http.netty.websocket.WebSocketSessionRepository
-
getWebSocketSessionRepository
public io.micronaut.http.netty.websocket.WebSocketSessionRepository getWebSocketSessionRepository()
- Returns:
NettyHttpServerwhich implementsWebSocketSessionRepository
-
isClientChannel
public boolean isClientChannel()
- Specified by:
isClientChannelin interfaceio.micronaut.http.netty.channel.ChannelPipelineCustomizer
-
doOnConnect
public void doOnConnect(@NonNull io.micronaut.http.netty.channel.ChannelPipelineListener listener)- Specified by:
doOnConnectin interfaceio.micronaut.http.netty.channel.ChannelPipelineCustomizer
-
getObservedConfigurationPrefixes
public java.util.Set<java.lang.String> getObservedConfigurationPrefixes()
- Specified by:
getObservedConfigurationPrefixesin interfaceio.micronaut.runtime.context.scope.refresh.RefreshEventListener
-
onApplicationEvent
public void onApplicationEvent(io.micronaut.runtime.context.scope.refresh.RefreshEvent event)
- Specified by:
onApplicationEventin interfaceio.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
-
-