Class ResourceBundleWrapper


  • public class ResourceBundleWrapper
    extends java.lang.Object
    Wrapper of ResourceBundle.getBundle() methods. This wrapper is introduced to avoid a dramatic performance penalty by superfluous resource (and classes loaded by Class.forName) lookups on web server in applets.
     public class AppletC extends javax.swing.JApplet {
        public void init() {
           ResourceBundleWrapper.removeCodeBase(getCodeBase(),
                   (URLClassLoader) getClass().getClassLoader());
        ...
     
    See Also:
    Bug ID: 4243379, Bug ID: 4668479
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.net.URLClassLoader noCodeBaseClassLoader
      A special class loader with no code base lookup.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ResourceBundleWrapper()
      Private constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.ResourceBundle getBundle​(java.lang.String baseName)
      Finds and returns the specified resource bundle.
      static java.util.ResourceBundle getBundle​(java.lang.String baseName, java.util.Locale locale)
      Finds and returns the specified resource bundle.
      static java.util.ResourceBundle getBundle​(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader loader)
      Maps directly to ResourceBundle.getBundle(baseName, locale, loader).
      static void removeCodeBase​(java.net.URL codeBase, java.net.URLClassLoader urlClassLoader)
      Instantiate a URLClassLoader for resource lookups where the codeBase URL is removed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • noCodeBaseClassLoader

        private static java.net.URLClassLoader noCodeBaseClassLoader
        A special class loader with no code base lookup. This field may be null (the field is only initialised if removeCodeBase() is called from an applet).
    • Constructor Detail

      • ResourceBundleWrapper

        private ResourceBundleWrapper()
        Private constructor.
    • Method Detail

      • removeCodeBase

        public static void removeCodeBase​(java.net.URL codeBase,
                                          java.net.URLClassLoader urlClassLoader)
        Instantiate a URLClassLoader for resource lookups where the codeBase URL is removed. This method is typically called from an applet's init() method. If this method is never called, the getBundle() methods map to the standard ResourceBundle lookup methods.
        Parameters:
        codeBase - the codeBase URL.
        urlClassLoader - the class loader.
      • getBundle

        public static java.util.ResourceBundle getBundle​(java.lang.String baseName)
        Finds and returns the specified resource bundle.
        Parameters:
        baseName - the base name.
        Returns:
        The resource bundle.
      • getBundle

        public static java.util.ResourceBundle getBundle​(java.lang.String baseName,
                                                         java.util.Locale locale)
        Finds and returns the specified resource bundle.
        Parameters:
        baseName - the base name.
        locale - the locale.
        Returns:
        The resource bundle.
      • getBundle

        public static java.util.ResourceBundle getBundle​(java.lang.String baseName,
                                                         java.util.Locale locale,
                                                         java.lang.ClassLoader loader)
        Maps directly to ResourceBundle.getBundle(baseName, locale, loader).
        Parameters:
        baseName - the base name.
        locale - the locale.
        loader - the class loader.
        Returns:
        The resource bundle.