aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes About remote client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "About remote client" Watch "About remote client" New topic
Author

About remote client

Tang Yue
Ranch Hand

Joined: Nov 11, 2008
Posts: 40
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...


Houston Rockets go go go!
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
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

Joined: Nov 11, 2008
Posts: 40
"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?
 
jQuery in Action, 2nd edition
 
subject: About remote client