• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

about ejbcreate()

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when client invoke create() method in home interface this causes the container to invoke newInstance() on bean class to create new bean instance, next container calls setSessionContext() followed by ejbcreate().
correct me if i am wrong!

My question is
Q) can container call bean class newInstance() method from the home interface?
Q) whats purpose of setSessionContext() method and what will it return??
Q) If newInstance() method creates new bean instance then why ejbcreate???
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shanthi

Here are the answers to your questions

Q) can container call bean class newInstance() method from the home interface?
Ans. No, the EJB specs do not permit you to call the newInstance().
We need to call the create method on the home interface as the container creates the Object of the home interface and when you call the create method on the home interface the container intercepts your request. It creates an EJBObject. This EJB object is not just an instance of your bean class but it also has the logic for the various services which you have requested for from your container.

If you directly want to use the newInstance method() on the bean class you will have to write all the logic for transaction managment, caching etc, and thus you will loose the purpose of using EJB's. These are services provided by you EJB container and you therefore skip coding for these services when writing your bean code.

I hope this has answered your 3rd question also.

Q) whats purpose of setSessionContext() method and what will it return??
Ans. setters as such do not reurn anything. setSessionContext() will associate you bean with a session context. You can use this context to know about the beans current transactional state, its security state etc.

I hope this clears most of your doubts.

----
Ankur
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic