I have create a RestFUL service using Spring MVC, but this server was not built like others RESTFull servers.
The server has just 1 controller(It a kind of Faced) with 3 mapping, see bellow
Mapping 1
@RequestMapping(value = "domain/{entity}/{action}", method = {
RequestMethod.POST }, consumes = "application/json", produces="application/json")
As you can see, this mapping process ALL request about DOMAIN and receive as Request body an object called Request ex: /domain/customer/save
/domain/customer/delete
/domain/customer/find
/domain/customer/anyotherserviceaboutcustomer
/domain/employer/save
/domain/employer/employerEspecificService etc.
Mapping 2
@RequestMapping(value = "service/{service}/{action}", method = {
RequestMethod.POST }, consumes = "application/json", produces="application/json")
This mapping process ALL service class, like
/service/email/send
/service/report/getreport
/service/schema/getschema
Mapping 3
This maping is about login, after login client receive an token to send future request to consume other resources
Everything is working fine, the controller process de request using Reflection and Spring manage the objects requested (Beans).
Advantages ?
Using Conversion over Configuration is possible to have a standard behavior about process request from only one controller.
The business logic keep in only Service layer, never in Controller or domain class
I just need to process the request in only one place.
...
Question 1
So, even it works, I'd like to know the opinion about you guys, what's the problem about this "design"?
Question 2
Independent of this approach, the Client receive an Response, in this case in JSON Format, so, I wouldn't like the Client knows about any class of the server, how can I process the server objects with no knows them?
For example, if I receive the JSON about CUSTOMER
{
"id" : "1",
"name" : "RODRIGO"
}
I can convert it to Object in the client, but after that?
I'm thinking to create a kind of "Container Object" that will convert received JSOn to Container object, this Container it seen like a database table, it will be a Class to manipulate the data from client side
Thanks