Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J2EE Implementation of patterns

 
Philip Pomario
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, I'm a bit confused regarding the implementation of Design Patterns on the J2EE realm...

1) The container implementation of EJBHome and EJBObject is an example of which pattern? I found it's a Decorator (Whizlabs simulator) and Proxy (Pete Morgan's SCEA Part 1 Notes).

2) The Home interface is based on which pattern? I found it's a Factory Method (Whizlab's) and Abstract Factory (Pete Morgan's).

Your help clarifying these questions is much appreciated.
 
rania ferrag
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Philip,

The answer to your questions, the Home Interface acts as a factory pattern to create instance of the EJB.

The remote interface contains the business methods that can be called by the client, and the remote interface acts as proxy pattern.

Hope this Help, and you can check that at Mark Cade book.

Regards,

Rania
 
Philip Pomario
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate your input, Rania. But Cade's book doesn't explicitly state that information as far as I could find. I would appreciate some reliable source explicitly stating which patterns match what in J2EE API. I'm very confused since Whizlabs simulator says one thing and another study guide states something totally different.
 
rania ferrag
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Filip ,


I understand your confusion, that true some time when we read from different sources, I get confused me too ... but to go back to your question regarding the EJB and Patterns ....From my knowledge, what�s important to understand is that when they ask which pattern describe best an EJB interface (remote or home ) is to give the main action of that interface and see which pattern is doing that Job(that main action). So for Home Interface you agree that it�s used by the client to create, remove and find an EJB, so just because it�s creating instance of EJB , it�s acts as Factory !!!, now is it Abstract Factory or the Factory Method ??, the point is not which kind from the Factory pattern... for the Exam, you have a hole section for Design Pattern where you have questions on different pattern ( select the most appropriate design Pattern for a Given Scenario, or State the name of the design pattern from given UML Diagram) and where you have to select exactly which design pattern was on the given Scenario...
Mark Cade , explain that very well (for EJB and pattern) go read Chapter2 p 16.

Hope this help, and let me know if you still confused, I�ll try to find other good resource where you can get bit more details.

Regards,

Rania
 
Manish S Malhotra
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Filip I think Rania is very true as per Marc Cade's book literature and basic fundamentals of we all.

But I just want one more thing that if options comes with both the cases like Decorator and Proxy for the EJBOBject then its better to choose the Proxy (Cade) and same for the EJBHome, I think its truly Factory Method but Cade said its a Factory whether Abstract or Fac. Method that he hasnt specified.
So, my call is on Factory Method because it creates only one type of Product that is one type of Bean's Remote/Local object but not other objects which are related to the bean and type family.

I think this will make things more clear.

Regards,
Manish
 
Anirudh Borkar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice question,
if we keep aside the answers given by the simulators/literature, the answer is not quite black-and-white.The Container's implementation the EJBHome is an adapter around the bean; the client stub is a Proxy. If one considers that the calls to EJBHome and EJBComponent are intercepted by the container and 'additional functionality of authorization is performed' one could think of it as a decorator.However, I'd say its a proxy because while the decorated object can be accessed directly, the bean cannot.

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic