cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Updating default ClassHelper and WebClient to check Proxy
Date Tue, 20 Jan 2015 17:30:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 62d904855 -> c584e44a3


Updating default ClassHelper and WebClient to check Proxy


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c584e44a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c584e44a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c584e44a

Branch: refs/heads/master
Commit: c584e44a3ab98f2efbf8866e07d471b5116433e6
Parents: 62d9048
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Jan 20 17:30:23 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Jan 20 17:30:23 2015 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/common/util/ClassHelper.java |  6 ++--
 .../org/apache/cxf/jaxrs/client/WebClient.java  | 31 +++++++++++++++-----
 2 files changed, 27 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c584e44a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
index db2dbdb..68ea3b3 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.common.util;
 
+import java.lang.reflect.Proxy;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 
@@ -52,14 +54,14 @@ public class ClassHelper {
     }
     
     protected Class<?> getRealClassInternal(Object o) {
-        return o.getClass();
+        return getRealObjectInternal(o).getClass();
     }
     
     protected Class<?> getRealClassFromClassInternal(Class<?> cls) {
         return cls;
     }
     protected Object getRealObjectInternal(Object o) {
-        return o;
+        return o instanceof Proxy ? Proxy.getInvocationHandler(o) : o;
     }
     
     public static Class<?> getRealClass(Object o) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/c584e44a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
index f183ab2..d1279b4 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
@@ -55,6 +55,7 @@ import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
+import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.feature.Feature;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -247,6 +248,15 @@ public class WebClient extends AbstractClient {
      * Creates WebClient, baseURI will be set to Client currentURI
      * @param client existing client
      */
+    public static WebClient fromClientObject(Object object) {
+        Client client = client(object);
+        return client == null ? null : fromClient(client, false);
+    }
+    
+    /**
+     * Creates WebClient, baseURI will be set to Client currentURI
+     * @param client existing client
+     */
     public static WebClient fromClient(Client client) {
         return fromClient(client, false);
     }
@@ -1229,11 +1239,18 @@ public class WebClient extends AbstractClient {
     }
     
     private static AbstractClient toAbstractClient(Object client) {
+        
         if (client instanceof AbstractClient) {
             return (AbstractClient)client;
-        } else {
+        } else if (client instanceof InvocationHandlerAware) {
             return (AbstractClient)((InvocationHandlerAware)client).getInvocationHandler();
+        } else {
+            Object realObject = ClassHelper.getRealObject(client);
+            if (realObject instanceof AbstractClient) {
+                return (AbstractClient)realObject;
+            }
         }
+        return null;
     }
     
     static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation) {
@@ -1249,14 +1266,12 @@ public class WebClient extends AbstractClient {
     }
     
     static ClientState getClientState(Client client) {
-        ClientState clientState = null;
-        if (client instanceof WebClient) { 
-            clientState = ((AbstractClient)client).getState();
-        } else if (client instanceof InvocationHandlerAware) {
-            Object handler = ((InvocationHandlerAware)client).getInvocationHandler();
-            clientState = ((AbstractClient)handler).getState();
+        AbstractClient newClient = toAbstractClient(client);
+        if (newClient == null) { 
+            return null;
+        } else  {
+            return newClient.getState();
         }
-        return clientState;
     }
     
     static URI convertStringToURI(String baseAddress) {


Mime
View raw message