Merge branch 'develop-cxf' into stable-cxf
This commit is contained in:
@@ -24,6 +24,8 @@ import org.apache.cxf.BusFactory;
|
|||||||
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
||||||
import org.apache.cxf.jaxrs.client.WebClient;
|
import org.apache.cxf.jaxrs.client.WebClient;
|
||||||
import org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -129,6 +131,17 @@ public class ClientCxfImpl extends Client {
|
|||||||
// so we need to create a CXF client
|
// so we need to create a CXF client
|
||||||
WebClient client = WebClient.create(this.getConfig().getBaseUrl(), providersAndFilters);
|
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()) {
|
if (!this.getConfig().isDefaultBusEnabled()) {
|
||||||
// Some applications (like ACS) add interceptors to the default bus
|
// Some applications (like ACS) add interceptors to the default bus
|
||||||
// those interceptors may treat all messages as SOAP messages (like ACS), resulting in ClassCastExceptions
|
// those interceptors may treat all messages as SOAP messages (like ACS), resulting in ClassCastExceptions
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.inteligr8.rs;
|
package com.inteligr8.rs;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
import javax.ws.rs.client.ClientBuilder;
|
||||||
import javax.ws.rs.client.WebTarget;
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
|
||||||
@@ -83,6 +85,11 @@ public abstract class Client {
|
|||||||
.register(provider)
|
.register(provider)
|
||||||
.register(new LoggingFilter());
|
.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)
|
if (authFilter == null)
|
||||||
authFilter = this.getConfig().createAuthorizationFilter();
|
authFilter = this.getConfig().createAuthorizationFilter();
|
||||||
if (authFilter != null)
|
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.
|
* @return true to enable Jackson UNWRAP_ROOT_VALUE feature; false otherwise.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user