Session Facade Pattern
Bank example invoked from a Servlet directly to Database (entity
beans)
Problems:
- Too many network requests (Client to database)....6
- Not scalable as increase number of clients (tie up resources..database)
while servicing client needs
- If not carefull, the logic could do the withdrawl and fail on
the deposit and the money would be floating in the system
A Solution.....the Session FacadePattern
- Now have 1 network request to a Session Facade code (BankTeller
Session EJB)
- Bundle all of the business logic in a seperated Session Facade
code (Bank Teller Session EJB)
- Able to have better control of processes ...not fail on deposit
or put back money
Extensible to other Business Logic (Session Facade)
Synopsis: Session Facade
Name: Session Facade
Context
A client needs to execute business logic in order to complete
a use case.
Problem (forces)
How can a client execute a use case's business logic in
one transaction and one bulk network call?
Solution
Wrap any business logic in a layer of session programs
called the Sesion Facade. Clients should only have access
to these session programs (beans) and not any underlying
data layers, etc. The session programs (beans) ideally sit
on same network/machine as data programs (entity beans)
thus reducing network load.
Related Patterns
Message Facade, Data Transfer Object.
|
AVOID:
Creating session facade "SUPER Class" ...Sometimes
developers want to put all the use cases in a systemn in one session
bean. This results in a bloated session bean and reduced development
productivity.
|