use of retrofit.client.OkClient in project halyard by spinnaker.
the class RetrofitConfig method okClient.
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
OkClient okClient() {
OkHttpClient client = okHttpClientConfig.create();
client.setConnectionPool(new ConnectionPool(maxIdleConnections, keepAliveDurationMs));
client.setRetryOnConnectionFailure(retryOnConnectionFailure);
return new OkClient(client);
}
use of retrofit.client.OkClient in project steps by linroid.
the class WeatherApp method initWeatherService.
private void initWeatherService() {
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(Config.ENDPOINT).setClient(new OkClient(new OkHttpClient())).setLogLevel(RestAdapter.LogLevel.BASIC).setErrorHandler(new ErrorHandler() {
@Override
public Throwable handleError(RetrofitError retrofitError) {
Timber.e(retrofitError, "访问 %s 出错", retrofitError.getUrl());
return retrofitError;
}
}).setRequestInterceptor(new RequestInterceptor() {
@Override
public void intercept(RequestFacade requestFacade) {
requestFacade.addQueryParam("ak", Config.BAIDU_AK);
requestFacade.addEncodedQueryParam("mcode", Config.M_CODE);
requestFacade.addQueryParam("output", "json");
}
}).build();
weatherService = restAdapter.create(WeatherService.class);
}
use of retrofit.client.OkClient in project divide by HiddenStage.
the class AbstractWebManager method createRestAdapter.
private RestAdapter createRestAdapter(Config config) {
RestAdapter.Builder builder = new RestAdapter.Builder();
builder.setClient(new OkClient(config.client)).setEndpoint(config.serverUrl).setLogLevel(RestAdapter.LogLevel.FULL).setLog(new RestAdapter.Log() {
@Override
public void log(String s) {
retrologger.debug(s);
}
}).setConverter(new GsonConverter(new Gson())).setRequestInterceptor(new RequestInterceptor() {
@Override
public void intercept(RequestFacade requestFacade) {
onRequest(requestFacade);
}
}).setProfiler(new Profiler() {
@Override
public Object beforeCall() {
return null;
}
@Override
public void afterCall(RequestInformation requestInformation, long l, int i, Object o) {
retrologger.error("afterCall(" + requestInformation.getRelativePath() + ":" + requestInformation.getMethod() + ": " + i + " : " + o);
requestEventPublisher.onNext(new RequestObject(requestInformation, l, i, o));
}
});
return builder.build();
}
use of retrofit.client.OkClient in project divide by HiddenStage.
the class AuthServerHelper method buildTestService.
private TestService buildTestService(String url) {
if (testService == null) {
RestAdapter restAdapter = new RestAdapter.Builder().setClient(new OkClient()).setEndpoint(url).setLogLevel(RestAdapter.LogLevel.FULL).setLog(new RestAdapter.Log() {
@Override
public void log(String s) {
System.out.println(s);
}
}).build();
testService = restAdapter.create(TestService.class);
}
return testService;
}
Aggregations