Renames basic annotation to better express its meaning
Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8d35e613 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8d35e613 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8d35e613 Branch: refs/heads/feature/http-interceptor Commit: 8d35e613c1e375f18d83b5ac962a716bfda680db Parents: f888e67 Author: Lukasz Lenart <[email protected]> Authored: Sun Apr 20 22:35:01 2014 +0200 Committer: Lukasz Lenart <[email protected]> Committed: Sun Apr 20 22:35:01 2014 +0200 ---------------------------------------------------------------------- .../httpmethod/AllowedHttpMethod.java | 20 ++++++++++++++++++++ .../interceptor/httpmethod/AllowedMethod.java | 20 -------------------- .../httpmethod/HttpMethodInterceptor.java | 14 +++++++------- .../apache/struts2/HttpMethodsTestAction.java | 4 ++-- 4 files changed, 29 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/8d35e613/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedHttpMethod.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedHttpMethod.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedHttpMethod.java new file mode 100644 index 0000000..7438c45 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedHttpMethod.java @@ -0,0 +1,20 @@ +package org.apache.struts2.interceptor.httpmethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Use this annotation to limit with what http method action or action's method can be called + * + * @see HttpMethodInterceptor + * @since 2.3.18 + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface AllowedHttpMethod { + + HttpMethod[] value() default {}; + +} http://git-wip-us.apache.org/repos/asf/struts/blob/8d35e613/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java deleted file mode 100644 index 435e60e..0000000 --- a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.apache.struts2.interceptor.httpmethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Use this annotation to limit with what http method action or action's method can be called - * - * @see HttpMethodInterceptor - * @since 2.3.18 - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface AllowedMethod { - - HttpMethod[] value() default {}; - -} http://git-wip-us.apache.org/repos/asf/struts/blob/8d35e613/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpMethodInterceptor.java ---------------------------------------------------------------------- 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 1a57af4..ac64050 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 @@ -21,13 +21,13 @@ import java.util.List; * and {@link HttpMethodAware#getBadRequestResultName()} returns non-null result name, * thus value will be used instead. * <p/> - * To limit allowed http methods, annotate action class with {@link AllowedMethod} and specify + * 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} * * @see HttpMethodAware * @see HttpMethod - * @see AllowedMethod + * @see AllowedHttpMethod * @see GetOnly * @see PostOnly * @see GetPostOnly @@ -35,7 +35,7 @@ import java.util.List; */ public class HttpMethodInterceptor extends AbstractInterceptor { - public static final Class[] HTTP_METHOD_ANNOTATIONS = {AllowedMethod.class, PostOnly.class, GetOnly.class, GetPostOnly.class}; + public static final Class[] HTTP_METHOD_ANNOTATIONS = {AllowedHttpMethod.class, PostOnly.class, GetOnly.class, GetPostOnly.class}; private static final Logger LOG = LoggerFactory.getLogger(HttpMethodInterceptor.class); @@ -57,14 +57,14 @@ public class HttpMethodInterceptor extends AbstractInterceptor { if (AnnotationUtils.isAnnotatedBy(method, HTTP_METHOD_ANNOTATIONS)) { if (LOG.isDebugEnabled()) { LOG.debug("Action's method #0 annotated with #1, checking if request #2 meets allowed methods!", - invocation.getProxy().getMethod(), AllowedMethod.class.getSimpleName(), request.getMethod()); + invocation.getProxy().getMethod(), AllowedHttpMethod.class.getSimpleName(), request.getMethod()); } return doIntercept(invocation, method); } } else if (AnnotationUtils.isAnnotatedBy(action.getClass(), HTTP_METHOD_ANNOTATIONS)) { if (LOG.isDebugEnabled()) { LOG.debug("Action #0 annotated with #1, checking if request #2 meets allowed methods!", - action, AllowedMethod.class.getSimpleName(), request.getMethod()); + action, AllowedHttpMethod.class.getSimpleName(), request.getMethod()); } return doIntercept(invocation, action.getClass()); } @@ -90,8 +90,8 @@ public class HttpMethodInterceptor extends AbstractInterceptor { protected List<HttpMethod> readAllowedMethods(AnnotatedElement element) { List<HttpMethod> allowedMethods = Collections.emptyList(); - if (AnnotationUtils.isAnnotatedBy(element, AllowedMethod.class)) { - allowedMethods = Arrays.asList(element.getAnnotation(AllowedMethod.class).value()); + 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()); http://git-wip-us.apache.org/repos/asf/struts/blob/8d35e613/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java b/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java index 79dd16e..c67ec39 100644 --- a/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java +++ b/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java @@ -1,7 +1,7 @@ package org.apache.struts2; import com.opensymphony.xwork2.ActionSupport; -import org.apache.struts2.interceptor.httpmethod.AllowedMethod; +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.HttpMethod; @@ -10,7 +10,7 @@ import org.apache.struts2.interceptor.httpmethod.PostOnly; import static org.apache.struts2.interceptor.httpmethod.HttpMethod.POST; -@AllowedMethod(POST) +@AllowedHttpMethod(POST) public class HttpMethodsTestAction extends ActionSupport implements HttpMethodAware { private String resultName = null;
