Skip to content

Commit

Permalink
#276 add Ordered interface to internal bean post processors to ensure…
Browse files Browse the repository at this point in the history
… correct processing order
  • Loading branch information
tomix26 committed Nov 25, 2024
1 parent 49e474f commit 812c965
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -59,7 +60,7 @@

import static com.google.common.base.Preconditions.checkState;

public class FlywayDatabaseExtension implements BeanPostProcessor {
public class FlywayDatabaseExtension implements BeanPostProcessor, Ordered {

private static final FlywayVersion flywayVersion = FlywayClassUtils.getFlywayVersion();

Expand All @@ -68,6 +69,11 @@ public class FlywayDatabaseExtension implements BeanPostProcessor {
protected final Multimap<DatabaseContext, Flyway> flywayBeans = HashMultimap.create();
protected final BlockingQueue<FlywayOperation> pendingOperations = new LinkedBlockingQueue<>();

@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 1;
}

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) {
if (bean instanceof AopInfrastructureBean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.flyway.FlywayProperties;
import org.springframework.core.Ordered;

public class FlywayPropertiesPostProcessor implements BeanPostProcessor {
public class FlywayPropertiesPostProcessor implements BeanPostProcessor, Ordered {

@Override
public int getOrder() {
return Ordered.LOWEST_PRECEDENCE - 1;
}

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;

import static com.google.common.base.Preconditions.checkState;

public class LiquibaseDatabaseExtension implements BeanPostProcessor {
public class LiquibaseDatabaseExtension implements BeanPostProcessor, Ordered {

@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 1;
}

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.core.Ordered;

public class LiquibasePropertiesPostProcessor implements BeanPostProcessor {
public class LiquibasePropertiesPostProcessor implements BeanPostProcessor, Ordered {

@Override
public int getOrder() {
return Ordered.LOWEST_PRECEDENCE - 1;
}

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
Expand Down

0 comments on commit 812c965

Please sign in to comment.