Friday 15 March 2013

java - Cannot add Spring Cache advice to method - internalCacheAdvisor is created in same batch as cachable annotated bean -



java - Cannot add Spring Cache advice to method - internalCacheAdvisor is created in same batch as cachable annotated bean -

we have refactored parts of our application, , after that, methods annotated spring cachable stopped beingness cached although class containing cached method not touched.

after debugging, can see after refactoring , adding new spring beans, bean cachable method created in same batch internalcacheadvisor itself. advice can not applied , spring cache aspect never invoked. method result not cached, @cachable annotation not work.

what mechanism deciding beans can created simultaneously, , how can debug , impact mechanism?

i have looked in spring method beanfactoryadvisorretrievalhelper::findadvisorbeans, , when running old , worikng code, looks this:

after refactoring looks this:

our annotated class couchbasetranslationprovider created @ same batch internalcacheadvisor, not possible. when trying apply advice proxy, debug message "skipping created advisor ...". (i think should have been error message!)

our pom-file enabling cache looks this:

@configuration @enablewebmvc @componentscan({"[package]", "[package].connectors"}) @import({eventsconfig.class, cmsconfig.class}) @enablecaching public class apiconfig { public static class caches{ public static final string sports = "sports"; [...] public static final string pipedtranslations = "translations"; } @value("${[package].document}") private string someurl; @bean public couchbaseclient getcouchbaseclient() throws ioexception { [code] } @bean public cachemanager cachemanager() { simplecachemanager cachemanager = new simplecachemanager(); cachemanager.setcaches(arrays.aslist(new concurrentmapcache(caches.sports), [...], new concurrentmapcache(caches.pipedtranslations))); homecoming cachemanager; } @autowired private eventupdategate eventupdategate; @bean @conditionalonproperty("adaptergate.events.active") public adaptergatereceiver eventadaptergatereceiver(@value("${adaptergate.events.gatechannel}") string channel, @value("${adaptergate.events.apiversion}") string version) { homecoming new adaptergatereceiver(channel, version, eventupdategate); } }

java spring spring-annotations spring-cache

No comments:

Post a Comment