public interface BundleFactory
Tentackle applications should use BundleFactory.getBundle(...) instead of
ResourceBundle.getBundle(...) because the use cases of ResourceBundleControlProvider
are still very limited in Java 8. The major restriction is that the providers
are loaded from installed extensions only. This requires either a copy the tentackle-jars in
the extensions directory of the JRE installation (which is a bad habit in general, because it applies to all applications)
or to set the runtime option -Djava.ext.dirs=... to a directory path containing the jars.
The latter may be a workaround for applications started from the shell, but is not feasable for webstart
applications or applications running within a container.
Tentackle's bundle factory uses the same interface ResourceBundleControlProvider and semantics
to lookup and install providers as the standard JRE, but scans the application classpath instead
of the system classpath.
See org.tentackle.locale.StoredBundleControlProvider in tentackle-i18n for an example.
| Modifier and Type | Method and Description |
|---|---|
ResourceBundle |
findBundle(String baseName)
Finds a resource bundle using the specified base name, the default locale, and the caller's class loader.
|
ResourceBundle |
findBundle(String baseName,
Locale locale)
Finds a resource bundle using the specified base name and locale, and the caller's class loader.
|
ResourceBundle |
findBundle(String baseName,
Locale locale,
ClassLoader loader)
Finds a resource bundle using the specified base name, locale, and class loader.
|
static ResourceBundle |
getBundle(String baseName)
Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.
Replacement for ResourceBundle.getBundle(java.lang.String). |
static ResourceBundle |
getBundle(String baseName,
Locale locale)
Gets a resource bundle using the specified base name and locale, and the caller's class loader.
Replacement for ResourceBundle.getBundle(java.lang.String, java.util.Locale). |
static ResourceBundle |
getBundle(String baseName,
Locale locale,
ClassLoader loader)
Gets a resource bundle using the specified base name, locale, and class loader.
Replacement for ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader). |
ClassLoader |
getClassLoader()
Gets the classloader to load the bundles.
|
ResourceBundle.Control |
getControl(String baseName)
Gets the control to load the bundle.
|
static BundleFactory |
getInstance()
The singleton.
|
List<ResourceBundleControlProvider> |
getProviders()
Gets the control providers.
Method can be used to add a provider explicitly. |
void |
setClassLoader(ClassLoader classLoader)
Sets the classloader to load the bundles.
If set, this classloader will be used for getBundle(java.lang.String) and
getBundle(java.lang.String, java.util.Locale). |
static BundleFactory getInstance()
static ResourceBundle getBundle(String baseName)
ResourceBundle.getBundle(java.lang.String).baseName - the base name of the resource bundle, a fully qualified class namestatic ResourceBundle getBundle(String baseName, Locale locale)
ResourceBundle.getBundle(java.lang.String, java.util.Locale).baseName - the base name of the resource bundle, a fully qualified class namelocale - the locale for which a resource bundle is desiredstatic ResourceBundle getBundle(String baseName, Locale locale, ClassLoader loader)
ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader).baseName - the base name of the resource bundle, a fully qualified class namelocale - the locale for which a resource bundle is desiredloader - the class loader from which to load the resource bundleClassLoader getClassLoader()
void setClassLoader(ClassLoader classLoader)
getBundle(java.lang.String) and
getBundle(java.lang.String, java.util.Locale).classLoader - the classloader, null if defaultList<ResourceBundleControlProvider> getProviders()
ResourceBundle.Control getControl(String baseName)
baseName - the bundle basenameResourceBundle findBundle(String baseName)
baseName - the base name of the resource bundle, a fully qualified class nameResourceBundle findBundle(String baseName, Locale locale)
baseName - the base name of the resource bundle, a fully qualified class namelocale - the locale for which a resource bundle is desiredResourceBundle findBundle(String baseName, Locale locale, ClassLoader loader)
baseName - the base name of the resource bundle, a fully qualified class namelocale - the locale for which a resource bundle is desiredloader - the class loader from which to load the resource bundleTentackle - a domain driven enterprise framework