cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1486147 - in /cxf/trunk/rt/frontend: jaxws/src/main/java/org/apache/cxf/jaxws/ jaxws/src/test/java/org/apache/cxf/jaxws/ simple/src/main/java/org/apache/cxf/frontend/
Date Fri, 24 May 2013 18:19:20 GMT
Author: dkulp
Date: Fri May 24 18:19:20 2013
New Revision: 1486147

URL: http://svn.apache.org/r1486147
Log:
Make proxy's also implement the Client interface which can make it easier to use and configure.
ClientProxy.getClient can be deprecated and/or removed once all the usage of it is cleaned.

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxyFactoryBean.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=1486147&r1=1486146&r2=1486147&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Fri
May 24 18:19:20 2013
@@ -106,19 +106,21 @@ public class JaxWsClientProxy extends or
             params = new Object[0];
         }        
         
-        BindingOperationInfo oi = dispatcher.getBindingOperation(method, endpoint);
-        if (oi == null) {
-            // check for method on BindingProvider and Object
+        
+        try {
             if (method.getDeclaringClass().equals(BindingProvider.class)
                 || method.getDeclaringClass().equals(Object.class)
                 || method.getDeclaringClass().equals(Closeable.class)) {
-                try {
-                    return method.invoke(this, params);
-                } catch (InvocationTargetException e) {
-                    throw e.getCause();
-                }
+                return method.invoke(this, params);
+            } else if (method.getDeclaringClass().isInstance(client)) {
+                return method.invoke(client, params);
             }
-
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+        
+        BindingOperationInfo oi = dispatcher.getBindingOperation(method, endpoint);
+        if (oi == null) {
             Message msg = new Message("NO_BINDING_OPERATION_INFO", LOG, method.getName());
             throw new WebServiceException(msg.toString());
         }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java?rev=1486147&r1=1486146&r2=1486147&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
Fri May 24 18:19:20 2013
@@ -119,15 +119,7 @@ public class JaxWsProxyFactoryBean exten
     @Override
     protected Class<?>[] getImplementingClasses() {
         Class<?> cls = getClientFactoryBean().getServiceClass();
-        Class<?> ret[] = new Class[] {cls, BindingProvider.class};
-        try {
-            cls.getMethod("close");
-        } catch (Exception e) {
-            //ignore - doesn't have a close method so we
-            //can implement Closeable
-            ret = new Class[] {cls, BindingProvider.class, Closeable.class};
-        }
-
+        Class<?> ret[] = new Class[] {cls, BindingProvider.class, Closeable.class,
Client.class};
         try {
             Proxy.getProxyClass(cls.getClassLoader(), ret);
         } catch (Throwable t) {

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java?rev=1486147&r1=1486146&r2=1486147&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java Fri
May 24 18:19:20 2013
@@ -33,7 +33,6 @@ import javax.xml.ws.WebServiceException;
 
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ClientImpl;
-import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
@@ -265,9 +264,9 @@ public class JaxWsClientTest extends Abs
         Greeter greeter2 = (Greeter) cf.create();
         Greeter greeter3 = (Greeter) cf.create();
 
-        Client c = ClientProxy.getClient(greeter);
-        Client c2 = ClientProxy.getClient(greeter2);
-        Client c3 = ClientProxy.getClient(greeter3);
+        Client c = (Client)greeter;
+        Client c2 = (Client)greeter2;
+        Client c3 = (Client)greeter3;
         assertNotSame(c, c2);
         assertNotSame(c, c3);
         assertNotSame(c3, c2);
@@ -275,6 +274,12 @@ public class JaxWsClientTest extends Abs
         assertNotSame(c.getEndpoint(), c3.getEndpoint());
         assertNotSame(c3.getEndpoint(), c2.getEndpoint());
 
+        c3.getInInterceptors();
+        
+        System.out.println(c2.getRequestContext());
+        System.out.println(((BindingProvider)greeter2).getRequestContext());
+        
+        
         ((BindingProvider)greeter).getRequestContext().put("test", "manny");
         ((BindingProvider)greeter2).getRequestContext().put("test", "moe");
         ((BindingProvider)greeter3).getRequestContext().put("test", "jack");

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java?rev=1486147&r1=1486146&r2=1486147&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java (original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java Fri
May 24 18:19:20 2013
@@ -59,17 +59,17 @@ public class ClientProxy implements Invo
         if (client == null) {
             throw new IllegalStateException("The client has been closed.");
         }
+        if (method.getDeclaringClass().equals(Object.class)
+            || method.getDeclaringClass().equals(Closeable.class)) {
+            return method.invoke(this);
+        } else if (method.getDeclaringClass().isInstance(client)) {
+            return method.invoke(client, args);
+        }
         
         MethodDispatcher dispatcher = (MethodDispatcher)endpoint.getService().get(MethodDispatcher.class
                                                                                       .getName());
         BindingOperationInfo oi = dispatcher.getBindingOperation(method, endpoint);
         if (oi == null) {
-            // check for method on BindingProvider and Object
-            if (method.getDeclaringClass().equals(Object.class)
-                || method.getDeclaringClass().equals(Closeable.class)) {
-                return method.invoke(this);
-            }
-
             throw new Fault(new Message("NO_OPERATION_INFO", LOG, method.getName()));
         }
 

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxyFactoryBean.java?rev=1486147&r1=1486146&r2=1486147&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxyFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxyFactoryBean.java
Fri May 24 18:19:20 2013
@@ -187,15 +187,7 @@ public class ClientProxyFactoryBean exte
 
     protected Class<?>[] getImplementingClasses() {
         Class<?> cls = clientFactoryBean.getServiceClass();
-        try {
-            if (cls.getMethod("close") != null) {
-                return new Class[] {cls};
-            }
-        } catch (Exception e) {
-            //ignore - doesn't have a close method so we
-            //can implement Closeable
-        }
-        return new Class[] {cls, Closeable.class};
+        return new Class[] {cls, Closeable.class, Client.class};
     }
 
     protected ClientProxy clientClientProxy(Client c) {



Mime
View raw message