I like the new Cache abstraction that is possible using Annotations. I am wondering if there's been thought put toward enabling Cache abstraction for classes that you don't have control of (third-party libs).
Maybe something like:
...Code:@Bean @CacheableBean(cacheInstructor = AbstractCachingThirdPartyApi.class) public ThirdPartyApi thirdPartyApi() { return new ThirdPartyApiImpl(); }
The reason why I say this is because the cleanest alternative I've come up with is using classes that refer to delegates.Code:// The same approach could be taken for classes instead of interface, if necessary public abstract class AbstractCachingThirdPartyApi implements ThirdPartyApi { // Any methods that should be cached can be annotated @Cacheable("responseObjectCache") public abstract ResponseObject fetchObject(int id); }


Reply With Quote
