Class ApplicationContextStatusProvider
java.lang.Object
com.github.jpmsilva.jsystemd.spring.ApplicationContextStatusProvider
- All Implemented Interfaces:
StatusProvider,BeanPostProcessor
public class ApplicationContextStatusProvider
extends Object
implements StatusProvider, BeanPostProcessor
Implementation of
StatusProvider that provides information regarding the bean creation progress of a bean factory.- Author:
- Joao Silva
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance, which sends the status to systemd as the beans are created. -
Method Summary
Modifier and TypeMethodDescription@Nullable ObjectpostProcessAfterInitialization(Object bean, String beanName) @Nullable ObjectpostProcessBeforeInitialization(Object bean, String beanName) Notifies systemd of the bean creation progress, at most once a second, while the application starts up: the beans created afterwards, such as prototype or request scoped beans, are not part of the startup, and must neither extend the shutdown timeout once the application is stopping, nor update the status on the threads that create them, such as the threads that serve requests.status()Returns the bean creation progress, counting the singletons created so far, out of those created on startup: lazy ones, which may only be created once used, are left out, and nothing is reported when all of them are lazy.
-
Constructor Details
-
ApplicationContextStatusProvider
Creates a new instance, which sends the status to systemd as the beans are created.The created instance is not registered as a status provider of
Systemd.instance(): that is up to the caller.- Parameters:
factory- the bean factory of the application context, whose bean creation progress is reported
-
-
Method Details
-
status
Returns the bean creation progress, counting the singletons created so far, out of those created on startup: lazy ones, which may only be created once used, are left out, and nothing is reported when all of them are lazy. They are counted only when the status is read, that is, when systemd is notified (at most once a second while beans are being created) and on each periodic status update, rather than every time a bean is created.- Specified by:
statusin interfaceStatusProvider- Returns:
- the string message to add to the service status
-
postProcessBeforeInitialization
public @Nullable Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException Notifies systemd of the bean creation progress, at most once a second, while the application starts up: the beans created afterwards, such as prototype or request scoped beans, are not part of the startup, and must neither extend the shutdown timeout once the application is stopping, nor update the status on the threads that create them, such as the threads that serve requests.- Specified by:
postProcessBeforeInitializationin interfaceBeanPostProcessor- Throws:
BeansException
-
postProcessAfterInitialization
public @Nullable Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException - Specified by:
postProcessAfterInitializationin interfaceBeanPostProcessor- Throws:
BeansException
-