boolean matchMatchEvent )
{
/* Save the pre-event state. Update the post-event state after
* applying the filter.
*/
ServiceItem oldItem;
ServiceItem oldFilteredItem;
synchronized(itemReg) {
oldItem = itemReg.item;
oldFilteredItem = itemReg.filteredItem;
if(itemReg.isDiscarded()) {
itemReg.item = newItem;//capture changes for discard
itemReg.filteredItem = null;//so filter will be retried
return;
}//endif
itemReg.addProxy(proxy);
}//end sync(itemReg)
/* For an explanation of the logic of the following if-else-block,
* refer to the method description above.
*/
boolean attrsChanged = false;
boolean versionChanged = false;
boolean isSameVersion = sameVersion(newItem,oldItem);
if( matchMatchEvent || isSameVersion ) {
/* Same version, determine if the attributes have changed.
* But first, replace the new service proxy with the old
* service proxy so the client always uses the old proxy
* (at least, until the version is changed).
*/
newItem.service = oldItem.service;
/* Now compare attributes */
attrsChanged = !LookupAttributes.equal(newItem.attributeSets,
oldItem.attributeSets);
if (logger.isLoggable(Level.FINEST)) {
if((oldItem != null) && (oldItem.attributeSets != null)) {
for(int i=0; i<(oldItem.attributeSets).length; i++) {
logger.finest("itemMatchMatchChange - "
+"OLD Attribute["+i+"] = "
+(oldItem.attributeSets)[i]);
}//end loop
}//endif
logger.finest(" ");
if((newItem != null) && (newItem.attributeSets != null)) {
for(int i=0; i<(newItem.attributeSets).length; i++) {
logger.finest("itemMatchMatchChange - "
+"NEW Attribute["+i+"] = "
+(newItem.attributeSets)[i]);
}//end loop
}//endif
}//endif(FINEST)
if (logger.isLoggable(Level.FINER)) {
if(attrsChanged) {
if(matchMatchEvent) {
logger.finer("itemMatchMatchChange - attributes "
+"changed [TRANSITION_MATCH_MATCH]");
} else if( isSameVersion ) {
logger.finer("ServiceDiscoveryManager."
+"itemMatchMatchChange - attributes "
+"changed [same version]");
}//endif
} else {//(!attrChanged)
if(matchMatchEvent) {
logger.finer("itemMatchMatchChange - "
+"attributes NOT changed ["
+"TRANSITION_MATCH_MATCH] ..."
+"return");
} else if( isSameVersion ) {
logger.finer("itemMatchMatchChange - "
+"attributes NOT changed [same"
+"version] ... return");
}//endif
}//endif
}//endif
if(!attrsChanged) return;//no change, no need to filter
} else {//(!matchMatchEvent && !same version) ==> re-registration
versionChanged = true;
logger.finer("itemMatchMatchChange - version changed");
}//endif
/* Now apply the filter, and send events if appropriate */
ServiceItem newFilteredItem = filterMaybeDiscard
(newItem, proxy, true);
if(newFilteredItem != null) {
/* Passed the filter, okay to send event(s). */
if(attrsChanged) {
logger.finer("itemMatchMatchChange - send serviceChanged");