private void notifyServiceMap(Object eventSource,long eventID,long seqNo,ServiceID sid,ServiceItem item,int transition){
  if (eventSource == null)   return;
synchronized (serviceIdMap) {
    ProxyReg reg=null;
    EventReg eReg=null;
    Set set=eventRegMap.entrySet();
    Iterator iter=set.iterator();
    while (iter.hasNext()) {
      Map.Entry e=(Map.Entry)iter.next();
      eReg=(EventReg)e.getValue();
      if (eventSource.equals(eReg.source) && (eventID == eReg.eventID)) {
        reg=(ProxyReg)e.getKey();
        break;
      }
    }
    if (reg == null)     return;
    long prevSeqNo=eReg.seqNo;
    eReg.seqNo=seqNo;
    CacheTask t;
    if (seqNo == (prevSeqNo + 1)) {
      t=new NotifyEventTask(lookupCacheClassLoader,reg,sid,item,transition,taskSeqN++);
    }
 else {
      t=new LookupTask(lookupCacheClassLoader,reg,taskSeqN++);
      if (logger.isLoggable(Levels.HANDLED)) {
        String msg="notifyServiceMap - GAP in event sequence " + "[serviceRegistrar={0}], " + "[serviceItem={1}, "+ "serviceID={2}], "+ "[eventSource={3}, "+ "eventID={4,number,#}, "+ "oldSeqN={5,number,#}, "+ "newSeqN={6,number,#}]";
        Object[] params=new Object[]{reg == null ? null : reg.proxy,item.service,sid,eventSource,new Long(eventID),new Long(prevSeqNo),new Long(seqNo)};
        logger.log(Levels.HANDLED,msg,params);
      }
    }
    cacheTaskMgr.add(t);
  }
}

private void notifyServiceMap ( Object eventSource , long eventID , long seqNo , ServiceID sid , ServiceItem item , int transition ) { if ( eventSource == null ) return ; synchronized ( serviceIdMap ) { ProxyReg reg = null ; EventReg eReg = null ; Set set = eventRegMap . entrySet ( ) ; Iterator iter = set . iterator ( ) ; while ( iter . hasNext ( ) ) { Map . Entry e = ( Map . Entry ) iter . next ( ) ; eReg = ( EventReg ) e . getValue ( ) ; if ( eventSource . equals ( eReg . source ) && ( eventID == eReg . eventID ) ) { reg = ( ProxyReg ) e . getKey ( ) ; break ; } } if ( reg == null ) return ; long prevSeqNo = eReg . seqNo ; eReg . seqNo = seqNo ; CacheTask t ; if ( seqNo == ( prevSeqNo + 1 ) ) { t = new NotifyEventTask ( lookupCacheClassLoader , reg , sid , item , transition , taskSeqN ++ ) ; } else { t = new LookupTask ( lookupCacheClassLoader , reg , taskSeqN ++ ) ; if ( logger . isLoggable ( Levels . HANDLED ) ) { String msg = "notifyServiceMap - GAP in event sequence " + "[serviceRegistrar={0}], " + "[serviceItem={1}, " + "serviceID={2}], " + "[eventSource={3}, " + "eventID={4,number,#}, " + "oldSeqN={5,number,#}, " + "newSeqN={6,number,#}]" ; Object [ ] params = new Object [ ] { reg == null ? null : reg . proxy , item . service , sid , eventSource , new Long ( eventID ) , new Long ( prevSeqNo ) , new Long ( seqNo ) } ; logger . log ( Levels . HANDLED , msg , params ) ; } } cacheTaskMgr . add ( t ) ; } }
called by the lookuplistener ' s notify ( ) method . checks the event sequence number and , based on whether or not a " gap " is found in in the event sequence , creates and places on the queue , either a lookuptask ( if a gap was found ) or a notifytask . recall that the event specification states that if the sequence numbers of two successive events differ by only 1 , then one can be assured that no events were missed . on the other hand , if the difference is greater than 1 ( the sequence contains a " gap " ) , then one or more events may - - or may not - - have been missed . thus , if a gap is found in the events , although it ' s possible that no events were missed , this method takes the conservative approach by assuming events were missed . when this method determines that an event may have been missed , it requests a current " snapshot " of the given serviceregistrar ' s state by queueing the execution of a lookuptask . since this method can safely assume that no events have been missed if it finds no gaps in the event sequence , this method queues the notification of the entity by requesting the execution of a notifyeventtask . note that when a lookup service is discovered , this utility registers with that lookup service ' s event mechanism for service events related to the services of interest . upon registering with the event mechanism , a data structure ( of type eventreg ) containing information about that registration is placed in a map for later processing when events do arrive . if the timing is right , it is possible that a service event may arrive between the time the registration is made and the time the eventreg is stored in the map . thus , this method may find that the eventregmap does not contain an element corresponding to the event this method is currently processing . in that case , this method will do nothing . it will simply return so that the service referenced in the event can be discovered using the snapshot returned by the lookuptask that is ultimately queued by the registerlistenertask ( whose listener registration caused this method to be invoked in the first place ) .
