close abstract method
Shuts the context down: publishes ContextClosedEvent, stops the
running Lifecycle beans and destroys the singletons (each bean after
the beans that depend on it), which runs their @PreDestroy and
destroy methods.
Call it when the program ends, or let registerShutdownHook do it. It
does nothing unless the context is active, so a second call is
harmless; it also works during refresh, for example from a
ContextRefreshedEvent listener. It never throws because of a failing
ContextClosedEvent listener or a bean that fails to stop: the error
is logged and the shutdown goes on. It does not wait: a
SmartLifecycle stop callback that comes later, or a destroy callback
that returns a Future, is logged and skipped; use closeAsync to
wait for them.
final context = ApplicationContext.run([appBeans]);
context.registerShutdownHook(); // or close() yourself
Spring (Java):
context.close(); // or context.registerShutdownHook();
Implementation
void close();