Allow user-provided ExecuteListenerProvider to go after Boot's

Closes gh-14598
This commit is contained in:
Andy Wilkinson
2018-10-03 16:55:48 +01:00
parent 7e4b22d25e
commit 7cbee701cd
2 changed files with 12 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfigu
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
@@ -79,6 +80,7 @@ public class JooqAutoConfiguration {
} }
@Bean @Bean
@Order(0)
public DefaultExecuteListenerProvider jooqExceptionTranslatorExecuteListenerProvider() { public DefaultExecuteListenerProvider jooqExceptionTranslatorExecuteListenerProvider() {
return new DefaultExecuteListenerProvider(new JooqExceptionTranslator()); return new DefaultExecuteListenerProvider(new JooqExceptionTranslator());
} }

View File

@@ -38,6 +38,7 @@ import org.jooq.TransactionListenerProvider;
import org.jooq.TransactionalRunnable; import org.jooq.TransactionalRunnable;
import org.jooq.VisitListener; import org.jooq.VisitListener;
import org.jooq.VisitListenerProvider; import org.jooq.VisitListenerProvider;
import org.jooq.impl.DefaultExecuteListenerProvider;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -45,6 +46,7 @@ import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
@@ -150,8 +152,13 @@ public class JooqAutoConfigurationTests {
.isEqualTo(TestExecutorProvider.class); .isEqualTo(TestExecutorProvider.class);
assertThat(dsl.configuration().recordListenerProviders().length) assertThat(dsl.configuration().recordListenerProviders().length)
.isEqualTo(1); .isEqualTo(1);
assertThat(dsl.configuration().executeListenerProviders().length) ExecuteListenerProvider[] executeListenerProviders = dsl
.isEqualTo(2); .configuration().executeListenerProviders();
assertThat(executeListenerProviders.length).isEqualTo(2);
assertThat(executeListenerProviders[0])
.isInstanceOf(DefaultExecuteListenerProvider.class);
assertThat(executeListenerProviders[1])
.isInstanceOf(TestExecuteListenerProvider.class);
assertThat(dsl.configuration().visitListenerProviders().length) assertThat(dsl.configuration().visitListenerProviders().length)
.isEqualTo(1); .isEqualTo(1);
assertThat(dsl.configuration().transactionListenerProviders().length) assertThat(dsl.configuration().transactionListenerProviders().length)
@@ -260,6 +267,7 @@ public class JooqAutoConfigurationTests {
} }
@Order(100)
protected static class TestExecuteListenerProvider protected static class TestExecuteListenerProvider
implements ExecuteListenerProvider { implements ExecuteListenerProvider {