當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。