• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HierarchicalMessageSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.context.HierarchicalMessageSource的典型用法代码示例。如果您正苦于以下问题:Java HierarchicalMessageSource类的具体用法?Java HierarchicalMessageSource怎么用?Java HierarchicalMessageSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HierarchicalMessageSource类属于org.springframework.context包,在下文中一共展示了HierarchicalMessageSource类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: configureMessageSource

import org.springframework.context.HierarchicalMessageSource; //导入依赖的package包/类
/**
 * 配置基于配置的MessageSource
 */
private void configureMessageSource() {
    // MessageSource bean name
    String messageSourceBeanName = AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME;

    // Config MessageSource bean name
    String configMessageSourceBeanName = CONFIG_MESSAGE_SOURCE_BEAN_NAME;

    // 基于配置服务的MessageSource
    ConfigMessageSource configMessageSource = beanFactory.getBean(configMessageSourceBeanName, ConfigMessageSource.class);

    // 如果已经存在MessageSource bean,则将ConfigMessageSource设置为messageSource的parent,将messageSource原来的parent设置为ConfigMessageSource的parent
    if (beanFactory.containsLocalBean(messageSourceBeanName)) {
        MessageSource messageSource = beanFactory.getBean(messageSourceBeanName, MessageSource.class);
        if (messageSource instanceof HierarchicalMessageSource) {
            HierarchicalMessageSource hms = (HierarchicalMessageSource) messageSource;
            MessageSource pms = hms.getParentMessageSource();

            hms.setParentMessageSource(configMessageSource);
            configMessageSource.setParentMessageSource(pms);
        }
    } else {
        beanFactory.registerSingleton(messageSourceBeanName, configMessageSource);
    }
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:28,代码来源:ConfigMessageSourceConfigurer.java


示例2: messageSource

import org.springframework.context.HierarchicalMessageSource; //导入依赖的package包/类
@RefreshScope
@Bean
public HierarchicalMessageSource messageSource() {
    final CasReloadableMessageBundle bean = new CasReloadableMessageBundle();
    bean.setDefaultEncoding(casProperties.getMessageBundle().getEncoding());
    bean.setCacheSeconds(casProperties.getMessageBundle().getCacheSeconds());
    bean.setFallbackToSystemLocale(casProperties.getMessageBundle().isFallbackSystemLocale());
    bean.setUseCodeAsDefaultMessage(casProperties.getMessageBundle().isUseCodeMessage());
    bean.setBasenames(casProperties.getMessageBundle().getBaseNames());
    return bean;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:12,代码来源:CasCoreWebConfiguration.java


示例3: initMessageSource

import org.springframework.context.HierarchicalMessageSource; //导入依赖的package包/类
/**
 * Initialize the MessageSource.
 * Use parent's if none defined in this context.
 */
protected void initMessageSource() {
	ConfigurableListableBeanFactory beanFactory = getBeanFactory();
	if (beanFactory.containsLocalBean(MESSAGE_SOURCE_BEAN_NAME)) {
		this.messageSource = beanFactory.getBean(MESSAGE_SOURCE_BEAN_NAME, MessageSource.class);
		// Make MessageSource aware of parent MessageSource.
		if (this.parent != null && this.messageSource instanceof HierarchicalMessageSource) {
			HierarchicalMessageSource hms = (HierarchicalMessageSource) this.messageSource;
			if (hms.getParentMessageSource() == null) {
				// Only set parent context as parent MessageSource if no parent MessageSource
				// registered already.
				hms.setParentMessageSource(getInternalParentMessageSource());
			}
		}
		if (logger.isDebugEnabled()) {
			logger.debug("Using MessageSource [" + this.messageSource + "]");
		}
	}
	else {
		// Use empty MessageSource to be able to accept getMessage calls.
		DelegatingMessageSource dms = new DelegatingMessageSource();
		dms.setParentMessageSource(getInternalParentMessageSource());
		this.messageSource = dms;
		beanFactory.registerSingleton(MESSAGE_SOURCE_BEAN_NAME, this.messageSource);
		if (logger.isDebugEnabled()) {
			logger.debug("Unable to locate MessageSource with name '" + MESSAGE_SOURCE_BEAN_NAME +
					"': using default [" + this.messageSource + "]");
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:AbstractApplicationContext.java


示例4: initParent

import org.springframework.context.HierarchicalMessageSource; //导入依赖的package包/类
/**
 * Initialize the MessageSource of the given theme with the
 * one from the corresponding parent of this ThemeSource.
 * @param theme the Theme to (re-)initialize
 */
protected void initParent(Theme theme) {
	if (theme.getMessageSource() instanceof HierarchicalMessageSource) {
		HierarchicalMessageSource messageSource = (HierarchicalMessageSource) theme.getMessageSource();
		if (getParentThemeSource() != null && messageSource.getParentMessageSource() == null) {
			Theme parentTheme = getParentThemeSource().getTheme(theme.getName());
			if (parentTheme != null) {
				messageSource.setParentMessageSource(parentTheme.getMessageSource());
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ResourceBundleThemeSource.java


示例5: resolveRootMessageSource

import org.springframework.context.HierarchicalMessageSource; //导入依赖的package包/类
HierarchicalMessageSource resolveRootMessageSource(MessageSource messageSource) {

        if (messageSource instanceof HierarchicalMessageSource) {
            MessageSource parent = ((HierarchicalMessageSource) messageSource).getParentMessageSource();

            return parent != null ? resolveRootMessageSource(parent) : (HierarchicalMessageSource) messageSource;

        } else {
            return null;
        }
    }
 
开发者ID:jirutka,项目名称:spring-rest-exception-handler,代码行数:12,代码来源:RestHandlerExceptionResolverBuilder.java


示例6: build

import org.springframework.context.HierarchicalMessageSource; //导入依赖的package包/类
public RestHandlerExceptionResolver build() {

        if (withDefaultMessageSource) {
            if (messageSource != null) {
                // set default message source as top parent
                HierarchicalMessageSource messages = resolveRootMessageSource(messageSource);
                if (messages != null) {
                    messages.setParentMessageSource(createDefaultMessageSource());
                }
            } else {
                messageSource = createDefaultMessageSource();
            }
        }

        if (withDefaultHandlers) {
            // add default handlers
            putAllIfAbsent(exceptionHandlers, getDefaultHandlers());
        }

        // initialize handlers
        for (RestExceptionHandler handler : exceptionHandlers.values()) {
            if (messageSource != null && handler instanceof MessageSourceAware) {
                ((MessageSourceAware) handler).setMessageSource(messageSource);
            }
            if (messageInterpolator != null && handler instanceof MessageInterpolatorAware) {
                ((MessageInterpolatorAware) handler).setMessageInterpolator(messageInterpolator);
            }
        }

        RestHandlerExceptionResolver resolver = new RestHandlerExceptionResolver();
        resolver.setExceptionHandlers((Map) exceptionHandlers);

        if (httpMessageConverters != null) {
            resolver.setMessageConverters(httpMessageConverters);
        }
        if (contentNegotiationManager != null) {
            resolver.setContentNegotiationManager(contentNegotiationManager);
        }
        if (defaultContentType != null) {
            resolver.setDefaultContentType(defaultContentType);
        }
        resolver.afterPropertiesSet();

        return resolver;
    }
 
开发者ID:jirutka,项目名称:spring-rest-exception-handler,代码行数:46,代码来源:RestHandlerExceptionResolverBuilder.java



注:本文中的org.springframework.context.HierarchicalMessageSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IForgeRegistry类代码示例发布时间:2022-05-22
下一篇:
Java TCharSet类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap