hi, I am reading "mastering ejb" by ad roman. while raeding the "ejb best parctices and performance optimizations" chapter.. i am getting the follwing line...can anybody explain it in details probably with example.. thanks in advance.. "you should wraps entity beans with session beans.The session bean perform bulk create,read,update,delete operations on behalf of remote clients.The session beans also serve as transactional facade,enforcing that transaction occurs on the server,rather than involving remote client.
"you should wraps entity beans with session beans.The session bean perform bulk create,read,update,delete operations on behalf of remote clients.The session beans also serve as transactional facade,enforcing that transaction occurs on the server,rather than involving remote client.
Exactly. This is the well-known session facade design pattern. The idea is that you can have remote clients (running anywhere in the network) invoking methods to perform a single unit of work. The remote client will probably need to do more than one network call (executing many methods) to perform a single unit of work. and this consumes resources (network calls, etc). So putting a session between in the middle improves your design, not only in terms of network consumption, but as well as decoupling your presentation layer with your business logic. Clients should never access entity beans directly, instead session beans access them using local interfaces (that do not require network calls). Also imagine how hard it would be to manage transactions using client-entity comunication. With a session bean as a facade, you can "tell" your container (via deployment descriptor) to handle transactions. Imagine also if your client is using a standalone application and he asks you to migrate the code to a web application. Having all your business logic in the session bean reduces the amount of work you have to do. You are decoupling your application. what would happen if you need to change the structure of your table in the dabase? i.e., modifying a field ? You probably do not need to change anything on your clients because clients are not communicating directly with the entity bean.. they know nothing about your database structure, all your logic is placed in the bean. hope it helps
I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Joined: Nov 27, 2001
Prashant .. forgot let u know... EJB design patterns by floyd marinescu (FREE pdf available as well). Excellent book... it'll wipe all your doubts...
Joined: Mar 25, 2003
thanks a lot Andres... again one doubt.."The session beans also serve as transactional facade,enforcing that transaction occurs on the server,rather than involving remote client." please tell me know what i understand is right for the above statement. It means that rather than "client will initiate" a transaction involving entity bean in the client code, provide the session bean method interface which will wrap the entity bean and also start the transaction by using deployment description on the server. This means rather than client initiates the transction, the transaction work will be done by the container which will be on the server.