From 400454850c6a9fc060e75c6cd2b189b3273533b4 Mon Sep 17 00:00:00 2001 From: bdaniel Date: Mon, 9 Aug 2010 20:07:27 +0000 Subject: JCA 11010 Add SOAP intent to the interface if any parameter on any method in the interface is annotated with @WebParam with header=true git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@983802 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/impl/PolicyJavaInterfaceVisitor.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'sca-java-2.x/trunk/modules') diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java index f6daac64e4..34ea4db3e9 100644 --- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java +++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java @@ -25,6 +25,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import javax.jws.WebParam; import javax.jws.WebResult; import javax.jws.soap.SOAPBinding; import javax.xml.namespace.QName; @@ -158,7 +159,8 @@ public class PolicyJavaInterfaceVisitor implements JavaInterfaceVisitor { } } - public void readWebResult(Method m, Class clazz, List requiredIntents) { + public void readWebServicesAnnotations(Method m, Class clazz, List requiredIntents) { + WebResult webResultAnnotation = m.getAnnotation(WebResult.class); if (webResultAnnotation != null) { if (webResultAnnotation.header()) { @@ -166,8 +168,26 @@ public class PolicyJavaInterfaceVisitor implements JavaInterfaceVisitor { Intent intent = policyFactory.createIntent(); intent.setName(Constants.SOAP_INTENT); requiredIntents.add(intent); + return; } } + + Annotation[][] parameterAnnotations = m.getParameterAnnotations(); + for ( int i=0; i < parameterAnnotations.length; i++ ) { + for ( int j=0; j < parameterAnnotations[i].length; j++) { + if ( parameterAnnotations[i][j] instanceof WebParam ) { + WebParam webParam = (WebParam)parameterAnnotations[i][j]; + if ( webParam.header() ) { + // Add SOAP intent + Intent intent = policyFactory.createIntent(); + intent.setName(Constants.SOAP_INTENT); + requiredIntents.add(intent); + return; + } + } + } + } + } public void visitInterface(JavaInterface javaInterface) throws InvalidInterfaceException { @@ -183,7 +203,7 @@ public class PolicyJavaInterfaceVisitor implements JavaInterfaceVisitor { readIntents(method.getAnnotation(Requires.class), op.getRequiredIntents()); readSpecificIntents(method.getAnnotations(), op.getRequiredIntents()); readPolicySets(method.getAnnotation(PolicySets.class), op.getPolicySets()); - readWebResult(method, javaInterface.getJavaClass(), javaInterface.getRequiredIntents()); + readWebServicesAnnotations(method, javaInterface.getJavaClass(), javaInterface.getRequiredIntents()); } } } -- cgit v1.2.3