Skip to content

Commit d81cb4a

Browse files
committed
renaming interface
1 parent 2616948 commit d81cb4a

5 files changed

Lines changed: 29 additions & 88 deletions

File tree

‎spring-integration/src/main/java/com/baeldung/subflows/publishsubscribechannel/PublishSubscibeChannelExample.java‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
@EnableIntegration
1717
@IntegrationComponentScan
1818
public class PublishSubscibeChannelExample {
19-
2019
@MessagingGateway
21-
public interface I {
22-
20+
public interface NumbersClassifier {
2321
@Gateway(requestChannel = "flow.input")
24-
void flow(Collection<Integer> is);
25-
22+
void flow(Collection<Integer> numbers);
2623
}
2724

2825
@Bean
@@ -43,30 +40,24 @@ DirectChannel remainderIs2Channel() {
4340
@Bean
4441
public IntegrationFlow flow() {
4542
return flow -> flow.split()
46-
.publishSubscribeChannel(s ->
47-
s.subscribe(f -> f.<Integer> filter(p -> p % 3 == 0).channel("multipleof3Channel"))
48-
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 1).channel("remainderIs1Channel"))
49-
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 2).channel("remainderIs2Channel"))
50-
);
43+
.publishSubscribeChannel(s -> s.subscribe(f -> f.<Integer> filter(p -> p % 3 == 0)
44+
.channel("multipleof3Channel"))
45+
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 1)
46+
.channel("remainderIs1Channel"))
47+
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 2)
48+
.channel("remainderIs2Channel")));
5149
}
5250

5351
public static void main(String[] args) {
5452
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(PublishSubscibeChannelExample.class);
55-
5653
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
5754
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
58-
5955
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
6056
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
61-
6257
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
6358
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
64-
65-
ctx.getBean(I.class)
59+
ctx.getBean(NumbersClassifier.class)
6660
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
67-
6861
ctx.close();
69-
7062
}
71-
7263
}

‎spring-integration/src/main/java/com/baeldung/subflows/routeToRecipients/RouteToRecipientsExample.java‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
@EnableIntegration
1717
@IntegrationComponentScan
1818
public class RouteToRecipientsExample {
19-
2019
@MessagingGateway
21-
public interface I {
22-
20+
public interface NumbersClassifier {
2321
@Gateway(requestChannel = "flow.input")
24-
void flow(Collection<Integer> is);
25-
22+
void flow(Collection<Integer> numbers);
2623
}
2724

2825
@Bean
@@ -43,7 +40,6 @@ DirectChannel remainderIs2Channel() {
4340
@Bean
4441
public IntegrationFlow flow() {
4542
return flow -> flow.split()
46-
4743
.routeToRecipients(r -> r.<Integer> recipient("multipleof3Channel", p -> p % 3 == 0)// filter
4844
.<Integer> recipient("remainderIs1Channel", p -> p % 3 == 1)
4945
.recipientFlow(sf -> sf.<Integer> filter(p -> p % 3 == 2)
@@ -52,20 +48,14 @@ public IntegrationFlow flow() {
5248

5349
public static void main(String[] args) {
5450
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(RouteToRecipientsExample.class);
55-
5651
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
5752
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
58-
5953
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
6054
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
61-
6255
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
6356
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
64-
65-
ctx.getBean(I.class)
57+
ctx.getBean(NumbersClassifier.class)
6658
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
67-
6859
ctx.close();
69-
7060
}
7161
}

‎spring-integration/src/main/java/com/baeldung/subflows/separateflows/SeparateFlowsExample.java‎

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,16 @@
1616
@EnableIntegration
1717
@IntegrationComponentScan
1818
public class SeparateFlowsExample {
19-
2019
@MessagingGateway
21-
public interface I {
22-
20+
public interface NumbersClassifier {
2321
@Gateway(requestChannel = "multipleof3Flow.input")
2422
void multipleof3(Collection<Integer> is);
2523

2624
@Gateway(requestChannel = "remainderIs1Flow.input")
2725
void remainderIs1(Collection<Integer> is);
2826

2927
@Gateway(requestChannel = "remainderIs2Flow.input")
30-
void remainderIs2(Collection<Integer> is);
31-
28+
void remainderIs2(Collection<Integer> numbers);
3229
}
3330

3431
@Bean
@@ -51,49 +48,36 @@ public IntegrationFlow multipleof3Flow() {
5148
return f -> f.split()
5249
.<Integer> filter(p -> p % 3 == 0)
5350
.channel("multipleof3Channel");
54-
5551
}
5652

5753
@Bean
5854
public IntegrationFlow remainderIs1Flow() {
5955
return f -> f.split()
6056
.<Integer> filter(p -> p % 3 == 1)
6157
.channel("remainderIs1Channel");
62-
6358
}
6459

6560
@Bean
6661
public IntegrationFlow remainderIs2Flow() {
6762
return f -> f.split()
6863
.<Integer> filter(p -> p % 3 == 2)
6964
.channel("remainderIs2Channel");
70-
7165
}
7266

7367
public static void main(String[] args) {
74-
7568
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(SeparateFlowsExample.class);
76-
7769
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
7870
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
79-
8071
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
8172
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
82-
8373
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
8474
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
85-
86-
ctx.getBean(I.class)
75+
ctx.getBean(NumbersClassifier.class)
8776
.multipleof3(Arrays.asList(1, 2, 3, 4, 5, 6));
88-
89-
ctx.getBean(I.class)
77+
ctx.getBean(NumbersClassifier.class)
9078
.remainderIs1(Arrays.asList(1, 2, 3, 4, 5, 6));
91-
92-
ctx.getBean(I.class)
79+
ctx.getBean(NumbersClassifier.class)
9380
.remainderIs2(Arrays.asList(1, 2, 3, 4, 5, 6));
94-
9581
ctx.close();
96-
9782
}
98-
99-
}
83+
}

‎spring-integration/src/main/java/com/baeldung/subflows/subflowchannel/FilterExample.java‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
@EnableIntegration
1717
@IntegrationComponentScan
1818
public class FilterExample {
19-
2019
@MessagingGateway
21-
public interface I {
22-
20+
public interface NumbersClassifier {
2321
@Gateway(requestChannel = "flow.input")
24-
void flow(Collection<Integer> is);
25-
22+
void flow(Collection<Integer> numbers);
2623
}
2724

2825
@Bean
@@ -43,33 +40,21 @@ DirectChannel remainderIs2Channel() {
4340
@Bean
4441
public IntegrationFlow flow() {
4542
return flow -> flow.split()
46-
47-
.<Integer> filter(x -> x % 3 == 0, sf -> sf.discardFlow(subf -> subf
48-
49-
.<Integer> filter(x -> x % 3 == 1, ssf -> ssf.discardChannel("remainderIs2Channel"))
50-
.channel("remainderIs1Channel")
51-
52-
))
53-
43+
.<Integer> filter(x -> x % 3 == 0, sf -> sf.discardFlow(subf -> subf.<Integer> filter(x -> x % 3 == 1, ssf -> ssf.discardChannel("remainderIs2Channel"))
44+
.channel("remainderIs1Channel")))
5445
.channel("multipleof3Channel");
5546
}
5647

5748
public static void main(String[] args) {
5849
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(FilterExample.class);
59-
6050
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
6151
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
62-
6352
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
6453
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
65-
6654
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
6755
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
68-
69-
ctx.getBean(I.class)
56+
ctx.getBean(NumbersClassifier.class)
7057
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
71-
7258
ctx.close();
73-
7459
}
7560
}

‎spring-integration/src/main/java/com/baeldung/subflows/subflowmapping/RouterExample.java‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
@IntegrationComponentScan
1818
public class RouterExample {
1919
@MessagingGateway
20-
public interface I {
21-
20+
public interface NumbersClassifier {
2221
@Gateway(requestChannel = "flow.input")
23-
void flow(Collection<Integer> is);
24-
22+
void flow(Collection<Integer> numbers);
2523
}
2624

2725
@Bean
@@ -43,28 +41,21 @@ DirectChannel remainderIs2Channel() {
4341
public IntegrationFlow flow() {
4442
return f -> f.split()
4543
.<Integer, Integer> route(p -> p % 3, m -> m.channelMapping(0, "multipleof3Channel")
46-
.subFlowMapping(1, sf -> sf .channel("remainderIs1Channel"))
47-
.subFlowMapping(2, sf -> sf.<Integer> handle((p,h)->p)))
44+
.subFlowMapping(1, sf -> sf.channel("remainderIs1Channel"))
45+
.subFlowMapping(2, sf -> sf.<Integer> handle((p, h) -> p)))
4846
.channel("remainderIs2Channel");
4947
}
5048

5149
public static void main(String[] args) {
5250
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(RouterExample.class);
53-
5451
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
5552
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
56-
5753
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
5854
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
59-
6055
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
6156
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
62-
63-
ctx.getBean(I.class)
57+
ctx.getBean(NumbersClassifier.class)
6458
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
65-
6659
ctx.close();
67-
6860
}
69-
70-
}
61+
}

0 commit comments

Comments
 (0)