com.jakewharton.retrofit.Ok3Client Java Examples
The following examples show how to use
com.jakewharton.retrofit.Ok3Client.
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: HttpUtils.java From qvod with MIT License | 6 votes |
private RestAdapter getRestAdapter(String HOST) { File cacheFile = new File(mContext.getApplicationContext().getCacheDir().getAbsolutePath(), "videoCache"); int cacheSize = 10 * 1024 * 1024; Cache cache = new Cache(cacheFile, cacheSize); OkHttpClient.Builder okBuilder = new OkHttpClient.Builder(); okBuilder.cache(cache); okBuilder.readTimeout(20, TimeUnit.SECONDS);//设置读取新连接超时 okBuilder.connectTimeout(10, TimeUnit.SECONDS);//设置新连接的默认连接超时 okBuilder.writeTimeout(20, TimeUnit.SECONDS);//设置默认为新连接编写超时 OkHttpClient client = okBuilder.build(); // RestAdapter.Builder restBuilder = new RestAdapter.Builder(); restBuilder.setClient(new Ok3Client(client)); restBuilder.setEndpoint(HOST);//URL_HOST restBuilder.setConverter(new GsonConverter(getGson()));//解析 // RestAdapter videoRestAdapter = restBuilder.build(); videoRestAdapter.setLogLevel(LOG_LEVEL); return videoRestAdapter; }
Example #2
Source File: FiatAuthenticationConfig.java From fiat with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean(FiatService.class) // Allows for override public FiatService fiatService( FiatClientConfigurationProperties fiatConfigurationProperties, SpinnakerRequestInterceptor interceptor, OkHttpClientProvider okHttpClientProvider) { // New role providers break deserialization if this is not enabled. val objectMapper = new ObjectMapper(); objectMapper.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL); objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); OkHttpClient okHttpClient = okHttpClientProvider.getClient( new DefaultServiceEndpoint("fiat", fiatConfigurationProperties.getBaseUrl())); return new RestAdapter.Builder() .setEndpoint(Endpoints.newFixedEndpoint(fiatConfigurationProperties.getBaseUrl())) .setRequestInterceptor(interceptor) .setClient(new Ok3Client(okHttpClient)) .setConverter(new JacksonConverter(objectMapper)) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(FiatService.class)) .build() .create(FiatService.class); }
Example #3
Source File: GitHubConfig.java From fiat with Apache License 2.0 | 6 votes |
@Bean public GitHubClient gitHubClient(OkHttpClientProvider clientProvider) { BasicAuthRequestInterceptor interceptor = new BasicAuthRequestInterceptor().setAccessToken(gitHubProperties.getAccessToken()); return new RestAdapter.Builder() .setEndpoint(Endpoints.newFixedEndpoint(gitHubProperties.getBaseUrl())) .setRequestInterceptor(interceptor) .setClient( new Ok3Client( clientProvider.getClient( new DefaultServiceEndpoint("github", gitHubProperties.getBaseUrl())))) .setConverter(new JacksonConverter()) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(GitHubClient.class)) .build() .create(GitHubClient.class); }
Example #4
Source File: IgorConfig.java From echo with Apache License 2.0 | 6 votes |
@Bean public IgorService igorService( Endpoint igorEndpoint, OkHttpClientProvider clientProvider, LogLevel retrofitLogLevel, SpinnakerRequestInterceptor spinnakerRequestInterceptor) { log.info("igor service loaded"); return new Builder() .setEndpoint(igorEndpoint) .setConverter(new JacksonConverter()) .setClient( new Ok3Client( clientProvider.getClient( new DefaultServiceEndpoint("igor", igorEndpoint.getUrl())))) .setRequestInterceptor(spinnakerRequestInterceptor) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(IgorService.class)) .build() .create(IgorService.class); }
Example #5
Source File: DryRunConfig.java From echo with Apache License 2.0 | 6 votes |
@Bean DryRunNotificationAgent dryRunNotificationAgent( Front50Service front50, OkHttpClientProvider clientProvider, RestAdapter.LogLevel retrofitLogLevel, Endpoint dryRunEndpoint, DryRunProperties properties) { log.info("Pipeline dry runs will execute at {}", dryRunEndpoint.getUrl()); OrcaService orca = new RestAdapter.Builder() .setEndpoint(dryRunEndpoint) .setConverter(new JacksonConverter()) .setClient( new Ok3Client( clientProvider.getClient( new DefaultServiceEndpoint("orca", dryRunEndpoint.getUrl())))) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(OrcaService.class)) .build() .create(OrcaService.class); return new DryRunNotificationAgent(front50, orca, properties); }
Example #6
Source File: Front50Config.java From echo with Apache License 2.0 | 6 votes |
@Bean public Front50Service front50Service( Endpoint front50Endpoint, OkHttpClientProvider clientProvider, LogLevel retrofitLogLevel, SpinnakerRequestInterceptor spinnakerRequestInterceptor) { log.info("front50 service loaded"); return new Builder() .setEndpoint(front50Endpoint) .setConverter(new JacksonConverter()) .setClient( new Ok3Client( clientProvider.getClient( new DefaultServiceEndpoint("front50", front50Endpoint.getUrl())))) .setRequestInterceptor(spinnakerRequestInterceptor) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(Front50Service.class)) .build() .create(Front50Service.class); }
Example #7
Source File: ResourcesConfig.java From fiat with Apache License 2.0 | 5 votes |
@Bean Front50Api front50Api() { return new RestAdapter.Builder() .setEndpoint(Endpoints.newFixedEndpoint(front50Endpoint)) .setClient( new Ok3Client( clientProvider.getClient(new DefaultServiceEndpoint("front50", front50Endpoint)))) .setConverter(new JacksonConverter(objectMapper)) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(Front50Api.class)) .build() .create(Front50Api.class); }
Example #8
Source File: ResourcesConfig.java From fiat with Apache License 2.0 | 5 votes |
@Bean ClouddriverApi clouddriverApi() { return new RestAdapter.Builder() .setEndpoint(Endpoints.newFixedEndpoint(clouddriverEndpoint)) .setClient( new Ok3Client( clientProvider.getClient( new DefaultServiceEndpoint("clouddriver", clouddriverEndpoint)))) .setConverter(new JacksonConverter(objectMapper)) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(ClouddriverApi.class)) .build() .create(ClouddriverApi.class); }
Example #9
Source File: ResourcesConfig.java From fiat with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty("services.igor.enabled") IgorApi igorApi(@Value("${services.igor.base-url}") String igorEndpoint) { return new RestAdapter.Builder() .setEndpoint(Endpoints.newFixedEndpoint(igorEndpoint)) .setClient( new Ok3Client( clientProvider.getClient(new DefaultServiceEndpoint("igor", igorEndpoint)))) .setConverter(new JacksonConverter(objectMapper)) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(IgorApi.class)) .build() .create(IgorApi.class); }
Example #10
Source File: KeelConfig.java From echo with Apache License 2.0 | 5 votes |
@Bean public KeelService keelService( Endpoint keelEndpoint, OkHttpClientProvider clientProvider, LogLevel retrofitLogLevel) { return new RestAdapter.Builder() .setEndpoint(keelEndpoint) .setConverter(new JacksonConverter()) .setClient( new Ok3Client( clientProvider.getClient( new DefaultServiceEndpoint("keel", keelEndpoint.getUrl())))) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(KeelService.class)) .build() .create(KeelService.class); }
Example #11
Source File: PipelineTriggerConfiguration.java From echo with Apache License 2.0 | 5 votes |
private <T> T bindRetrofitService(final Class<T> type, final String endpoint) { log.info("Connecting {} to {}", type.getSimpleName(), endpoint); return new RestAdapter.Builder() .setClient( new Ok3Client(clientProvider.getClient(new DefaultServiceEndpoint("orca", endpoint)))) .setRequestInterceptor(requestInterceptor) .setConverter(new JacksonConverter(EchoObjectMapper.getInstance())) .setEndpoint(endpoint) .setLogLevel(LogLevel.BASIC) .setLog(new Slf4jRetrofitLogger(type)) .build() .create(type); }
Example #12
Source File: EchoRetrofitConfig.java From echo with Apache License 2.0 | 4 votes |
@Bean public Ok3Client ok3Client(OkHttp3ClientConfiguration okHttpClientConfig) { return new Ok3Client(okHttpClientConfig.create().build()); }