cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1478686 - in /cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client: JAXRSClientFactory.java WebClient.java
Date Fri, 03 May 2013 09:21:09 GMT
Author: sergeyb
Date: Fri May  3 09:21:05 2013
New Revision: 1478686

URL: http://svn.apache.org/r1478686
Log:
[CXF-4998] Adding one more method to client factories to make it a bit simpler to register
providers and username and password

Modified:
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java?rev=1478686&r1=1478685&r2=1478686&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
Fri May  3 09:21:05 2013
@@ -193,6 +193,25 @@ public final class JAXRSClientFactory {
     }
     
     /**
+     * Creates a proxy which will do basic authentication
+     * @param baseAddress baseAddress
+     * @param cls proxy class, if not interface then a CGLIB proxy will be created
+     * @param providers list of providers
+     * @param username username
+     * @param password password
+     * @param configLocation classpath location of the configuration resource
+     * @return typed proxy
+     */
+    public static <T> T create(String baseAddress, Class<T> cls, List<?>
providers,
+                               String username, String password, String configLocation) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation);
+        bean.setUsername(username);
+        bean.setPassword(password);
+        bean.setProviders(providers);
+        return bean.create(cls);
+    }
+    
+    /**
      * Creates a proxy using user resource model
      * @param baseAddress baseAddress
      * @param cls proxy class, if not interface then a CGLIB proxy will be created

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1478686&r1=1478685&r2=1478686&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Fri May
 3 09:21:05 2013
@@ -205,6 +205,25 @@ public class WebClient extends AbstractC
     }
     
     /**
+     * Creates WebClient which will do basic authentication
+     * @param baseAddress baseAddress
+     * @param providers list of providers
+     * @param username username
+     * @param password password
+     * @param configLocation classpath location of the configuration resource, can be null
 
+     * @return WebClient instance
+     */
+    public static WebClient create(String baseAddress, List<?> providers, 
+                                   String username, String password, String configLocation)
{
+        JAXRSClientFactoryBean bean = getBean(baseAddress, configLocation);
+        
+        bean.setUsername(username);
+        bean.setPassword(password);
+        bean.setProviders(providers);
+        return bean.createWebClient();
+    }
+    
+    /**
      * Creates WebClient, baseURI will be set to Client currentURI
      * @param client existing client
      */



Mime
View raw message