diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java index de696efc31..9cf8eaf0d9 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2015 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. @@ -16,8 +16,9 @@ package org.springframework.integration.http.inbound; -import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import javax.servlet.http.HttpServletRequest; @@ -25,10 +26,10 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; import org.springframework.web.HttpRequestHandler; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerExecutionChain; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; @@ -113,51 +114,17 @@ public final class IntegrationRequestMappingHandlerMapping extends RequestMappin return null; } - org.springframework.web.bind.annotation.RequestMapping requestMappingAnnotation = - new org.springframework.web.bind.annotation.RequestMapping() { + Map requestMappingAttributes = new HashMap(); + requestMappingAttributes.put("name", endpoint.getComponentName()); + requestMappingAttributes.put("path", requestMapping.getPathPatterns()); + requestMappingAttributes.put("method", requestMapping.getRequestMethods()); + requestMappingAttributes.put("params", requestMapping.getParams()); + requestMappingAttributes.put("headers", requestMapping.getHeaders()); + requestMappingAttributes.put("consumes", requestMapping.getConsumes()); + requestMappingAttributes.put("produces", requestMapping.getProduces()); - //TODO consider add 'name' support when SF 4.1 will be minimal - public String name() { - return null; - } - - @Override - public String[] value() { - return requestMapping.getPathPatterns(); - } - - @Override - public RequestMethod[] method() { - return requestMapping.getRequestMethods(); - } - - @Override - public String[] params() { - return requestMapping.getParams(); - } - - @Override - public String[] headers() { - return requestMapping.getHeaders(); - } - - @Override - public String[] consumes() { - return requestMapping.getConsumes(); - } - - @Override - public String[] produces() { - return requestMapping.getProduces(); - } - - @Override - public Class annotationType() { - return org.springframework.web.bind.annotation.RequestMapping.class; - } - }; - - return this.createRequestMappingInfo(requestMappingAnnotation, this.getCustomTypeCondition(endpoint.getClass())); + return createRequestMappingInfo(AnnotationAttributes.fromMap(requestMappingAttributes), + getCustomTypeCondition(endpoint.getClass())); } @Override diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/RequestMapping.java b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/RequestMapping.java index c343410c16..c5220654e3 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/RequestMapping.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/RequestMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2015 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.http.inbound; import org.springframework.http.HttpMethod; @@ -36,15 +37,16 @@ public class RequestMapping { private HttpMethod[] methods = new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}; - private String[] params; + private String[] params = new String[0]; - private String[] headers; + private String[] headers = new String[0]; - private String[] consumes; + private String[] consumes = new String[0]; - private String[] produces; + private String[] produces = new String[0]; public void setPathPatterns(String... pathPatterns) { + Assert.notEmpty(pathPatterns, "at least one path pattern is required"); this.pathPatterns = pathPatterns; } @@ -62,6 +64,7 @@ public class RequestMapping { } public void setParams(String... params) { + Assert.notEmpty(params, "at least one param is required"); this.params = params; } @@ -70,6 +73,7 @@ public class RequestMapping { } public void setHeaders(String... headers) { + Assert.notEmpty(headers, "at least one header is required"); this.headers = headers; } @@ -78,6 +82,7 @@ public class RequestMapping { } public void setConsumes(String... consumes) { + Assert.notEmpty(consumes, "at least one consume value is required"); this.consumes = consumes; } @@ -86,6 +91,7 @@ public class RequestMapping { } public void setProduces(String... produces) { + Assert.notEmpty(produces, "at least one produce value is required"); this.produces = produces; }