private void deleteOrReplaceTemplate(Item item,boolean delete,Template tmpl){
  ConcurrentHashMap<ServiceID,Item> items=lookupServiceCache.get(tmpl);
  if (delete) {
    if (items != null) {
      items.remove(item.serviceID);
      if (loggerCache.isLoggable(Level.FINEST)) {
        loggerCache.finest("Removing cache template (explicitly): " + tmpl + "\n   ---- > "+ item.serviceID+ " "+ item.serviceType);
      }
    }
  }
 else {
    if (items == null) {
      items=new SizeConcurrentHashMap<ServiceID,Item>();
      lookupServiceCache.put(tmpl,items);
    }
    items.put(item.serviceID,item);
    if (loggerCache.isLoggable(Level.FINEST)) {
      loggerCache.finest("Adding to cache template (explicitly): " + tmpl + "\n   ---- > "+ item.serviceID+ " "+ item.serviceType);
    }
  }
}

private void deleteOrReplaceTemplate ( Item item , boolean delete , Template tmpl ) { ConcurrentHashMap < ServiceID , Item > items = lookupServiceCache . get ( tmpl ) ; if ( delete ) { if ( items != null ) { items . remove ( item . serviceID ) ; if ( loggerCache . isLoggable ( Level . FINEST ) ) { loggerCache . finest ( "Removing cache template (explicitly): " + tmpl + "\n   ---- > " + item . serviceID + " " + item . serviceType ) ; } } } else { if ( items == null ) { items = new SizeConcurrentHashMap < ServiceID , Item > ( ) ; lookupServiceCache . put ( tmpl , items ) ; } items . put ( item . serviceID , item ) ; if ( loggerCache . isLoggable ( Level . FINEST ) ) { loggerCache . finest ( "Adding to cache template (explicitly): " + tmpl + "\n   ---- > " + item . serviceID + " " + item . serviceType ) ; } } }
if delete is marked , then tries to perform another lookup ( should be very fast ) and find if something matches it . if so , it replaces the cache with the one that it found . if none is found , then nothing is added to the cache . < p / > < p > in case the service is not deleted , then just adds it to the cache .
