KickJava   Java API By Example, From Geeks To Geeks.

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


1 // DistrictClient.java
2
// mini Client for accessing bean District
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 DistrictClient {
15
16     static Context JavaDoc ctx = null;
17     static DistrictHome home = null;
18
19     public static void main(String JavaDoc[] arg) {
20
21     // Get InitialContext
22
try {
23         ctx = new InitialContext JavaDoc();
24     } catch (NamingException JavaDoc e) {
25         e.printStackTrace();
26         System.exit(2);
27     }
28
29     // Lookup bean home
30
String JavaDoc bName = "DistrictHome";
31     try {
32         home = (DistrictHome) PortableRemoteObject.narrow(ctx.lookup(bName), DistrictHome.class);
33
34     } catch(Exception JavaDoc e) {
35         e.printStackTrace();
36         System.exit(2);
37     }
38
39     // ...
40
}
41 }
42
Popular Tags