You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2016/09/10 14:41:25 UTC

[17/37] cxf git commit: [CXF-7042] Supporting system thread safe properties

[CXF-7042] Supporting system thread safe properties


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

Branch: refs/heads/master-jaxrs-2.1
Commit: e9a8fb39b449e08a720826bca9a2489d7f813d72
Parents: 25a305c
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Wed Sep 7 13:54:18 2016 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Wed Sep 7 13:54:18 2016 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/client/spec/ClientImpl.java       | 24 ++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e9a8fb39/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
index 4f089d6..60948df 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
@@ -39,6 +39,7 @@ import javax.ws.rs.core.Link;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriBuilder;
 
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.configuration.jsse.TLSClientParameters;
 import org.apache.cxf.jaxrs.client.ClientConfiguration;
 import org.apache.cxf.jaxrs.client.ClientProviderFactory;
@@ -55,6 +56,15 @@ public class ClientImpl implements Client {
     private static final String HTTP_AUTOREDIRECT_PROP = "http.autoredirect";
     private static final String HTTP_RESPONSE_AUTOCLOSE_PROP = "http.response.stream.auto.close";
     private static final String THREAD_SAFE_CLIENT_PROP = "thread.safe.client";
+    private static final String THREAD_SAFE_CLIENT_STATE_CLEANUP_PROP = "thread.safe.client.state.cleanup.period";
+    private static final Boolean DEFAULT_THREAD_SAFETY_CLIENT_STATUS;
+    private static final Integer THREAD_SAFE_CLIENT_STATE_CLEANUP_PERIOD;
+    static  {
+        DEFAULT_THREAD_SAFETY_CLIENT_STATUS = 
+            Boolean.parseBoolean(SystemPropertyAction.getPropertyOrNull(THREAD_SAFE_CLIENT_PROP));
+        THREAD_SAFE_CLIENT_STATE_CLEANUP_PERIOD = 
+            getIntValue(SystemPropertyAction.getPropertyOrNull(THREAD_SAFE_CLIENT_STATE_CLEANUP_PROP));
+    }
     
     private Configurable<Client> configImpl;
     private TLSConfiguration secConfig;
@@ -325,8 +335,18 @@ public class ClientImpl implements Client {
                 JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
                 bean.setAddress(uri.toString());
                 Boolean threadSafe = getBooleanValue(configProps.get(THREAD_SAFE_CLIENT_PROP));
-                if (threadSafe != null) {
-                    bean.setThreadSafe(threadSafe);
+                if (threadSafe == null) {
+                    threadSafe = DEFAULT_THREAD_SAFETY_CLIENT_STATUS;
+                }
+                bean.setThreadSafe(threadSafe);
+                if (threadSafe) {
+                    Integer cleanupPeriod = getIntValue(configProps.get(THREAD_SAFE_CLIENT_PROP));
+                    if (cleanupPeriod == null) {
+                        cleanupPeriod = THREAD_SAFE_CLIENT_STATE_CLEANUP_PERIOD;
+                    }
+                    if (cleanupPeriod != null) {
+                        bean.setSecondsToKeepState(cleanupPeriod);
+                    }
                 }
                 targetClient = bean.createWebClient();
                 ClientImpl.this.baseClients.add(targetClient);