user1340582 user1340582 - 2 months ago 13
Java Question

What application layer is responsible for providing external service integration capabilities?

I have a Spring Boot web application with presentation, business logic, data access logical tiers. Is it conceptually correct to describe external interface calls (REST, WS) to be in the Data Access Layer? I.e. also where database access resides. Conceptually, it would make sense to me.

Also, should interaction with external services be called DAOs or "clients"? I think e.g. Spring Boot tutorials call RestTemplates to be REST "clients", so one possibility would be to have a DAO, which then uses the RestTemplate "client" to actually make the REST call. Would this make sense?

Answer Source

Is it conceptually correct to describe external interface calls (REST, WS) to be in the Data Access Layer

Data Access Object is used to abstract and encapsulate access to the data source. Data source could be a persistent store, external service, repository and etc.

one possibility would be to have a DAO, which then uses the RestTemplate "client" to actually make the REST call

DAO implements the access mechanism required to work with the data source. It is responsibility of DAO to provide abstract API for application, but implementation can be any. Using RestTemplate to make REST calls in DAO is perfectly fine.

Article "Core J2EE Patterns - Data Access Object" might be useful for reading