Author: nthaker Date: Tue Aug 3 15:00:28 2010 New Revision: 981908 URL: http://svn.apache.org/viewvc?rev=981908&view=rev Log: AXIS2-4790
JAX-WS 2.2 update, Changes to support Implicit SEI restriction on exposing Static and Final Method as webservices. Added: axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImplTests.java Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MethodDescriptionComposite.java axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaMethodsToMDCConverter.java axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MethodDescriptionComposite.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MethodDescriptionComposite.java?rev=981908&r1=981907&r2=981908&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MethodDescriptionComposite.java (original) +++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MethodDescriptionComposite.java Tue Aug 3 15:00:28 2010 @@ -33,7 +33,9 @@ public class MethodDescriptionComposite private String returnType; //Methods return type private String[] exceptions; private String declaringClass; //the class/interface that actually declares this method - + private boolean staticModifier= false;//true if method is static + private boolean finalModifier = false; //true if method is final + boolean oneWayAnnotated; // boolean that indicates if an @XmlList annotation was found on the method private boolean isListType = false; @@ -333,6 +335,22 @@ public class MethodDescriptionComposite this.parentDBC = dbc; } + public boolean isStatic() { + return staticModifier; + } + + public void setStaticModifier(boolean staticModifier) { + this.staticModifier = staticModifier; + } + + public boolean isFinal() { + return finalModifier; + } + + public void setFinalModifier(boolean finalModifier) { + this.finalModifier = finalModifier; + } + public boolean compare(Object obj) { if (obj instanceof MethodDescriptionComposite) { MethodDescriptionComposite mdc = (MethodDescriptionComposite)obj; Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaMethodsToMDCConverter.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaMethodsToMDCConverter.java?rev=981908&r1=981907&r2=981908&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaMethodsToMDCConverter.java (original) +++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaMethodsToMDCConverter.java Tue Aug 3 15:00:28 2010 @@ -75,6 +75,8 @@ public class JavaMethodsToMDCConverter { mdc.setMethodName(method.getName()); setReturnType(mdc, method); setIsListType(mdc, method); + mdc.setStaticModifier(Modifier.isStatic(method.getModifiers())); + mdc.setFinalModifier(Modifier.isFinal(method.getModifiers())); mdc.setDeclaringClass(method.getDeclaringClass().getName()); attachHandlerChainAnnotation(mdc, method); attachOnewayAnnotation(mdc, method); Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java?rev=981908&r1=981907&r2=981908&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java (original) +++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java Tue Aug 3 15:00:28 2010 @@ -102,9 +102,6 @@ public class EndpointInterfaceDescriptio public static final javax.jws.soap.SOAPBinding.ParameterStyle SOAPBinding_ParameterStyle_DEFAULT = javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED; - private static String newRulesFlag = null; - - private static String newSunRulesFlag = null; /** * Add the operationDescription to the list of operations. Note that we can not create the @@ -252,7 +249,7 @@ public class EndpointInterfaceDescriptio OperationDescription operation = new OperationDescriptionImpl(mdc, this, axisOperation); - //In LegacyWebmethod case: + //1) if wsdl is defined then we should only expose operations that are in wsdl. //NOTE:If wsdl is defined AxisService will have all operations found in wsdl, //AxisServiceBuilder will do that part before metadata layer is invoked. @@ -811,30 +808,33 @@ public class EndpointInterfaceDescriptio private MethodRetriever getMethodRetriever () { MethodRetriever methodRetriever = null; - boolean newSunBehavior = false; - - //If the user has a setting for the property flag then that overrides and possible setting - //of the SUN flag. Assuming no - //property, we will still honor the setting of the SUN property. - - //REVIEW: We are making the assumption that the system property always overrides the manifest - // property. So, if both are set than the manifest property will be ignored - if (WSToolingUtils.hasValue(getNewRulesFlag())) { - if (newRulesFlag.equalsIgnoreCase("false")) { - if (log.isDebugEnabled()){ - log.debug("EndpointInterfaceDescriptionImpl: System or Manifest property USE_LEGACY_WEB_METHOD_RULES set to false" ); - } - newSunBehavior = isNewSunBehavior(MDQConstants.USE_LEGACY_WEB_METHOD_RULES); + //default behavior + boolean newSunBehavior = true; + //Lets make sure the default behavior is supported by packaged JDK. + //this check verifies JAX-WS2.2 tooling is supported. + newSunBehavior = isNewSunBehaviorSupported(); + + //The system property always overrides the manifest + //property. So, if both are set than the manifest property will be ignored + + String legacyWebmethod = readLegacyWebMethodFlag(); + if (WSToolingUtils.hasValue(legacyWebmethod) && legacyWebmethod.equalsIgnoreCase("true")) { + if (log.isDebugEnabled()){ + log.debug("EndpointInterfaceDescriptionImpl: System or Manifest property USE_LEGACY_WEB_METHOD_RULES set to true" ); } - } else if (WSToolingUtils.hasValue(getNewSunRulesFlag())) { - if (getNewSunRulesFlag().equalsIgnoreCase("false")) { + //LegacyWebmethod property set to true, use old JAX-WS tooling behavior. + newSunBehavior = false; + }else { + //If LegacyWebmehtod was not set check for sun property. + String newSunRulesFlag = getNewSunRulesFlag(); + if (WSToolingUtils.hasValue(newSunRulesFlag) && newSunRulesFlag.equalsIgnoreCase("true")) { if (log.isDebugEnabled()){ - log.debug("EndpointInterfaceDescriptionImpl: System property USE_LEGACY_WEB_METHOD_RULES_SUN set to false" ); + log.debug("EndpointInterfaceDescriptionImpl: System property USE_LEGACY_WEB_METHOD_RULES_SUN set to true" ); } - newSunBehavior = isNewSunBehavior(MDQConstants.USE_LEGACY_WEB_METHOD_RULES_SUN); + newSunBehavior = false;; } } - + //Now based on the outcome of LegacyWebmethod and sun property check, retrieve methods to expose. methodRetriever = newSunBehavior ? new PostRI216MethodRetrieverImpl(dbc, this) : new LegacyMethodRetrieverImpl(dbc, this); if(log.isDebugEnabled()) { @@ -899,15 +899,61 @@ public class EndpointInterfaceDescriptio return versionValid; } - - private String getNewRulesFlag () { + /** + * The user has indicated that they want to use the new Sun behavior (regardless) of which flag + * they were using. + * This method determines whether we have the proper JDK version for using the new SUN behavior for + * retrieving methods. We determine this by checking the version of WsGen. + * @param propertyToSet + * @return + */ + private boolean isNewSunBehaviorSupported() { + + if (log.isDebugEnabled()) { + log.debug("isNewSunBehavior: Validating that JDK version can be used"); + + } - if (newRulesFlag != null) { - return newRulesFlag; + boolean versionValid = false; + + try { + + String wsGenVersion = WSToolingUtils.getWsGenVersion(); + + versionValid = WSToolingUtils.isValidVersion(wsGenVersion); + + if (log.isDebugEnabled()) { + log.debug("isNewSunBehavior: versionValid is: " +versionValid); + } + + if (!versionValid) { + + if (log.isDebugEnabled()) { + log.debug("New Sun tooling behavior is not supported with this version of the JDK"); + } + } + + // We don't want to affect existing systems, if anything goes + // wrong just display + // a warning and default to old behavior + } catch (ClassNotFoundException e) { + if (log.isDebugEnabled()) { + log.debug(" Unable to determine WsGen version being used"); + } + } catch (IOException ioex) { + if (log.isDebugEnabled()) { + log.debug(" Unable to determine WsGen version being used"); + } } + + return versionValid; + } + private String readLegacyWebMethodFlag () { + + String legacyWebmethod= null; try { - newRulesFlag = (String) AccessController.doPrivileged( + legacyWebmethod = (String) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() { //System property takes precedence over manifest property. @@ -922,7 +968,7 @@ public class EndpointInterfaceDescriptio } } //System property not set, so let return the manifest property. - if(!WSToolingUtils.hasValue(newRulesFlag)){ + if(!WSToolingUtils.hasValue(legacyWebmethod)){ if (log.isDebugEnabled()){ log.debug("EndpointInterfaceDescriptionImpl: system property '"+MDQConstants.USE_LEGACY_WEB_METHOD_RULES + "' not set" ); } @@ -938,9 +984,9 @@ public class EndpointInterfaceDescriptio } }else{ if (log.isDebugEnabled()){ - log.debug("EndpointInterfaceDescriptionImpl: Manifest property '"+ MDQConstants.USE_MANIFEST_LEGACY_WEB_METHOD_RULES+ "' is set" ); + log.debug("EndpointInterfaceDescriptionImpl: Manifest property '"+ MDQConstants.USE_MANIFEST_LEGACY_WEB_METHOD_RULES+ "' is set to"+param ); } - newRulesFlag = param; + legacyWebmethod = param; } }else{ if (log.isDebugEnabled()){ @@ -953,14 +999,12 @@ public class EndpointInterfaceDescriptio log.debug("EndpointInterfaceDescriptionImpl: system property '"+MDQConstants.USE_LEGACY_WEB_METHOD_RULES + "' set" ); } } - return newRulesFlag; + return legacyWebmethod; } private static String getNewSunRulesFlag () { - if (newSunRulesFlag != null) { - return newSunRulesFlag; - } + String newSunRulesFlag = null; try { newSunRulesFlag = (String) AccessController.doPrivileged( @@ -975,7 +1019,16 @@ public class EndpointInterfaceDescriptio log.debug("Exception getting USE_LEGACY_WEB_METHOD_RULES_SUN system property: " +e.getException()); } } - + if(WSToolingUtils.hasValue(newSunRulesFlag)){ + if (log.isDebugEnabled()){ + log.debug("EndpointInterfaceDescriptionImpl: system property '"+MDQConstants.USE_LEGACY_WEB_METHOD_RULES_SUN + "' is set" ); + log.debug("MDQConstants.USE_LEGACY_WEB_METHOD_RULES_SUN ="+newSunRulesFlag); + } + }else{ + if (log.isDebugEnabled()){ + log.debug("EndpointInterfaceDescriptionImpl: system property '"+MDQConstants.USE_LEGACY_WEB_METHOD_RULES_SUN + "' is not set" ); + } + } return newSunRulesFlag; } Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java?rev=981908&r1=981907&r2=981908&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java (original) +++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java Tue Aug 3 15:00:28 2010 @@ -155,8 +155,15 @@ public class PostRI216MethodRetrieverImp iter = dbc.getMethodDescriptionsList().iterator(); while (iter.hasNext()) { MethodDescriptionComposite mdc = iter.next(); - - if (!DescriptionUtils.isExcludeTrue(mdc)) { + //flag to check if the method can be exposed as webservice. + boolean isWebservice = !DescriptionUtils.isExcludeTrue(mdc) && !mdc.isStatic() && !mdc.isFinal(); + if(!isWebservice){ + if(log.isDebugEnabled()){ + log.debug(mdc.getMethodName() + " has static or final modifiers in method signature or has @Webmethod(exclude=true) set"); + log.debug(mdc.getMethodName() + " cannot be exposed as a webservice"); + } + } + if (isWebservice) { mdc.setDeclaringClass(dbc.getClassName()); retrieveList.add(mdc); } Modified: axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java?rev=981908&r1=981907&r2=981908&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java (original) +++ axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java Tue Aug 3 15:00:28 2010 @@ -507,7 +507,12 @@ public class AnnotationServiceImplDescri // Test results from method with no annotation OperationDescription[] operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method1"); - assertNull(operationDescs); + + if(isLegacyBehavior()){ + assertNull(operationDescs); + }else{ + assertNotNull(operationDescs); + } OperationDescription operationDesc = testEndpointInterfaceDesc.getOperationForJavaMethod("method2")[0]; @@ -556,15 +561,8 @@ public class AnnotationServiceImplDescri } public void testWebMethodOldBehavior3() { - try { - - if (WSToolingUtils.isValidVersion(WSToolingUtils.getWsGenVersion())) { - System.setProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES, "true"); - //Try new behavior - } - } catch (ClassNotFoundException e) { - } catch (IOException ioex) { - } + + System.setProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES, "true"); EndpointInterfaceDescriptionImpl testEndpointInterfaceDesc = (EndpointInterfaceDescriptionImpl)getEndpointInterfaceDesc(WebMethodLegacyCheck.class); @@ -579,20 +577,22 @@ public class AnnotationServiceImplDescri } } - //This test verifies that the old WebMethod behavior has not changed if the system flag is - //not set, slightly redundant but still a safety check - public void testWebMethodOldBehavior1() { + //This test verifies default webMethod behavior + public void testWebMethodDefaultBehavior() { try { //If the version is valid then try the new behavior - if (WSToolingUtils.isValidVersion(WSToolingUtils.getWsGenVersion())) { - System.setProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES, "false"); - //Try new behavior - } + if (!WSToolingUtils.isValidVersion(WSToolingUtils.getWsGenVersion())) { + //No point in testing this case if new behavior is not supported. + //default is the new tooling behavior. + return; + + } } catch (ClassNotFoundException e) { } catch (IOException ioex) { } - + //default behavior + System.setProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES, ""); EndpointInterfaceDescription testEndpointInterfaceDesc = getEndpointInterfaceDesc(WebMethodTestImpl.class); @@ -602,7 +602,7 @@ public class AnnotationServiceImplDescri OperationDescription[] operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method1"); - assertNull(operationDescs); + assertNotNull(operationDescs); OperationDescription operationDesc = testEndpointInterfaceDesc.getOperationForJavaMethod("method2")[0]; @@ -634,27 +634,13 @@ public class AnnotationServiceImplDescri } - //This test verifies that, if we do have the appropriate JDK installed but we do not set - //the System property then the old behavior remains unchanged - public void testWebMethodOldBehavior2() { - - try { - //If the version is valid then try the new behavior - if (WSToolingUtils.isValidVersion(WSToolingUtils.getWsGenVersion())) { - //Set the property to empty just to make sure we are not trying the new behavior - //In order for the new behavior to work, this must be set explicitly to 'false' - System.setProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES, ""); - //Try new behavior - } else { - //At this point, just return as it would be redundant to continue...already tested - // in testWebMethodOldBehavior1 - return; - } - } catch (ClassNotFoundException e) { - } catch (IOException ioex) { - } + //This test verifies old webmethod behavior + public void testWebMethodOldBehavior() { + //Weather new tooling is supported or not, Legacy behavior should + //always work if LegacyWebMethod property is set. + System.setProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES, "true"); EndpointInterfaceDescription testEndpointInterfaceDesc = getEndpointInterfaceDesc(WebMethodTestImpl.class); @@ -662,7 +648,7 @@ public class AnnotationServiceImplDescri // Test results from method with no annotation OperationDescription[] operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method1"); - + //check legacy behavior assertNull(operationDescs); OperationDescription operationDesc = @@ -702,7 +688,7 @@ public class AnnotationServiceImplDescri // and // in this method, by forcing "validVersion" to true. Realize that by doing this other tests // will fail...So this should be considered temporary for testing this method - public void testWebMethodNewBehavior1() { + public void testWebMethodNewBehavior() { try { boolean validVersion = WSToolingUtils.isValidVersion(WSToolingUtils.getWsGenVersion()); @@ -713,13 +699,13 @@ public class AnnotationServiceImplDescri System.setProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES, "false"); } else { //At this point, just return since the test would be guaranteed to fail as we - //testing new rules + //testing new tooling rules and it seems new tooling is not supported here. return; } } catch (ClassNotFoundException e) { } catch (IOException ioex) { } - + System.setProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES, "true"); EndpointInterfaceDescription testEndpointInterfaceDesc = getEndpointInterfaceDesc(WebMethodTestImpl1.class); @@ -756,7 +742,11 @@ public class AnnotationServiceImplDescri OperationDescription[] operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method0"); - assertNull(operationDescs); + if(isLegacyBehavior()){ + assertNull(operationDescs); + }else{ + assertNotNull(operationDescs); + } OperationDescription operationDesc = testEndpointInterfaceDesc.getOperationForJavaMethod("method1")[0]; @@ -835,7 +825,11 @@ public class AnnotationServiceImplDescri // DOCUMENT / LITERAL / BARE methods operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method0_bare"); - assertNull(operationDescs); + if(isLegacyBehavior()){ + assertNull(operationDescs); + }else{ + assertNotNull(operationDescs); + } operationDesc = testEndpointInterfaceDesc.getOperationForJavaMethod("method1_bare")[0]; assertNotNull(operationDesc); @@ -915,6 +909,7 @@ public class AnnotationServiceImplDescri } public void testWebParamWrapped() { + EndpointInterfaceDescription testEndpointInterfaceDesc = getEndpointInterfaceDesc(WebParamTestImpl.class); @@ -923,11 +918,20 @@ public class AnnotationServiceImplDescri // method0 OperationDescription[] operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method0"); - assertNull(operationDescs); + if(isLegacyBehavior()){ + assertNull(operationDescs); + }else{ + assertNotNull(operationDescs); + } // method00 operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method00"); - assertNull(operationDescs); + if(isLegacyBehavior()){ + assertNull(operationDescs); + }else{ + assertNotNull(operationDescs); + } + // method1 OperationDescription operationDesc = @@ -1228,12 +1232,19 @@ public class AnnotationServiceImplDescri // DOCUMENT / LITERAL / BARE methods OperationDescription[] operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method0_bare"); - assertNull(operationDescs); + if(isLegacyBehavior()){ + assertNull(operationDescs); + }else{ + assertNotNull(operationDescs); + } // method00 operationDescs = testEndpointInterfaceDesc.getOperationForJavaMethod("method00_bare"); - assertNull(operationDescs); - + if(isLegacyBehavior()){ + assertNull(operationDescs); + }else{ + assertNotNull(operationDescs); + } // method1 OperationDescription operationDesc = testEndpointInterfaceDesc.getOperationForJavaMethod("method1_bare")[0]; @@ -1374,6 +1385,20 @@ public class AnnotationServiceImplDescri assertEquals("jaxws22MessageName", faultDescription.getMessageName()); } + + private boolean isLegacyBehavior(){ + + boolean legacyBehavior=false; + try { + //If the version is valid then try the new behavior + if (!WSToolingUtils.isValidVersion(WSToolingUtils.getWsGenVersion())) { + legacyBehavior=true; + } + } catch (ClassNotFoundException e) { + } catch (IOException ioex) { + } + return legacyBehavior; + } /* * Method to return the endpoint interface description for a given implementation class. Modified: axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java?rev=981908&r1=981907&r2=981908&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java (original) +++ axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java Tue Aug 3 15:00:28 2010 @@ -70,7 +70,7 @@ public class ReflectiveConverterTests ex List<MethodDescriptionComposite> mdcList = sortList(implDBC.getMethodDescriptionsList()); sortList(mdcList); assertNotNull(mdcList); - assertEquals(mdcList.size(), 3); + assertEquals(mdcList.size(), 5); MethodDescriptionComposite mdc = mdcList.get(0); assertNotNull(mdc); assertEquals("<init>", mdc.getMethodName()); @@ -82,13 +82,20 @@ public class ReflectiveConverterTests ex assertNotNull(mdc); assertEquals("invoke2", mdc.getMethodName()); assertEquals("int", mdc.getReturnType()); + mdc = mdcList.get(3); + assertNotNull(mdc); + assertTrue("invoke3 is static operation and should return true for static check", mdc.isStatic()); + mdc = mdcList.get(4); + assertNotNull(mdc); + assertTrue("invoke4 is final operation and should return true for static check", mdc.isFinal()); + } public static void testImplParams() { assertNotNull(implDBC); List<MethodDescriptionComposite> mdcList = sortList(implDBC.getMethodDescriptionsList()); assertNotNull(mdcList); - assertEquals(mdcList.size(), 3); + assertEquals(mdcList.size(), 5); MethodDescriptionComposite mdc = mdcList.get(0); assertNotNull(mdc); List<ParameterDescriptionComposite> pdcList = mdc.getParameterDescriptionCompositeList(); @@ -240,6 +247,14 @@ class SimpleServiceImpl { public int invoke2(int num1, int num2) { return num1 + num2; } + + public static String invoke3(){ + return "static"; + } + + public final String invoke4(){ + return "final"; + } } @WebService(name = "SimpleServicePort") Added: axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImplTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImplTests.java?rev=981908&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImplTests.java (added) +++ axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImplTests.java Tue Aug 3 15:00:28 2010 @@ -0,0 +1,72 @@ +package org.apache.axis2.jaxws.description.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import javax.jws.WebService; +import javax.xml.namespace.QName; + +import org.apache.axis2.jaxws.description.DescriptionFactory; +import org.apache.axis2.jaxws.description.ServiceDescription; +import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite; +import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite; +import org.apache.axis2.jaxws.description.builder.converter.JavaClassToDBCConverter; + +import junit.framework.TestCase; + +public class PostRI216MethodRetrieverImplTests extends TestCase { + + public void testMethodRetriever(){ + //Create DBC for implicit SEI + JavaClassToDBCConverter converter = new JavaClassToDBCConverter(EchoMessageService.class); + HashMap<String, DescriptionBuilderComposite> dbcMap = converter.produceDBC(); + assertNotNull(dbcMap); + DescriptionBuilderComposite dbc = dbcMap.get(EchoMessageService.class.getName()); + //create EndpointDescription + List<ServiceDescription> serviceDescList = + DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap); + ServiceDescription sd = serviceDescList.get(0); + EndpointInterfaceDescriptionImpl eid = new EndpointInterfaceDescriptionImpl(dbc, new EndpointDescriptionImpl(null, new QName("http://nonanonymous.complextype.test.org","EchoMessagePort"), (ServiceDescriptionImpl)sd)); + //Lets make sure correct MDC's where created. + List<MethodDescriptionComposite> mdcList = dbc.getMethodDescriptionsList(); + assertTrue("Expecting 3 methods in MDC found"+mdcList.size(), mdcList.size()==4); + + //Lets make sure static and final modifiers are set on MDC as expected. + for(MethodDescriptionComposite mdc:mdcList){ + if(mdc.getMethodName().contains("staticMethod")){ + assertTrue(mdc.isStatic()); + } + if(mdc.getMethodName().contains("finalMethod")){ + assertTrue(mdc.isFinal()); + } + } + + //Let make sure static and final methods are not exposed as webservice. + PostRI216MethodRetrieverImpl mr = new PostRI216MethodRetrieverImpl(dbc, eid); + Iterator<MethodDescriptionComposite> iter =mr.retrieveMethods(); + List<MethodDescriptionComposite> list = new ArrayList<MethodDescriptionComposite>(); + while(iter.hasNext()){ + list.add(iter.next()); + } + assertEquals(list.size(), 2); + MethodDescriptionComposite mdc = list.get(0); + assertEquals("echoMessage", mdc.getMethodName()); + mdc = list.get(1); + assertEquals("<init>", mdc.getMethodName()); + } + + @WebService(serviceName = "EchoMessageService", portName = "EchoMessagePort", targetNamespace = "http://nonanonymous.complextype.test.org", wsdlLocation = "") + public static class EchoMessageService { + public String echoMessage(String arg) { + return arg; + } + public static String staticMethod(String arg){ + return arg; + } + public final String finalMethod(String arg){ + return arg; + } + } +}