The moose likes EJB and other Java EE Technologies and the fly likes ejbCreate in remote interface? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejbCreate in remote interface?" Watch "ejbCreate in remote interface?" New topic

ejbCreate in remote interface?

Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
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?


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346

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.
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
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.

/ JeanLouis<br /><i>"software development has been, is, and will remain fundamentally hard" (Grady Booch)</i><br /> <br />Take a look at <a href="" target="_blank" rel="nofollow">Agile OpenUP</a> in the Eclipse community
I agree. Here's the link:
subject: ejbCreate in remote interface?
It's not a secret anymore!