Compare commits
5 Commits
v2.0.7-cxf
...
v2.0.8-cxf
Author | SHA1 | Date | |
---|---|---|---|
8c9cbecd53 | |||
81198de0fb | |||
803d49e53e | |||
adad70d884 | |||
d29ccbef79 |
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.inteligr8</groupId>
|
||||
<artifactId>common-rest-client</artifactId>
|
||||
<version>2.0.7-cxf</version>
|
||||
<version>2.0.8-cxf</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ReST API Client for Java</name>
|
||||
|
@@ -24,6 +24,8 @@ import org.apache.cxf.BusFactory;
|
||||
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
||||
import org.apache.cxf.jaxrs.client.WebClient;
|
||||
import org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl;
|
||||
import org.apache.cxf.transport.http.HTTPConduit;
|
||||
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -129,6 +131,17 @@ public class ClientCxfImpl extends Client {
|
||||
// so we need to create a CXF client
|
||||
WebClient client = WebClient.create(this.getConfig().getBaseUrl(), providersAndFilters);
|
||||
|
||||
if (this.getConfig().getConnectTimeoutInMillis() != null || this.getConfig().getResponseTimeoutInMillis() != null) {
|
||||
HTTPConduit conduit = client.getConfiguration().getHttpConduit();
|
||||
HTTPClientPolicy policy = conduit.getClient();
|
||||
if (policy == null)
|
||||
conduit.setClient(policy = new HTTPClientPolicy());
|
||||
if (this.getConfig().getConnectTimeoutInMillis() != null)
|
||||
policy.setConnectionTimeout(this.getConfig().getConnectTimeoutInMillis());
|
||||
if (this.getConfig().getResponseTimeoutInMillis() != null)
|
||||
policy.setReceiveTimeout(this.getConfig().getResponseTimeoutInMillis());
|
||||
}
|
||||
|
||||
if (!this.getConfig().isDefaultBusEnabled()) {
|
||||
// Some applications (like ACS) add interceptors to the default bus
|
||||
// those interceptors may treat all messages as SOAP messages (like ACS), resulting in ClassCastExceptions
|
||||
|
@@ -14,6 +14,8 @@
|
||||
*/
|
||||
package com.inteligr8.rs;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
|
||||
@@ -83,6 +85,11 @@ public abstract class Client {
|
||||
.register(provider)
|
||||
.register(new LoggingFilter());
|
||||
|
||||
if (this.getConfig().getConnectTimeoutInMillis() != null)
|
||||
clientBuilder.connectTimeout(this.getConfig().getConnectTimeoutInMillis(), TimeUnit.MILLISECONDS);
|
||||
if (this.getConfig().getResponseTimeoutInMillis() != null)
|
||||
clientBuilder.readTimeout(this.getConfig().getResponseTimeoutInMillis(), TimeUnit.MILLISECONDS);
|
||||
|
||||
if (authFilter == null)
|
||||
authFilter = this.getConfig().createAuthorizationFilter();
|
||||
if (authFilter != null)
|
||||
|
@@ -120,6 +120,16 @@ public interface ClientConfiguration {
|
||||
|
||||
|
||||
|
||||
default Integer getConnectTimeoutInMillis() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Integer getResponseTimeoutInMillis() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return true to enable Jackson UNWRAP_ROOT_VALUE feature; false otherwise.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user