KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > examples > CallbackClient


1 package org.sapia.ubik.rmi.examples;
2
3 import org.sapia.ubik.rmi.Consts;
4 import org.sapia.ubik.rmi.naming.remote.RemoteInitialContextFactory;
5 import org.sapia.ubik.rmi.server.Hub;
6 import org.sapia.ubik.rmi.server.Log;
7
8 import java.util.Properties JavaDoc;
9
10 import javax.naming.InitialContext JavaDoc;
11
12
13 /**
14  * @author Yanick Duchesne
15  * <dl>
16  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
17  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
18  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
19  * </dl>
20  */

21 public class CallbackClient {
22   /**
23    * Constructor for LookUpEg.
24    */

25   public CallbackClient() {
26     super();
27   }
28
29   public static void main(String JavaDoc[] args) {
30     try {
31       Log.setWarning();
32
33       Properties JavaDoc props = new Properties JavaDoc();
34
35       // ENABLES CALL BACK
36
System.setProperty(Consts.CALLBACK_ENABLED, "true");
37
38       // ENABLES MARSHALLING
39
System.setProperty(Consts.MARSHALLING, "true");
40
41       props.setProperty(InitialContext.PROVIDER_URL, "ubik://localhost:1100");
42       props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,
43         RemoteInitialContextFactory.class.getName());
44
45       InitialContext JavaDoc ctx = new InitialContext JavaDoc(props);
46       Foo f = (Foo) ctx.lookup("Foo");
47
48       for (int i = 0; i < 10; i++) {
49         System.out.println(f.getBar().getMsg());
50         Thread.sleep(2000);
51       }
52
53       Hub.shutdown(30000);
54     } catch (Exception JavaDoc e) {
55       e.printStackTrace();
56     }
57   }
58 }
59
Popular Tags