This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

ejbCreate in remote interface?

 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
We have create() method in Home interface and ejbCreate() in Bean class. whenever we invoke create() method of the home interface corresponding ejbCreate() method is invoked.

will it still work if we declare ejbCreate() method in the remote method, and invoke it as a normal remote method?

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

Although I never tried this but I think it should n't work if you define this method in Remote Interface. Because its a life cycle callback method which is implemented by container. but if you define it in Remote interface then you need to implement it like other Business methods.

I was just going thru a EJB book which specifies the methods that needs to be specified in each interface and the role of each interface. which means specifying ejbCreate method in Remote interface will violate these rules. Moreover, RemoteHome interface extends EJBHome interface and must specify create,remove and finder(for entity bean) methods.
 
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would "break the rules" doing it.
The EJB container is responsible for creating EJB objects, not you.
Home interface is dedicated to creation and destruction. You cannot decide to replace it by your own functions, as the container must be able to decide if it will create and object or reuse an existing one, etc..., etc.

So, this is definitively not a good idea.
Even if I've never tried it, I believe exposing ejbCreate in the Remote interface would call the ejbCreate of your bean.
But you would miss all the added value of the container, so I'm quite sure the EJB would not be properly created and instanciated.
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic