• 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:

Instance creation

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How basically the instance of beans are created without using keyword 'new'. Thorw some light on it.

Tx.
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a Stateful Session Bean, The EJB Container creates the bean. It actually calls newInstance on the class object as opposed to calling 'new'.

From the EJB 2.0 spec:


A session bean instance�s life starts when a client invokes a create<METHOD>(...) method on the session bean�s home interface. This causes the container to invoke newInstance() on the session bean class to create a new session bean instance. Next, the container calls setSessionContext() and ejbCreate<METHOD>(...) on the instance and returns the session object reference to the client. The instance is now in the method ready state.



A Stateless Session bean is created whenever the Container needs one. Again, from the spec:

A stateless session bean instance�s life starts when the container invokes newInstance() on the session bean class to create a new instance. Next, the container calls setSession-Context() followed by ejbCreate() on the instance. The container can perform the instance creation at any time�there is no relationship to a client�s invocation of the create() method.

 
reply
    Bookmark Topic Watch Topic
  • New Topic