Skip to content

Commit b91c943

Browse files
committed
* Fix Checkstyle violations
* Add JavaDocs to new classes * Fix some code style inconsistency in the `AbstractMessageProducingHandler`
1 parent fa16c21 commit b91c943

File tree

4 files changed

+61
-20
lines changed

4 files changed

+61
-20
lines changed

spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import org.reactivestreams.Publisher;
2929

30+
import org.springframework.beans.factory.BeanFactory;
3031
import org.springframework.core.ReactiveAdapter;
3132
import org.springframework.core.ReactiveAdapterRegistry;
3233
import org.springframework.integration.IntegrationMessageHeaderAccessor;
@@ -202,8 +203,9 @@ protected void onInit() {
202203
super.onInit();
203204
Assert.state(!(this.outputChannelName != null && this.outputChannel != null), //NOSONAR (inconsistent sync)
204205
"'outputChannelName' and 'outputChannel' are mutually exclusive.");
205-
if (getBeanFactory() != null) {
206-
this.messagingTemplate.setBeanFactory(getBeanFactory());
206+
BeanFactory beanFactory = getBeanFactory();
207+
if (beanFactory != null) {
208+
this.messagingTemplate.setBeanFactory(beanFactory);
207209
}
208210
this.messagingTemplate.setDestinationResolver(getChannelResolver());
209211
}
@@ -222,11 +224,11 @@ public MessageChannel getOutputChannel() {
222224
protected void sendOutputs(Object result, Message<?> requestMessage) {
223225
if (result instanceof Iterable<?> && shouldSplitOutput((Iterable<?>) result)) {
224226
for (Object o : (Iterable<?>) result) {
225-
this.produceOutput(o, requestMessage);
227+
produceOutput(o, requestMessage);
226228
}
227229
}
228230
else if (result != null) {
229-
this.produceOutput(result, requestMessage);
231+
produceOutput(result, requestMessage);
230232
}
231233
}
232234

@@ -246,8 +248,7 @@ protected void produceOutput(Object replyArg, final Message<?> requestMessage) {
246248
if (getOutputChannel() == null) {
247249
Map<?, ?> routingSlipHeader = obtainRoutingSlipHeader(requestHeaders, reply);
248250
if (routingSlipHeader != null) {
249-
Assert.isTrue(routingSlipHeader.size() == 1,
250-
"The RoutingSlip header value must be a SingletonMap");
251+
Assert.isTrue(routingSlipHeader.size() == 1, "The RoutingSlip header value must be a SingletonMap");
251252
Object key = routingSlipHeader.keySet().iterator().next();
252253
Object value = routingSlipHeader.values().iterator().next();
253254
Assert.isInstanceOf(List.class, key, "The RoutingSlip key must be List");
@@ -298,7 +299,7 @@ else if (reply instanceof AbstractIntegrationMessageBuilder<?>) {
298299
}
299300

300301
private void doProduceOutput(Message<?> requestMessage, MessageHeaders requestHeaders, Object reply,
301-
Object replyChannel) {
302+
@Nullable Object replyChannel) {
302303

303304
if (this.async && (reply instanceof ListenableFuture<?> || reply instanceof Publisher<?>)) {
304305
MessageChannel messageChannel = getOutputChannel();
@@ -341,7 +342,7 @@ else if (reply instanceof AbstractIntegrationMessageBuilder) {
341342
return builder;
342343
}
343344

344-
private void asyncNonReactiveReply(Message<?> requestMessage, Object reply, Object replyChannel) {
345+
private void asyncNonReactiveReply(Message<?> requestMessage, Object reply, @Nullable Object replyChannel) {
345346
ListenableFuture<?> future;
346347
if (reply instanceof ListenableFuture<?>) {
347348
future = (ListenableFuture<?>) reply;
@@ -508,9 +509,10 @@ private final class ReplyFutureCallback implements ListenableFutureCallback<Obje
508509

509510
private final Message<?> requestMessage;
510511

512+
@Nullable
511513
private final Object replyChannel;
512514

513-
ReplyFutureCallback(Message<?> requestMessage, Object replyChannel) {
515+
ReplyFutureCallback(Message<?> requestMessage, @Nullable Object replyChannel) {
514516
this.requestMessage = requestMessage;
515517
this.replyChannel = replyChannel;
516518
}

spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReactiveReplyProducingMessageHandler.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
1+
/*
2+
* Copyright 2020 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+
117
package org.springframework.integration.handler;
218

319
import org.springframework.messaging.Message;
420

521
import reactor.core.publisher.Mono;
622

23+
/**
24+
* A {@link BaseReplyProducingMessageHandler} extension for reply-producing message handlers with
25+
* reactive type reply.
26+
*
27+
* @author Artem Bilan
28+
*
29+
* @since 5.3
30+
*/
731
public abstract class AbstractReactiveReplyProducingMessageHandler
832
extends BaseReplyProducingMessageHandler<AbstractReactiveReplyProducingMessageHandler.RequestHandler> {
933

spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,8 @@
1616

1717
package org.springframework.integration.handler;
1818

19-
import java.util.LinkedList;
20-
import java.util.List;
21-
22-
import org.aopalliance.aop.Advice;
23-
24-
import org.springframework.aop.framework.ProxyFactory;
25-
import org.springframework.beans.factory.BeanClassLoaderAware;
26-
import org.springframework.integration.IntegrationPatternType;
27-
import org.springframework.integration.handler.advice.HandleMessageAdvice;
2819
import org.springframework.lang.Nullable;
2920
import org.springframework.messaging.Message;
30-
import org.springframework.util.Assert;
31-
import org.springframework.util.ClassUtils;
3221

3322
/**
3423
* Base class for MessageHandlers that are capable of producing replies.

spring-integration-core/src/main/java/org/springframework/integration/handler/BaseReplyProducingMessageHandler.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2020 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+
117
package org.springframework.integration.handler;
218

319
import java.util.LinkedList;
@@ -14,6 +30,16 @@
1430
import org.springframework.util.Assert;
1531
import org.springframework.util.ClassUtils;
1632

33+
/**
34+
* An {@link AbstractMessageProducingHandler} extension for an {@link Advice}s logic
35+
* to applied for the target implementation.
36+
*
37+
* @param <H> an internal advice request handler.
38+
*
39+
* @author Artem Bilan
40+
*
41+
* @since 5.3
42+
*/
1743
public abstract class BaseReplyProducingMessageHandler<H> extends AbstractMessageProducingHandler
1844
implements BeanClassLoaderAware {
1945

0 commit comments

Comments
 (0)