KickJava   Java API By Example, From Geeks To Geeks.

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


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

22 public class CallbackFoo implements Foo {
23   public CallbackFoo() throws java.rmi.RemoteException JavaDoc {
24   }
25
26   /**
27    * @see org.sapia.ubik.rmi.Foo#getBar()
28    */

29   public Bar getBar() throws RemoteException JavaDoc {
30     return new UbikBar();
31   }
32
33   public static void main(String JavaDoc[] args) {
34     try {
35       Log.setWarning();
36
37       Properties JavaDoc props = new Properties JavaDoc();
38
39       // ENABLES CALL BACK
40
System.setProperty(Consts.CALLBACK_ENABLED, "true");
41
42       // ENABLES MARSHALLING
43
System.setProperty(Consts.MARSHALLING, "true");
44
45       props.setProperty(InitialContext.PROVIDER_URL, "ubik://localhost:1099");
46       props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,
47         RemoteInitialContextFactory.class.getName());
48
49       InitialContext JavaDoc ctx = new InitialContext JavaDoc(props);
50
51       ctx.rebind("Foo", new CallbackFoo());
52
53       System.out.println("UbikFoo started...");
54
55       while (true) {
56         Thread.sleep(10000);
57       }
58     } catch (Throwable JavaDoc t) {
59       t.printStackTrace();
60     }
61   }
62 }
63
Popular Tags