• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About remote client

 
Tang Yue
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Oreilly EJB 3.0 20.4.2 "JAVA EE Application Client Components", there is an example:
public class MyJavaEEClient
{
private static @EJB ProcessPaymentRemote processPayment;
public static void main(String [] args) {
InitialContext
jndiCntx = new InitialContext( );
Object ref = jndiCntx.lookup("java:comp/env/ejb/TravelAgent");
TravelAgentRemote bean = (TravelAgentRemote)
PortableRemoteObject.narrow(ref,TravelAgentRemote.class);
Customer cust = new Customer( );
cust.setName("Bill");
bean.setCustomer(cust);
TicketDO ticket = bean.bookPassage(...);
}
}


The book says
"Notice that the client component did not need to use a network-specific
JNDI InitialContext. In other words, we did not have to specify the service provider in order to connect to the Java EE server. This is the
real power of the Java EE application client component: location transparency . The client component does not need to know the exact
location of the Ship EJB or choose a specific JNDI service provider; the JNDI ENC takes care of locating the enterprise bean."

But exactly how does the JNDI ENC take care of all these?
If the parameters of InitialContext() are not specified, how does the program locate the remote bean ProcessPaymentRemote? The book doesn't mention jndi.properties either.

Does this client has its own ENC?


In short, this is too magic for me...
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi <Cant remember your name >

My understanding is (may be wrong), since application is java ee application client, container provides its environmental properties. if you change default jnp port 1099 to something else, still application client can lookup without any property values.

Regards
Cham
[ November 18, 2008: Message edited by: Chaminda Amarasinghe ]
 
Tang Yue
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Object ref = jndiCntx.lookup("java:comp/env/ejb/TravelAgent");"

This client use a local jndi lookup. But How can the container for this client(on another machine) locates the remote bean?

As far as I know, the client should use a global lookup like " jndiCntx.lookup("TravelAgent/Remote") "

But why the example doesn't use a global lookup?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic