Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 98AA0200C44 for ; Mon, 27 Mar 2017 20:23:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 97884160B9A; Mon, 27 Mar 2017 18:23:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E4332160B7B for ; Mon, 27 Mar 2017 20:23:06 +0200 (CEST) Received: (qmail 54716 invoked by uid 500); 27 Mar 2017 18:23:06 -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 54696 invoked by uid 99); 27 Mar 2017 18:23:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Mar 2017 18:23:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EC070DFBCA; Mon, 27 Mar 2017 18:23:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkulp@apache.org To: commits@cxf.apache.org Date: Mon, 27 Mar 2017 18:23:05 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] cxf git commit: [CXF-4821] Find the invoke method on the provider implementation class directly archived-at: Mon, 27 Mar 2017 18:23:07 -0000 Repository: cxf Updated Branches: refs/heads/3.1.x-fixes 449e39521 -> 6b2066573 [CXF-4821] Find the invoke method on the provider implementation class directly Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a6b87b4d Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a6b87b4d Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a6b87b4d Branch: refs/heads/3.1.x-fixes Commit: a6b87b4d8b1c6a35493732611bc9e71fb7a052a0 Parents: 449e395 Author: Daniel Kulp Authored: Mon Mar 27 13:05:00 2017 -0400 Committer: Daniel Kulp Committed: Mon Mar 27 14:22:56 2017 -0400 ---------------------------------------------------------------------- .../org/apache/cxf/common/util/ReflectionUtil.java | 17 +++++++++++++++++ .../org/apache/cxf/jaxws/JAXWSMethodInvoker.java | 2 +- .../cxf/jaxws/JAXWSProviderMethodDispatcher.java | 14 +++++++++++--- 3 files changed, 29 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/a6b87b4d/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java b/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java index 6b41895..3684d6b 100644 --- a/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java +++ b/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java @@ -164,6 +164,23 @@ public final class ReflectionUtil { } } } + public static Method getMethod(final Class clazz, final String name, + final Class... parameterTypes) throws NoSuchMethodException { + try { + return AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Method run() throws Exception { + return clazz.getMethod(name, parameterTypes); + } + }); + } catch (PrivilegedActionException pae) { + Exception e = pae.getException(); + if (e instanceof NoSuchMethodException) { + throw (NoSuchMethodException)e; + } else { + throw new SecurityException(e); + } + } + } public static Field[] getDeclaredFields(final Class cls) { return AccessController.doPrivileged(new PrivilegedAction() { http://git-wip-us.apache.org/repos/asf/cxf/blob/a6b87b4d/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java index 8c56fbc..bc5cd59 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java @@ -79,7 +79,7 @@ public class JAXWSMethodInvoker extends AbstractJAXWSMethodInvoker { final MessageContext oldCtx = WebServiceContextImpl.setMessageContext(ctx); List res = null; try { - if ((params == null || params.isEmpty()) && m.getDeclaringClass().equals(Provider.class)) { + if ((params == null || params.isEmpty()) && serviceObject instanceof Provider) { params = Collections.singletonList(null); } res = CastUtils.cast((List)super.invoke(exchange, serviceObject, m, params)); http://git-wip-us.apache.org/repos/asf/cxf/blob/a6b87b4d/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSProviderMethodDispatcher.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSProviderMethodDispatcher.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSProviderMethodDispatcher.java index 841f82c..40be623 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSProviderMethodDispatcher.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSProviderMethodDispatcher.java @@ -23,6 +23,7 @@ import java.lang.reflect.Method; import javax.xml.ws.Provider; +import org.apache.cxf.common.util.ReflectionUtil; import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.jaxws.support.JaxWsImplementorInfo; import org.apache.cxf.service.factory.ServiceConstructionException; @@ -36,9 +37,16 @@ public class JAXWSProviderMethodDispatcher public JAXWSProviderMethodDispatcher(JaxWsImplementorInfo implInfo) { try { - invoke = Provider.class.getMethod("invoke", new Class[] {Object.class}); - } catch (Exception e) { - throw new ServiceConstructionException(e); + invoke = ReflectionUtil.getMethod(implInfo.getImplementorClass(), "invoke", + new Class[] {implInfo.getProviderParameterType()}); + ReflectionUtil.setAccessible(invoke); + } catch (Exception e1) { + //fall back to the raw Provider provided invoke method + try { + invoke = Provider.class.getMethod("invoke", new Class[] {Object.class}); + } catch (Exception e) { + throw new ServiceConstructionException(e); + } } }