public interface SampleDAO {
public Sample findById( int id);
public Sample findByUrl( String url);
public void save(Sample sample);
}
public class SampleDAOImpl implements SampleDAO {
public Sample findById( int id) { /* - */ }
public Sample findByUrl( String url) { /* - */ }
public void save(Sample sample) { /* - */ }
}
* This source code was highlighted with Source Code Highlighter .< bean id ="sampleDAO" class ="SampleDAOImpl" >
< property name ="persistenceManagerFactory" ref ="persistenceManagerFactory" />
</ bean >
* This source code was highlighted with Source Code Highlighter .$ git clone git://github.com/abashev/spring-modules.git
$ cd spring-modules/projects
$ mvn install // , xml
$ cd spring-modules-cache
$ mvn install -DskipTests
* This source code was highlighted with Source Code Highlighter .public class SampleDAOImpl {
@Cacheable(modelId = "findByOldId" )
public Sample findById( int id) { /* - */ }
@Cacheable(modelId = "findByUrl" )
public Sample findByUrl( String url) { /* - */ }
@CacheFlush(modelId = "save" )
public void save(Sample sample) { /* - */ }
}
* This source code was highlighted with Source Code Highlighter .<!-- Cache manager for Jsr107 cache -->
< bean id ="cacheManager" class ="org.springmodules.cache.provider.jsr107.Jsr107CacheManagerFactoryBean" />
* This source code was highlighted with Source Code Highlighter .< bean id ="cacheProviderFacade" class ="org.springmodules.cache.provider.jsr107.Jsr107CacheFacade" >
< property name ="cacheManager" ref ="cacheManager" />
< property name ="cacheProperties" >
< map >
< entry key ="findByOldId" >
< map >
< entry key ="com.google.appengine.api.memcache.jsr107cache.NAMESPACE" value ="findByOldId" />
</ map >
</ entry >
< entry key ="findByUrl" >
< map >
< entry key ="com.google.appengine.api.memcache.jsr107cache.NAMESPACE" value ="findByUrl" />
</ map >
</ entry >
</ map >
</ property >
</ bean >
* This source code was highlighted with Source Code Highlighter .< bean id ="cachingAttributeSource" class ="org.springmodules.cache.annotations.AnnotationCachingAttributeSource" />
< bean id ="cachingInterceptor" class ="org.springmodules.cache.interceptor.caching.MetadataCachingInterceptor" >
< property name ="cacheProviderFacade" ref ="cacheProviderFacade" />
< property name ="cachingAttributeSource" ref ="cachingAttributeSource" />
< property name ="cachingModels" >
< map >
<!-- modelId -->
< entry key ="findByOldId" >
< bean class ="org.springmodules.cache.provider.jsr107.Jsr107CacheCachingModel" >
< constructor-arg value ="findByOldId" />
</ bean >
</ entry >
< entry key ="findByUrl" >
< bean class ="org.springmodules.cache.provider.jsr107.Jsr107CacheCachingModel" >
< constructor-arg value ="findByUrl" />
</ bean >
</ entry >
</ map >
</ property >
</ bean >
< bean id ="cachingAttributeSourceAdvisor" class ="org.springmodules.cache.interceptor.caching.CachingAttributeSourceAdvisor" >
< constructor-arg ref ="cachingInterceptor" />
</ bean >
* This source code was highlighted with Source Code Highlighter .< bean id ="flushingAttributeSource" class ="org.springmodules.cache.annotations.AnnotationFlushingAttributeSource" />
< bean id ="flushingInterceptor" class ="org.springmodules.cache.interceptor.flush.MetadataFlushingInterceptor" >
< property name ="cacheProviderFacade" ref ="cacheProviderFacade" />
< property name ="flushingAttributeSource" ref ="flushingAttributeSource" />
< property name ="flushingModels" >
< map >
<!-- modelId -->
< entry key ="save" >
< bean class ="org.springmodules.cache.provider.jsr107.Jsr107CacheFlushingModel" >
< constructor-arg value ="findByOldId, findByUrl" />
</ bean >
</ entry >
</ map >
</ property >
</ bean >
< bean id ="flushingAttributeSourceAdvisor" class ="org.springmodules.cache.interceptor.flush.FlushingAttributeSourceAdvisor" >
< constructor-arg ref ="flushingInterceptor" />
</ bean >
* This source code was highlighted with Source Code Highlighter .< bean class ="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" />
* This source code was highlighted with Source Code Highlighter .Source: https://habr.com/ru/post/98972/
All Articles