Writing a Client

Listing 12.15 shows a client that is used to test the order-line item relationship.

Listing 12.15. The Full Text of day12/Client.java
 package day12; import java.util.*; import javax.naming.*; import javax.ejb.*; public class Client { public static void main(String[] args) { print("Starting Client . . .\n"); Context initialContext = null; OrderHome orderHome = null; Order order = null; try { print("Looking up the order home via JNDI.\n"); initialContext = new InitialContext(); Object object = initialContext.lookup("day12/Order"); orderHome = (OrderHome) javax.rmi.PortableRemoteObject.narrow(object,OrderHome.class); object = (Order)orderHome.create("1", "Submitted", 100); order = (Order) javax.rmi.PortableRemoteObject.narrow(object,Order.class); ...

Get Sams Teach Yourself EJB in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.