You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2023/01/22 10:25:11 UTC
[struts] 09/15: Renames basic annotation to better express its meaning
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 2bc0158dfb0108649128cc43885a1f6e93aa1236
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Sun Apr 20 22:35:01 2014 +0200
Renames basic annotation to better express its meaning
---
.../{AllowedMethod.java => AllowedHttpMethod.java} | 2 +-
.../interceptor/httpmethod/HttpMethodInterceptor.java | 14 +++++++-------
.../java/org/apache/struts2/HttpMethodsTestAction.java | 4 ++--
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedHttpMethod.java
similarity index 92%
rename from core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java
rename to core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedHttpMethod.java
index 435e60e9a..7438c457c 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedHttpMethod.java
@@ -13,7 +13,7 @@ import java.lang.annotation.Target;
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
-public @interface AllowedMethod {
+public @interface AllowedHttpMethod {
HttpMethod[] value() default {};
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 1a57af426..ac64050cc 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());
diff --git a/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java b/core/src/test/java/org/apache/struts2/HttpMethodsTestAction.java
index 79dd16e54..c67ec39c0 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;