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


Java ResourceBundleMessageSource.setBasename方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: mailSetup

import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Before
public void mailSetup() {
  configuration = new Configuration(Configuration.VERSION_2_3_21);
  configuration.setDefaultEncoding("UTF-8");
  configuration.setTemplateLoader(new ClassTemplateLoader(MailComposer.class, "/mail"));

  //keep config same as application.yml and WebConfiguration.java
  messageSource = new ResourceBundleMessageSource();
  messageSource.setBasename("i18n/messages");
  messageSource.setDefaultEncoding("UTF-8");
  messageSource.setFallbackToSystemLocale(false);
}
 
开发者ID:kaif-open,项目名称:kaif,代码行数:13,代码来源:MailTestCases.java

示例6: 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

示例7: 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

示例8: 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

示例9: getMessageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean(name = "messageSource")
public MessageSource getMessageSource() {
    ResourceBundleMessageSource resource = new ResourceBundleMessageSource();
    resource.setBasename("messages");
    resource.setDefaultEncoding("UTF-8");
    return resource;
}
 
开发者ID:csokafor,项目名称:spring-security-angularjs,代码行数:8,代码来源:ServiceConfig.java

示例10: createMessageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
/**
 * Create a MessageSource for the given basename,
 * to be used as MessageSource for the corresponding theme.
 * <p>Default implementation creates a ResourceBundleMessageSource.
 * for the given basename. A subclass could create a specifically
 * configured ReloadableResourceBundleMessageSource, for example.
 * @param basename the basename to create a MessageSource for
 * @return the MessageSource
 * @see org.springframework.context.support.ResourceBundleMessageSource
 * @see org.springframework.context.support.ReloadableResourceBundleMessageSource
 */
protected MessageSource createMessageSource(String basename) {
	ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
	messageSource.setBasename(basename);
	if (this.defaultEncoding != null) {
		messageSource.setDefaultEncoding(this.defaultEncoding);
	}
	if (this.fallbackToSystemLocale != null) {
		messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
	}
	if (this.beanClassLoader != null) {
		messageSource.setBeanClassLoader(this.beanClassLoader);
	}
	return messageSource;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:ResourceBundleThemeSource.java

示例11: validateSubmission

import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
private String validateSubmission(SubmissionJudge submit, int lid){
    String errors = null;
    ResourceBundleMessageSource r=new ResourceBundleMessageSource();
    r.setBasename("messages_en");               
    submit.getLanguageIdByKey();        
    try{        
        if (!utilDAO.bool("submit.enabled"))
            return r.getMessage("errormsg.43", null, new Locale("en")).toLowerCase();

        if (!problemDAO.exists(submit.getPid()) || !problemDAO.isEnabled(submit.getPid()))
            return r.getMessage("errormsg.25", null, new Locale("en")).toLowerCase();

        if (problemDAO.isDisable24h(submit.getPid())) 
            return r.getMessage("errormsg.25", null, new Locale("en")).toLowerCase();

        int problemSourceLimit = problemDAO.getSourceLimitByPid(submit.getPid(), lid);

        if (submit.getCode().length() == 0)
            return r.getMessage("errormsg.27", null, new Locale("en")).toLowerCase();

        if (submit.getCode().length() > problemSourceLimit) 
            return r.getMessage("errormsg.28", null, new Locale("en")).toLowerCase();

    
    }catch(Exception e){
        errors = r.getMessage("errormsg.43", null, new Locale("en")).toLowerCase();
    }
    return errors;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:30,代码来源:RestJudgmentsController.java

示例12: validateEmail

import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
private String validateEmail(Mail mail) {
    String errors = null;
    ResourceBundleMessageSource r=new ResourceBundleMessageSource();
    r.setBasename("messages_en");
    try {
        if((mail.getTitle() == null || mail.getTitle().length() == 0) && (mail.getContent() == null || mail.getContent().length() == 0)) 
            return r.getMessage("errormsg.39",null, new Locale("en")).toLowerCase();
        
        if(mail.getUsernameTo().equals("") || mail.getUsernameTo() == null)
            return r.getMessage("errormsg.40",null, new Locale("en")).toLowerCase();
        
        String[] to = mail.getUsernameTo().split(";");
           if (to.length <= 10) {
            for (String to1 : to) {
                String string = to1.replaceAll(" ", "");
                if (!userDAO.isUser(string)) {
                    return r.getMessage("errormsg.41",null, new Locale("en")).toLowerCase();
                }
            }
            } else 
               return r.getMessage("errormsg.42",null, new Locale("en")).toLowerCase();
                        
            Mail m1 = mailDAO.getMailValues(mail.getId_from());
            int max = m1.getMail_quote();
            int consumed = m1.getConsumed_quote();
            int msgSize = mail.getContent().getBytes().length + mail.getTitle().getBytes().length;
            if (consumed + msgSize > max) 
                return "quote overflow";
      
            return errors;
    } catch (Exception e) {
        errors = "no valid mail";
    }
    
    return errors;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:37,代码来源:RestMailController.java

示例13: messageFactoryShowcase

import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
@Qualifier("wte4j-showcase")
public MessageFactory messageFactoryShowcase() {
	ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
	messageSource.setBasename("org.wte4j.examples.showcase.shared.Messages");
	return new MessageFactoryImpl(messageSource, serviceContext);
}
 
开发者ID:wte4j,项目名称:wte4j,代码行数:8,代码来源:Wte4jConfiguration.java

示例14: messageFactory

import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
@Qualifier("wte4j-admin")
public MessageFactory messageFactory() {
	ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
	messageSource.setBasename("org.wte4j.ui.shared.Messages");
	return new MessageFactoryImpl(messageSource, serviceContext);
}
 
开发者ID:wte4j,项目名称:wte4j,代码行数:8,代码来源:Wte4jAdminConfig.java

示例15: messageSource

import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public ResourceBundleMessageSource messageSource() {
    ResourceBundleMessageSource resource = new ResourceBundleMessageSource();
    resource.setBasename("messages");
    resource.setDefaultEncoding(StandardCharsets.UTF_8.toString());
    return resource;
}
 
开发者ID:muhamadto,项目名称:CoffeeBeansRest,代码行数:8,代码来源:ServicesConfig.java


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