1 package org.sapia.ubik.rmi.naming.remote; 2 3 import java.io.IOException ; 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 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 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 e) { 51 e.printStackTrace(); 52 } 53 } 54 } 55 } 56 | Popular Tags |