@Internal public class NettyHttpServer extends Object implements NettyEmbeddedServer
EmbeddedServer
.RoutingInBoundHandler
Modifier and Type | Field and Description |
---|---|
static String |
OUTBOUND_KEY |
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
DEFAULT_POSITION
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
NettyHttpServer(NettyHttpServerConfiguration serverConfiguration,
NettyEmbeddedServices nettyEmbeddedServices,
NettyCustomizableResponseTypeHandlerRegistry handlerRegistry,
boolean isDefault) |
Modifier and Type | Method and Description |
---|---|
void |
addChannel(io.netty.channel.Channel channel)
Adds a channel to the repository.
|
io.netty.channel.embedded.EmbeddedChannel |
buildEmbeddedChannel(boolean ssl)
Builds Embedded Channel.
|
protected io.netty.channel.EventLoopGroup |
createParentEventLoopGroup() |
protected io.netty.bootstrap.ServerBootstrap |
createServerBootstrap() |
protected io.netty.channel.EventLoopGroup |
createWorkerEventLoopGroup(EventLoopGroupConfiguration workerConfig) |
void |
doOnConnect(ChannelPipelineListener listener)
A hook to customize the pipeline upon establishing a connection.
|
ApplicationConfiguration |
getApplicationConfiguration() |
ApplicationContext |
getApplicationContext()
Resolves the
ApplicationContext for this class. |
Set<Integer> |
getBoundPorts()
Gets the set of all ports this Netty server is bound to.
|
io.netty.channel.group.ChannelGroup |
getChannelGroup()
Returns the
ChannelGroup used to store WebSocketSessions. |
String |
getHost() |
Set<String> |
getObservedConfigurationPrefixes()
Returns the set of observed configuration prefixes that the event listener should listen for.
|
int |
getPort() |
String |
getScheme() |
NettyHttpServerConfiguration |
getServerConfiguration() |
URI |
getURI() |
URL |
getURL() |
WebSocketSessionRepository |
getWebSocketSessionRepository() |
boolean |
isClientChannel() |
boolean |
isKeepAlive()
Most servers provide a way to block such that the server doesn't exit, however some require the creation of a keep alive thread.
|
boolean |
isRunning() |
void |
onApplicationEvent(RefreshEvent event)
Handle an application event.
|
void |
register(NettyServerCustomizer customizer)
Register a new customizer with this server.
|
void |
removeChannel(io.netty.channel.Channel channel)
Remove a channel from the repository.
|
NettyEmbeddedServer |
start()
Starts the lifecyle component.
|
NettyEmbeddedServer |
stop()
Stops the life cycle component.
|
NettyEmbeddedServer |
stopServerOnly()
Stops the Netty instance, but keeps the ApplicationContext running.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isServer
getEnvironment, isForceExit
isServerChannel
getOrder, supports
public static final String OUTBOUND_KEY
public NettyHttpServer(NettyHttpServerConfiguration serverConfiguration, NettyEmbeddedServices nettyEmbeddedServices, NettyCustomizableResponseTypeHandlerRegistry handlerRegistry, boolean isDefault)
serverConfiguration
- The Netty HTTP server configurationnettyEmbeddedServices
- The embedded server contexthandlerRegistry
- The handler registryisDefault
- Is this the default serverpublic boolean isKeepAlive()
EmbeddedServer
isKeepAlive
in interface EmbeddedServer
public NettyHttpServerConfiguration getServerConfiguration()
public boolean isRunning()
@NonNull public NettyEmbeddedServer start()
LifeCycle
start
in interface ApplicationContextLifeCycle<EmbeddedServer>
start
in interface LifeCycle
start
in interface NettyEmbeddedServer
@NonNull public NettyEmbeddedServer stop()
LifeCycle
stop
in interface ApplicationContextLifeCycle<EmbeddedServer>
stop
in interface LifeCycle
stop
in interface NettyEmbeddedServer
@NonNull public NettyEmbeddedServer stopServerOnly()
NettyEmbeddedServer
stopServerOnly
in interface NettyEmbeddedServer
public void register(@NonNull NettyServerCustomizer customizer)
NettyServerCustomizer.Registry
register
in interface NettyEmbeddedServer
register
in interface NettyServerCustomizer.Registry
customizer
- The customizer to register.public int getPort()
getPort
in interface EmbeddedServer
public String getHost()
getHost
in interface EmbeddedServer
public String getScheme()
getScheme
in interface EmbeddedServer
public URL getURL()
getURL
in interface EmbeddedServer
public URI getURI()
getURI
in interface EmbeddedServer
public ApplicationContext getApplicationContext()
ApplicationContextProvider
ApplicationContext
for this class.getApplicationContext
in interface ApplicationContextProvider
getApplicationContext
in interface EmbeddedApplication<EmbeddedServer>
ApplicationContext
for the serverpublic ApplicationConfiguration getApplicationConfiguration()
getApplicationConfiguration
in interface EmbeddedApplication<EmbeddedServer>
ApplicationConfiguration
instancepublic final Set<Integer> getBoundPorts()
NettyEmbeddedServer
getBoundPorts
in interface NettyEmbeddedServer
NettyEmbeddedServer.start()
an empty set otherwise.protected io.netty.channel.EventLoopGroup createParentEventLoopGroup()
protected io.netty.channel.EventLoopGroup createWorkerEventLoopGroup(@Nullable EventLoopGroupConfiguration workerConfig)
workerConfig
- The worker configurationprotected io.netty.bootstrap.ServerBootstrap createServerBootstrap()
public void addChannel(io.netty.channel.Channel channel)
WebSocketSessionRepository
addChannel
in interface WebSocketSessionRepository
channel
- The channelpublic void removeChannel(io.netty.channel.Channel channel)
WebSocketSessionRepository
removeChannel
in interface WebSocketSessionRepository
channel
- The channelpublic io.netty.channel.group.ChannelGroup getChannelGroup()
WebSocketSessionRepository
ChannelGroup
used to store WebSocketSessions.getChannelGroup
in interface WebSocketSessionRepository
ChannelGroup
public WebSocketSessionRepository getWebSocketSessionRepository()
NettyHttpServer
which implements WebSocketSessionRepository
public boolean isClientChannel()
isClientChannel
in interface ChannelPipelineCustomizer
public void doOnConnect(@NonNull ChannelPipelineListener listener)
ChannelPipelineCustomizer
doOnConnect
in interface ChannelPipelineCustomizer
listener
- The listener The listener.public Set<String> getObservedConfigurationPrefixes()
RefreshEventListener
getObservedConfigurationPrefixes
in interface RefreshEventListener
public void onApplicationEvent(RefreshEvent event)
ApplicationEventListener
onApplicationEvent
in interface ApplicationEventListener<RefreshEvent>
event
- the event to respond to@Internal public io.netty.channel.embedded.EmbeddedChannel buildEmbeddedChannel(boolean ssl)
ssl
- SSL