- java.lang.Object
-
- org.tentackle.common.DefaultBundleFactory
-
- All Implemented Interfaces:
BundleFactory
public class DefaultBundleFactory extends java.lang.Object implements BundleFactory
Default implementation of a bundle factory.Works for modular and non-modular applications.
- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description DefaultBundleFactory()Creates the bundle factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache()Clears the bundle cache.protected java.util.List<java.util.spi.ResourceBundleControlProvider>createProviders()Creates a list of providers.java.util.ResourceBundlefindBundle(java.lang.String baseName, java.util.Locale locale)Finds a resource bundle using the specified base name and locale, and the caller's class loader.java.util.ResourceBundlefindBundle(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader loader)Finds a resource bundle using the specified base name, locale, and class loader.protected java.util.ResourceBundlegetBundle(BundleSupport support, java.util.Locale locale)Gets the bundle from the corresponding module according to the bundle support.java.lang.ClassLoadergetClassLoader()Gets the classloader to load the bundles.java.util.ResourceBundle.ControlgetControl(java.lang.String baseName)Gets the control to load the bundle.java.util.List<java.util.spi.ResourceBundleControlProvider>getProviders()Gets the control providers.
Method can be used to add a provider explicitly.protected java.lang.StringnormalizeBasename(java.lang.String baseName)Normalizes the basename.
The name is usually a dotted classname or a slashed resourcename without a leading slash.voidsetClassLoader(java.lang.ClassLoader classLoader)Sets the classloader to load the bundles.
If set, this classloader will be used forBundleFactory.getBundle(java.lang.String)andBundleFactory.getBundle(java.lang.String, java.util.Locale).
-
-
-
Method Detail
-
clearCache
public void clearCache()
Description copied from interface:BundleFactoryClears the bundle cache.- Specified by:
clearCachein interfaceBundleFactory
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:BundleFactoryGets the classloader to load the bundles.- Specified by:
getClassLoaderin interfaceBundleFactory- Returns:
- the classloader, null if default
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader classLoader)
Description copied from interface:BundleFactorySets the classloader to load the bundles.
If set, this classloader will be used forBundleFactory.getBundle(java.lang.String)andBundleFactory.getBundle(java.lang.String, java.util.Locale).- Specified by:
setClassLoaderin interfaceBundleFactory- Parameters:
classLoader- the classloader, null if default
-
getProviders
public final java.util.List<java.util.spi.ResourceBundleControlProvider> getProviders()
Description copied from interface:BundleFactoryGets the control providers.
Method can be used to add a provider explicitly.- Specified by:
getProvidersin interfaceBundleFactory- Returns:
- the non-empty list of providers or null, if no providers found
-
getControl
public java.util.ResourceBundle.Control getControl(java.lang.String baseName)
Description copied from interface:BundleFactoryGets the control to load the bundle.- Specified by:
getControlin interfaceBundleFactory- Parameters:
baseName- the bundle basename- Returns:
- the control, null if delegate to ResourceBundle's default
-
findBundle
public java.util.ResourceBundle findBundle(java.lang.String baseName, java.util.Locale locale)Description copied from interface:BundleFactoryFinds a resource bundle using the specified base name and locale, and the caller's class loader.- Specified by:
findBundlein interfaceBundleFactory- Parameters:
baseName- the base name of the resource bundle, a fully qualified class namelocale- the locale for which a resource bundle is desired- Returns:
- a resource bundle for the given base name and locale
-
findBundle
public java.util.ResourceBundle findBundle(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader loader)Description copied from interface:BundleFactoryFinds a resource bundle using the specified base name, locale, and class loader.- Specified by:
findBundlein interfaceBundleFactory- Parameters:
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 bundle- Returns:
- a resource bundle for the given base name and locale
-
getBundle
protected java.util.ResourceBundle getBundle(BundleSupport support, java.util.Locale locale)
Gets the bundle from the corresponding module according to the bundle support.- Parameters:
support- the bundle supportlocale- the locale- Returns:
- the bundle
-
createProviders
protected java.util.List<java.util.spi.ResourceBundleControlProvider> createProviders()
Creates a list of providers.- Returns:
- the non-empty list of providers, null if no providers found
-
normalizeBasename
protected java.lang.String normalizeBasename(java.lang.String baseName)
Normalizes the basename.
The name is usually a dotted classname or a slashed resourcename without a leading slash.- Parameters:
baseName- the name- Returns:
- the normalized name
-
-