Class PojaHttpServerlessApplication<REQ,RES>

java.lang.Object
io.micronaut.http.poja.PojaHttpServerlessApplication<REQ,RES>
Type Parameters:
REQ - The request type
RES - The response type
All Implemented Interfaces:
io.micronaut.context.ApplicationContextLifeCycle<PojaHttpServerlessApplication<REQ,RES>>, io.micronaut.context.ApplicationContextProvider, io.micronaut.context.LifeCycle, io.micronaut.runtime.EmbeddedApplication<PojaHttpServerlessApplication<REQ,RES>>, Closeable, AutoCloseable
Direct Known Subclasses:
ApacheServerlessApplication

public abstract class PojaHttpServerlessApplication<REQ,RES> extends Object implements io.micronaut.runtime.EmbeddedApplication<PojaHttpServerlessApplication<REQ,RES>>
A base class for POJA serverless applications. It implements EmbeddedApplication for POSIX serverless environments.
Since:
4.10.0
Author:
Andriy Dmytruk.
  • Constructor Details

    • PojaHttpServerlessApplication

      public PojaHttpServerlessApplication(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)
      Default constructor.
      Parameters:
      applicationContext - The application context
      applicationConfiguration - The application configuration
  • Method Details

    • 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<REQ>
    • getApplicationConfiguration

      public io.micronaut.runtime.ApplicationConfiguration getApplicationConfiguration()
      Specified by:
      getApplicationConfiguration in interface io.micronaut.runtime.EmbeddedApplication<REQ>
    • isRunning

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

      @NonNull public @NonNull PojaHttpServerlessApplication<REQ,RES> start(InputStream input, OutputStream output)
      Run the application using a particular channel.
      Parameters:
      input - The input stream
      output - The output stream
      Returns:
      The application
    • start

      @NonNull public @NonNull PojaHttpServerlessApplication<REQ,RES> start()
      Specified by:
      start in interface io.micronaut.context.ApplicationContextLifeCycle<REQ>
      Specified by:
      start in interface io.micronaut.context.LifeCycle<REQ>
    • runIndefinitely

      protected void runIndefinitely(ServletHttpHandler<REQ,RES> servletHttpHandler, InputStream in, OutputStream out) throws IOException
      A method to start the application in a loop.
      Parameters:
      servletHttpHandler - The handler
      in - The input stream
      out - The output stream
      Throws:
      IOException - IO exception
    • handleSingleRequest

      protected abstract void handleSingleRequest(ServletHttpHandler<REQ,RES> servletHttpHandler, InputStream in, OutputStream out) throws IOException
      Handle a single request.
      Parameters:
      servletHttpHandler - The handler
      in - The input stream
      out - The output stream
      Throws:
      IOException - IO exception
    • useInheritedChannel

      protected boolean useInheritedChannel()
      Whether to use the inherited channel by default. If false, STDIN and STDOUT will be used directly instead.
      Returns:
      Whether to use the inherited channel
    • stop

      @NonNull public @NonNull PojaHttpServerlessApplication<REQ,RES> stop()
      Specified by:
      stop in interface io.micronaut.context.ApplicationContextLifeCycle<REQ>
      Specified by:
      stop in interface io.micronaut.context.LifeCycle<REQ>