====== AsyncHttpClient ====== * https://github.com/AsyncHttpClient/async-http-client * async, non-blocking IO Java HTTP Client ===== Retrofit 2 지원 ===== * https://github.com/AsyncHttpClient/async-http-client/tree/master/extras/retrofit2 * [[java:retrofit|retrofit]] * ''Call.Factory'' 객체를 한 번만 생성해서 공유해서 사용할 것. 매번 생성시 리소스 고갈 됨. // instantiate async-http-client AsyncHttpClient httpClient = ... // instantiate async-http-client call factory Call.Factory callFactory = AsyncHttpClientCallFactory.builder() .httpClient(httpClient) // required .onRequestStart(onRequestStart) // optional .onRequestFailure(onRequestFailure) // optional .onRequestSuccess(onRequestSuccess) // optional .requestCustomizer(requestCustomizer) // optional .build(); // instantiate retrofit Retrofit retrofit = new Retrofit.Builder() .callFactory(callFactory) // use our own call factory .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(JacksonConverterFactory.create()) // ... add other converter factories // .addCallAdapterFactory(RxJavaCallAdapterFactory.createAsync()) .validateEagerly(true) // highly recommended!!! .baseUrl("https://api.github.com/"); // time to instantiate service GitHub github = retrofit.create(Github.class); // enjoy your type-safe github service api! :-)