KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > samplehttp > beans > SessClient


1 // SessClient.java
2
// mini Client for accessing bean Sess
3

4 package samplehttp.beans;
5
6 import java.rmi.RemoteException;
7 import java.util.Collection;
8 import javax.naming.Context;
9 import javax.naming.InitialContext;
10 import javax.naming.NamingException;
11 import javax.rmi.PortableRemoteObject;
12
13 /**
14  *
15  */

16 public class SessClient {
17
18     static Context ctx = null;
19     static SessHome home = null;
20
21     public static void main(String[] arg) {
22
23     // Get InitialContext
24
try {
25         ctx = new InitialContext();
26     } catch (NamingException e) {
27         e.printStackTrace();
28         System.exit(2);
29     }
30
31     // Lookup bean home
32
String bName = "sessSessSLRHome";
33     try {
34         home = (SessHome) PortableRemoteObject.narrow(ctx.lookup(bName), SessHome.class);
35     } catch(Exception e) {
36         e.printStackTrace();
37         System.exit(2);
38     }
39
40     // ...
41
}
42 }
43
Popular Tags