From 80ca73f521b9c70ebe9bfdd6b43fde09ff6b799e Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 30 Apr 2010 17:15:46 +0000 Subject: Enhancing processing of JAX-RS interfaces, and fixing typo on the annotation used for delete operations git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@939743 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/jaxrs/JAXRSJavaInterfaceProcessor.java | 40 ++++++++++------------ 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'sca-java-2.x/trunk/modules/interface-java-jaxrs/src') 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 ff3229771d..49fbb31a30 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 @@ -21,7 +21,6 @@ package org.apache.tuscany.sca.interfacedef.java.jaxrs; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import javax.ws.rs.DELETE; @@ -48,8 +47,8 @@ public class JAXRSJavaInterfaceProcessor implements JavaInterfaceVisitor { boolean hasJAXRSAnnotarions = false; - for (Iterator it = contract.getOperations().iterator(); it.hasNext();) { - final JavaOperation operation = (JavaOperation)it.next(); + for (Operation op : contract.getOperations()) { + final JavaOperation operation = (JavaOperation)op; final Method method = operation.getJavaMethod(); GET get = method.getAnnotation(GET.class); @@ -58,22 +57,13 @@ public class JAXRSJavaInterfaceProcessor implements JavaInterfaceVisitor { operation.getAttributes().put(GET.class, true); getOperations.add(operation); } - - if(! getOperations.isEmpty()) { - contract.getAttributes().put(GET.class, getOperations); - } - + PUT put = method.getAnnotation(PUT.class); if(put != null) { hasJAXRSAnnotarions = true; operation.getAttributes().put(PUT.class, true); putOperations.add(operation); } - - if(! putOperations.isEmpty()) { - contract.getAttributes().put(PUT.class, putOperations); - } - POST post = method.getAnnotation(POST.class); if(post != null) { @@ -81,10 +71,6 @@ public class JAXRSJavaInterfaceProcessor implements JavaInterfaceVisitor { operation.getAttributes().put(POST.class, true); postOperations.add(operation); } - - if(! postOperations.isEmpty()) { - contract.getAttributes().put(POST.class, postOperations); - } DELETE delete = method.getAnnotation(DELETE.class); if(delete != null) { @@ -92,12 +78,24 @@ public class JAXRSJavaInterfaceProcessor implements JavaInterfaceVisitor { operation.getAttributes().put(DELETE.class, true); deleteOperations.add(operation); } + } + + if(! getOperations.isEmpty()) { + contract.getAttributes().put(GET.class, getOperations); + } - if(! deleteOperations.isEmpty()) { - contract.getAttributes().put(GET.class, deleteOperations); - } - + if(! putOperations.isEmpty()) { + contract.getAttributes().put(PUT.class, putOperations); } + + if(! postOperations.isEmpty()) { + contract.getAttributes().put(POST.class, postOperations); + } + + if(! deleteOperations.isEmpty()) { + contract.getAttributes().put(DELETE.class, deleteOperations); + } + // Always set JAX-RS annotated interfaces as remotables if (hasJAXRSAnnotarions) { -- cgit v1.2.3