• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why EJB has such a complex architecture

 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys
Two months back i started getting into the EJB.I had got enough knowledge and was able to write Entity and Session beans .. but recently i had an interview with a firm who questioned me about EJB (which i answered) but in the end they asked me "Why such a complex mechanism of home,remote and bean class. Why should i look up home then get remote and then invoke the method?"
I dunno what got me at that time. but i answered in a manner which was correct but not that convincing. Can any of you actually tell me what should be the perfect answer or shall i say a textbook explanation?..
bye and thanks in advance
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not complex. It's just the Factory pattern. Turn the question around to them -- ask them how you would find a specific instance (in the Entity case, of course) WITHOUT a Factory. This was a problem we always had in RMI and CORB before the days of EJB -- RMI and CORBA did not have the Factory idiom (well, CORBA did in the lifecycle service, but no one used that), and so what we stored in the registry or naming service was the "end user" object. It was a mess. Registries were filled with objects whose utility was dubious -- either they were all effectively singletons, or you had to "wall off" certain objects in certain namespaces to keep clients from using non-shared objects and stepping on other clients.
The Factory idiom emerged out of this mess. What you stored in the registry was a factory, and what was returned back was a client-specific instance. If you lost your handle, you could go back to the Factory and ask for it to do a search. That is what EJB Homes are...
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!