Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stateless ejbCreate can access Component

 
Dimiter Stoilov
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers

Following problem buzzs me,

Stateless Bean creation is different for container and client:

1. Container creation - newInstance >> setSessionContext >> ejbCreate
Bean stays in pool. It's associated with Home, but NO EJBObject(Component interface not created yet)

2. Client creation - create() >> new EJBObject

Bean things which we can do in ejbCreate are:
a. sessionContext .getEJBHome
b. sessionContext .getEJBObject
c. JNDI access to java:comp/env


My question is:
How is possible in ejbCreate to access EJBObject, when there is no Component created yet?
Bean is in pool, there should be one Home and no Component yet. EJBObject is created from client.

Thank you for your time
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dimiter Stoilov:
Hi ranchers



2. Client creation - create() >> new EJBObject

Bean things which we can do in ejbCreate are:
a. sessionContext .getEJBHome
b. sessionContext .getEJBObject
c. JNDI access to java:comp/env


My question is:
How is possible in ejbCreate to access EJBObject, when there is no Component created yet?
Bean is in pool, there should be one Home and no Component yet. EJBObject is created from client.

Thank you for your time


This is not true Dimiter. For stateless session beans, the create() method invoked by the client doesn't trigger the invocation of ejbCreate() on the bean instance. It's the container that decides when and how many stateless session bean to create and put them in the pool. When the client invokes create(), the container makes an EJBObject, creates a stub and passes it to the client, but it will not take a bean out from the pool until the client will invoke a business method. But for each ejbCreate() invoked by the container, and EJBObject can be retrieved (and here I think the behaviour is container specific). The point is that the container can make an EJBObject for a stateless session bean whenever it wants, because they are all the same! It only must be of the same type (I mean, from the same bean class)
 
Dimiter Stoilov
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Marco,

For stateless MyBean Container calls :
1. newInstance
2. setSessioCtx
3. ejbCreate

So if i understood right, In point 3 even though there is no EJBObject yet, in MyBean.ejbCreate i can access MyComponent. Container will create one for me. In a container specific way.

Sound strange because i didn't read it anywhere ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic