java.lang.Object
org.tentackle.common.DefaultBundleFactory
- All Implemented Interfaces:
BundleFactory
@Service(BundleFactory.class)
public class DefaultBundleFactory
extends Object
implements BundleFactory
Default implementation of a bundle factory.
Works for modular and non-modular applications.
- Author:
- harald
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the bundle cache.protected List<ResourceBundleControlProvider> Creates a list of providers.findBundle(String baseName, Locale locale) Finds a resource bundle using the specified base name and locale, and the caller's class loader.findBundle(String baseName, Locale locale, ClassLoader loader) Finds a resource bundle using the specified base name, locale, and class loader.protected ResourceBundlegetBundle(BundleSupport support, Locale locale) Gets the bundle from the corresponding module according to the bundle support.Gets the classloader to load the bundles.getControl(String baseName) Gets the control to load the bundle.Gets the control providers.
Method can be used to add a provider explicitly.protected StringnormalizeBasename(String baseName) Normalizes the basename.
The name is usually a dotted classname or a slashed resource name without a leading slash.voidsetClassLoader(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).
-
Constructor Details
-
DefaultBundleFactory
public DefaultBundleFactory()Creates the bundle factory.
-
-
Method Details
-
clearCache
public void clearCache()Description copied from interface:BundleFactoryClears the bundle cache.- Specified by:
clearCachein interfaceBundleFactory
-
getClassLoader
Description copied from interface:BundleFactoryGets the classloader to load the bundles.- Specified by:
getClassLoaderin interfaceBundleFactory- Returns:
- the classloader, null if default
-
setClassLoader
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
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
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
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
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
Gets the bundle from the corresponding module according to the bundle support.- Parameters:
support- the bundle supportlocale- the locale- Returns:
- the bundle
-
createProviders
Creates a list of providers.- Returns:
- the non-empty list of providers, null if no providers found
-
normalizeBasename
Normalizes the basename.
The name is usually a dotted classname or a slashed resource name without a leading slash.- Parameters:
baseName- the name- Returns:
- the normalized name
-