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
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
ConstructorDescriptionPojaHttpServerlessApplication
(io.micronaut.context.ApplicationContext applicationContext, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.runtime.ApplicationConfiguration
io.micronaut.context.ApplicationContext
protected abstract void
handleSingleRequest
(ServletHttpHandler<REQ, RES> servletHttpHandler, InputStream in, OutputStream out) Handle a single request.boolean
protected void
runIndefinitely
(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 boolean
Whether to use the inherited channel by default.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.runtime.EmbeddedApplication
getEnvironment, isForceExit, isServer
Methods 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:
getApplicationContext
in interfaceio.micronaut.context.ApplicationContextProvider
- Specified by:
getApplicationContext
in interfaceio.micronaut.runtime.EmbeddedApplication<REQ>
-
getApplicationConfiguration
public io.micronaut.runtime.ApplicationConfiguration getApplicationConfiguration()- Specified by:
getApplicationConfiguration
in interfaceio.micronaut.runtime.EmbeddedApplication<REQ>
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in 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 void handleSingleRequest(ServletHttpHandler<REQ, RES> servletHttpHandler, InputStream in, OutputStream out) throws IOExceptionHandle a single request.- Parameters:
servletHttpHandler
- The handlerin
- The input streamout
- 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
-