当前位置: 首页>>代码示例>>Java>>正文


Java ResourceBundleMessageSource类代码示例

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


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

示例1: defaultMessageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Bean
public MessageSource defaultMessageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("messages", "i18n/messages");
    messageSource.setDefaultEncoding(Charset.forName("UTF-8").name());
    messageSource.setFallbackToSystemLocale(true);
    messageSource.setCacheSeconds(-1);
    messageSource.setAlwaysUseMessageFormat(false);
    messageSource.setUseCodeAsDefaultMessage(true);
    return messageSource;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:12,代码来源:LocaleConfiguration.java

示例2: getMessageService

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Override
   public MessageSource getMessageService(String messageFilename) {
if (messageFilename != null) {
    MessageSource ms = messageServices.get(messageFilename);
    if (ms == null) {
	ResourceBundleMessageSource rbms = (ResourceBundleMessageSource) beanFactory
		.getBean(LOADED_MESSAGE_SOURCE_BEAN);
	rbms.setBasename(messageFilename);
	messageServices.put(messageFilename, rbms);
	ms = rbms;
    }
    return ms;
} else {
    return null;
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:LoadedMessageSourceService.java

示例3: simpleTest

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Test
public void simpleTest() throws Throwable
{
	try
	{
		String dir = this.getClass().getResource("/").getFile();
		String resource = "writer";
		File dirFile = new File(dir);
		new PropertiesWriter().writePropertiesSet(this.messages(), new Locale("de"), resource, dirFile, "ISO-8859-1");

		ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
		messageSource.setBasename(resource);
		Assert.assertEquals(FR_TEST, messageSource.getMessage("test.key", null, new Locale("fr")));
		Assert.assertEquals(DE_TEST, messageSource.getMessage("test.key", null, new Locale("de")));
	}
	finally
	{

	}
}
 
开发者ID:namics,项目名称:spring-i18n-support,代码行数:21,代码来源:PropertiesWriterTest.java

示例4: onContextRefreshed

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Override
public void onContextRefreshed() {
    Set<String> messages = new HashSet<>();
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    for (String beanName : BeanFactory.getBeanNames()) {
        Package beanPackage = BeanFactory.getBeanClass(beanName).getPackage();
        if (beanPackage == null) {
            logger.warn(null, "无法获得Bean[{}]包。", beanName);

            continue;
        }

        String packageName = beanPackage.getName();
        if (resolver.getResource(packageName.replace('.', File.separatorChar) + "/message.properties").exists())
            messages.add(packageName);
    }

    String[] names = new String[messages.size()];
    int i = 0;
    for (String name : messages)
        names[i++] = name + ".message";
    messageSource = new ResourceBundleMessageSource();
    messageSource.setDefaultEncoding(context.getCharset(null));
    messageSource.setBasenames(names);
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:26,代码来源:MessageImpl.java

示例5: getJstlAwareMessageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
/**
 * Checks JSTL's "javax.servlet.jsp.jstl.fmt.localizationContext"
 * context-param and creates a corresponding child message source,
 * with the provided Spring-defined MessageSource as parent.
 * @param servletContext the ServletContext we're running in
 * (to check JSTL-related context-params in {@code web.xml})
 * @param messageSource the MessageSource to expose, typically
 * the ApplicationContext of the current DispatcherServlet
 * @return the MessageSource to expose to JSTL; first checking the
 * JSTL-defined bundle, then the Spring-defined MessageSource
 * @see org.springframework.context.ApplicationContext
 */
public static MessageSource getJstlAwareMessageSource(
		ServletContext servletContext, MessageSource messageSource) {

	if (servletContext != null) {
		String jstlInitParam = servletContext.getInitParameter(Config.FMT_LOCALIZATION_CONTEXT);
		if (jstlInitParam != null) {
			// Create a ResourceBundleMessageSource for the specified resource bundle
			// basename in the JSTL context-param in web.xml, wiring it with the given
			// Spring-defined MessageSource as parent.
			ResourceBundleMessageSource jstlBundleWrapper = new ResourceBundleMessageSource();
			jstlBundleWrapper.setBasename(jstlInitParam);
			jstlBundleWrapper.setParentMessageSource(messageSource);
			return jstlBundleWrapper;
		}
	}
	return messageSource;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:JstlUtils.java

示例6: init

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
public void init() {
    URL url = buildMidpointHomeLocalizationFolderUrl();
    ClassLoader classLoader = new URLClassLoader(new URL[]{url}, null);

    sources.add(buildSource("Midpoint", classLoader));
    sources.add(buildSource(SchemaConstants.BUNDLE_NAME, classLoader));
    sources.add(buildSource("localization/Midpoint", null));
    sources.add(buildSource(SchemaConstants.SCHEMA_LOCALIZATION_PROPERTIES_RESOURCE_BASE_PATH, null));

    // model security messages as fallback
    ResourceBundleMessageSource modelSecurity = new ResourceBundleMessageSource();
    modelSecurity.setBasename("com.evolveum.midpoint.security");
    sources.add(modelSecurity);

    // spring security messages as a fallback
    ResourceBundleMessageSource springSecurity = new ResourceBundleMessageSource();
    springSecurity.setBasename("org.springframework.security.messages");
    sources.add(springSecurity);
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:20,代码来源:LocalizationServiceImpl.java

示例7: resolve

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Override
public void resolve(Component component) {
    if( component.isPlain()) return;
    logger.debug("Resolving {} {} feature", component, getName());
    ApplicationContext parent = resolveContext.getRootContext() ;
    ClassLoader realm = component.getClassLoader();
    //在根据配置的情况下,根据 manifest里面的App-Message加载资源
    String appMessage = getAppMessage(component);
    if(StringUtils.isNotBlank(appMessage)){
        CombinedMessageSource combined  = parent.getBean(CombinedMessageSource.class);
        ResourceBundleMessageSource source = new ResourceBundleMessageSource();
        source.setBundleClassLoader(realm);
        source.setBasenames(StringUtils.split(appMessage, CONFIG_LOCATION_DELIMITERS));
        combined.combine(source);
    }
    resolveContext.registerFeature(component, getName(), realm);
}
 
开发者ID:Kadvin,项目名称:spring-component-framework,代码行数:18,代码来源:StaticFeatureResolver.java

示例8: beforeClass

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@BeforeClass
public void beforeClass()
{
	AllPropertiesMessageSource molgenisLocalizationMessages = new AllPropertiesMessageSource();
	molgenisLocalizationMessages.addMolgenisNamespaces("web");
	ResourceBundleMessageSource hibernateValidationMessages = new ResourceBundleMessageSource();
	hibernateValidationMessages.addBasenames("org.hibernate.validator.ValidationMessages");
	molgenisLocalizationMessages.setParentMessageSource(hibernateValidationMessages);
	MessageSourceHolder.setMessageSource(molgenisLocalizationMessages);

	globalError = new ObjectError("entityCollectionRequestV2", new String[] { "TwoFieldsSet" }, new Object[] { 1 },
			"must have two fields set");
	fieldError = new FieldError("entityCollectionRequestV2", "num", -10, false,
			new String[] { "Min.entityCollectionRequestV2.num", "Min.num", "Min.int", "Min" }, new Object[] {
			new DefaultMessageSourceResolvable(new String[] { "entityCollectionRequestV2.num", "num" }, null,
					"num"), 0 }, "must be greater than or equal to 0");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:18,代码来源:SpringExceptionHandlerTest.java

示例9: messageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Bean
public ResourceBundleMessageSource messageSource()
{
    ResourceBundleMessageSource source = new ResourceBundleMessageSource();
    source.setBasename("locale/messages");
    source.setDefaultEncoding("UTF-8");
    return source;
}
 
开发者ID:scrumtracker,项目名称:scrumtracker2017,代码行数:9,代码来源:ApplicationContext.java

示例10: createMessageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Override
protected MessageSource createMessageSource(String basename) {
    ResourceBundleMessageSource messageSource = (ResourceBundleMessageSource) super.createMessageSource(basename);

    // Create parent theme recursively.
    for (Theme theme : settingsService.getAvailableThemes()) {
        if (basename.equals(basenamePrefix + theme.getId()) && theme.getParent() != null) {
            String parent = basenamePrefix + theme.getParent();
            messageSource.setParentMessageSource(createMessageSource(parent));
            break;
        }
    }
    return messageSource;
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:15,代码来源:CustomThemeSource.java

示例11: mailMessageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Bean
public MessageSource mailMessageSource() {
    ResourceBundleMessageSource msgsource = new ResourceBundleMessageSource();
    if (nixmashModeEnabled)
        msgsource.setBasename("mail-nixmash");
    else
        msgsource.setBasename("mail-messages");
    return msgsource;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:10,代码来源:MailConfig.java

示例12: messageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Bean
public MessageSource messageSource() {
    ResourceBundleMessageSource msgsource = new ResourceBundleMessageSource();
    if (nixmashModeEnabled)
        msgsource.setBasename("nixmash");
    else
        msgsource.setBasename("messages");

    msgsource.setUseCodeAsDefaultMessage(
            Boolean.parseBoolean(environment.getRequiredProperty(USE_CODE_AS_DEFAULT_MESSAGE)));
    return msgsource;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:13,代码来源:WebConfig.java

示例13: messageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
/**
 * @return ResourceBundleMessageSource pour les messages de l'application
 */
@Bean
public ResourceBundleMessageSource messageSource() {
	ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
	resourceBundleMessageSource.setBasenames(
			"i18n/messages",
			"i18n/backoffice/backoffice-messages",
			"i18n/backoffice/nomenclature-messages",
			"i18n/candidat/candidat-messages");
	resourceBundleMessageSource.setFallbackToSystemLocale(false);
	return resourceBundleMessageSource;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:15,代码来源:SpringConfig.java

示例14: messageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Bean
public ResourceBundleMessageSource messageSource() {
    ResourceBundleMessageSource source = new ResourceBundleMessageSource();
    source.setBasenames("i18n/messages");
    source.setUseCodeAsDefaultMessage(true);
    source.setDefaultEncoding("UTF-8");
    return source;
}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:9,代码来源:LocalizationConfiguration.java

示例15: messageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入依赖的package包/类
@Bean
public MessageSource messageSource()
{
  ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
  resourceBundleMessageSource.setDefaultEncoding("UTF-8");
  resourceBundleMessageSource.addBasenames("templates/index");
  return resourceBundleMessageSource;
}
 
开发者ID:de-luxe,项目名称:burstcoin-faucet,代码行数:9,代码来源:BurstcoinFaucet.java


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