Java Code Examples for javax.ws.rs.client.Client#property()

The following examples show how to use javax.ws.rs.client.Client#property() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXRS20ClientServerBookTest.java    From cxf with Apache License 2.0 7 votes vote down vote up
@Test
public void testGetBookSpecTemplate() {
    String address = "http://localhost:" + PORT + "/bookstore/{a}";
    Client client = ClientBuilder.newClient();
    client.register((Object)ClientFilterClientAndConfigCheck.class);
    client.register(new BTypeParamConverterProvider());
    client.property("clientproperty", "somevalue");
    WebTarget webTarget = client.target(address).path("{b}")
        .resolveTemplate("a", "bookheaders").resolveTemplate("b", "simple");
    Invocation.Builder builder = webTarget.request("application/xml").header("a", new BType());

    Response r = builder.get();
    Book book = r.readEntity(Book.class);
    assertEquals(124L, book.getId());
    assertEquals("b", r.getHeaderString("a"));
}
 
Example 2
Source File: OpenTsdb.java    From metrics with Apache License 2.0 6 votes vote down vote up
private OpenTsdb(String baseURL, Integer connectionTimeout, Integer readTimeout) {
    final Client client = ClientBuilder.newBuilder().register(JacksonFeature.class).build();
    client.property(ClientProperties.CONNECT_TIMEOUT, connectionTimeout);
    client.property(ClientProperties.READ_TIMEOUT, readTimeout);

    this.apiResource = client.target(baseURL);
}
 
Example 3
Source File: JAXRS20ClientServerBookTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetBookSpec() {
    String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
    Client client = ClientBuilder.newClient();
    client.register((Object)ClientFilterClientAndConfigCheck.class);
    client.register(new BTypeParamConverterProvider());
    client.property("clientproperty", "somevalue");
    WebTarget webTarget = client.target(address);
    Invocation.Builder builder = webTarget.request("application/xml").header("a", new BType());

    Response r = builder.get();
    Book book = r.readEntity(Book.class);
    assertEquals(124L, book.getId());
    assertEquals("b", r.getHeaderString("a"));
}
 
Example 4
Source File: RestResendClientFactory.java    From tessera with Apache License 2.0 5 votes vote down vote up
public ResendClient create(final Config config) {
    final String resendWaitTime =
            new IntervalPropertyHelper(config.getP2PServerConfig().getProperties()).resendWaitTime();

    final SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();

    final ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
    final Client client = clientFactory.buildFrom(config.getP2PServerConfig());

    client.property("jersey.config.client.readTimeout", resendWaitTime);
    return new RestResendClient(client);
}
 
Example 5
Source File: OpenTsdb.java    From metrics-opentsdb with Apache License 2.0 5 votes vote down vote up
private OpenTsdb(String baseURL, Integer connectionTimeout, Integer readTimeout, boolean gzipEnabled) {
    ClientBuilder builder = ClientBuilder.newBuilder()
                                         .register(JacksonFeature.class);
    if (gzipEnabled) {
        builder = builder.register(GZipEncoder.class)
                         .register(EncodingFilter.class)
                         .property(ClientProperties.USE_ENCODING, "gzip");
    }
    final Client client = builder.build();
    client.property(ClientProperties.CONNECT_TIMEOUT, connectionTimeout);
    client.property(ClientProperties.READ_TIMEOUT, readTimeout);

    this.apiResource = client.target(baseURL);
}