Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 8143 invoked from network); 8 Dec 2008 21:05:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Dec 2008 21:05:14 -0000 Received: (qmail 34732 invoked by uid 500); 8 Dec 2008 21:05:27 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 34682 invoked by uid 500); 8 Dec 2008 21:05:27 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 34670 invoked by uid 99); 8 Dec 2008 21:05:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Dec 2008 13:05:27 -0800 X-ASF-Spam-Status: No, hits=-1998.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Dec 2008 21:03:53 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 145A3238889E; Mon, 8 Dec 2008 13:04:42 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r724481 - in /cxf/trunk/tools/wsdlto: frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/ frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ test/src/test/java/org/... Date: Mon, 08 Dec 2008 21:04:41 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081208210442.145A3238889E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Mon Dec 8 13:04:41 2008 New Revision: 724481 URL: http://svn.apache.org/viewvc?rev=724481&view=rev Log: [CXF-1935] Bunch of issues with enableAsyncMapping not being picked up all the time. Added: cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl (contents, props changed) - copied, changed from r724441, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async.wsdl Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBinding.java cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/OperationProcessor.java cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBinding.java URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBinding.java?rev=724481&r1=724480&r2=724481&view=diff ============================================================================== --- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBinding.java (original) +++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBinding.java Mon Dec 8 13:04:41 2008 @@ -28,15 +28,14 @@ public class JAXWSBinding implements ExtensibilityElement, Serializable { - private boolean enableAsyncMapping; - - private boolean enableMime; + private Boolean enableAsyncMapping; + private Boolean enableWrapperStyle; + private Boolean enableMime; private Element element; private boolean required; private QName elementType; - private boolean enableWrapperStyle = true; private String documentBaseURI; @@ -87,25 +86,31 @@ } public boolean isEnableMime() { - return enableMime; + return enableMime == null ? false : enableMime; + } + public boolean isSetEnableMime() { + return enableMime != null; } - public void setEnableMime(boolean enableMime) { this.enableMime = enableMime; } public boolean isEnableAsyncMapping() { - return this.enableAsyncMapping; + return enableAsyncMapping == null ? false : enableAsyncMapping; + } + public boolean isSetEnableAsyncMapping() { + return enableAsyncMapping != null; } - public void setEnableAsyncMapping(boolean enableAsync) { this.enableAsyncMapping = enableAsync; } public boolean isEnableWrapperStyle() { - return enableWrapperStyle; + return enableWrapperStyle == null ? true : enableWrapperStyle; + } + public boolean isSetEnableWrapperStyle() { + return enableWrapperStyle != null; } - public void setEnableWrapperStyle(boolean pEnableWrapperStyle) { this.enableWrapperStyle = pEnableWrapperStyle; } Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/OperationProcessor.java URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/OperationProcessor.java?rev=724481&r1=724480&r2=724481&view=diff ============================================================================== --- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/OperationProcessor.java (original) +++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/OperationProcessor.java Mon Dec 8 13:04:41 2008 @@ -59,7 +59,9 @@ public void process(JavaInterface intf, OperationInfo operation) throws ToolException { JavaMethod method = new MethodMapper().map(operation); method.setInterface(intf); - processMethod(method, operation, null); + + processMethod(method, operation); + Collection faults = operation.getFaults(); FaultProcessor faultProcessor = new FaultProcessor(context); faultProcessor.process(method, faults); @@ -69,8 +71,8 @@ intf.addMethod(method); } - void processMethod(JavaMethod method, OperationInfo operation, - JAXWSBinding globalBinding) throws ToolException { + void processMethod(JavaMethod method, + OperationInfo operation) throws ToolException { if (isAsyncMethod(method)) { return; } @@ -102,21 +104,43 @@ method.annotate(new WebResultAnnotator()); JAXWSBinding opBinding = (JAXWSBinding)operation.getExtensor(JAXWSBinding.class); - + JAXWSBinding ptBinding = operation.getInterface().getExtensor(JAXWSBinding.class); + JAXWSBinding defBinding = operation.getInterface().getService() + .getDescription().getExtensor(JAXWSBinding.class); + boolean enableAsync = false; - if (globalBinding != null && globalBinding.isEnableAsyncMapping() - || opBinding != null && opBinding.isEnableAsyncMapping()) { - enableAsync = true; + boolean enableMime = false; + if (defBinding != null) { + if (defBinding.isSetEnableMime()) { + enableMime = defBinding.isEnableMime(); + } + if (defBinding.isSetEnableAsyncMapping()) { + enableAsync = defBinding.isEnableAsyncMapping(); + } } - - + if (ptBinding != null) { + if (ptBinding.isSetEnableMime()) { + enableMime = ptBinding.isEnableMime(); + } + if (ptBinding.isSetEnableAsyncMapping()) { + enableAsync = ptBinding.isEnableAsyncMapping(); + } + } + if (opBinding != null) { + if (opBinding.isSetEnableMime()) { + enableMime = opBinding.isEnableMime(); + } + if (opBinding.isSetEnableAsyncMapping()) { + enableAsync = opBinding.isEnableAsyncMapping(); + } + } + if (!method.isOneWay() - && enableAsync && !isAddedAsyMethod(method)) { + && enableAsync && !isAddedAsycMethod(method)) { addAsyncMethod(method); } - if (globalBinding != null && globalBinding.isEnableMime() - || opBinding != null && opBinding.isEnableMime()) { + if (enableMime) { method.setMimeEnable(true); } } @@ -154,9 +178,14 @@ } private boolean isAsyncMethod(JavaMethod method) { - if (method.getName().toLowerCase() - .equals((method.getOperationName() + ToolConstants.ASYNC_METHOD_SUFFIX).toLowerCase())) { - return true; + if (method.getName().endsWith(ToolConstants.ASYNC_METHOD_SUFFIX)) { + if (method.getReturn().getClassName().startsWith("Response<")) { + return true; + } else if (method.getParameterCount() > 0 + && method.getParameters().get(method.getParameterCount() - 1) + .getClassName().startsWith("AsyncHandler<")) { + return true; + } } return false; } @@ -256,7 +285,7 @@ return sb.toString(); } - private boolean isAddedAsyMethod(JavaMethod method) { + private boolean isAddedAsycMethod(JavaMethod method) { List jmethods = method.getInterface().getMethods(); int counter = 0; for (JavaMethod jm : jmethods) { Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java?rev=724481&r1=724480&r2=724481&view=diff ============================================================================== --- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java (original) +++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java Mon Dec 8 13:04:41 2008 @@ -383,12 +383,12 @@ // changed wrapper style jm.setWrapperStyle(false); - processor.processMethod(jm, bop.getOperationInfo(), jaxwsBinding); + processor.processMethod(jm, bop.getOperationInfo()); jm.getAnnotationMap().remove("ResponseWrapper"); jm.getAnnotationMap().remove("RequestWrapper"); } else { - processor.processMethod(jm, bop.getOperationInfo(), jaxwsBinding); + processor.processMethod(jm, bop.getOperationInfo()); } Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=724481&r1=724480&r2=724481&view=diff ============================================================================== --- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java (original) +++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java Mon Dec 8 13:04:41 2008 @@ -536,7 +536,11 @@ env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/bug627/hello_world.wsdl")); env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/bug627/async_binding.xml")); processor.setContext(env); - processor.execute(); + try { + processor.execute(); + } catch (Exception ex) { + //ignore + } Class clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter"); Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?rev=724481&r1=724480&r2=724481&view=diff ============================================================================== --- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java (original) +++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java Mon Dec 8 13:04:41 2008 @@ -283,7 +283,7 @@ } @Test - public void testAsynMethod() throws Exception { + public void testAsyncMethod() throws Exception { env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_async.wsdl")); processor.setContext(env); processor.execute(); @@ -322,6 +322,81 @@ } @Test + public void testAsyncMethodNoService() throws Exception { + env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_async_noservice.wsdl")); + processor.setContext(env); + processor.execute(); + + assertNotNull(output); + + File org = new File(output, "org"); + assertTrue(org.exists()); + File apache = new File(org, "apache"); + assertTrue(apache.exists()); + File cxf = new File(apache, "cxf"); + assertTrue(cxf.exists()); + File w2j = new File(cxf, "w2j"); + assertTrue(w2j.exists()); + File async = new File(w2j, "hello_world_async_soap_http"); + assertTrue(async.exists()); + + File[] files = async.listFiles(); + assertEquals(Arrays.asList(files).toString(), 9, files.length); + + Class clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterAsync"); + + Method method1 = clz.getMethod("greetMeSometimeAsync", new Class[] {java.lang.String.class, + javax.xml.ws.AsyncHandler.class}); + WebMethod webMethodAnno1 = AnnotationUtil.getPrivMethodAnnotation(method1, WebMethod.class); + + assertEquals(method1.getName() + "()" + " Annotation : WebMethod.operationName ", "greetMeSometime", + webMethodAnno1.operationName()); + + java.lang.reflect.Method method2 = clz.getMethod("greetMeSometimeAsync", + new Class[] {java.lang.String.class}); + WebMethod webMethodAnno2 = AnnotationUtil.getPrivMethodAnnotation(method2, WebMethod.class); + assertEquals(method2.getName() + "()" + " Annotation : WebMethod.operationName ", "greetMeSometime", + webMethodAnno2.operationName()); + + method1 = clz.getMethod("greetMeSometimeAsync", new Class[] {java.lang.String.class, + javax.xml.ws.AsyncHandler.class}); + try { + method1 = clz.getMethod("testIntAsync", new Class[] {Integer.TYPE, + javax.xml.ws.AsyncHandler.class}); + fail("Should not have generated testIntAsync"); + } catch (NoSuchMethodException ex) { + //ignore + } + + + clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterDAsync"); + method1 = clz.getMethod("greetMeSometimeAsync", new Class[] {java.lang.String.class, + javax.xml.ws.AsyncHandler.class}); + + clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterCAsync"); + try { + method1 = clz.getMethod("greetMeSometimeAsync", new Class[] {java.lang.String.class, + javax.xml.ws.AsyncHandler.class}); + fail("Should not have generated greetMeSometimeAsync"); + } catch (NoSuchMethodException ex) { + //ignore + } + method1 = clz.getMethod("testIntAsync", new Class[] {Integer.TYPE, + javax.xml.ws.AsyncHandler.class}); + + clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterBAsync"); + try { + method1 = clz.getMethod("greetMeSometimeAsync", new Class[] {java.lang.String.class, + javax.xml.ws.AsyncHandler.class}); + fail("Should not have generated greetMeSometimeAsync"); + } catch (NoSuchMethodException ex) { + //ignore + } + method1 = clz.getMethod("testIntAsync", new Class[] {Integer.TYPE, + javax.xml.ws.AsyncHandler.class}); + } + + @Test public void testHelloWorldSoap12() throws Exception { env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_soap12.wsdl")); processor.setContext(env); Copied: cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl (from r724441, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async.wsdl) URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl?p2=cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl&p1=cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async.wsdl&r1=724441&r2=724481&rev=724481&view=diff ============================================================================== --- cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async.wsdl (original) +++ cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl Mon Dec 8 13:04:41 2008 @@ -17,92 +17,111 @@ specific language governing permissions and limitations under the License. --> - - true + true - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - - - + + false + + + + true + + + + + + + + + + + + true + + + + false + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - Propchange: cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl ------------------------------------------------------------------------------ svn:mime-type = text/xml