Hi. Thank you for raising your questions around software architecture.
One advice I can certainly give you is you don't allow your business rules or entities to be accessible from the UI layer. Always define Data Transfer Objects as a means of transferring data between the UI layer and the Business layer. I've seen examples that expose entities to the UI layer. But it is a better design to use DTOs, offering flexibility, security and better decoupling features.
Consider the following:
application (ui, integration) -> service -> domain -> gateway
Further information can be found here. But I'll provide an overview.
The Application layer contains user interface implementations (JSP, controllers, AJAX, etc.). The common pattern to adopt here is the Model-View-Controller pattern.
The Service layer acts as a Facade between the Application and Domain layer. This means that any changes to the Application layer won't affect the Domain layer and vice versa (along with the use of DTOs). It can also handle transactions, exceptions and logging. The Facade pattern is adopted here.
The Domain layer is where the business rules are kept. Objects normally kept here are entities and data transfer objects (DTOs). Work with DTOs to, say, transfer form field data from a web page to the Domain layer ready for processing. The Strategy and Factory patterns are used here, where the Factory pattern is used to instantiate entities to work with.
The Gateway layer is your interface between the application and the external resource (i.e. database, SMTP, MQ, FTP, etc.). Work with entities to retrieve or persist data. DTOs can also be used here acting as MDBs. perhaps you can call these DTOs as MDBs if you like. The Gateway pattern or DAO pattern is used here.
Notice that I've also mentioned "integration" as part of the application layer. This is a (sub)layer used if you want external applications to talk to you rather than you talking to them. This Application Integration layer could be implemented as a web service, for example. You can take a look at an example here (http://forum.springframework.org/sho...75&postcount=4).
The principle behind the above has been adopted from http://martinfowler.com/eaaCatalog/serviceLayer.html (thanks Martin!).
Let us know what you think. We can try and help you with a good layered design.