-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
SpringIntegrationWebFluxRequestHandler.java
86 lines (75 loc) · 3.1 KB
/
SpringIntegrationWebFluxRequestHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
*
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package springfox.documentation.spring.web;
import com.fasterxml.classmate.ResolvedType;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.http.inbound.BaseHttpInboundEndpoint;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.reactive.result.method.RequestMappingInfo;
import springfox.documentation.service.ResolvedMethodParameter;
import springfox.documentation.spring.web.plugins.SpringIntegrationParametersProvider;
import springfox.documentation.spring.web.readers.operation.HandlerMethodResolver;
import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Optional;
import static java.util.Optional.*;
/**
* Provides information about WebFlux based Spring Integration inbound HTTP handlers.
*/
public class SpringIntegrationWebFluxRequestHandler extends WebFluxRequestHandler {
private final HandlerMethodResolver methodResolver;
private final HandlerMethod handlerMethod;
private SpringIntegrationParametersProvider parametersProvider;
public SpringIntegrationWebFluxRequestHandler(
HandlerMethodResolver methodResolver,
RequestMappingInfo requestMapping,
HandlerMethod handlerMethod,
SpringIntegrationParametersProvider parametersProvider) {
super(methodResolver, requestMapping, handlerMethod);
this.methodResolver = methodResolver;
this.handlerMethod = handlerMethod;
this.parametersProvider = parametersProvider;
}
@Override
public String groupName() {
// TODO come up with a better group name, instead of generic handler class name
// maybe the defining class of a flow in DSL? - but what about xml?
return ControllerNamingUtils.controllerNameAsGroup(handlerMethod);
}
@Override
public String getName() {
return ((BaseHttpInboundEndpoint) handlerMethod.getBean())
.getComponentName();
}
@Override
public ResolvedType getReturnType() {
// always void, hence we need the spring restdocs plugin
return methodResolver.methodReturnType(handlerMethod);
}
@Override
public <T extends Annotation> Optional<T> findAnnotation(Class<T> annotation) {
// TODO see if we can synthesize the annotations usually requested here
return ofNullable(AnnotationUtils.findAnnotation(handlerMethod.getMethod(), annotation));
}
@Override
public List<ResolvedMethodParameter> getParameters() {
return parametersProvider
.getParameters((BaseHttpInboundEndpoint) handlerMethod.getBean());
}
}