cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/3] cxf git commit: [CXF-4821] Find the invoke method on the provider implementation class directly
Date Mon, 27 Mar 2017 18:24:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes b1808da98 -> 9ec048d79


[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/daf34f19
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/daf34f19
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/daf34f19

Branch: refs/heads/3.0.x-fixes
Commit: daf34f19493bccb174f896788914d54f00d1982f
Parents: b1808da
Author: Daniel Kulp <dkulp@apache.org>
Authored: Mon Mar 27 13:05:00 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Mon Mar 27 14:24:12 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/daf34f19/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<Method>()
{
+                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<Field[]>() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/daf34f19/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 4a7cddf..7142355 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
@@ -63,7 +63,7 @@ public class JAXWSMethodInvoker extends AbstractJAXWSMethodInvoker {
         final MessageContext oldCtx = WebServiceContextImpl.setMessageContext(ctx);
         List<Object> 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/daf34f19/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);
+            }
         }
     }
 


Mime
View raw message