private static NLS getNLS ( Locale l , String resourceBundle , String statsType ) { // init Locale boolean bDefaultLocale = false ; if ( l == null || l == Locale . getDefault ( ) ) { bDefaultLocale = true ; l = Locale . getDefault ( ) ; } NLS aNLS = null ; if ( resourceBundle == null ) { // resourceBundle is NULL // trial 1: try prepending the 5.0 default resourcebundle location prefix (to support commerce, portal, etc.) // trial 2: if that fails return default 6.0 PMI resourcebundle int trial = 1 ; do { if ( trial == 1 ) resourceBundle = PMI_RESOURCE_BUNDLE_PREFIX_50 + statsType ; else if ( trial == 2 ) resourceBundle = PMI_RESOURCE_BUNDLE ; // 234782 - JPM: Check in NLS cache aNLS = ( NLS ) nlsMap . get ( getNlsKey ( resourceBundle , l ) ) ; if ( aNLS != null ) return aNLS ; else aNLS = new NLS ( resourceBundle , l , true , false ) ; // first time create if ( aNLS . isResourceLoaded ( ) ) break ; ++ trial ; } while ( trial <= 2 ) ; } else { // resourcebundle != null // Custom resource bundle // 234782 - JPM: Check in NLS cache aNLS = ( NLS ) nlsMap . get ( getNlsKey ( resourceBundle , l ) ) ; if ( aNLS != null ) return aNLS ; else aNLS = new NLS ( resourceBundle , l , true , false ) ; // first time create // resourcebundle not loaded. so try using contextClassLoader to support // custom pmi in applications (war/ear file) // custom pmi resource bundle that is not found in the path // may its an application so use context classloader if ( ! aNLS . isResourceLoaded ( ) ) { // ------ security code final String _rbName = resourceBundle ; final Locale _locale = l ; try { aNLS = ( NLS ) AccessController . doPrivileged ( new PrivilegedExceptionAction ( ) { @ Override public Object run ( ) throws Exception { return new NLS ( _rbName , _locale , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } } ) ; } catch ( Exception e1 ) { Tr . warning ( tc , "PMI0030W" , resourceBundle ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Error loading custom resource bundle using context classloader: " + e1 . getMessage ( ) ) ; } if ( aNLS == null || ! aNLS . isResourceLoaded ( ) ) { aNLS = null ; } // ------ security code } } // 234782 - JPM: Cache NLS object if successfully created if ( aNLS != null && aNLS . isResourceLoaded ( ) ) { if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Caching resource bundle: " + resourceBundle + " locale: " + l ) ; // 234782 - JPM: Cache resourcebundle for this locale nlsMap . put ( getNlsKey ( resourceBundle , l ) , aNLS ) ; } return aNLS ; }
in which case we dont cache