• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Stateless ejbCreate can access Component

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic