INT-2312b: Compatibility with SPR 3.2.x and 4.0

From SPR 3.2.x the 'the path mapping' is **required** for `Controller`,
But with SI it is OK, because we can configure HTTP Inbound Endpoint via `HttpRequestHandlerServlet`.

So, add check if `requestMapping.getPathPatterns()` has values and don't register HTTP Inbound Endpoint
as `HandlerMethod` and just rely on user choice.

JIRA: https://jira.springsource.org/browse/INT-2312

INT-2312b: Polishing
This commit is contained in:
Artem Bilan
2013-10-02 13:32:23 +03:00
committed by Gary Russell
parent 6a9cb75668
commit fb186d3dd5
2 changed files with 9 additions and 3 deletions

View File

@@ -271,7 +271,7 @@ public abstract class HttpRequestHandlingEndpointSupport extends MessagingGatewa
this.requestMapping = requestMapping;
}
public RequestMapping getRequestMapping() {
public final RequestMapping getRequestMapping() {
return requestMapping;
}
@@ -521,7 +521,6 @@ public abstract class HttpRequestHandlingEndpointSupport extends MessagingGatewa
/**
* Converts a servlet request's parameterMap to a {@link MultiValueMap}.
*/
@SuppressWarnings("rawtypes")
private MultiValueMap<String, String> convertParameterMap(Map<String, String[]> parameterMap) {
MultiValueMap<String, String> convertedMap = new LinkedMultiValueMap<String, String>(parameterMap.size());
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {

View File

@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -96,7 +97,9 @@ public final class IntegrationRequestMappingHandlerMapping extends RequestMappin
handler = this.getApplicationContext().getBean((String) handler);
}
RequestMappingInfo mapping = this.getMappingForEndpoint((HttpRequestHandlingEndpointSupport) handler);
this.registerHandlerMethod(handler, HANDLE_REQUEST_METHOD, mapping);
if (mapping != null) {
this.registerHandlerMethod(handler, HANDLE_REQUEST_METHOD, mapping);
}
}
/**
@@ -107,6 +110,10 @@ public final class IntegrationRequestMappingHandlerMapping extends RequestMappin
private RequestMappingInfo getMappingForEndpoint(HttpRequestHandlingEndpointSupport endpoint) {
final RequestMapping requestMapping = endpoint.getRequestMapping();
if (ObjectUtils.isEmpty(requestMapping.getPathPatterns())) {
return null;
}
org.springframework.web.bind.annotation.RequestMapping requestMappingAnnotation =
new org.springframework.web.bind.annotation.RequestMapping() {
public String[] value() {