KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > naming > remote > ClientListener


1 package org.sapia.ubik.rmi.naming.remote;
2
3 import java.io.IOException JavaDoc;
4
5 import org.sapia.ubik.mcast.AsyncEventListener;
6 import org.sapia.ubik.mcast.EventChannel;
7 import org.sapia.ubik.mcast.RemoteEvent;
8 import org.sapia.ubik.net.ServerAddress;
9 import org.sapia.ubik.rmi.server.Log;
10
11
12 /**
13  * @author Yanick Duchesne
14  * <dl>
15  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <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 ClientListener implements AsyncEventListener {
21   private EventChannel _channel;
22   private ServerAddress _addr;
23
24   public ClientListener(EventChannel channel, ServerAddress addr) {
25     _channel = channel;
26     _addr = addr;
27   }
28
29   /**
30    * @see org.sapia.ubik.mcast.AsyncEventListener#onAsyncEvent(RemoteEvent)
31    */

32   public void onAsyncEvent(RemoteEvent evt) {
33     if (evt.getType().equals(Consts.JNDI_CLIENT_PUBLISH)) {
34       ServerAddress addr = _channel.getView().getAddressFor(evt.getNode());
35
36
37       try {
38         if (addr != null) {
39           if(Log.isDebug()){
40             Log.debug(getClass(), "Dispatching JNDI discovery event to expecting client: " + addr);
41           }
42           _channel.dispatch(addr, Consts.JNDI_SERVER_DISCO, _addr);
43         }
44         else{
45           if(Log.isDebug()){
46             Log.debug(getClass(), "Dispatching JNDI discovery event to whole domain");
47           }
48           _channel.dispatch(Consts.JNDI_SERVER_DISCO, _addr);
49         }
50       } catch (IOException JavaDoc e) {
51         e.printStackTrace();
52       }
53     }
54   }
55 }
56
Popular Tags