Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

does the stub depend on the client location?

 
Jingyi Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I have a remote Client R and two remote ejb A and B. A and B are remote as well.

I have a business method in A like this:

BRemote getB () throws RemoteException {
Context ct = new InitialContext ();
HomeB hb = (HomeB) PortableRemoteObject.narrow ( ct.lookup ( "java:comp/env/B" ), HomeB.class );
BRemote rb = hb.create ();
return rb;
}

Then in client R:
void doSth () throws RemoteException {
//after get Remote component reference for A, ar
BRemote br = ar.getB ();
br.callBussinessMethod ();
}

Would the above code work?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...two remote ejb A and B. A and B are remote as well.
Not sure what you mean by that...
 
Jingyi Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean ejb A and ejb B are not in the same heap.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I thought

Then it's the same problem as described here, I guess...
 
Jingyi Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, we have three objects: ejb A, ejb B and client R. R is remote to A and B, A and B are not on the same heap ( Remote each other ).
Suppose I have a buiness method in ejb A:

// in ejb A, get remote component interface reference of B
public BRemote getB () throws RemoteException {
Context cxt = new InitialContext ();
Object o = cxt.lookup ( "java:comp/env/ejb/B" );
BHome bh = (BHome) PortableRemoteObject.narrow ( o, BHome.class );
BRemote br = bh.create ();
return br;
}

// in client R
public void doSth () throws RemoteException {
Context cxt = new InitialContext ();
Object o = cxt.lookup ( "java:comp/env/ejb/A" );
AHome ah = (AHome) PortableRemoteObject.narrow ( o, AHome.class );
ARemote ar = ah.create ();
BHome br = ar.getB (); // call ejb A's buiness method to get B's
// component interface reference
br.callSomeBusinessMethod (); // does work here?
}
 
Jingyi Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic