Spring Framework AbstractMessageSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework AbstractMessageSource class.

This code example shows how to use the following methods:
 * </p> 
 *  
 * @author Arvids Grabovskis 
 * @version $Revision$ 
 */ 
public class DatabaseMessageSource extends AbstractMessageSource implements MessageSource { 
     
    private IMessageDao messageDao; 
     
    @Autowired 
    public void setMessageDao(IMessageDao messageDao) { 
        this.messageDao = messageDao; 
    } 
     
    @Override 
    protected MessageFormat resolveCode(String code, Locale locale) { 
        if (locale == null) { 
            return null; 
        } 
         
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 *  
 * @author JunHo Yoon 
 * @since 3.1 
 */ 
@Component("userMessageSource") 
public class UserMessageSource extends AbstractMessageSource {
 
	private static final Logger LOGGER = LoggerFactory.getLogger(UserMessageSource.class); 
	@Autowired 
	private Config config;
 
	// It's safe to use hash map in multi thread here. because it's read only. 
	private Map<LocaleAndCode, MessageFormat> langMessageMap = Maps.newHashMap();
 
	/** 
	 * Message key holder with local and code. 
	 *  
	 * @author JunHo Yoon 
	 * @since 3.1 
	 */ 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    public void translateTest() throws Exception {
        when(serverReceivesGetRequest("/")); 
        then(theGetResult(), body(is(equalTo("Hello JTwig-New")))); 
    } 
 
    public static class InMemoryMessageSource extends AbstractMessageSource {
        private Map<String, String> map = new HashMap<String, String>();
 
        @Override 
        protected MessageFormat resolveCode(String code, Locale locale) {
            return new MessageFormat(map.get(code), locale);
        } 
 
        public InMemoryMessageSource add (String code, String message) {
            this.map.put(code, message);
            return this;
        } 
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDefaultMessage
     
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
     
    @Override 
    protected String getDefaultMessage(final String code) {
        final String messageToReturn = super.getDefaultMessage(code);
        if (!StringUtils.isBlank(messageToReturn) && messageToReturn.equals(code)) {
            logger.warn("The code [{}] cannot be found in the default language bundle and will "
                    + "be used as the message itself.", code);
        } 
        return messageToReturn;
    } 
 
    @Override 
    protected String getMessageInternal(final String code, final Object[] args, final Locale locale) {
        boolean foundCode = false;
         
        if (!locale.equals(Locale.ENGLISH)) {
          for (int i = 0; !foundCode && i < this.basenames.length; i++) {
              final String filename = this.basenames[i] + "_" + locale.getLanguage();
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java