Class AbstractServletServer<T>
java.lang.Object
io.micronaut.servlet.http.server.AbstractServletServer<T>
- Type Parameters:
T- The server type
- All Implemented Interfaces:
io.micronaut.context.ApplicationContextLifeCycle<io.micronaut.runtime.server.EmbeddedServer>, io.micronaut.context.ApplicationContextProvider, io.micronaut.context.LifeCycle<io.micronaut.runtime.server.EmbeddedServer>, io.micronaut.runtime.EmbeddedApplication<io.micronaut.runtime.server.EmbeddedServer>, io.micronaut.runtime.graceful.GracefulShutdownCapable, io.micronaut.runtime.server.EmbeddedServer, Closeable, AutoCloseable
- Direct Known Subclasses:
JettyServer, TomcatServer, UndertowServer
@Internal
public abstract class AbstractServletServer<T>
extends Object
implements io.micronaut.runtime.server.EmbeddedServer, io.micronaut.runtime.graceful.GracefulShutdownCapable
Abstract base class for servlet embedded servers.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractServletServer(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, @Nullable io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.runtime.server.event.ServerShutdownEvent> serverShutdownEventPublisher, T server) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal io.micronaut.runtime.ApplicationConfigurationfinal io.micronaut.context.ApplicationContextfinal TShuts the server down gracefully: it stops accepting new requests, then completes once every request that was already in flight has terminated.final io.micronaut.runtime.server.EmbeddedServerstart()protected abstract voidStart the server.final io.micronaut.runtime.server.EmbeddedServerstop()protected voidStops the underlying server accepting new requests while leaving in-flight requests to complete.protected abstract voidStop the server.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.runtime.EmbeddedApplication
getEnvironment, isForceExit, isShutdownHookNeededMethods inherited from interface io.micronaut.runtime.server.EmbeddedServer
getContextURI, getHost, getPort, getScheme, getURI, getURL, isKeepAlive, isServerMethods inherited from interface io.micronaut.context.LifeCycle
close, isRunning, refresh
-
Constructor Details
-
AbstractServletServer
protected AbstractServletServer(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, @Nullable io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.runtime.server.event.ServerShutdownEvent> serverShutdownEventPublisher, T server) Default constructor.- Parameters:
applicationContext- The application contextapplicationConfiguration- The application configurationserverShutdownEventPublisher-ApplicationEventPublisherfor theServerShutdownEventevent.server- The server object
-
-
Method Details
-
getServer
- Returns:
- The server object.
-
shutdownGracefully
Shuts the server down gracefully: it stops accepting new requests, then completes once every request that was already in flight has terminated. Called by theGracefulShutdownManagerwhenmicronaut.lifecycle.graceful-shutdown.enabledis set, before the server is stopped.- Specified by:
shutdownGracefullyin interfaceio.micronaut.runtime.graceful.GracefulShutdownCapable- Returns:
- A stage that completes when no request is active
- Since:
- 6.2.0
-
reportActiveTasks
- Specified by:
reportActiveTasksin interfaceio.micronaut.runtime.graceful.GracefulShutdownCapable
-
stopAcceptingRequests
protected void stopAcceptingRequests()Stops the underlying server accepting new requests while leaving in-flight requests to complete. Each container has its own way of doing this; the default does nothing, and the graceful shutdown then only waits for in-flight requests.- Since:
- 6.2.0
-
getApplicationContext
public final io.micronaut.context.ApplicationContext getApplicationContext()- Specified by:
getApplicationContextin interfaceio.micronaut.context.ApplicationContextProvider- Specified by:
getApplicationContextin interfaceio.micronaut.runtime.EmbeddedApplication<T>
-
getApplicationConfiguration
public final io.micronaut.runtime.ApplicationConfiguration getApplicationConfiguration()- Specified by:
getApplicationConfigurationin interfaceio.micronaut.runtime.EmbeddedApplication<T>
-
start
-
stop
-
startServer
-
stopServer
-