Package io.micronaut.http.poja
Class PojaHttpServerlessApplication<REQ,RES>
java.lang.Object
io.micronaut.http.poja.PojaHttpServerlessApplication<REQ,RES>
- Type Parameters:
REQ- The request typeRES- 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
@Internal
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 Summary
ConstructorsConstructorDescriptionPojaHttpServerlessApplication(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.runtime.ApplicationConfigurationio.micronaut.context.ApplicationContextprotected abstract booleanhandleSingleRequest(ServletHttpHandler<REQ, RES> servletHttpHandler, InputStream in, OutputStream out) Handle a single request.booleanprotected voidrunIndefinitely(ServletHttpHandler<REQ, RES> servletHttpHandler, InputStream in, OutputStream out) A method to start the application in a loop.@NonNull PojaHttpServerlessApplication<REQ,RES> start()@NonNull PojaHttpServerlessApplication<REQ,RES> start(InputStream input, OutputStream output) Run the application using a particular channel.@NonNull PojaHttpServerlessApplication<REQ,RES> stop()protected booleanWhether to use the inherited channel by default.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.runtime.EmbeddedApplication
getEnvironment, isForceExit, isServer, isShutdownHookNeededMethods inherited from interface io.micronaut.context.LifeCycle
close, refresh
-
Constructor Details
-
PojaHttpServerlessApplication
public PojaHttpServerlessApplication(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) Default constructor.- Parameters:
applicationContext- The application contextapplicationConfiguration- The application configuration
-
-
Method Details
-
getApplicationContext
public io.micronaut.context.ApplicationContext getApplicationContext()- Specified by:
getApplicationContextin interfaceio.micronaut.context.ApplicationContextProvider- Specified by:
getApplicationContextin interfaceio.micronaut.runtime.EmbeddedApplication<REQ>
-
getApplicationConfiguration
public io.micronaut.runtime.ApplicationConfiguration getApplicationConfiguration()- Specified by:
getApplicationConfigurationin interfaceio.micronaut.runtime.EmbeddedApplication<REQ>
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceio.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 streamoutput- The output stream- Returns:
- The application
-
start
-
runIndefinitely
protected void runIndefinitely(ServletHttpHandler<REQ, RES> servletHttpHandler, InputStream in, OutputStream out) throws IOExceptionA method to start the application in a loop.- Parameters:
servletHttpHandler- The handlerin- The input streamout- The output stream- Throws:
IOException- IO exception
-
handleSingleRequest
protected abstract boolean handleSingleRequest(ServletHttpHandler<REQ, RES> servletHttpHandler, InputStream in, OutputStream out) throws IOExceptionHandle a single request.- Parameters:
servletHttpHandler- The handlerin- The input streamout- The output stream- Returns:
trueiff more requests can come in,falsewhen the connection should be closed- 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
-