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 Details

    • ApplicationContextStatusProvider

      public ApplicationContextStatusProvider(ConfigurableListableBeanFactory factory)
      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

      public String 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:
      status in interface StatusProvider
      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:
      postProcessBeforeInitialization in interface BeanPostProcessor
      Throws:
      BeansException
    • postProcessAfterInitialization

      public @Nullable Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
      Specified by:
      postProcessAfterInitialization in interface BeanPostProcessor
      Throws:
      BeansException