本文整理汇总了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;
}
}
示例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
{
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}