diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-16 17:49:20 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-16 17:49:20 +0000 |
commit | 1725e763b9a7fdd4c862167accca060180c9dde1 (patch) | |
tree | dd70249c6d23593e8450b548aa4028427408ef2a /sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org | |
parent | 63cc1a8c2eb2116ce449456bde19ff6e282163df (diff) |
Align the JAX-RS resource class/method checks with the spec
Allow the binding.rest client to issue RPC over GET calls
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@964880 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org')
-rw-r--r-- | sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java index 71683ba2c4..83f88c98cb 100644 --- a/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.interfacedef.java.jaxrs; +import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; @@ -54,22 +55,26 @@ public class JAXRSJavaInterfaceProcessor implements JavaInterfaceVisitor { Method method = operation.getJavaMethod(); String methodName = null; - HttpMethod httpMethod = method.getAnnotation(HttpMethod.class); - if (httpMethod != null) { - methodName = httpMethod.value(); - } - if (method.isAnnotationPresent(GET.class)) { - methodName = HttpMethod.GET; - } else if (method.isAnnotationPresent(POST.class)) { - methodName = HttpMethod.POST; - } else if (method.isAnnotationPresent(PUT.class)) { - methodName = HttpMethod.PUT; - } else if (method.isAnnotationPresent(DELETE.class)) { - methodName = HttpMethod.DELETE; - } else if (method.isAnnotationPresent(HEAD.class)) { - methodName = HttpMethod.HEAD; - } else if (method.isAnnotationPresent(OPTIONS.class)) { - methodName = HttpMethod.OPTIONS; + + /** + * A request method designator is a runtime annotation that is annotated with the @HttpMethod annotation. + * JAX-RS defines a set of request method designators for the common HTTP methods: @GET, @POST, @PUT, + * @DELETE, @HEAD. Users may define their own custom request method designators including alternate + * designators for the common HTTP methods. + */ + for (Annotation a : method.getAnnotations()) { + Class<?> annotationType = a.annotationType(); + if (annotationType == HttpMethod.class) { + methodName = ((HttpMethod)a).value(); + break; + } + // Http method related annotations such as @GET, @POST will have itself annotated with + // @HttpMethod + HttpMethod m = a.annotationType().getAnnotation(HttpMethod.class); + if (m != null) { + methodName = m.value(); + break; + } } boolean jaxrs = false; |