We have an (existential) question about architecture.
We are arrived on a project designed with Struts1, Spring, Hibernate. The architecture is very heavy with Service Locator, Delegate & Facade Pattern to expose Services. A service has his own DAO and can call other services. DAO don't return domain model but some DTO :(
We can't change the philosophy of the application. But now i have to develop a new functionnal domain.
We have to develop an import functionnality where the purpose is classical :
- create a folder A which is persisted into Database
- create some imports B linked to the folder by reading a CSV
- create all lines read in a third tables C
Of course, there is another functionnality which is to calculate some informations based on imports B for the folder A.
So, there is a Facade which has 2 services :
- a X service to manage the folder A
- a Y service to manage the imports B
In general in the Facade, each method just call a service method only.
Considering we have DTO in parameters, we have to reattach the bean. So the function in the X service calls the Y service to get imports. But the import function in the Y service calls the X service to get folder informations and reattach the bean before saving the imports.
Don't know if it's very clear with my poor english (sorry)
But, the problem is all spring configuration are made without singleton. So X call Y, which call X is a recursive declaration....
How to resolve that ?
Is a facade just a class which group some services to expose all methods by only 1 class ?
Or can we code business logic into ? In other words, is it possible to create a method which call the service X & Y AND to manage all the code around, too ? And possibly to throw a BusinessException...
Aucun commentaire:
Enregistrer un commentaire