A bit confused about the Service Layer
So, I've got a "rich domain model" sorted for a fun little app Im playing with at home. All the "business rules" are in the model.
So, next step - I guess I want a "Service Layer" which directs the use cases in the app, controls security and transaction demarcation and would be talked to by, say, the WS layer (prob axis 2) and the Web layer (prob spring MVC).
Now here's what I dont get: If my service layer talks the same language as the domain model (no need for DTOs here) - whats to stop other layers triggering domain logic through the model?
E.g - (and assuming the service layer exposes "finder" methods to satisfy some front-end requirement)
Person client = service.locatePerson(personName);
Book book = service.locateBook(bookName);
client.hireBook(book);// invoking business logic thru model
So I suppose what Im not immediately getting is how to have a clean service layer (without requiring a whole set of DTOs) without some form of "programming by convention" coming in to play.
One way I thought of was to use layered interfaces - with the model objects returned from the service layer being exposed under more "restrictive" interfaces. I can see this getting pretty clunky pretty quickly however.
Anyone have any tips in this area at all?
Cheers,
~D

