01: package jca.simple;
02:
03: import javax.naming.InitialContext;
04:
05: import java.util.Hashtable;
06:
07: public class SimpleClient {
08:
09: public static void main(String args[]) throws Exception {
10:
11: final boolean OC4J = true;
12:
13: InitialContext iniCtx = null;
14: Hashtable env = new Hashtable();
15: if (OC4J) {
16: env
17: .put("java.naming.factory.initial",
18: "com.evermind.server.ApplicationClientInitialContextFactory");
19: env.put("java.naming.provider.url",
20: "ormi://localhost:23791/Simple");
21: env.put("java.naming.security.principal", "oc4jadmin");
22: env.put("java.naming.security.credentials", "oc4jadmin");
23: iniCtx = new InitialContext(env);
24: } else {
25: iniCtx = new InitialContext();
26: }
27:
28: Object ref = iniCtx.lookup("SimpleBean");
29: SimpleHome home = (SimpleHome) ref;
30: Simple simple = home.create();
31: System.out.println("Created Simple");
32: simple.put(args[0], args[1]);
33: System.out.println("Simple.get('" + args[0] + "') = "
34: + simple.get(args[0]));
35: }
36: }
|