KickJava   Java API By Example, From Geeks To Geeks.

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


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

20 public class JndiDiscoListenerEg implements JndiDiscoListener {
21   /**
22    * Constructor for ServiceDiscoListenerExample.
23    */

24   public JndiDiscoListenerEg() {
25     super();
26   }
27
28   /**
29    * @see org.sapia.ubik.rmi.naming.remote.discovery.JndiDiscoListener#onJndiDiscovered(Context)
30    */

31   public void onJndiDiscovered(Context ctx) {
32     System.out.println("JNDI discovered!!!!");
33   }
34
35   public static void main(String JavaDoc[] args) {
36     try {
37       Properties props = new Properties();
38       props.setProperty(InitialContext.PROVIDER_URL, "ubik://localhost:1099");
39       props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,
40         RemoteInitialContextFactory.class.getName());
41
42       InitialContext ctx = new InitialContext(props);
43
44       JndiDiscoListenerEg sdisco = new JndiDiscoListenerEg();
45
46       ReliableLocalContext rctx = ReliableLocalContext.currentContext();
47       rctx.addJndiDiscoListener(sdisco);
48
49       System.out.println("Waiting for jndi discovery. Press CTRL-C to stop.");
50
51       while (true) {
52         Thread.sleep(100000);
53       }
54     } catch (Exception JavaDoc e) {
55       e.printStackTrace();
56     }
57   }
58 }
59
Popular Tags