Class UndertowServer

java.lang.Object
io.micronaut.servlet.http.server.AbstractServletServer<io.undertow.Undertow>
io.micronaut.servlet.undertow.UndertowServer
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

@Singleton public class UndertowServer extends AbstractServletServer<io.undertow.Undertow>
Implementation of AbstractServletServer for Undertow.
Since:
1.0.0
Author:
graemerocher
  • Constructor Summary

    Constructors
    Constructor
    Description
    UndertowServer(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, @Nullable io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.runtime.server.event.ServerShutdownEvent> serverShutdownEventPublisher, io.undertow.Undertow undertow)
    Default constructor.
    UndertowServer(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, io.undertow.Undertow undertow)
    Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
     
     
     
     
    boolean
     
    Waits for the requests the handler counted, and then for Undertow's own exchanges: the handler is done once the response has been handed to the container, but Undertow ends an exchange on its IO thread afterwards, and stopping the server before that drops a response that was written but not yet flushed (seen with Connection: close requests).
    protected void
    Start the server.
    protected void
    Makes the server answer new requests with 503 Service Unavailable while requests already in progress complete.
    protected void
    Stop the server.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.runtime.EmbeddedApplication

    getEnvironment, isForceExit, isShutdownHookNeeded

    Methods inherited from interface io.micronaut.runtime.server.EmbeddedServer

    getContextURI, isKeepAlive, isServer

    Methods inherited from interface io.micronaut.context.LifeCycle

    close, refresh
  • Constructor Details

    • UndertowServer

      @Inject public UndertowServer(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, @Nullable io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.runtime.server.event.ServerShutdownEvent> serverShutdownEventPublisher, io.undertow.Undertow undertow)
      Default constructor.
      Parameters:
      applicationContext - The app context
      applicationConfiguration - The app config
      serverShutdownEventPublisher - ApplicationEventPublisher for the ServerShutdownEvent event.
      undertow - The undertow instance
    • UndertowServer

      @Deprecated(forRemoval=true, since="5.2.0") public UndertowServer(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, io.undertow.Undertow undertow)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Default constructor.
      Parameters:
      applicationContext - The app context
      applicationConfiguration - The app config
      undertow - The undertow instance
  • Method Details

    • startServer

      protected void startServer() throws Exception
      Description copied from class: AbstractServletServer
      Start the server.
      Specified by:
      startServer in class AbstractServletServer<io.undertow.Undertow>
      Throws:
      Exception - when an error occurred starting the server
    • stopServer

      protected void stopServer() throws Exception
      Description copied from class: AbstractServletServer
      Stop the server.
      Specified by:
      stopServer in class AbstractServletServer<io.undertow.Undertow>
      Throws:
      Exception - when an error occurred stopping the server
    • stopAcceptingRequests

      protected void stopAcceptingRequests()
      Makes the server answer new requests with 503 Service Unavailable while requests already in progress complete. Undertow's own listener suspension is not used because it closes every connection, including those with a request in flight.
      Overrides:
      stopAcceptingRequests in class AbstractServletServer<io.undertow.Undertow>
    • shutdownGracefully

      public CompletionStage<?> shutdownGracefully()
      Waits for the requests the handler counted, and then for Undertow's own exchanges: the handler is done once the response has been handed to the container, but Undertow ends an exchange on its IO thread afterwards, and stopping the server before that drops a response that was written but not yet flushed (seen with Connection: close requests).
      Specified by:
      shutdownGracefully in interface io.micronaut.runtime.graceful.GracefulShutdownCapable
      Overrides:
      shutdownGracefully in class AbstractServletServer<io.undertow.Undertow>
      Returns:
      A stage that completes when no request is active
    • getPort

      public int getPort()
    • getHost

      public String getHost()
    • getScheme

      public String getScheme()
    • getURL

      public URL getURL()
    • getURI

      public URI getURI()
    • isRunning

      public boolean isRunning()