|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.sling.i18n.impl.JcrResourceBundleProvider
@Service(value=ResourceBundleProvider.class) public class JcrResourceBundleProvider
The JcrResourceBundleProvider
implements the
ResourceBundleProvider
interface creating
ResourceBundle
instances from resources stored in the
repository.
Field Summary |
---|
Fields inherited from interface org.apache.sling.i18n.ResourceBundleProvider |
---|
BUNDLE_REQ_ATTR |
Constructor Summary | |
---|---|
JcrResourceBundleProvider()
|
Method Summary | |
---|---|
protected void |
activate(org.osgi.service.component.ComponentContext context)
Activates and configures this component with the repository access details and the default locale to use |
protected void |
bindResourceResolverFactory(org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)
Binds a new ResourceResolverFactory . |
protected void |
deactivate()
|
Locale |
getDefaultLocale()
Returns the configured default Locale which is used as a
fallback for getResourceBundle(Locale) and also as the basis for
any messages requested from resource bundles. |
ResourceBundle |
getResourceBundle(Locale locale)
Returns the ResourceBundle for the given
locale . |
ResourceBundle |
getResourceBundle(String baseName,
Locale locale)
Returns a ResourceBundle for the given locale. |
void |
onEvent(javax.jcr.observation.EventIterator events)
Called whenever something is changed inside of jcr:language
or sling:Message nodes. |
protected void |
unbindResourceResolverFactory(org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)
Unbinds the ResourceResolverFactory . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JcrResourceBundleProvider()
Method Detail |
---|
public Locale getDefaultLocale()
Locale
which is used as a
fallback for getResourceBundle(Locale)
and also as the basis for
any messages requested from resource bundles.
getDefaultLocale
in interface ResourceBundleProvider
public ResourceBundle getResourceBundle(Locale locale)
ResourceBundle
for the given
locale
.
getResourceBundle
in interface ResourceBundleProvider
locale
- The Locale
for which to return the resource
bundle. If this is null
the configured
default locale
is assumed.
ResourceBundle
for the given locale.
MissingResourceException
- If the ResourceResolver
is not available to access the resources.public ResourceBundle getResourceBundle(String baseName, Locale locale)
ResourceBundleProvider
ResourceBundle
for the given locale.
getResourceBundle
in interface ResourceBundleProvider
baseName
- The base name for the resource bundle. If this is
null
, the same resource bundle will be
returned as when calling the
ResourceBundleProvider.getResourceBundle(Locale)
method.locale
- The Locale
for which to return the resource
bundle. If this is null
the default locale as
returned by ResourceBundleProvider.getDefaultLocale()
is assumed.
ResourceBundle
for the given localepublic void onEvent(javax.jcr.observation.EventIterator events)
jcr:language
or sling:Message
nodes. We just removed all cached
resource bundles in this case to force reloading them.
This is much simpler than analyzing the events and trying to be clever about which exact resource bundles to remove from the cache and at the same time care for any resource bundle dependencies.
onEvent
in interface javax.jcr.observation.EventListener
events
- The actual JCR events are ignored by this implementation.protected void activate(org.osgi.service.component.ComponentContext context)
protected void deactivate()
protected void bindResourceResolverFactory(org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)
ResourceResolverFactory
. If we are already
bound to another factory, we release that latter one first.
protected void unbindResourceResolverFactory(org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory)
ResourceResolverFactory
. If we are bound to
this factory, we release it.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |