use of org.apache.cxf.jaxrs.client.ClientConfiguration in project components by Talend.
the class AmbariClientBuilder method closeClient.
/**
* Closes the transport level conduit in the client. Reopening a new connection, requires creating a new client
* object using the build() method in this builder.
*
* @param root The resource returned by the build() method of this builder class
*/
public static void closeClient(ApiRootResource root) {
ClientConfiguration config = WebClient.getConfig(root);
HTTPConduit conduit = config.getHttpConduit();
if (conduit == null) {
throw new IllegalArgumentException("Client is not using the HTTP transport");
}
conduit.close();
}
use of org.apache.cxf.jaxrs.client.ClientConfiguration in project pinpoint by naver.
the class CxfClientIT method test.
@Test
public void test() throws Exception {
String address = getADDRESS();
String json = "{\"id\" : 12345, \"name\" : \"victor\"}";
WebClient client = WebClient.create(address, true);
ClientConfiguration configuration = WebClient.getConfig(client);
// add logging interceptor
configuration.getInInterceptors().add(new LoggingInInterceptor());
configuration.getOutInterceptors().add(new LoggingOutInterceptor());
client.path("/test1").accept("application/json").type("application/json; charset=UTF-8").post(json).close();
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
verifier.ignoreServiceType("JDK_HTTPURLCONNECTOR");
verifier.verifyTrace(event("CXF_MESSAGE_SENDER", MessageSenderInterceptor.class.getDeclaredMethod("handleMessage", Message.class)));
verifier.verifyTrace(event("CXF_LOGGING_OUT", LoggingOutInterceptor.class.getDeclaredMethod("formatLoggingMessage", LoggingMessage.class), annotation("cxf.address", address + "/test1"), annotation("cxf.http.method", "POST"), annotation("cxf.content.type", "application/json; charset=UTF-8"), annotation("cxf.headers", "{Accept=[application/json], Content-Type=[application/json; charset=UTF-8]}"), annotation("cxf.payload", "{\"id\" : 12345, \"name\" : \"victor\"}")));
// verifier.verifyTrace(event("CXF_LOGGING_IN", LoggingInInterceptor.class.getDeclaredMethod("formatLoggingMessage", LoggingMessage.class),
// annotation("cxf.response.code", "200"),
// annotation("cxf.encoding", "ISO-8859-1"),
// annotation("cxf.content.type", "text/html"),
// annotation("cxf.headers", "{connection=[keep-alive], Content-Length=[2], content-type=[text/html], Date=[" + new Date() + "]}"),
// annotation("cxf.payload", "{}")
// ));
verifier.verifyTraceCount(1);
client.close();
}
use of org.apache.cxf.jaxrs.client.ClientConfiguration in project ddf by codice.
the class SecureCxfClientFactoryImpl method getNewClient.
private T getNewClient() {
T clientImpl = interfaceClass.equals(WebClient.class) ? (T) clientFactory.create() : JAXRSClientFactory.fromClient(clientFactory.create(), interfaceClass);
ClientConfiguration clientConfig = WebClient.getConfig(clientImpl);
clientConfig.getRequestContext().put(Message.MAINTAIN_SESSION, Boolean.TRUE);
configureConduit(clientConfig);
configureTimeouts(clientConfig, connectionTimeout, receiveTimeout);
return clientImpl;
}
use of org.apache.cxf.jaxrs.client.ClientConfiguration in project midpoint by Evolveum.
the class RestServiceInitializer method prepareClient.
protected WebClient prepareClient(String username, String password) {
List providers = new ArrayList<>();
providers.add(getProvider());
// ,
WebClient client = WebClient.create(ENDPOINT_ADDRESS, providers);
// provider);
ClientConfiguration clientConfig = WebClient.getConfig(client);
clientConfig.getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
client.accept(getAcceptHeader());
client.type(getContentType());
createAuthorizationHeader(client, username, password);
return client;
}
use of org.apache.cxf.jaxrs.client.ClientConfiguration in project ddf by codice.
the class SecureCxfClientFactory method getNewClient.
private T getNewClient() {
T clientImpl = interfaceClass.equals(WebClient.class) ? (T) clientFactory.create() : JAXRSClientFactory.fromClient(clientFactory.create(), interfaceClass);
ClientConfiguration clientConfig = WebClient.getConfig(clientImpl);
clientConfig.getRequestContext().put(Message.MAINTAIN_SESSION, Boolean.TRUE);
configureConduit(clientConfig);
configureTimeouts(clientConfig, connectionTimeout, receiveTimeout);
return clientImpl;
}
Aggregations