Business Delegate and Session Facade usage.
I am new to JavaEE and I recently learnt the Business Delegate and Session Facade design patterns. The tutorials from Oracle did gave me a basic idea of what they are and why they are used, but the example didn't really answer all my questions. So I decided to use a real life scenario here and put my question in to it. Any help is appreciated.
Assume I want to create a search employee page for my company, the employees are categorized by his or her department and the province he or she is in. I have in the database a look up table for department and province. (as shown in the image below)
So I create three JPA entities, one for each table. Now I am stuck with what is the proper way to design the session facade design pattern. I know that I will need the to access all three entities in my page. (to get the drop down list for Provinces and Departments, and to retrieve list of Employees based on the selection) So should I create a Stateless Session Bean as session facade to access all three JPA Entities or should I create three separate Stateless Session Bean to manage one Entity each?
I came up three component diagram in the below picture.
The first one has one Stateless Session Bean as session facade and manages all three Entities.
The second one has a session facade to manage the relationship between business objects such as ProvinceManagerEJB and DepartmentManagerEJB which will manage the corresponding Entities.
The last one has three Stateless Session Beans that will manage one Entity each, all three Stateless Session Beans can be looked up via the Business Delegate pattern.
Please let me know if any one of them is the proper way to use business delegate and session facade. or none of them is correct. (which I assume might happen)
Again, thank you so much for your help.
Re: Business Delegate and Session Facade usage.
Session Facade is not a commonly used pattern. Pick up a copy of Martin Fowler's Patterns of Enterprise Application Architecture to learn more.
Business Delegate is more common but most architects I know don't use that either. Sun/Oracle did a nice job of trying to establish common patterns (i.e. Pet Store). Unfortunately the term "Design Pattern" was created to document common patterns in use. Sun suggested an architecture based partly existing (real) design patterns, and new patterns, which they also called Design Patterns, stretching the definition.
In my experience, most good architects tried the "Pet Store" patterns and moved on. Check out the Grails framework. It's architecture is based on (again, in my experience) the most popular Java Web architectural approach. I learned this from guru's I met along the way, and when Grails came out, it's architecture was completely familiar to me.