cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1477553 - in /cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client: LocalClientState.java ThreadLocalClientState.java
Date Tue, 30 Apr 2013 11:06:05 GMT
Author: sergeyb
Date: Tue Apr 30 11:06:05 2013
New Revision: 1477553

URL: http://svn.apache.org/r1477553
Log:
[CXF-4992] Minor cleanup

Modified:
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java?rev=1477553&r1=1477552&r2=1477553&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
Tue Apr 30 11:06:05 2013
@@ -46,8 +46,7 @@ public class LocalClientState implements
     
     public LocalClientState(URI baseURI) {
         this.baseURI = baseURI;
-        String scheme = baseURI.getScheme();
-        if (!StringUtils.isEmpty(scheme) && scheme.startsWith(HTTP_SCHEME)) {
+        if (isHttpScheme(baseURI)) {
             this.currentBuilder = UriBuilder.fromUri(baseURI);
         } else {
             this.currentBuilder = UriBuilder.fromUri("/");
@@ -127,7 +126,7 @@ public class LocalClientState implements
                                 MultivaluedMap<String, String> headers,
                                 MultivaluedMap<String, String> templatesMap) {
         ClientState state = null;
-        if (!StringUtils.isEmpty(currentURI.getScheme()) && currentURI.getScheme().startsWith(HTTP_SCHEME))
{
+        if (isHttpScheme(currentURI)) {
             state = new LocalClientState(currentURI);
         } else {
             state = new LocalClientState(baseURI, currentURI);
@@ -145,4 +144,8 @@ public class LocalClientState implements
         state.setTemplates(newTemplateParams);
         return state;
     }
+    
+    private static boolean isHttpScheme(URI uri) {
+        return !StringUtils.isEmpty(uri.getScheme()) && uri.getScheme().startsWith(HTTP_SCHEME);
+    }
 }

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java?rev=1477553&r1=1477552&r2=1477553&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
Tue Apr 30 11:06:05 2013
@@ -28,15 +28,12 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 
-import org.apache.cxf.common.util.StringUtils;
-
 /**
  * Keeps the client state such as the baseURI, currentURI, requestHeaders, current response
  * in a thread local storage
  *
  */
 public class ThreadLocalClientState implements ClientState {
-    private static final String HTTP_SCHEME = "http";
     private Map<Thread, LocalClientState> state = 
         Collections.synchronizedMap(new WeakHashMap<Thread, LocalClientState>());
     
@@ -106,14 +103,7 @@ public class ThreadLocalClientState impl
     public ClientState newState(URI currentURI, 
                                 MultivaluedMap<String, String> headers,
                                 MultivaluedMap<String, String> templates) {
-        LocalClientState ls = null;
-        if (!StringUtils.isEmpty(currentURI.getScheme()) && currentURI.getScheme().startsWith(HTTP_SCHEME))
{
-            ls = new LocalClientState(currentURI);
-        } else {
-            ls = new LocalClientState(initialState.getBaseURI(), currentURI);
-        }
-        ls.setRequestHeaders(headers);
-        ls.setTemplates(templates);
+        LocalClientState ls = (LocalClientState)initialState.newState(currentURI, headers,
templates);
         return new ThreadLocalClientState(ls, timeToKeepState);
     }
     



Mime
View raw message