KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > stests > appli > OrderEntryClerkClient


1 // OrderEntryClerkClient.java
2
// mini Client for accessing bean OrderEntryClerk
3

4 package org.objectweb.jonas.stests.appli;
5
6 import javax.naming.Context JavaDoc;
7 import javax.naming.InitialContext JavaDoc;
8 import javax.naming.NamingException JavaDoc;
9 import javax.rmi.PortableRemoteObject JavaDoc;
10
11 /**
12  *
13  */

14 public class OrderEntryClerkClient {
15
16     static Context JavaDoc ctx = null;
17     static OrderEntryClerkHome oechome = null;
18     static CustomerHome chome = null;
19
20     public static void main(String JavaDoc[] arg) {
21
22     // Get InitialContext
23
try {
24         ctx = new InitialContext JavaDoc();
25     } catch (NamingException JavaDoc e) {
26         e.printStackTrace();
27         System.exit(2);
28     }
29
30     // Lookup bean home
31
String JavaDoc oecName = "OrderEntryClerkHome";
32     String JavaDoc cName = "CustomerHome";
33     try {
34         oechome = (OrderEntryClerkHome) PortableRemoteObject.narrow(ctx.lookup(oecName), OrderEntryClerkHome.class);
35         OrderEntryClerk oecbean = oechome.create();
36         oecbean.createAllTables();
37         System.out.println("all tables created");
38         oecbean.setCustomer(new Integer JavaDoc(9));
39         oecbean.addOrderLine(new Integer JavaDoc(20),24);
40         oecbean.addOrderLine(new Integer JavaDoc(10),12);
41         oecbean.addOrderLine(new Integer JavaDoc(1),1);
42         oecbean.addOrderLine(new Integer JavaDoc(2),6);
43         String JavaDoc numorder = oecbean.placeOrder();
44         System.out.println("numorder = "+numorder);
45         oecbean.setCustomer(new Integer JavaDoc(5));
46         oecbean.addOrderLine(new Integer JavaDoc(20),24);
47         oecbean.addOrderLine(new Integer JavaDoc(10),12);
48         oecbean.addOrderLine(new Integer JavaDoc(1),1);
49         oecbean.addOrderLine(new Integer JavaDoc(2),6);
50         numorder = oecbean.placeOrder();
51         System.out.println("numorder = "+numorder);
52
53     } catch(Exception JavaDoc e) {
54         e.printStackTrace();
55         System.exit(2);
56     }
57
58     // ...
59
}
60 }
61
Popular Tags