Hey

Javier Deniz wrote:
> Sorry if this has already already discussed. In that case, can you point
> me to such
> discussion? (for example, EJB-interest XX/Aug/98 or similar).
>
> In EJB spec, section 9.4.1 (about method ejbPostCreate) we read:
>
>    The EJB object identity is available during the ejbPostCreate()
> method.
>    The instance may, for example, pass its own EJB object reference to
> another
>    EJB object as a method argument.
>
> Let me see if I have well understood that?
> Consider 3 cases depending who am I giving that reference to:
>    1) a client
>          How did this EJB got the reference to a client? Is that
> possible?
>          I remember to have used callbacks to client in CORBA but I have
>
>          not seen much of that yet in EJB.

The client object can be a parameter of the create method.

>    2) another EJB object
>          I would expect such an object being another client of "this
> EJB".
>          In that case, it should be able to obtain a reference to "this
> object"
>          through JNDI and the home interface as any other client would.
>          However, let us suppose that it is possible and I write:
>              otherEJB.takeThisRef(this)
>          Then otherEJB keeps myRef in a variable called you and
> eventually
>          does, for example:
>              you.yourBusinessMethod()
>          In that case, the container has no control over that call so it
> cannot
>          control the transaction in which that method will run.
>          And what if that object does something like
>              you.ejbPostCreate()     // without any previous
> ejbCreate,...
>              you.ejbPassivate()       // Uumm!
>              etc.
>           Also, "otherEJB" (or its class) would be using the type of
> "thisObject",
>           say "ThisBean" as it has a method with signature
>                 public void takeThisRef (ThisBean beanRef)

You are never *ever* allowed to send "this" to another EJBean. You can
only send the result of EntityContext.getEJBObject() (which is only
available in and after ejbPostCreate). This ensures that the container
can always intercept calls.

>   3) another Java object
>           All the previous comments apply.
>           Is there anything new to consider here? I can think for
> example that
>           a method in such object does not even run in a transaction
> (managed
>           by the container). I don't know if there would be further
> implications
>           with this....<<too much?? I am not on firm land here!>>

The above assumption that you made is not correct so there's no problem.

> I would be interested in how useful it may be something like that.
> What was the spirit of the EJB spec when that paragraph was written.
> Am I missing something here. Isn't it "this" what is passed in a
> parameter.

Nope. The EJBObject.

> In that case, what would it be? I would expect at least that it is not
> the actual
> bean implementation but the class created by the container that
> implements
> the remote interface and intercepts all the business method calls.

Exactly.

/Rickard

--
Rickard �berg

Computer Science student@LiTH
@home: +46 13 177937
Email: [EMAIL PROTECTED]
Homepage: http://www-und.ida.liu.se/~ricob684

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to