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...