Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

does the stub depend on the client location?

 
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?
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • 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
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic