本文整理汇总了Java中javax.ws.rs.client.Client.property方法的典型用法代码示例。如果您正苦于以下问题:Java Client.property方法的具体用法?Java Client.property怎么用?Java Client.property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.client.Client
的用法示例。
在下文中一共展示了Client.property方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RadioBrowser
import javax.ws.rs.client.Client; //导入方法依赖的package包/类
/** Custom constructor for mocked unit testing.
* @param apiUrl the base URL of the API.
* @param timeout the timeout in milliseconds for connecting
* and reading.
* @param myUserAgent the user agent string to use.
* */
RadioBrowser(final String apiUrl,
final int timeout,
final String myUserAgent) {
if (timeout <= 0) {
throw new IllegalArgumentException(
"timeout must be > 0, but is "
+ timeout);
}
this.userAgent = Objects.requireNonNull(myUserAgent,
"User agent is null");
Client client = ClientBuilder.newBuilder()
.register(JacksonFeature.class)
.build();
client.property(ClientProperties.CONNECT_TIMEOUT, timeout);
client.property(ClientProperties.READ_TIMEOUT, timeout);
webTarget = client.target(apiUrl);
}
示例2: getInvocationBuilder
import javax.ws.rs.client.Client; //导入方法依赖的package包/类
protected Builder getInvocationBuilder(String url, Map<String, String> queryParameters) {
ClientConfig clientConfig = new ClientConfig();
if (getProxyAddress() != null) {
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ClientProperties.PROXY_URI, getProxyAddress());
}
Client client = ClientBuilder.newClient(clientConfig);
client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
WebTarget webTarget = client.target(url);
if (queryParameters != null) {
for (Map.Entry<String, String> queryParameter: queryParameters.entrySet())
// webTarget = webTarget.queryParam(queryParameter.getKey(), queryParameter.getValue().replace("_", "_1").replace("%", "_0"));
webTarget = webTarget.queryParam(queryParameter.getKey(), queryParameter.getValue());
}
return webTarget.request(MediaType.APPLICATION_JSON).accept("application/ld+json").header("Authorization", getCloudTokenValue());
}
示例3: init
import javax.ws.rs.client.Client; //导入方法依赖的package包/类
@PostConstruct
public void init() {
Client client = ClientBuilder.newClient();
client.property("http.connection.timeout", this.connectionTimeout);
System.out.println(connectionTimeout);
System.out.println(readTimeout);
client.property("http.receive.timeout", this.readTimeout);
this.webTarget = client.target(ADDITION_URI);
}