List of usage examples for com.squareup.okhttp OkHttpClient clone
@Override
public OkHttpClient clone()
From source file:io.fabric8.kubernetes.client.dsl.internal.WatchConnectionManager.java
License:Apache License
public WatchConnectionManager(final OkHttpClient client, final BaseOperation<T, L, ?, ?> baseOperation, final String version, final Watcher<T> watcher, final int reconnectInterval, final int reconnectLimit) throws InterruptedException, ExecutionException, MalformedURLException { if (version == null) { KubernetesResourceList currentList = baseOperation.list(); this.resourceVersion = new AtomicReference<>(currentList.getMetadata().getResourceVersion()); } else {//from w w w .j av a 2 s . c o m this.resourceVersion = new AtomicReference<>(version); } this.clonedClient = client.clone(); this.baseOperation = baseOperation; this.watcher = watcher; this.reconnectInterval = reconnectInterval; this.reconnectLimit = reconnectLimit; runWatch(); }
From source file:syncthing.api.SyncthingApiLongpollModule.java
License:Open Source License
@Provides @SessionScope/*from w w w . j a v a 2 s .c o m*/ @Named("longpoll") public SyncthingApi provideSyncthingApi(Gson gson, OkHttpClient okClient, SyncthingApiConfig config) { OkHttpClient client = okClient.clone(); client.setConnectTimeout(LONGPOLL_CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); client.setReadTimeout(LONGPOLL_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); client.setSslSocketFactory(SyncthingSSLSocketFactory.create(config.getCACert())); client.setHostnameVerifier(new NullHostNameVerifier()); client.interceptors().add(new SyncthingApiInterceptor(config)); Retrofit.Builder b = new Retrofit.Builder().addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create(gson)).client(client).baseUrl(config.getBaseUrl()); if (BuildConfig.DEBUG) { b.validateEagerly(); } return b.build().create(SyncthingApi.class); }
From source file:syncthing.api.SyncthingApiModule.java
License:Open Source License
@Provides @SessionScope/*from www . j av a 2 s.co m*/ public SyncthingApi provideSyncthingApi(Gson gson, OkHttpClient okClient, SyncthingApiConfig config) { OkHttpClient client = okClient.clone(); client.setConnectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); client.setReadTimeout(READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); client.setSslSocketFactory(SyncthingSSLSocketFactory.create(config.getCACert())); client.setHostnameVerifier(new NullHostNameVerifier()); client.interceptors().add(new SyncthingApiInterceptor(config)); Retrofit.Builder b = new Retrofit.Builder().addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create(gson)).client(client).baseUrl(config.getBaseUrl()); if (BuildConfig.DEBUG) { b.validateEagerly(); } return b.build().create(SyncthingApi.class); }