This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

General question of EJB!!  RSS feed

 
Ravi Kumar Ravuru
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folks,
Why do we need Home and Remote Interface in EJBs?Why can't we keep both business methods and life-cycle methods in any one interface instead of two interfaces...any specific reason.Please help me out.
Regards,
Ravi
 
Tina Coleman
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just beginning to wrap my arms around EJB, but, for the purposes of stretching my brain and contrasting my answer with other folks, thoughts include:
* Home vs. Object interfaces give the container more flexibility in how it implements getting remote clients to instances of business logic/data. More flexibility lets containers optimize in various ways, re: caching, loading, etc.
* Once the remote client has a handle to the EJBObject stub, it may no longer need the EJBHome interface object, and so can let that object go to be garbage-collected.
* Just general, good, class/interface design where the interface doesn't attempt to accomplish two fundamentally separate kinds of things (lifecycle management vs. business methods).
 
Junaid Bhatra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can think of the Home interface as really being a factory for creating/locating your actual EJBObjects. In general it's a good design to separate your business object interface (Remote interface) from the
interface that manages the location/life-cycle of your business objects. You should not mingle up the two.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!