private void updateAttributesCache ( String key , Attributes missAttrs , Attributes cachedAttrs , String [ ] missAttrIds ) { final String METHODNAME = "updateAttributesCache(key,missAttrs,cachedAttrs,missAttrIds)" ; if ( missAttrIds != null ) { boolean newattr = false ; // differentiate between a new entry and an entry we'll update so we change the cache correctly and maintain the creation TTL. if ( missAttrIds . length > 0 ) { if ( cachedAttrs != null ) { cachedAttrs = ( Attributes ) cachedAttrs . clone ( ) ; } else { cachedAttrs = new BasicAttributes ( true ) ; newattr = true ; } for ( int i = 0 ; i < missAttrIds . length ; i ++ ) { boolean findAttr = false ; for ( NamingEnumeration < ? > neu = missAttrs . getAll ( ) ; neu . hasMoreElements ( ) ; ) { Attribute attr = ( Attribute ) neu . nextElement ( ) ; if ( attr . getID ( ) . equalsIgnoreCase ( missAttrIds [ i ] ) ) { findAttr = true ; // If the size of the attributes is larger than the // limit, do not cache it. if ( ! ( iAttrsSizeLmit > 0 && attr . size ( ) > iAttrsSizeLmit ) ) { cachedAttrs . put ( attr ) ; } break ; } else { int pos = attr . getID ( ) . indexOf ( ";" ) ; if ( pos > 0 && missAttrIds [ i ] . equalsIgnoreCase ( attr . getID ( ) . substring ( 0 , pos ) ) ) { findAttr = true ; // If the size of the attributes is larger than // the limit, do not cache it. if ( ! ( iAttrsSizeLmit > 0 && attr . size ( ) > iAttrsSizeLmit ) ) { cachedAttrs . put ( attr ) ; } break ; } } } if ( ! findAttr ) { Attribute nullAttr = new BasicAttribute ( missAttrIds [ i ] , null ) ; cachedAttrs . put ( nullAttr ) ; } } if ( newattr ) { // only set the the TTL if we're putting in a new entry getAttributesCache ( ) . put ( key , cachedAttrs , 1 , iAttrsCacheTimeOut , 0 , null ) ; } else { getAttributesCache ( ) . put ( key , cachedAttrs ) ; } if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , METHODNAME + " Update " + iAttrsCacheName + "(size: " + getAttributesCache ( ) . size ( ) + " newEntry: " + newattr + ")\n" + key + ": " + cachedAttrs ) ; } } } else { updateAttributesCache ( key , missAttrs , cachedAttrs ) ; } }
Update the cached attributes for the specified key . Only attribute IDs that are in the missAttrIds array will be added into the cached attributes .