Interface EmbeddedApplication<T extends EmbeddedApplication>
- Type Parameters:
 T- EmbeddedApplication
- All Superinterfaces:
 ApplicationContextLifeCycle<T>,ApplicationContextProvider,AutoCloseable,Closeable,LifeCycle
- All Known Subinterfaces:
 EmbeddedServer,NettyEmbeddedServer
- All Known Implementing Classes:
 MessagingApplication,NettyHttpServer
An EmbeddedApplication is a runnable application that starts and manages the ApplicationContext.
This interface is the parent interface of EmbeddedServer which formalizes the concept of a
 server that exposes a port and address
Applications that did not expose a port and address (messaging applications, CLI applications etc. may wish to use this interface instead
- Since:
 - 1.0
 - Author:
 - Graeme Rocher
 - See Also:
 
- 
Method Summary
Modifier and TypeMethodDescriptionResolves theApplicationContextfor this class.default Environmentdefault booleanMost servers shutdown cleanly, however some integrations make require a forced exist.default booleanisServer()This method returns whether the application is a server application or not.default booleanDetermines whether the application requires a shutdown hook for graceful shutdown.Methods inherited from interface io.micronaut.context.ApplicationContextLifeCycle
start, stop 
- 
Method Details
- 
getApplicationContext
ApplicationContext getApplicationContext()Description copied from interface:ApplicationContextProviderResolves theApplicationContextfor this class.- Specified by:
 getApplicationContextin interfaceApplicationContextProvider- Returns:
 - The 
ApplicationContextfor the server 
 - 
getApplicationConfiguration
ApplicationConfiguration getApplicationConfiguration()- Returns:
 - The 
ApplicationConfigurationinstance 
 - 
getEnvironment
- Returns:
 - The 
Environmentfor the server 
 - 
isServer
default boolean isServer()This method returns whether the application is a server application or not. Server applications require that the thread be kept a live, preventing the application from exiting.- Returns:
 - True if the application is a server
 
 - 
isForceExit
default boolean isForceExit()Most servers shutdown cleanly, however some integrations make require a forced exist. If true is returned Micronaut will explicitly invoke System.exit(...).- Returns:
 - Whether exiting the server should be forced.
 
 - 
isShutdownHookNeeded
default boolean isShutdownHookNeeded()Determines whether the application requires a shutdown hook for graceful shutdown.Due to the JVM's non-deterministic shutdown hook execution order, a custom hook may be necessary to perform certain actions before or after closing the application context. Additionally, tests often close the application context immediately after execution, making a shutdown hook unnecessary. In such cases, registering a shutdown hook may lead to memory leaks due to excessive application context creation.
- Returns:
 trueif the application allows registering shutdown hooks,falseotherwise
 
 -