• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why do bean classes need access to homes and objects

 
Nirmala Rayudu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spec makes a big deal about which of the lifecycle and container callback methods of a bean class can call (getEJBHome, getEJBObject, getEJBLocalHome, getEJBLocalObject) methods on their corresponding contexts(SessionContext, EntityContext or MessageDrivenContext). I do not understand why a bean class instance would need to access its home and component interfaces? Would anyony who has any idea/example of this, please share it?

Thanks
 
Nadeem Awad
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure about the following, but this is what came to my mind:

  • If you want to create another bean of the same type from within the bean class (I don't know why would you wanna do that! ). You have to do it using the home interface by calling the getEJBHome() method.
  • If you want to pass a reference of the bean to another bean, you can't pass this as a parameter. You're only allowed to pass your bean's EJBObject.


  • Regards,
    [ July 12, 2005: Message edited by: Nadeem Awad ]
     
    Jason Cao
    Greenhorn
    Posts: 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I also think that the getEJBHome can be used as a cached object. Then when you want to get the bean object again sometime later. In this way, you save a lot of resource to lookup the ejbHome object.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!