All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.transferwise.common.gracefulshutdown.DefaultGracefulShutdownStrategiesRegistry Maven / Gradle / Ivy

There is a newer version: 2.14.5
Show newest version
package com.transferwise.common.gracefulshutdown;

import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;

@Slf4j
public class DefaultGracefulShutdownStrategiesRegistry implements GracefulShutdownStrategiesRegistry {

  @Autowired
  private ApplicationContext applicationContext;

  private List strategies;

  @Override
  public List getStrategies() {
    if (strategies == null) {
      List strategies = new ArrayList<>(applicationContext.getBeansOfType(GracefulShutdownStrategy.class).values());

      AnnotationAwareOrderComparator.sort(strategies);

      this.strategies = strategies;

      log.info("Following strategies were detected: '" + strategies + "'.");
    }
    return strategies;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy