com.transferwise.common.gracefulshutdown.DefaultGracefulShutdownStrategiesRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tw-graceful-shutdown Show documentation
Show all versions of tw-graceful-shutdown Show documentation
TransferWise Graceful Shutdown - no noise and errors during releases.
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;
}
}