KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.sapia.ubik.rmi.examples;
2
3 import org.sapia.ubik.rmi.naming.remote.RemoteInitialContextFactory;
4
5 import java.util.Properties JavaDoc;
6
7 import javax.naming.InitialContext JavaDoc;
8
9
10 /**
11  * @author Yanick Duchesne
12  * <dl>
13  * <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>
14  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
15  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
16  * </dl>
17  */

18 public class LoadBalanceEg {
19   /**
20    * Constructor for LookUpEg.
21    */

22   public LoadBalanceEg() {
23     super();
24   }
25
26   public static void main(String JavaDoc[] args) {
27     try {
28       Properties JavaDoc props = new Properties JavaDoc();
29       props.setProperty(InitialContext.PROVIDER_URL, "ubik://localhost:1099");
30       props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,
31         RemoteInitialContextFactory.class.getName());
32
33       InitialContext JavaDoc ctx = new InitialContext JavaDoc(props);
34
35       Foo f = (Foo) ctx.lookup("Foo");
36
37       while (true) {
38         System.out.println(f.getBar().getMsg());
39         Thread.sleep(1000);
40       }
41     } catch (Exception JavaDoc e) {
42       e.printStackTrace();
43     }
44   }
45 }
46
Popular Tags