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

can home business method return ....

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

HFEJB PgNo. 325 it sayz

"Client can call a home business method that returns a reference to bean's component interface".
My question is : "is it actually possible for a home business method to return a component interface?".

On PgNo.278 it contradicts the above written statement.

Thankz,
Puneet
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have the book with me, but it seems that first statement is wrong. Business methods execute with the bean still in the pool, so there is no component interface. Page 180 of the EJB 2.0 spec shows that ejbHome methods can't access the EJBObject (or EJBLocalObject), so how could they return a reference to it?
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

ejbSelect can return a remote/local component interface.
So why can't we call ejbSelect inside ejbHome method and return the same thing.

Micheal
 
Puneet Vashisht
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You r very right Greg, because ejbHome methods can't access the EJBObject, there's no point of returning it.
According to HFEJB Pg No.278
"Home business methods can return something other than EJB object references! They are perfect for queries where the client just wants entity data, not references to themselves"
"They are also great for batch operations or anything else you might want to do with more than open specific entity, when you dont want to return references to the component inteface"

All these point justify that a home business method cannot return component interfaces.

But nothing stops from a select method to return component interfaces, and it is perfectly acceptable to call a select method from inside a home.

Secondly, HFEJB PG No. 325 sayz
"There are three ways to retrun a reference to the EJBObject":
1)Finder methods
2)Create methods from home.
3)Client calls a home business method that returns a reference to the bean's component interface.

I'm very confused...

Any help is well appreciated.

Thankz
Puneet
 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I think, ejbHome methods CAN be used to return component interface.
But practically, bean provider may not use this method to return component interface. (Because he could very well define find method, which means less source code)

Regarding returning component interface, ejbHome method can return component interface, but until any method gets called in that EJBObject, container may not assign any entity object.

But still the bean which is used to execute ejbHome method is in pooled state. (i.e.) not attached to any entity.

Any help is much appreciated, to clear this out.

Micheal.
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My understanding is that you cannot do a context.getEJBObject() from a home business method. The bean executes the method from within the pool and is not tied to the EJBObject of any particular entity. But you can always do a JNDI look up, get the home interface of a bean, do a find by primary key, get the component interface reference and THEN return it to the caller, right?
 
Puneet Vashisht
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i'm still very confused, because nothing stops me from calling a select method from a home business method, and wid select methods v can alwayz return component interfaces.

thankz,
Puneet
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I read that page 278, and I believe all it's saying is that ejbSelect calls can return something besides the component interface or a collection of the component interfaces, not that it has to. An ejbSelect could also return a component interface or a collection of them, but then why not use a finder? Anyway, a home business method, in fact, could return a component interface, by calling an ejbSelect method. The bean would still be in the pool though, and in no way related to the remote interface(s) it was returning. The first time the client called a business method on that remote interface, the container would pull a bean out of the pool and call its ejbLoad method. It would be a strange coincidence if the bean instance pulled out of the pool was the same bean instance that executed the home business method.

B Satish's example is also correct. In fact, you can get the home interface from the ejbHome methods, so you could skip the JNDI lookup.

Great question, by the way. I think I've got everything straight in my mind now, but I'll be checking back to see if there are any corrections.
 
Puneet Vashisht
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks greg
reply
    Bookmark Topic Watch Topic
  • New Topic