Skip to content

Commit 2c65dfa

Browse files
committed
* Remove org.springframework.cloud dependencies from the project
since we don't use `@PollableBean` anymore, which comes from the `spring-cloud-function-context` * Simplify `JdbcSupplierConfiguration` and `MongodbSupplierConfiguration` code more: more injections to the respective bean method. * Use `(__) ->` lambda syntax for unused argument * Remove unused `ThreadLocalFluxSinkMessageChannel` internal class * Update Copyrights of the classes in this change
1 parent 5eea911 commit 2c65dfa

File tree

8 files changed

+19
-60
lines changed

8 files changed

+19
-60
lines changed

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ allprojects {
5858
mavenBom "io.debezium:debezium-bom:$debeziumVersion"
5959
mavenBom "io.awspring.cloud:spring-cloud-aws-dependencies:$springCloudAwsVersion"
6060
mavenBom "org.springframework.boot:spring-boot-dependencies:$springBootVersion"
61-
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
6261
mavenBom "ai.djl:bom:$djlVersion"
6362
}
6463
}

dependencies.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
ext {
22
springBootVersion = '3.4.1'
3-
springCloudVersion = '2024.0.0'
43
springCloudAwsVersion = '3.2.1'
54

65
debeziumVersion = '3.0.6.Final'

function/spring-splitter-function/src/main/java/org/springframework/cloud/fn/splitter/SplitterFunctionConfiguration.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2024 the original author or authors.
2+
* Copyright 2011-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,11 +17,9 @@
1717
package org.springframework.cloud.fn.splitter;
1818

1919
import java.nio.charset.Charset;
20-
import java.util.List;
2120
import java.util.Optional;
2221
import java.util.function.Function;
2322

24-
import org.reactivestreams.Publisher;
2523
import reactor.core.publisher.Flux;
2624

2725
import org.springframework.beans.factory.annotation.Qualifier;
@@ -33,13 +31,11 @@
3331
import org.springframework.context.annotation.Bean;
3432
import org.springframework.context.annotation.Conditional;
3533
import org.springframework.integration.channel.FluxMessageChannel;
36-
import org.springframework.integration.channel.ReactiveStreamsSubscribableChannel;
3734
import org.springframework.integration.file.splitter.FileSplitter;
3835
import org.springframework.integration.splitter.AbstractMessageSplitter;
3936
import org.springframework.integration.splitter.DefaultMessageSplitter;
4037
import org.springframework.integration.splitter.ExpressionEvaluatingSplitter;
4138
import org.springframework.messaging.Message;
42-
import org.springframework.messaging.MessageChannel;
4339

4440
/**
4541
* Auto-configuration for Splitter function.
@@ -67,7 +63,7 @@ public Function<Flux<Message<?>>, Flux<Message<?>>> splitterFunction(
6763
inputChannel.subscribe(messageSplitter);
6864
FluxMessageChannel outputChannel = new FluxMessageChannel();
6965
messageSplitter.setOutputChannel(outputChannel);
70-
return (messageFlux) -> Flux.from(outputChannel).doOnRequest((l) -> inputChannel.subscribeTo(messageFlux));
66+
return (messageFlux) -> Flux.from(outputChannel).doOnRequest((__) -> inputChannel.subscribeTo(messageFlux));
7167
}
7268

7369
@Bean
@@ -118,22 +114,4 @@ static class FileMarkers {
118114

119115
}
120116

121-
private static final class ThreadLocalFluxSinkMessageChannel
122-
implements MessageChannel, ReactiveStreamsSubscribableChannel {
123-
124-
private final ThreadLocal<List<Message<?>>> publisherThreadLocal = new ThreadLocal<>();
125-
126-
@Override
127-
@SuppressWarnings("unchecked")
128-
public void subscribeTo(Publisher<? extends Message<?>> publisher) {
129-
this.publisherThreadLocal.set(Flux.from(publisher).collectList().cast(List.class).block());
130-
}
131-
132-
@Override
133-
public boolean send(Message<?> message, long l) {
134-
throw new UnsupportedOperationException("This channel only supports a reactive 'subscribeTo()' ");
135-
}
136-
137-
}
138-
139117
}

function/spring-splitter-function/src/test/java/org/springframework/cloud/fn/splitter/SplitterFunctionApplicationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2024 the original author or authors.
2+
* Copyright 2011-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

supplier/spring-jdbc-supplier/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ dependencies {
22
api project(':spring-splitter-function')
33
api 'org.springframework.integration:spring-integration-jdbc'
44
api 'org.springframework.boot:spring-boot-starter-jdbc'
5-
api 'org.springframework.cloud:spring-cloud-function-context'
65

76
runtimeOnly 'org.hsqldb:hsqldb'
87
runtimeOnly 'com.h2database:h2'

supplier/spring-jdbc-supplier/src/main/java/org/springframework/cloud/fn/supplier/jdbc/JdbcSupplierConfiguration.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 the original author or authors.
2+
* Copyright 2019-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,23 +46,14 @@
4646
@EnableConfigurationProperties(JdbcSupplierProperties.class)
4747
public class JdbcSupplierConfiguration {
4848

49-
private final JdbcSupplierProperties properties;
50-
51-
private final DataSource dataSource;
52-
53-
public JdbcSupplierConfiguration(JdbcSupplierProperties properties, DataSource dataSource) {
54-
this.properties = properties;
55-
this.dataSource = dataSource;
56-
}
57-
5849
@Bean
59-
public JdbcPollingChannelAdapter jdbcMessageSource(
50+
public JdbcPollingChannelAdapter jdbcMessageSource(JdbcSupplierProperties properties, DataSource dataSource,
6051
@Nullable ComponentCustomizer<JdbcPollingChannelAdapter> jdbcPollingChannelAdapterCustomizer) {
6152

62-
JdbcPollingChannelAdapter jdbcPollingChannelAdapter = new JdbcPollingChannelAdapter(this.dataSource,
63-
this.properties.getQuery());
64-
jdbcPollingChannelAdapter.setMaxRows(this.properties.getMaxRows());
65-
jdbcPollingChannelAdapter.setUpdateSql(this.properties.getUpdate());
53+
JdbcPollingChannelAdapter jdbcPollingChannelAdapter = new JdbcPollingChannelAdapter(dataSource,
54+
properties.getQuery());
55+
jdbcPollingChannelAdapter.setMaxRows(properties.getMaxRows());
56+
jdbcPollingChannelAdapter.setUpdateSql(properties.getUpdate());
6657
if (jdbcPollingChannelAdapterCustomizer != null) {
6758
jdbcPollingChannelAdapterCustomizer.customize(jdbcPollingChannelAdapter);
6859
}

supplier/spring-mongodb-supplier/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ dependencies {
22
api project(':spring-splitter-function')
33
api 'org.springframework.integration:spring-integration-mongodb'
44
api 'org.mongodb:mongodb-driver-sync'
5-
api 'org.springframework.cloud:spring-cloud-function-context'
65

76
testImplementation 'org.testcontainers:mongodb'
87
testImplementation project(':spring-mongodb-consumer').sourceSets.test.output

supplier/spring-mongodb-supplier/src/main/java/org/springframework/cloud/fn/supplier/mongo/MongodbSupplierConfiguration.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 the original author or authors.
2+
* Copyright 2019-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,15 +48,6 @@
4848
@EnableConfigurationProperties({ MongodbSupplierProperties.class })
4949
public class MongodbSupplierConfiguration {
5050

51-
private final MongodbSupplierProperties properties;
52-
53-
private final MongoTemplate mongoTemplate;
54-
55-
public MongodbSupplierConfiguration(MongodbSupplierProperties properties, MongoTemplate mongoTemplate) {
56-
this.properties = properties;
57-
this.mongoTemplate = mongoTemplate;
58-
}
59-
6051
@Bean(name = "mongodbSupplier")
6152
@ConditionalOnProperty(prefix = "mongodb", name = "split", matchIfMissing = true)
6253
public Supplier<Flux<Message<?>>> splittedSupplier(MongoDbMessageSource mongoDbSource,
@@ -72,15 +63,18 @@ public Supplier<Message<?>> mongodbSupplier(MongoDbMessageSource mongoDbSource)
7263
}
7364

7465
@Bean
75-
public MongoDbMessageSource mongoDbSource(
66+
public MongoDbMessageSource mongoDbSource(MongodbSupplierProperties properties, MongoTemplate mongoTemplate,
7667
@Nullable ComponentCustomizer<MongoDbMessageSource> mongoDbMessageSourceCustomizer) {
7768

78-
Expression queryExpression = (this.properties.getQueryExpression() != null)
79-
? this.properties.getQueryExpression() : new LiteralExpression(this.properties.getQuery());
80-
MongoDbMessageSource mongoDbMessageSource = new MongoDbMessageSource(this.mongoTemplate, queryExpression);
81-
mongoDbMessageSource.setCollectionNameExpression(new LiteralExpression(this.properties.getCollection()));
69+
Expression queryExpression = properties.getQueryExpression();
70+
if (queryExpression == null) {
71+
queryExpression = new LiteralExpression(properties.getQuery());
72+
}
73+
74+
MongoDbMessageSource mongoDbMessageSource = new MongoDbMessageSource(mongoTemplate, queryExpression);
75+
mongoDbMessageSource.setCollectionNameExpression(new LiteralExpression(properties.getCollection()));
8276
mongoDbMessageSource.setEntityClass(String.class);
83-
mongoDbMessageSource.setUpdateExpression(this.properties.getUpdateExpression());
77+
mongoDbMessageSource.setUpdateExpression(properties.getUpdateExpression());
8478

8579
if (mongoDbMessageSourceCustomizer != null) {
8680
mongoDbMessageSourceCustomizer.customize(mongoDbMessageSource);

0 commit comments

Comments
 (0)