• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Session bean create method.

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Accordint to one book:-
"The create() method is invoked by the client to get a reference
to the component interface of a session bean. It does not necessarily mean that a bean instance will be created upon receiving this call. If the bean is a stateless session bean, the container may already have created some bean instances and may use one of those instances to service the method calls. Or the container may wait until the client invokes a business method before it creates a bean instance."
My question is, if a bean instance is created when business method is called then what will be the value of remote component interface between create and before the business method is called. Will it be null?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vivek Hello,
Look at your following, last line in your quotes

"Or the container may wait until the client invokes a business method before it creates a bean instance."

Here how container can wait for business method unless and until client get reference of Remote ie. component interface.
Any way container already put some bean ready in pool, and it keeps creating in case suppose all the bean in pool in use.
When client calls create() of Home interface, here in application server until server has object of component interface it wan't give response to the client or it might be exception that server cannot create object.

So, the moral of the story what i feel is that above statement makes you confuse, however it might not be the case in reality because actual implementation is done by container.

So enjoy...
If you are not agree please tell me.
 
vivek kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, U mean to say that the flow will not procees till we successfully run create() method( or say some exception).
I am not sure about it, what some of my friends told me is like this..
"When we call create method on home interface container will create an EJBObject and return the referecce of this EJBObject. Now when we call a business method on this EJBObject reference,then the actual bean will be create(If it is not in the pool)"
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vivek,

you have understood it right.. now dont confuse yourself. Refer the first post you have wrote. the container may already have created some bean instances and may use one of those instances to service the method calls. Now if it doesnt have one then its again said in your post that it would wait the container may wait until the client invokes a business method before it creates a bean instance..
Now coming to your question whether the EJBObject would be null. No it will not be null. When you actually make a call for the bean by invoking the business method from remote interface then the bean instance would be created if it cant find one in the pool. Create method of EJBHome would only return the instance of the remote object but not the actual instance of the bean.
 
Makwana Deepak
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Badri Nath Hello,

Is that the case.....

"Create method of EJBHome would only return the instance of the remote object but not the actual instance of the bean."

So you mean that it does not create object of actual bean when we ask container for the same, I am still not agree with your above mentioned statement can you please breife it more....

I would be glad to you if you can Badri nath.

Regards,
Makwana Deepak
 
vivek kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,
Let me explain you. We have two entity on severe EJBObject and Actual Bean. Client can never access actual mean instance,it will always invoke method on EJBObject instance.When we call create method, an instance of EJBObject is creates and is returned to client. But this EJBObject is not attached to any Bean instance. When we call a business method then the container pull a bean insatce from pool and attach this bean instance with the returned EJBObject and call the business method.
- Client call goes to EJBObject
- Container pull a bean instacne and attach it to the EJBObject on which client has called a business method.
- then this EJBObject instace delegate this methos to bean instance
 
Makwana Deepak
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vivek Hi,

Thank you very much, I got the exact idea of how the EJBObject is different from the actual bean, I was confident because i read somewhere that EJBObject is the actual bean, but after reading your explanation I came to know that it is the actual bean but it creates it when we actually call business methods on that.

Thanks & Regars Vivek,
Makwana Deepak.
 
machines help you to do more, but experience less. Experience 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