if(applicationContext.containsBean("custom_settingService")){
return (SettingService)applicationContext.getBean("custom_settingService");
}
DefaultSettingService settingService = new DefaultSettingService();
settingService.setJdbcOperations(jdbcOperations());
settingService.setEnvironment(env);
if(env.getProperty("setting.cacheable", Boolean.class, Boolean.FALSE)){
EhCacheFactoryBean cacheFactory = new EhCacheFactoryBean();
//use default cache manager CacheManager.getInstance();
cacheFactory.setCacheName("settingCache");
try{
cacheFactory.afterPropertiesSet();
}catch(Exception e){
//TODO: do something
e.printStackTrace();
}
Ehcache settingCache = cacheFactory.getObject();
settingService.setSettingCache(settingCache);
}
return settingService;
}