Making UrlFetchServiceImpl as singleton spring bean
Convert http clients into spring singleton components
Context and Scope
In current OSDU core commons there are two http clients
- UrlFetchServiceImpl which is implementation of IUrlFetchService. It uses HttpClientHandler which is a spring with request scope
- HttpClient which is implementation of IHttpClient
UrlFetchServiceImpl is a spring component with request scope and HttpClient is not a spring component.
Questions
- Any specific reason for having UrlFetchServiceImpl as request scoped spring bean? Is this because of injection of JaxRsDpsLogger in HttpClientHandler?
- Any specific reason for not having HttpClient as spring bean?
Proposal
Convert these two http clients to spring bean with singleton as scope.
- Converting the existing UrlFetchServiceImpl and HttpClientHandler to singleton scope
- Converting the HttpClient as singleton scoped spring bean. We still support the constructor way of invoking for backward compatibility.
Rationale
I am working on logging the request/response for external clients at these clients. For this logging I want to use JaxRsDpsLogger which needs to be autowired.
----------------- ADR update based on discussion ---------------
Splitting this ADR into two different issues. This ADR is about converting UrlFetchServiceImpl as singleton spring bean.