• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB naming context  RSS feed

 
Gabriel Buheler
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a newbie in EJB.
I understand that as of EJB 2.0 spec we can use Local and Remote interfaces. It stands clear to me that with Local there's no parameter's serialization, thus better performance 'cause on the same JVM.
when using different JVM's with remote...
If I am on a LAN and I have deployed an EJB using remote interfaces. I do not know the scope of my look up search done by the ejb client (probably a servlet).
I am looking an EJB remote home interface something like this...
try{
Context context = new InitialContext();
Object homeObject = context.lookup("BonusCalculatorHome");
thebonusEJBHome = (bonusEJBHome)
PortableRemoteObject.narrow(homeObject,bonusEJBHome.class);
}catch(javax.naming.NamingException ne){
System.out.println("An error ocurred with a NamingException.");
}
It means that if I am running this code on a servlet on my machine A, and the EJB is deployed on a machine B I can reach it, right? But on which scope? I mean, if the machine B (where ejb deployment) is on the other side of the world, but on a public machine, I will reach it anyway?
thanks
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where your program goes to resolve names when using JNDI is determined by parameters used when creating the InitialContext. When you use the default constructor, InitialContext uses properties laid out in a jndi.properties file locally. You can also create your own and pass it to the constructor.
For a machine A to be able to resolve home interfaces bound on a remote JNDI naming service (machine B), you will need to pass InitialContext some additional information so it will look toward machine B to resolve those names. What properties do you need to pass? Well, you should consult the documentation of your JNDI naming service, or the server that has it embedded, like JBoss, or whatever application server you are using.
And then I believe you'll be able to do what you want. Somebody pop in here if I'm off on some of this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!