ServiceItemReg itemReg = null;
synchronized(serviceIdMap) {
itemReg = (ServiceItemReg)serviceIdMap.get(serviceID);
}//end sync(serviceIdMap)
if(itemReg != null) {
ServiceItem item = null;
ServiceItem filteredItem = null;
synchronized(itemReg) {
if(itemReg.filteredItem == null) {
item = new ServiceItem
( (itemReg.item).serviceID,
(itemReg.item).service,
(itemReg.item).attributeSets);
filteredItem = new ServiceItem
( (itemReg.item).serviceID,
(itemReg.item).service,
(itemReg.item).attributeSets);
}//endif
}//end sync(itemReg)
if(filteredItem != null) {//retry the filter
if( filterPassFail(filteredItem,filter) ) {
addFilteredItemToMap(item,filteredItem);
} else {//'quietly' remove the item
removeServiceIdMapSendNoEvent(serviceID);
return;
}//endif
}//endif
/* Either the filter was retried and passed, in which case,
* the filtered itemCopy was placed in the map; or the
* filter wasn't applied above (a non-null filteredItem
* field in the itemReg in the map means that the filter
* was applied at some previous time). In either case, the
* service can now be "un-discarded", and a notification
* that the service is now available can be sent.
*/
ServiceItem itemToSend;
synchronized(itemReg) {
itemReg.setDiscarded(false);
itemToSend = itemReg.filteredItem;
}//end sync(itemReg)
addServiceNotify(itemToSend);