Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
 package org.apache.felix.webconsole.internal.i18n;
 import java.util.Map;
The ResourceBundleManager manages resource bundle instance per OSGi Bundle. It contains a local cache, for bundles, but when a bundle is being unistalled, its resources stored in the cache are cleaned up.
 public class ResourceBundleManager implements BundleListener
     private final BundleContext bundleContext;
     private final Map resourceBundleCaches;

Creates a new object and adds self as a bundle listener

bundleContext the bundle context of the Web Console.
     public ResourceBundleManagerfinal BundleContext bundleContext )
         this. = bundleContext;
         this. = new ResourceBundleCachebundleContext.getBundle() );
         this. = new HashMap();
         bundleContext.addBundleListenerthis );

Removes the bundle lister.
     public void dispose()
         .removeBundleListenerthis );

This method is used to retrieve a /cached/ instance of the i18n resource associated with a given bundle.

provider the bundle, provider of the resources
locale the requested locale.
the resource bundle - if not bundle with the requested locale exists, the default locale is used.
     public ResourceBundle getResourceBundlefinal Bundle providerfinal Locale locale )
         // check whether we have to return the resource bundle for the
         // Web Console itself in which case we directly return it
         final ResourceBundle defaultResourceBundle = .getResourceBundlelocale );
         if ( provider == null || provider.equals.getBundle() ) )
             return defaultResourceBundle;
         ResourceBundleCache cache;
         synchronized (  )
             Long key = new Longprovider.getBundleId() );
             cache = ( ResourceBundleCache ) .getkey );
             if ( cache == null )
                 cache = new ResourceBundleCacheprovider );
                 .putkeycache );
        final ResourceBundle bundleResourceBundle = cache.getResourceBundlelocale );
        return new CombinedResourceBundlebundleResourceBundledefaultResourceBundlelocale );
    // ---------- BundleListener

    public final void bundleChangedBundleEvent event )
        if ( event.getType() == . )
            Long key = new Longevent.getBundle().getBundleId() );
            synchronized (  )
                .removekey );
New to GrepCode? Check out our FAQ X