java.lang.Object
dk.cloudcreate.essentials.components.foundation.lifecycle.DefaultLifecycleManager
All Implemented Interfaces:
LifecycleManager, EventListener, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ApplicationContextEvent>

public final class DefaultLifecycleManager extends Object implements LifecycleManager, org.springframework.context.ApplicationListener<org.springframework.context.event.ApplicationContextEvent>, org.springframework.context.ApplicationContextAware
Default LifecycleManager that integrate with Spring to ensure that ApplicationContext Beans that implement the Lifecycle interface are started and stopped in response to ContextRefreshedEvent and ContextClosedEvent
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultLifecycleManager(boolean isStartLifecycles)
     
    DefaultLifecycleManager(Consumer<org.springframework.context.ApplicationContext> contextRefreshedEventConsumer, boolean isStartLifecycles)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onApplicationEvent(org.springframework.context.event.ApplicationContextEvent event)
     
    void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.context.ApplicationListener

    supportsAsyncExecution
  • Field Details

    • log

      public static final org.slf4j.Logger log
  • Constructor Details

    • DefaultLifecycleManager

      public DefaultLifecycleManager(Consumer<org.springframework.context.ApplicationContext> contextRefreshedEventConsumer, boolean isStartLifecycles)
      Parameters:
      contextRefreshedEventConsumer - callback that will be called after all Lifecycle Beans Lifecycle.start() has been called
      isStartLifecycles - determines if lifecycle beans should be started automatically
    • DefaultLifecycleManager

      public DefaultLifecycleManager(boolean isStartLifecycles)
      Parameters:
      isStartLifecycles - determines if lifecycle beans should be started automatically
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • onApplicationEvent

      public void onApplicationEvent(org.springframework.context.event.ApplicationContextEvent event)
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ApplicationContextEvent>