Skip to content

Commit 97ab596

Browse files
artembilangaryrussell
authored andcommitted
GH-2708: Make messaging annotations as repeatable
Fixes #2708 There are some requests to use the same service method for different input channels * Make all the messaging annotations as `@Repeatable` with their respective container annotations * Modify `MessagingAnnotationPostProcessor` logic to deal with the mentioned repeatable requirements
1 parent f54d4b3 commit 97ab596

24 files changed

+453
-39
lines changed

spring-integration-core/src/main/java/org/springframework/integration/annotation/Aggregator.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Repeatable;
2122
import java.lang.annotation.Retention;
2223
import java.lang.annotation.RetentionPolicy;
2324
import java.lang.annotation.Target;
@@ -39,6 +40,7 @@
3940
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
4041
@Retention(RetentionPolicy.RUNTIME)
4142
@Documented
43+
@Repeatable(Aggregators.class)
4244
public @interface Aggregator {
4345

4446
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.annotation;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* The repeatable container for {@link Aggregator} annotations.
27+
*
28+
* @author Artem Bilan
29+
*
30+
* @since 6.0
31+
*/
32+
@Documented
33+
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
34+
@Retention(RetentionPolicy.RUNTIME)
35+
public @interface Aggregators {
36+
37+
Aggregator[] value();
38+
39+
}

spring-integration-core/src/main/java/org/springframework/integration/annotation/BridgeFrom.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Repeatable;
2122
import java.lang.annotation.Retention;
2223
import java.lang.annotation.RetentionPolicy;
2324
import java.lang.annotation.Target;
@@ -45,6 +46,7 @@
4546
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
4647
@Retention(RetentionPolicy.RUNTIME)
4748
@Documented
49+
@Repeatable(BridgeFromRepeatable.class)
4850
public @interface BridgeFrom {
4951

5052
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.annotation;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* The repeatable container for {@link BridgeFrom} annotations.
27+
*
28+
* @author Artem Bilan
29+
*
30+
* @since 6.0
31+
*/
32+
@Documented
33+
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
34+
@Retention(RetentionPolicy.RUNTIME)
35+
public @interface BridgeFromRepeatable {
36+
37+
BridgeFrom[] value();
38+
39+
}

spring-integration-core/src/main/java/org/springframework/integration/annotation/BridgeTo.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Repeatable;
2122
import java.lang.annotation.Retention;
2223
import java.lang.annotation.RetentionPolicy;
2324
import java.lang.annotation.Target;
@@ -50,6 +51,7 @@
5051
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
5152
@Retention(RetentionPolicy.RUNTIME)
5253
@Documented
54+
@Repeatable(BridgeToRepeatable.class)
5355
public @interface BridgeTo {
5456

5557
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.annotation;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* The repeatable container for {@link BridgeTo} annotations.
27+
*
28+
* @author Artem Bilan
29+
*
30+
* @since 6.0
31+
*/
32+
@Documented
33+
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
34+
@Retention(RetentionPolicy.RUNTIME)
35+
public @interface BridgeToRepeatable {
36+
37+
BridgeTo[] value();
38+
39+
}

spring-integration-core/src/main/java/org/springframework/integration/annotation/Filter.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Repeatable;
2122
import java.lang.annotation.Retention;
2223
import java.lang.annotation.RetentionPolicy;
2324
import java.lang.annotation.Target;
@@ -47,6 +48,7 @@
4748
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
4849
@Retention(RetentionPolicy.RUNTIME)
4950
@Documented
51+
@Repeatable(Filters.class)
5052
public @interface Filter {
5153

5254
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.annotation;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* The repeatable container for {@link Filter} annotations.
27+
*
28+
* @author Artem Bilan
29+
*
30+
* @since 6.0
31+
*/
32+
@Documented
33+
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
34+
@Retention(RetentionPolicy.RUNTIME)
35+
public @interface Filters {
36+
37+
Filter[] value();
38+
39+
}

spring-integration-core/src/main/java/org/springframework/integration/annotation/InboundChannelAdapter.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Repeatable;
2122
import java.lang.annotation.Retention;
2223
import java.lang.annotation.RetentionPolicy;
2324
import java.lang.annotation.Target;
@@ -53,6 +54,7 @@
5354
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
5455
@Retention(RetentionPolicy.RUNTIME)
5556
@Documented
57+
@Repeatable(InboundChannelAdapters.class)
5658
public @interface InboundChannelAdapter {
5759

5860
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.annotation;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* The repeatable container for {@link InboundChannelAdapter} annotations.
27+
*
28+
* @author Artem Bilan
29+
*
30+
* @since 6.0
31+
*/
32+
@Documented
33+
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
34+
@Retention(RetentionPolicy.RUNTIME)
35+
public @interface InboundChannelAdapters {
36+
37+
InboundChannelAdapter[] value();
38+
39+
}

spring-integration-core/src/main/java/org/springframework/integration/annotation/Router.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Repeatable;
2122
import java.lang.annotation.Retention;
2223
import java.lang.annotation.RetentionPolicy;
2324
import java.lang.annotation.Target;
@@ -50,6 +51,7 @@
5051
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
5152
@Retention(RetentionPolicy.RUNTIME)
5253
@Documented
54+
@Repeatable(Routers.class)
5355
public @interface Router {
5456

5557
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.annotation;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* The repeatable container for {@link Router} annotations.
27+
*
28+
* @author Artem Bilan
29+
*
30+
* @since 6.0
31+
*/
32+
@Documented
33+
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
34+
@Retention(RetentionPolicy.RUNTIME)
35+
public @interface Routers {
36+
37+
Router[] value();
38+
39+
}

spring-integration-core/src/main/java/org/springframework/integration/annotation/ServiceActivator.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Repeatable;
2122
import java.lang.annotation.Retention;
2223
import java.lang.annotation.RetentionPolicy;
2324
import java.lang.annotation.Target;
@@ -48,6 +49,7 @@
4849
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
4950
@Retention(RetentionPolicy.RUNTIME)
5051
@Documented
52+
@Repeatable(ServiceActivators.class)
5153
public @interface ServiceActivator {
5254

5355
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.annotation;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* The repeatable container for {@link ServiceActivator} annotations.
27+
*
28+
* @author Artem Bilan
29+
*
30+
* @since 6.0
31+
*/
32+
@Documented
33+
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
34+
@Retention(RetentionPolicy.RUNTIME)
35+
public @interface ServiceActivators {
36+
37+
ServiceActivator[] value();
38+
39+
}

0 commit comments

Comments
 (0)