Cedric Beust wrote:

> > From: A mailing list for Enterprise JavaBeans development
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Richard Monson-Haefel
>
> > We need some mechanism for converting from the remote to local
> > references and visa versa.
>
> Is it really needed?
>
> If you are a client to the EJB, you obviously don't have access to its local
> interface.
>
> >From the bean perspective, looking up the local interface of another EJB is
> a simple JNDI look-up, or even simpler if the other EJB is ejb-ref'ed.
>
> It doesn't make much sense to me, but maybe I'm missing something.

It will be common, IMO, for some beans to implement both a local and remote
interface. Especially coarse grained entity beans.

For example, Customer maintains a CMR with the coarse grained entity, SalesRep,
using the SalesRep's local interface.  It's very possible that some remote
client would want to obtain a reference of the Customer's SalesRep.  Below is
the business method, which is implemented by the Customer beans remote
interface, that would do that.  Following that is a method that allows a remote
client to set the sales rep for the bean.

public abstract class CustomerBean extends javax.ejb.EntityBean {

...

public SalesRepRemote getSalesRepresentative( ){

    SalesRepLocal salesRepLocal = this.getSalesRep( );
    return (SalesRepRemote) ejbContext.getEJBObject( salesRepLocal );

}

public void setSalesRepresentative(SalesRepRemote salesRepRemote){

    SalesRepLocal salesRepLocal = ejbContext.getEJBLocalObject( salesRepRemote
);
    this.setSalesRep( salesRepLocal );

}

public abstract void setSalesRep(SalesRepLocal rep);
public abstract SalesRepLocal getSalesRep( );

...

}


Now in most interactions between the Customer and the SalesRep, you'll be using
the local interfaces and business methods that work those interface, but it
would be convenient, although not critical, to provide some mechanism for
converting a reference.  Obviously, you want to work with entity beans
"container-side" as much as possible through session bean facades ( I've been
preaching this for over 2 years ), but having the flexibility to do otherwise is
good.  You also have to make sure that the remote reference points to a bean
that is collocated with the bean doing the conversion, otherwise it won't work,
but this is also true if you use JNDI and local finder methods.

Richard
--
Richard Monson-Haefel
Author of Enterprise JavaBeans, 2nd Edition  (O'Reilly 2000)
Co-Author of Java Message Service (O'Reilly 2000)
http://www.jMiddleware.com

===========================================================================
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