public void addDiscoveryListener(DiscoveryListener l){
  if (l == null) {
    throw new NullPointerException("can't add null listener");
  }
synchronized (this) {
    if (terminated) {
      throw new IllegalStateException("discovery terminated");
    }
    if (listeners.contains(l))     return;
    listeners.add(l);
    if (!discoveredLocators.isEmpty()) {
      HashMap groupsMap=new HashMap(discoveredLocators.size());
      Iterator iter=discoveredLocators.iterator();
      for (int i=0; iter.hasNext(); i++) {
        LocatorReg reg=(LocatorReg)iter.next();
        groupsMap.put(reg.proxy,reg.memberGroups);
      }
      ArrayList list=new ArrayList(1);
      list.add(l);
      addNotify(list,groupsMap,false);
    }
  }
}

public void addDiscoveryListener ( DiscoveryListener l ) { if ( l == null ) { throw new NullPointerException ( "can't add null listener" ) ; } synchronized ( this ) { if ( terminated ) { throw new IllegalStateException ( "discovery terminated" ) ; } if ( listeners . contains ( l ) ) return ; listeners . add ( l ) ; if ( ! discoveredLocators . isEmpty ( ) ) { HashMap groupsMap = new HashMap ( discoveredLocators . size ( ) ) ; Iterator iter = discoveredLocators . iterator ( ) ; for ( int i = 0 ; iter . hasNext ( ) ; i ++ ) { LocatorReg reg = ( LocatorReg ) iter . next ( ) ; groupsMap . put ( reg . proxy , reg . memberGroups ) ; } ArrayList list = new ArrayList ( 1 ) ; list . add ( l ) ; addNotify ( list , groupsMap , false ) ; } } }
add a discoverylistener to the listener set . the listener ' s discovered method gets called right way with an array of serviceregistrars that have already been discovered , and will be called in the future whenever additional lookup services are discovered .
