Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jooq.RecordListenerProvider;
import org.jooq.RecordMapperProvider;
import org.jooq.RecordUnmapperProvider;
import org.jooq.TransactionListenerProvider;
import org.jooq.TransactionProvider;
import org.jooq.VisitListenerProvider;
import org.jooq.conf.Settings;
Expand Down Expand Up @@ -51,6 +52,7 @@
*
* @author Andreas Ahlenstorf
* @author Michael Simons
* @author Dmytro Nosan
* @since 1.3.0
*/
@Configuration
Expand Down Expand Up @@ -105,6 +107,8 @@ public static class DslContextConfiguration {

private final VisitListenerProvider[] visitListenerProviders;

private final TransactionListenerProvider[] transactionListenerProviders;

public DslContextConfiguration(JooqProperties properties,
ConnectionProvider connectionProvider, DataSource dataSource,
ObjectProvider<TransactionProvider> transactionProvider,
Expand All @@ -113,7 +117,8 @@ public DslContextConfiguration(JooqProperties properties,
ObjectProvider<Settings> settings,
ObjectProvider<RecordListenerProvider[]> recordListenerProviders,
ExecuteListenerProvider[] executeListenerProviders,
ObjectProvider<VisitListenerProvider[]> visitListenerProviders) {
ObjectProvider<VisitListenerProvider[]> visitListenerProviders,
ObjectProvider<TransactionListenerProvider[]> transactionListenerProviders) {
this.properties = properties;
this.connection = connectionProvider;
this.dataSource = dataSource;
Expand All @@ -124,6 +129,8 @@ public DslContextConfiguration(JooqProperties properties,
this.recordListenerProviders = recordListenerProviders.getIfAvailable();
this.executeListenerProviders = executeListenerProviders;
this.visitListenerProviders = visitListenerProviders.getIfAvailable();
this.transactionListenerProviders = transactionListenerProviders
.getIfAvailable();
}

@Bean
Expand Down Expand Up @@ -152,6 +159,8 @@ public DefaultConfiguration jooqConfiguration() {
configuration.set(this.recordListenerProviders);
configuration.set(this.executeListenerProviders);
configuration.set(this.visitListenerProviders);
configuration
.setTransactionListenerProvider(this.transactionListenerProviders);
return configuration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.jooq.RecordUnmapper;
import org.jooq.RecordUnmapperProvider;
import org.jooq.SQLDialect;
import org.jooq.TransactionListener;
import org.jooq.TransactionListenerProvider;
import org.jooq.TransactionalRunnable;
import org.jooq.VisitListener;
import org.jooq.VisitListenerProvider;
Expand All @@ -56,6 +58,7 @@
* @author Phillip Webb
* @author Andy Wilkinson
* @author Stephane Nicoll
* @author Dmytro Nosan
*/
public class JooqAutoConfigurationTests {

Expand Down Expand Up @@ -137,8 +140,8 @@ public void customProvidersArePickedUp() {
this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class,
TxManagerConfiguration.class, TestRecordMapperProvider.class,
TestRecordUnmapperProvider.class, TestRecordListenerProvider.class,
TestExecuteListenerProvider.class, TestVisitListenerProvider.class)
.run((context) -> {
TestExecuteListenerProvider.class, TestVisitListenerProvider.class,
TestTransactionListenerProvider.class).run((context) -> {
DSLContext dsl = context.getBean(DSLContext.class);
assertThat(dsl.configuration().recordMapperProvider().getClass())
.isEqualTo(TestRecordMapperProvider.class);
Expand All @@ -150,6 +153,8 @@ public void customProvidersArePickedUp() {
.isEqualTo(2);
assertThat(dsl.configuration().visitListenerProviders().length)
.isEqualTo(1);
assertThat(dsl.configuration().transactionListenerProviders().length)
.isEqualTo(1);
});
}

Expand Down Expand Up @@ -273,4 +278,14 @@ public VisitListener provide() {

}

protected static class TestTransactionListenerProvider
implements TransactionListenerProvider {

@Override
public TransactionListener provide() {
return null;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3773,6 +3773,7 @@ following jOOQ Types:
* `RecordListenerProvider`
* `ExecuteListenerProvider`
* `VisitListenerProvider`
* `TransactionListenerProvider`

You can also create your own `org.jooq.Configuration` `@Bean` if you want to take
complete control of the jOOQ configuration.
Expand Down