Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 86209 invoked from network); 21 Nov 2006 19:38:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Nov 2006 19:38:00 -0000 Received: (qmail 76442 invoked by uid 500); 21 Nov 2006 19:38:09 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 76355 invoked by uid 500); 21 Nov 2006 19:38:08 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 76344 invoked by uid 500); 21 Nov 2006 19:38:08 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 76341 invoked by uid 99); 21 Nov 2006 19:38:08 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Nov 2006 11:38:08 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Nov 2006 11:37:57 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id B29621A9846; Tue, 21 Nov 2006 11:37:23 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r477841 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/description/impl/ test/org/apache/axis2/jaxws/description/ test/org/apache/axis2/jaxws/description/jaxws/ test/org/apache/axis2/jaxws/framework/ Date: Tue, 21 Nov 2006 19:37:23 -0000 To: axis2-cvs@ws.apache.org From: barrettj@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061121193723.B29621A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: barrettj Date: Tue Nov 21 11:37:22 2006 New Revision: 477841 URL: http://svn.apache.org/viewvc?view=rev&rev=477841 Log: Add logic to handle a possible jaxws subpackage under the SEI package for generated request and response wrapper artifacts. Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1.java webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1Response.java Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java?view=diff&rev=477841&r1=477840&r2=477841 ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java Tue Nov 21 11:37:22 2006 @@ -244,4 +244,10 @@ } return protocol + "://" + sb.toString() + "/"; } + + static Class loadClass(String className)throws ClassNotFoundException { + // TODO J2W AccessController Needed + // Don't make this public, its a security exposure + return Class.forName(className, true, Thread.currentThread().getContextClassLoader()); + } } Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java?view=diff&rev=477841&r1=477840&r2=477841 ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java Tue Nov 21 11:37:22 2006 @@ -610,6 +610,7 @@ String className = DescriptionUtils.javaMethodtoClassName(seiMethod.getName()); requestWrapperClassName = packageName + "." + className; } + requestWrapperClassName = determineActualAritfactPackage(requestWrapperClassName); } } return requestWrapperClassName; @@ -708,10 +709,11 @@ Class clazz = seiMethod.getDeclaringClass(); String packageName = clazz.getPackage().getName(); String className = DescriptionUtils.javaMethodtoClassName(seiMethod.getName()); - responseWrapperClassName = packageName + "." + className; + responseWrapperClassName = packageName + "." + className + "Response"; } else { - responseWrapperClassName = methodComposite.getDeclaringClass(); + responseWrapperClassName = methodComposite.getDeclaringClass() + "Response"; } + responseWrapperClassName = determineActualAritfactPackage(responseWrapperClassName); } } return responseWrapperClassName; @@ -1083,4 +1085,58 @@ else return false; } + + /** + * Determine the actual packager name for the generated artifacts by trying to load the class from one of two + * packages. This is necessary because the RI implementations of WSGen and WSImport generate the artifacts + * in different packages: + * - WSImport generates the artifacts in the same package as the SEI + * - WSGen generates the artifacts in a "jaxws" sub package under the SEI package. + * Note that from reading the JAX-WS spec, it seems that WSGen is doing that correctly; See + * the conformance requirement in JAX-WS 2.0 Spec Section 3.6.2.1 Document Wrapped on page 36: + * Conformance (Default wrapper bean package): In the absence of customizations, the wrapper beans package + * MUST be a generated jaxws subpackage of the SEI package. + * ^^^^^^^^^^^^^^^^ + * @param requestWrapperClassName + * @return + */ + private static final String JAXWS_SUBPACKAGE = "jaxws"; + private static String determineActualAritfactPackage(String wrapperClassName) { + String returnWrapperClassName = null; + + // Try to load the class that was passed in + try { + DescriptionUtils.loadClass(wrapperClassName); + returnWrapperClassName = wrapperClassName; + } + catch (ClassNotFoundException e) { + // Couldn't load the class; we'll try another one below. + } + + // If the original class couldn't be loaded, try adding ".jaxws." to the package + if (returnWrapperClassName == null) { + String originalPackage = DescriptionUtils.getJavaPackageName(wrapperClassName); + if (originalPackage != null) { + String alternatePackage = originalPackage + "." + JAXWS_SUBPACKAGE; + String className = DescriptionUtils.getSimpleJavaClassName(wrapperClassName); + String alternateWrapperClass = alternatePackage + "." + className; + try { + DescriptionUtils.loadClass(alternateWrapperClass); + returnWrapperClassName = alternateWrapperClass; + } + catch (ClassNotFoundException e) { + // Couldn't load the class + } + } + } + + if (returnWrapperClassName == null){ + // Couldn't load either class, so stick with the original wrapper class name + // REVIEW: Is this correct behavior? Note that some of the annotation unit tests don't have the actual + // classes available, and so will fail if this is changed. + returnWrapperClassName = wrapperClassName; + } + return returnWrapperClassName; + } + } Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java?view=diff&rev=477841&r1=477840&r2=477841 ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java Tue Nov 21 11:37:22 2006 @@ -376,7 +376,7 @@ assertEquals("http://description.jaxws.axis2.apache.org/", operationDesc.getRequestWrapperTargetNamespace()); assertEquals("http://description.jaxws.axis2.apache.org/", operationDesc.getResponseWrapperTargetNamespace()); assertEquals("org.apache.axis2.jaxws.description.WrappedParams", operationDesc.getRequestWrapperClassName()); - assertEquals("org.apache.axis2.jaxws.description.WrappedParams", operationDesc.getResponseWrapperClassName()); + assertEquals("org.apache.axis2.jaxws.description.WrappedParamsResponse", operationDesc.getResponseWrapperClassName()); // Test WebResult annotation defaults assertNull(((OperationDescriptionJava) operationDesc).getAnnoWebResult()); assertFalse(((OperationDescriptionJava) operationDesc).isWebResultAnnotationSpecified()); @@ -412,7 +412,7 @@ assertEquals("http://description.jaxws.axis2.apache.org/", operationDesc.getRequestWrapperTargetNamespace()); assertEquals("http://description.jaxws.axis2.apache.org/", operationDesc.getResponseWrapperTargetNamespace()); assertEquals("org.apache.axis2.jaxws.description.WrappedParams", operationDesc.getRequestWrapperClassName()); - assertEquals("org.apache.axis2.jaxws.description.WrappedParams", operationDesc.getResponseWrapperClassName()); + assertEquals("org.apache.axis2.jaxws.description.WrappedParamsResponse", operationDesc.getResponseWrapperClassName()); operationDesc = testEndpointInterfaceDesc.getOperationForJavaMethod("bareParams")[0]; assertNotNull(operationDesc); @@ -441,7 +441,7 @@ assertEquals("http://a.b.c.method2ReqTNS", operationDesc.getRequestWrapperTargetNamespace()); assertEquals("http://a.b.c.method2RspTNS", operationDesc.getResponseWrapperTargetNamespace()); assertEquals("org.apache.axis2.jaxws.description.method2ReqWrapper", operationDesc.getRequestWrapperClassName()); - assertEquals("org.apache.axis2.jaxws.description.Method2", operationDesc.getResponseWrapperClassName()); + assertEquals("org.apache.axis2.jaxws.description.Method2Response", operationDesc.getResponseWrapperClassName()); } public void testWebMethod() { Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java?view=auto&rev=477841 ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java (added) +++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java Tue Nov 21 11:37:22 2006 @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.axis2.jaxws.description; + +import javax.jws.WebService; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +import junit.framework.TestCase; + +/** + * Tests the request and response wrappers based on the different values used by + * WSGen and WSImport; WSGen generates artifacts in the "jaxws" package below the + * SEI package (which seems to be correct per JAX-WS 2.0 Spec Section 3.6.2.1) while + * WSImport generates them in the same package of the SEI. + */ +public class WrapperPackageTests extends TestCase { + + public void testSEIPackageWrapper() { + EndpointInterfaceDescription eiDesc = getEndpointInterfaceDesc(SEIPackageWrapper.class); + OperationDescription opDesc = eiDesc.getOperation("method1"); + String requestWrapperClass = opDesc.getRequestWrapperClassName(); + assertEquals("org.apache.axis2.jaxws.description.Method1", requestWrapperClass); + String responseWrapperClass = opDesc.getResponseWrapperClassName(); + assertEquals("org.apache.axis2.jaxws.description.Method1Response", responseWrapperClass); + + } + + public void testSEISubPackageWrapper() { + EndpointInterfaceDescription eiDesc = getEndpointInterfaceDesc(SEISubPackageWrapper.class); + OperationDescription opDesc = eiDesc.getOperation("subPackageMethod1"); + String requestWrapperClass = opDesc.getRequestWrapperClassName(); + assertEquals("org.apache.axis2.jaxws.description.jaxws.SubPackageMethod1", requestWrapperClass); + String responseWrapperClass = opDesc.getResponseWrapperClassName(); + assertEquals("org.apache.axis2.jaxws.description.jaxws.SubPackageMethod1Response", responseWrapperClass); + + } + + /* + * Method to return the endpoint interface description for a given implementation class. + */ + private EndpointInterfaceDescription getEndpointInterfaceDesc(Class implementationClass) { + // Use the description factory directly; this will be done within the JAX-WS runtime + ServiceDescription serviceDesc = + DescriptionFactory.createServiceDescriptionFromServiceImpl(implementationClass, null); + assertNotNull(serviceDesc); + + EndpointDescription[] endpointDesc = serviceDesc.getEndpointDescriptions(); + assertNotNull(endpointDesc); + assertEquals(1, endpointDesc.length); + + // TODO: How will the JAX-WS dispatcher get the appropriate port (i.e. endpoint)? Currently assumes [0] + EndpointDescription testEndpointDesc = endpointDesc[0]; + EndpointInterfaceDescription testEndpointInterfaceDesc = testEndpointDesc.getEndpointInterfaceDescription(); + assertNotNull(testEndpointInterfaceDesc); + + return testEndpointInterfaceDesc; + } +} + +@WebService() +class SEIPackageWrapper { + @RequestWrapper() + @ResponseWrapper() + public String method1(String string) { + return string; + } +} + +class Method1 { + +} + +class Method1Response { + +} + +@WebService() +class SEISubPackageWrapper { + @RequestWrapper() + @ResponseWrapper() + public String subPackageMethod1(String string) { + return string; + } +} \ No newline at end of file Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1.java?view=auto&rev=477841 ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1.java (added) +++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1.java Tue Nov 21 11:37:22 2006 @@ -0,0 +1,9 @@ +package org.apache.axis2.jaxws.description.jaxws; + +/** + * Used by WrappedPackageTests + * + */ +public class SubPackageMethod1 { + +} Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1Response.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1Response.java?view=auto&rev=477841 ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1Response.java (added) +++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/jaxws/SubPackageMethod1Response.java Tue Nov 21 11:37:22 2006 @@ -0,0 +1,9 @@ +package org.apache.axis2.jaxws.description.jaxws; + +/** + * Used by WrappedPackageTests + * + */ +public class SubPackageMethod1Response { + +} Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=477841&r1=477840&r2=477841 ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Tue Nov 21 11:37:22 2006 @@ -33,6 +33,7 @@ import org.apache.axis2.jaxws.description.ValidateWSDLTests; import org.apache.axis2.jaxws.description.WSDLDescriptionTests; import org.apache.axis2.jaxws.description.WSDLTests; +import org.apache.axis2.jaxws.description.WrapperPackageTests; import org.apache.axis2.jaxws.description.builder.DescriptionBuilderTests; import org.apache.axis2.jaxws.description.impl.ServiceDescriptionTests; import org.apache.axis2.jaxws.dispatch.SOAP12Dispatch; @@ -108,6 +109,7 @@ suite.addTestSuite(PartialWSDLTests.class); suite.addTestSuite(ValidateWSDLTests.class); suite.addTestSuite(GetDescFromBindingProvider.class); + suite.addTestSuite(WrapperPackageTests.class); suite.addTestSuite(HandlerChainProcessorTests.class); suite.addTestSuite(JaxwsMessageBundleTests.class); --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org