create() method not in API

Why create() method is not in J2EE API.
[46 byte] By [amarjavasea] at [2007-11-26 18:33:20]
# 1

I assume you're asking why it's not in the EJB API in J2EE?

In EJB 2.1 and earlier it does not appear in the actual javax.ejb.* API

because the create() signature is bean specific. That allows the

developer to decide what information should be passed to a Stateful

Session Bean or 2.x Entity Bean at creation time. Stateless session

beans never take any parameters to their create method.

In EJB 3.0, Home interfaces were removed so there aren't any create

mehods needed.Stateful session beans are created as a side

effect or lookup or injection.To pass in specific initialization state

you just define a business method and call it after acquiring the

bean reference.

--ken

ksaksa at 2007-7-9 6:07:25 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Thank you very much Ken.As create() method is bean specific, it is madatory to use it to get Remote Reference, or is there any alternative?Amar
amarjavasea at 2007-7-9 6:07:25 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

As Ken already said, EJB3 does not use Home interfaces and its factory methods, so EJB3 usage is an alernative.

However, if you have to use EJB2.1 or lower, the specs requires to implement exactly one create method for a stateless session bean:

create() in the Home interface and the corresponding ejbCreate() method in the bean implementation.

For stateful session beans, at least one create(PARAM) in the home interface and its corresponding ejbCreate(PARAMS) in the bean class must be defined. In this case create() and ejbCreate() can be overloaded, as long as the create has a corresponding ejbCreate.

For entity beans, create methods or optional, however, each create(PARAMS) definened in the home interface must have a corresponding ejbCreate(PARAMS) and an ejbPostCreate(PARAM) in the bean class

robert@javixa at 2007-7-9 6:07:25 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Thank you very much Ken.

The concept is clear.

But i've a queation reg bean specific.

What exactly you mean by bean specific.?.

Where we can find it?.

If i'm not wrong, bean specific means is it Vendor specific.

My req is to just give one example on this bean specific.

Thanks in Advance.

Amar

amarjavasea at 2007-7-9 6:07:25 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

Hi Amar,

What that means is that in the EJB 2.x (and earlier) programming model for Stateful Session

Beans, the developer decides what the signature of the create() method should be. It all

depends what initializaion information needs to passed in. Naturally, that will be different for

different beans.

E.g., a Shopping Cart SFSB might have :

public ShoppingCart create(String userId);

whereas a simple Counter SFSB might not need any initialization info :

public Counter create();

That's why the create() method was not put in the javax.ejb.SessionBean interface. It

was up to the developer.

--ken

ksaksa at 2007-7-9 6:07:25 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6
Hi Ken,Thak you very much. Now i got clear idea on it.Amar
amarjavasea at 2007-7-9 6:07:25 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...