Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

About remote client

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic