package com.aperture_software.glados_wiki.spring.root; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.ehcache.EhCacheCacheManager; import org.springframework.cache.ehcache.EhCacheManagerFactoryBean; import org.springframework.context.annotation.AdviceMode; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; /** * Created by jhyun on 13. 12. 29. */ @ComponentScan(basePackages = { "com.aperture_software.glados_wiki.services", "com.aperture_software.glados_wiki.support", "com.aperture_software.glados_wiki.webmvc", }) @Configuration @EnableCaching(proxyTargetClass = true, mode = AdviceMode.PROXY) public class CacheContext { @Bean public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() { EhCacheManagerFactoryBean c = new EhCacheManagerFactoryBean(); c.setConfigLocation(new ClassPathResource("ehcache.xml")); return c; } @Bean public CacheManager cacheManager(net.sf.ehcache.CacheManager ehcacheManager) { EhCacheCacheManager cacheManager = new EhCacheCacheManager(); cacheManager.setCacheManager(ehcacheManager); return cacheManager; } }