MetaBundle.setContextLocale(Locale l) and MetaBundle.getContextLocale() can be used to set and get the context Locale used by Meta Facility thread wide, so that code in lower layers can just use this value instead of interfering with upper layers for the preferred Locale.
And metadata inquirying methods of MetaBundle , those without a Locale argument (such as MetaBundle.getInteger(String xpath) ) will automatically use this context Locale, which made things even easier.
Always use these methods to fetch metadata through MetaBundles in your components/libraries those intend to be reused for many applications. This is the standard way of Meta Facility to pass preferred Locale across code layers.
To reuse components/libraries those I18n ready based on Meta Facility, an I18n ready application should set the context Locale via MetaBundle.setContextLocale(Locale l) at the beginning of a round of processing, before passing control to any of the components/libraries. The context Locale is effective thread wide, so it needs only be set once per round of processing.
Take an HttpServlet for example, it just needs to set the context Locale at the beginning of each request processing, such as:
protected void service(HttpServletRequest req, HttpServletResponse resp)
{
MetaBundle.setContextLocale(req.getLocale());
super.service(req, resp);
}