Java 类org.springframework.context.support.MessageSourceResourceBundle 实例源码

项目:spring4-understanding    文件:AbstractJasperReportsView.java   
/**
 * Expose current Spring-managed Locale and MessageSource to JasperReports i18n
 * ($R expressions etc). The MessageSource should only be exposed as JasperReports
 * resource bundle if no such bundle is defined in the report itself.
 * <p>The default implementation exposes the Spring RequestContext Locale and a
 * MessageSourceResourceBundle adapter for the Spring ApplicationContext,
 * analogous to the {@code JstlUtils.exposeLocalizationContext} method.
 * @see org.springframework.web.servlet.support.RequestContextUtils#getLocale
 * @see org.springframework.context.support.MessageSourceResourceBundle
 * @see #getApplicationContext()
 * @see net.sf.jasperreports.engine.JRParameter#REPORT_LOCALE
 * @see net.sf.jasperreports.engine.JRParameter#REPORT_RESOURCE_BUNDLE
 * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext
 */
protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) {
    RequestContext rc = new RequestContext(request, getServletContext());
    Locale locale = rc.getLocale();
    if (!model.containsKey(JRParameter.REPORT_LOCALE)) {
        model.put(JRParameter.REPORT_LOCALE, locale);
    }
    TimeZone timeZone = rc.getTimeZone();
    if (timeZone != null && !model.containsKey(JRParameter.REPORT_TIME_ZONE)) {
        model.put(JRParameter.REPORT_TIME_ZONE, timeZone);
    }
    JasperReport report = getReport();
    if ((report == null || report.getResourceBundle() == null) &&
            !model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) {
        model.put(JRParameter.REPORT_RESOURCE_BUNDLE,
                new MessageSourceResourceBundle(rc.getMessageSource(), locale));
    }
}
项目:spring4-understanding    文件:JstlUtils.java   
@Override
public ResourceBundle getResourceBundle() {
    HttpSession session = this.request.getSession(false);
    if (session != null) {
        Object lcObject = Config.get(session, Config.FMT_LOCALIZATION_CONTEXT);
        if (lcObject instanceof LocalizationContext) {
            ResourceBundle lcBundle = ((LocalizationContext) lcObject).getResourceBundle();
            return new MessageSourceResourceBundle(this.messageSource, getLocale(), lcBundle);
        }
    }
    return new MessageSourceResourceBundle(this.messageSource, getLocale());
}
项目:class-guard    文件:JstlUtils.java   
@Override
public ResourceBundle getResourceBundle() {
    HttpSession session = this.request.getSession(false);
    if (session != null) {
        Object lcObject = Config.get(session, Config.FMT_LOCALIZATION_CONTEXT);
        if (lcObject instanceof LocalizationContext) {
            ResourceBundle lcBundle = ((LocalizationContext) lcObject).getResourceBundle();
            return new MessageSourceResourceBundle(this.messageSource, getLocale(), lcBundle);
        }
    }
    return new MessageSourceResourceBundle(this.messageSource, getLocale());
}
项目:molgenis    文件:MolgenisInterceptor.java   
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception
{
    if (modelAndView != null)
    {
        modelAndView.addObject(KEY_RESOURCE_FINGERPRINT_REGISTRY, resourceFingerprintRegistry);
        modelAndView.addObject(KEY_THEME_FINGERPRINT_REGISTRY, themeFingerprintRegistry);
        modelAndView.addObject(KEY_APP_SETTINGS, appSettings);
        modelAndView.addObject(KEY_AUTHENTICATION_SETTINGS, authenticationSettings);
        modelAndView.addObject(KEY_ENVIRONMENT, getEnvironmentAttributes());
        modelAndView.addObject(KEY_I18N,
                new MessageSourceResourceBundle(messageSource, LocaleContextHolder.getLocale()));
    }
}
项目:lams    文件:MessageSourceResourceBundleLocator.java   
@Override
public ResourceBundle getResourceBundle(Locale locale) {
    return new MessageSourceResourceBundle(this.messageSource, locale);
}
项目:spring4-understanding    文件:MessageSourceResourceBundleLocator.java   
@Override
public ResourceBundle getResourceBundle(Locale locale) {
    return new MessageSourceResourceBundle(this.messageSource, locale);
}
项目:my-spring-cache-redis    文件:MessageSourceResourceBundleLocator.java   
@Override
public ResourceBundle getResourceBundle(Locale locale) {
    return new MessageSourceResourceBundle(this.messageSource, locale);
}
项目:spring    文件:MessageSourceResourceBundleLocator.java   
@Override
public ResourceBundle getResourceBundle(Locale locale) {
    return new MessageSourceResourceBundle(this.messageSource, locale);
}
项目:spring-javafx    文件:FXMLComponentConfiguration.java   
@Bean
public ResourceBundle fxmlComponentResourceBundle(MessageSource messageSource) {
    return new MessageSourceResourceBundle(messageSource, LocaleContextHolder.getLocale());
}
项目:class-guard    文件:MessageSourceResourceBundleLocator.java   
public ResourceBundle getResourceBundle(Locale locale) {
    return new MessageSourceResourceBundle(this.messageSource, locale);
}
项目:molgenis    文件:LanguageService.java   
/**
 * Creates a localization ResourceBundle for current locale.
 *
 * @return MessageSourceResourceBundle
 */
@Deprecated
public static MessageSourceResourceBundle getBundle()
{
    return new MessageSourceResourceBundle(getMessageSource(), getLocale());
}
项目:class-guard    文件:AbstractJasperReportsView.java   
/**
 * Expose current Spring-managed Locale and MessageSource to JasperReports i18n
 * ($R expressions etc). The MessageSource should only be exposed as JasperReports
 * resource bundle if no such bundle is defined in the report itself.
 * <p>The default implementation exposes the Spring RequestContext Locale and a
 * MessageSourceResourceBundle adapter for the Spring ApplicationContext,
 * analogous to the {@code JstlUtils.exposeLocalizationContext} method.
 * @see org.springframework.web.servlet.support.RequestContextUtils#getLocale
 * @see org.springframework.context.support.MessageSourceResourceBundle
 * @see #getApplicationContext()
 * @see net.sf.jasperreports.engine.JRParameter#REPORT_LOCALE
 * @see net.sf.jasperreports.engine.JRParameter#REPORT_RESOURCE_BUNDLE
 * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext
 */
protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) {
    RequestContext rc = new RequestContext(request, getServletContext());
    if (!model.containsKey(JRParameter.REPORT_LOCALE)) {
        model.put(JRParameter.REPORT_LOCALE, rc.getLocale());
    }
    JasperReport report = getReport();
    if ((report == null || report.getResourceBundle() == null) &&
            !model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) {
        model.put(JRParameter.REPORT_RESOURCE_BUNDLE,
                new MessageSourceResourceBundle(rc.getMessageSource(), rc.getLocale()));
    }
}