question: 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 ) ; } }
target:  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).