Package com.jpoweredcart.common.i18n

Examples of com.jpoweredcart.common.i18n.CustomMessageResolver


  }
 
  @Bean
  public MessageResolver messageResolver(){
   
    CustomMessageResolver messageResolver = new CustomMessageResolver();
    messageResolver.setEnvironment(env);
    String baseDir = env.getProperty("language.baseDir", "/WEB-INF/languages");
    if(baseDir.startsWith("/")){
      baseDir = servletContext.getRealPath(baseDir);
    }
    messageResolver.setBaseDir(baseDir);
    messageResolver.setJdbcTemplate(jdbcOperations);
    messageResolver.setLocaleResolver(localeResolver());
   
    boolean cacheable = env.getProperty("language.cacheable", Boolean.class, Boolean.TRUE);
    if(cacheable){
      EhCacheFactoryBean cacheFactory = new EhCacheFactoryBean();
      //use default cache manager CacheManager.getInstance();
      cacheFactory.setCacheName("messageCache");
      try {
        cacheFactory.afterPropertiesSet();
      } catch (Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
      }
      messageResolver.setCacheable(true);
      messageResolver.setCache(cacheFactory.getObject());
    }else{
      messageResolver.setCacheable(false);
    }
   
    return messageResolver;
  }
View Full Code Here


public class CustomMessageResolverTest {
 
  private CustomMessageResolver messageResolver;
 
  public CustomMessageResolverTest(){
    messageResolver = new CustomMessageResolver();
  }
View Full Code Here

TOP

Related Classes of com.jpoweredcart.common.i18n.CustomMessageResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.