Forums Register Login
Where are create() and ejbCreate() methods
Hi All,
Was going through the API spec. of J2EE1.4 and was confused at one point.

The interfaces SessionBean and EntityBean does not have ejbCreate() method declared in them. Is it not mandatory to have an ejbCreate() in these interfaces? How do we force bean developers to have this method in their bean code then?

Also, there is no create() method in EJBHome. How will we mandate this in our home interface. I know that the vendor specific application server is going to generate the "Home Object" code for me, but it will use my home interface and create the home object. Right?

So how do we mandate the presence of create() and ejbCreate() in our Home interface and Bean respectively? Please explain!
The EJB spec isn't completely enforced by the compiler. That is, a bean that doesn't have an ejbCreate() may still compile, but it won't be able to successfully deployeed into an EJB container. That's where the term "contract" comes from. The compiler will let us violate the contract, but we promise not to.
Nathaniel! Thanks for your reply! But, why was this not forced at the interface itself? If forced, the compiler itself will mandate these methods to be present in the Bean and the Home interface class?

Any restrictions/problems because of which they were not able to include this method in the interface?
Well, for entity beans surely the interface cannot specify a parameterless ejbCreate() method as you may need one or more create methods all taking one or more parameters.

This thread has been viewed 745 times.

All times above are in ranch (not your local) time.
The current ranch time is
Oct 17, 2018 11:10:07.