You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2015/04/20 13:39:49 UTC

[1/2] cxf git commit: [CXF-6353] Support for HTTP proxy properties

Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 646424838 -> 1731258de


[CXF-6353] Support for HTTP proxy properties


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

Branch: refs/heads/3.0.x-fixes
Commit: f3eaa61a2ac9c9a22b31519bbe0dc92f9cf84219
Parents: 6464248
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Fri Apr 17 17:29:28 2015 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Fri Apr 17 17:30:49 2015 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/f3eaa61a/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 95c7650..f19a32f 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
@@ -50,6 +50,8 @@ import org.apache.cxf.transport.https.SSLUtils;
 public class ClientImpl implements Client {
     private static final String HTTP_CONNECTION_TIMEOUT_PROP = "http.connection.timeout";
     private static final String HTTP_RECEIVE_TIMEOUT_PROP = "http.receive.timeout";
+    private static final String HTTP_PROXY_SERVER_PROP = "http.proxy.server.uri";
+    private static final String HTTP_PROXY_SERVER_PORT_PROP = "http.proxy.server.port";
     
     private Configurable<Client> configImpl;
     private TLSConfiguration secConfig;
@@ -271,6 +273,13 @@ public class ClientImpl implements Client {
                 || tlsParams.getTrustManagers() != null) {
                 clientCfg.getHttpConduit().setTlsClientParameters(tlsParams);
             }
+            
+            setConnectionProperties(configProps, clientCfg);
+            
+            // start building the invocation
+            return new InvocationBuilderImpl(WebClient.fromClient(targetClient));
+        }
+        private void setConnectionProperties(Map<String, Object> configProps, ClientConfiguration clientCfg) {
             Long connTimeOutValue = getLongValue(configProps.get(HTTP_CONNECTION_TIMEOUT_PROP));
             if (connTimeOutValue != null) {
                 clientCfg.getHttpConduit().getClient().setConnectionTimeout(connTimeOutValue);
@@ -279,13 +288,16 @@ public class ClientImpl implements Client {
             if (recTimeOutValue != null) {
                 clientCfg.getHttpConduit().getClient().setReceiveTimeout(recTimeOutValue);
             }
-            
-            // start building the invocation
-            return new InvocationBuilderImpl(WebClient.fromClient(targetClient));
-        }
-        private Long getLongValue(Object o) {
-            return o instanceof Long ? (Long)o : o instanceof String ? Long.valueOf(o.toString()) : null;
+            Object proxyServerValue = configProps.get(HTTP_PROXY_SERVER_PROP);
+            if (proxyServerValue != null) {
+                clientCfg.getHttpConduit().getClient().setProxyServer((String)proxyServerValue);
+            }
+            Integer proxyServerPortValue = getIntValue(configProps.get(HTTP_PROXY_SERVER_PORT_PROP));
+            if (proxyServerPortValue != null) {
+                clientCfg.getHttpConduit().getClient().setProxyServerPort(proxyServerPortValue);
+            }
         }
+
         private void initTargetClientIfNeeded() {
             URI uri = uriBuilder.build();
             if (targetClient == null) {
@@ -483,4 +495,10 @@ public class ClientImpl implements Client {
             checkNull(templatesMap.values().toArray());
         }
     }
+    private static Long getLongValue(Object o) {
+        return o instanceof Long ? (Long)o : o instanceof String ? Long.valueOf(o.toString()) : null;
+    }
+    private static Integer getIntValue(Object o) {
+        return o instanceof Integer ? (Integer)o : o instanceof String ? Integer.valueOf(o.toString()) : null;
+    }
 }


[2/2] cxf git commit: [CXF-6356] Adding a Date header delegate, patch from Iris Ding applied

Posted by se...@apache.org.
[CXF-6356] Adding a Date header delegate, patch from Iris Ding applied


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

Branch: refs/heads/3.0.x-fixes
Commit: 1731258de6957803540284199f3a4b9863e19d0d
Parents: f3eaa61
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Mon Apr 20 12:35:57 2015 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Mon Apr 20 12:39:25 2015 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/impl/DateHeaderProvider.java      | 43 ++++++++++++++++++++
 .../cxf/jaxrs/impl/RuntimeDelegateImpl.java     |  2 +
 .../org/apache/cxf/jaxrs/utils/HttpUtils.java   |  2 +-
 .../cxf/jaxrs/impl/DateHeaderProviderTest.java  | 43 ++++++++++++++++++++
 4 files changed, 89 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1731258d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/DateHeaderProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/DateHeaderProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/DateHeaderProvider.java
new file mode 100644
index 0000000..2d2e046
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/DateHeaderProvider.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.impl;
+
+import java.util.Date;
+
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+
+import org.apache.cxf.jaxrs.utils.HttpUtils;
+
+public class DateHeaderProvider implements HeaderDelegate<Date> {
+    
+    public Date fromString(String value) {
+        
+        if (value == null) {
+            throw new IllegalArgumentException("Date value can not be null");
+        }
+        return HttpUtils.getHttpDate(value);
+    }
+
+    public String toString(Date date) {
+        return HttpUtils.toHttpDate(date);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/1731258d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java
index aadd3b2..dcd5946 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxrs.impl;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -51,6 +52,7 @@ public class RuntimeDelegateImpl extends RuntimeDelegate {
         headerProviders.put(Cookie.class, new CookieHeaderProvider());
         headerProviders.put(NewCookie.class, new NewCookieHeaderProvider());
         headerProviders.put(Link.class, new LinkHeaderProvider());
+        headerProviders.put(Date.class, new DateHeaderProvider());
     }
     
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/1731258d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
index 5cb02dd..76c66e9 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
@@ -200,7 +200,7 @@ public final class HttpUtils {
     }
     
     public static HeaderDelegate<Object> getHeaderDelegate(Object o) {
-        return getHeaderDelegate(getOtherRuntimeDelegate(), o);
+        return getHeaderDelegate(RuntimeDelegate.getInstance(), o);
     }
     
     @SuppressWarnings("unchecked")

http://git-wip-us.apache.org/repos/asf/cxf/blob/1731258d/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/DateHeaderProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/DateHeaderProviderTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/DateHeaderProviderTest.java
new file mode 100644
index 0000000..6384f7a
--- /dev/null
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/DateHeaderProviderTest.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.impl;
+
+import java.util.Date;
+
+import javax.ws.rs.ServiceUnavailableException;
+
+import org.apache.cxf.jaxrs.utils.HttpUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DateHeaderProviderTest extends Assert {
+    
+    @Test
+    public void testToFromSimpleString() {
+        Date retry = new Date();
+        ServiceUnavailableException ex = new ServiceUnavailableException(retry);
+        Date retry2 = ex.getRetryTime(new Date());
+        assertEquals(HttpUtils.toHttpDate(retry), HttpUtils.toHttpDate(retry2));
+    }
+    
+    
+        
+}