2.17.2: 2011-06-17

net.sf.basedb.util.resources
Class ResourceBundleFactory

java.lang.Object
  extended by net.sf.basedb.util.resources.ResourceBundleFactory

public class ResourceBundleFactory
extends Object

Factory for loading resource bundles. The factory return ResourceBundleWrapper objects which are wrappers around regular ResourceBundle:s that provide us with some extra functionality.

NOTE! Plug-ins and extensions that are not part of the BASE core are usually loaded with a different class loader than the rest of BASE. If they are including resource in their own JAR files, they must use the versions that take a class loader as the last parameter and set it to the class loader of of their own classes. Eg. this.getClass().getClassLoader().

Since:
2.16
Author:
Nicklas
Last modified
$Date: 2010-09-16 13:32:06 +0200 (Thu, 16 Sep 2010) $

Constructor Summary
private ResourceBundleFactory()
           
 
Method Summary
static ResourceBundleWrapper getResourceBundle(String name, Locale locale)
          Same as getResouceBundle(name, locale, null).
static ResourceBundleWrapper getResourceBundle(String name, Locale locale, ClassLoader loader)
          Get a resource bundle for the given locale.
static ResourceBundleWrapper getResourceBundle(String name, SessionControl sc)
          Same as getResouceBundle(name, sc, null).
static ResourceBundleWrapper getResourceBundle(String name, SessionControl sc, ClassLoader loader)
          Get a resource bundle for the given session control.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceBundleFactory

private ResourceBundleFactory()
Method Detail

getResourceBundle

public static ResourceBundleWrapper getResourceBundle(String name,
                                                      SessionControl sc)
Same as getResouceBundle(name, sc, null).

See Also:
getResourceBundle(String, SessionControl, ClassLoader)

getResourceBundle

public static ResourceBundleWrapper getResourceBundle(String name,
                                                      SessionControl sc,
                                                      ClassLoader loader)
Get a resource bundle for the given session control. If the session control is not null the SessionControl.getLocale() is used as the locale, otherwise the server default locale (Config.getLocale()) is used.

Parameters:
name - The name of the resource bundle
sc - A session control, or null
loader - The class loader to use when locating the resource bundle(s). If null, the context class loader of the current thread is used
Returns:
A resource bundle wrapper
See Also:
Thread.getContextClassLoader()

getResourceBundle

public static ResourceBundleWrapper getResourceBundle(String name,
                                                      Locale locale)
Same as getResouceBundle(name, locale, null).

See Also:
getResourceBundle(String, Locale, ClassLoader)

getResourceBundle

public static ResourceBundleWrapper getResourceBundle(String name,
                                                      Locale locale,
                                                      ClassLoader loader)
Get a resource bundle for the given locale.

Parameters:
name - The name of the resource bundle
locale - A locale object
loader - The class loader to use when locating the resource bundle(s). If null, the context class loader of the current thread is used
Returns:
A resource bundle wrapper
See Also:
Thread.getContextClassLoader()

2.17.2: 2011-06-17