This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch http-interceptor in repository https://gitbox.apache.org/repos/asf/struts.git
commit 33f63cee3cf2dbf2dffc3cfae96687ed707eef1f Author: Lukasz Lenart <[email protected]> AuthorDate: Sun Sep 21 21:52:54 2014 +0200 Renames annotation to have more explicit meaning --- .../httpmethod/{GetOnly.java => HttpGet.java} | 2 +- .../{GetPostOnly.java => HttpGetOrPost.java} | 2 +- .../httpmethod/HttpMethodInterceptor.java | 24 +++++++++++----------- .../httpmethod/{PostOnly.java => HttpPost.java} | 2 +- .../org/apache/struts2/HttpMethodsTestAction.java | 12 +++++------ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetOnly.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpGet.java similarity index 94% rename from core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetOnly.java rename to core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpGet.java index 6cf2dc6d4..893bee1d2 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetOnly.java +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpGet.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) -public @interface GetOnly { +public @interface HttpGet { HttpMethod[] value() default { HttpMethod.GET }; diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetPostOnly.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpGetOrPost.java similarity index 93% rename from core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetPostOnly.java rename to core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpGetOrPost.java index 0668784b5..f831fcb29 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetPostOnly.java +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpGetOrPost.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) -public @interface GetPostOnly { +public @interface HttpGetOrPost { HttpMethod[] value() default { HttpMethod.GET, HttpMethod.POST }; diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpMethodInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpMethodInterceptor.java index ac64050cc..706046061 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpMethodInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpMethodInterceptor.java @@ -22,20 +22,20 @@ import java.util.List; * thus value will be used instead. * <p/> * To limit allowed http methods, annotate action class with {@link AllowedHttpMethod} and specify - * which methods are allowed. You can also use shorter versions {@link GetOnly}, {@link PostOnly} - * and {@link GetPostOnly} + * which methods are allowed. You can also use shorter versions {@link HttpGet}, {@link HttpPost} + * and {@link HttpGetOrPost} * * @see HttpMethodAware * @see HttpMethod * @see AllowedHttpMethod - * @see GetOnly - * @see PostOnly - * @see GetPostOnly + * @see HttpGet + * @see HttpPost + * @see HttpGetOrPost * @since 2.3.18 */ public class HttpMethodInterceptor extends AbstractInterceptor { - public static final Class[] HTTP_METHOD_ANNOTATIONS = {AllowedHttpMethod.class, PostOnly.class, GetOnly.class, GetPostOnly.class}; + public static final Class[] HTTP_METHOD_ANNOTATIONS = {AllowedHttpMethod.class, HttpPost.class, HttpGet.class, HttpGetOrPost.class}; private static final Logger LOG = LoggerFactory.getLogger(HttpMethodInterceptor.class); @@ -93,14 +93,14 @@ public class HttpMethodInterceptor extends AbstractInterceptor { if (AnnotationUtils.isAnnotatedBy(element, AllowedHttpMethod.class)) { allowedMethods = Arrays.asList(element.getAnnotation(AllowedHttpMethod.class).value()); } - if (AnnotationUtils.isAnnotatedBy(element, GetOnly.class)) { - allowedMethods = Arrays.asList(element.getAnnotation(GetOnly.class).value()); + if (AnnotationUtils.isAnnotatedBy(element, HttpGet.class)) { + allowedMethods = Arrays.asList(element.getAnnotation(HttpGet.class).value()); } - if (AnnotationUtils.isAnnotatedBy(element, PostOnly.class)) { - allowedMethods = Arrays.asList(element.getAnnotation(PostOnly.class).value()); + if (AnnotationUtils.isAnnotatedBy(element, HttpPost.class)) { + allowedMethods = Arrays.asList(element.getAnnotation(HttpPost.class).value()); } - if (AnnotationUtils.isAnnotatedBy(element, GetPostOnly.class)) { - allowedMethods = Arrays.asList(element.getAnnotation(GetPostOnly.class).value()); + if (AnnotationUtils.isAnnotatedBy(element, HttpGetOrPost.class)) { + allowedMethods = Arrays.asList(element.getAnnotation(HttpGetOrPost.class).value()); } return Collections.unmodifiableList(allowedMethods); } diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/PostOnly.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpPost.java similarity index 94% rename from core/src/main/java/org/apache/struts2/interceptor/httpmethod/PostOnly.java rename to core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpPost.java index 0f3bcd537..7c9ff4a0e 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/PostOnly.java +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpPost.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) -public @interface PostOnly { +public @interface HttpPost { HttpMethod[] value() default { HttpMethod.POST }; diff --git a/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java b/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java index c67ec39c0..ba93d7df3 100644 --- a/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java +++ b/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java @@ -2,11 +2,11 @@ package org.apache.struts2; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.httpmethod.AllowedHttpMethod; -import org.apache.struts2.interceptor.httpmethod.GetOnly; -import org.apache.struts2.interceptor.httpmethod.GetPostOnly; +import org.apache.struts2.interceptor.httpmethod.HttpGet; +import org.apache.struts2.interceptor.httpmethod.HttpGetOrPost; import org.apache.struts2.interceptor.httpmethod.HttpMethod; import org.apache.struts2.interceptor.httpmethod.HttpMethodAware; -import org.apache.struts2.interceptor.httpmethod.PostOnly; +import org.apache.struts2.interceptor.httpmethod.HttpPost; import static org.apache.struts2.interceptor.httpmethod.HttpMethod.POST; @@ -22,17 +22,17 @@ public class HttpMethodsTestAction extends ActionSupport implements HttpMethodAw this.resultName = resultName; } - @GetOnly + @HttpGet public String onGetOnly() { return "onGetOnly"; } - @PostOnly + @HttpPost public String onPostOnly() { return "onPostOnly"; } - @GetPostOnly + @HttpGetOrPost public String onGetPostOnly() { return "onGetPostOnly"; }
