cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5621] Adding JAXRS client factory methods allowing to control the time the thread local proxy keeps the state, patch from Parwiz Rezai applied
Date Tue, 18 Mar 2014 21:34:55 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 9bb928f75 -> 9893ce9d0


[CXF-5621] Adding JAXRS client factory methods allowing to control the time the thread local
proxy keeps the state, patch from Parwiz Rezai applied


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

Branch: refs/heads/master
Commit: 9893ce9d05456b7cdf95beac70fd56d29c2c6f08
Parents: 9bb928f
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Mar 18 21:32:37 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Mar 18 21:34:33 2014 +0000

----------------------------------------------------------------------
 .../cxf/jaxrs/client/JAXRSClientFactory.java    | 35 ++++++++++++++++++++
 .../org/apache/cxf/jaxrs/client/WebClient.java  | 13 ++++++++
 2 files changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9893ce9d/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
index 44b3e12..b10de68 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
@@ -144,6 +144,21 @@ public final class JAXRSClientFactory {
     }
     
     /**
+     * Creates a thread safe proxy and allows to specify time to keep state.
+     * @param baseAddress baseAddress
+     * @param cls proxy class, if not interface then a CGLIB proxy will be created
+     * @param providers list of providers
+     * @param timeToKeepState how long to keep this state 
+     * @return typed proxy
+     */
+    public static <T> T create(String baseAddress, Class<T> cls, List<?>
providers, long timeToKeepState) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null);
+        bean.setProviders(providers);
+        bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState));
+        return bean.create(cls);
+    }
+    
+    /**
      * Creates a proxy
      * @param baseAddress baseAddress
      * @param cls proxy class, if not interface then a CGLIB proxy will be created
@@ -263,6 +278,26 @@ public final class JAXRSClientFactory {
     }
     
     /**
+     * Creates a thread safe proxy using user resource model and allows to 
+     * specify time to keep state.
+     * @param baseAddress baseAddress
+     * @param cls proxy class, if not interface then a CGLIB proxy will be created
+     * @param modelRef model location
+     * @param providers list of providers
+     * @param timeToKeepState how long to keep this state
+     * @return typed proxy
+     */
+    public static <T> T createFromModel(String baseAddress, Class<T> cls, String
modelRef, 
+                                        List<?> providers, long timeToKeepState) {
+        JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, null);
+        bean.setProviders(providers);
+        bean.setModelRef(modelRef);
+        bean.setServiceClass(cls);
+        bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState));
+        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

http://git-wip-us.apache.org/repos/asf/cxf/blob/9893ce9d/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 9ef890e..325922c 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
@@ -151,6 +151,19 @@ public class WebClient extends AbstractClient {
     }
     
     /**
+     * Creates a thread safe WebClient
+     * @param baseURI baseURI
+     * @param providers list of providers
+     * @param timeToKeepState time to keep this thread safe state.
+     */
+    public static WebClient create(String baseAddress, List<?> providers, long timeToKeepState)
{
+        JAXRSClientFactoryBean bean = getBean(baseAddress, null);
+        bean.setProviders(providers);
+        bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState));
+        return bean.createWebClient();        
+    }
+    
+    /**
      * Creates WebClient
      * @param baseAddress baseAddress
      * @param providers list of providers


Mime
View raw message