wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes who owns create()   ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "who owns create()   ?" Watch "who owns create()   ?" New topic
Author

who owns create() ?

kriti sharma
Ranch Hand

Joined: Feb 16, 2001
Posts: 160
my question is : the standard method 'create' belongs to which interface or class?i know that the container implements it by : Class.newInstance("myBean.class").

when is the actual create() method that instantiates ejbObject called?at the time the application server boots up?if so,then whenever the client calls a create() (parameterized/empty) on home interface, there actually may not be any actual instantiation occuring, in fact just the ejbCreate method is being called on an existing free-to-use instance of ejbObject in the instance pool.am i right?

the client executes the following statement:
remote=home.create()

if this is a stateful session bean,the container will look for an instance in the pool,if it finds one,it does not call create(),instead it sets its session context,then it calls bean's ejbCreate() for initialization. am i right?should a stateless session bean have ejbCreate()?what is the actual flow of execution?

create()->setSessionContext()->ejbCreate()->businessMethods()->passivate()/activate()->remove(){ejbRemove()}
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You're confusing alot of stuff here.

1) "create" is only invoked by the client -- never the container.
2) The time that "ejbCreate" is invoked depends on the bean type.

I'd type further about it, but I don't quite know how without spitting out everything I know about the various beans' lifecycle.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
kriti sharma
Ranch Hand

Joined: Feb 16, 2001
Posts: 160
Originally posted by Nathaniel Stoddard:

1) "create" is only invoked by the client -- never the container.


after create is invoked at the client, where does the control go,where is the executable code...the code that runs before ejbCreate?
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
As I said, it depends on the bean type.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
it depends on the bean type.
yeah. but also on the vendor, how the creation actually takes place.

i-Ok, Using JNDI get the reference of an EJBHome Object. (it might even be instantiated while you call the lookup. or already have been instantiated by the appln server at startup)
Now the Home stub object is also available at the client.
ii-the container creates a Bean object or gets an already created bean instance object from a pool-like container.. sets a SessionContext or EntityContext etc.
iii-the home at the server also coordinates the EJBRemote I such that an EJBRemote object is instantiated and it is passed a reference to the actual bean object in part ii.
iv-the stub of the remote component object is sent to the client.
that is all..

hope clarifiable?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: who owns create() ?
 
Similar Threads
Stateless Sessionbean ejbCreate() mtd
Getting EJBObject for SLSB in ejbCreate()
getEJBObject in setSessionContext
life cycle and access to beanness
Access to EJBObject from within ebjCreate of a stateless SessionBean