Announcement Announcement Module
Collapse
No announcement yet.
no strategy for own @Cacheable annotation parsing available? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • no strategy for own @Cacheable annotation parsing available?

    Hi,

    we have a CDI application which we are about to migrate to a Spring application. In CDI we used an own @Cachable annotation inspired by Springs Cache abstraction and an Interceptor which works like org.springframework.cache.interceptor.CacheAspectS upport.

    While we are migrating towards a Spring application, we want to continue using our own Annotations in our components (Business Services). But instead of using our own CDI Caching Interceptor, we now want to use Springs own Caching engine in proxy mode.

    Our @Cachable (Evict, Put....) annotations are 100% compatible to the Spring annotation definitions. We are able to provide a Spring @CacheManager in an upper layer of our application which is Spring-depending, but the Spring Caching framework only acts on Springs own @Chacheable annotations and ignores ours as can be seen in org.springframework.cache.annotation.SpringCacheAn notationParser. We found no hook to switch to another strategy (CacheAnnotationParser).

    What we've tried so far:

    1.) We defined an own CacheAnnotationParser which works with our @Cacheable annotations and not the @Cacheable annotations (Evict, Put...) provided by spring but exactly like the SpringCacheAnnotationParser.
    2.) Afterwards we created an own ProxyCachingConfiguration exactly like org.springframework.cache.annotation.ProxyCachingC onfiguration. The only difference is, that our CacheOperationSource Bean is wired up differently. Springs own CacheOperationSource Bean definition:
    Code:
    	@Bean
    	@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    	public CacheOperationSource cacheOperationSource() {
    		return new AnnotationCacheOperationSource();
    	}
    Our Bean definition:
    Code:
    	@Bean
    	@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    	public CacheOperationSource cacheOperationSource() {
    		return new AnnotationCacheOperationSource(new OurCacheAnnotationParser());
    	}
    3.) To switch off the currently hardcoded default mechanism for Annotation Parsing and Auto Proxying in Spring, we removed the @EnableCaching annotation in our Javaconfig based Spring configuration.
    4.) The beans we are providing in our ProxyCachingConfiguration are generally wired, but the auto proxy mechanism does not start automatically and we can't find any hook to start it up manually.

    Another approach we tried to use @EnableCaching and create an Bean Post Processor to hook us into the wirering of the original BeanFactoryCacheOperationSourceAdvisor implementation in spring and redefine the CacheOperationSource with our CacheOperationSource implementation
    But our own BeanPostProcessor is not executed during starting up the context and wirering the BeanFactoryCacheOperationSourceAdvisor Bean.

    Maybe we are a bit lost here in details, but our general goal is:

    Our own Cache annotations used in our core business service domain layer should behave in the same manner as the Spring Cache annotations when used in a Spring application Context. Our core business service domain layer only allows JSR annotations and is generelly technologyless. This is why we invented our own Cache-annotations in the first place as it helps us in abstracting the technologies.

    Greetings from the sunny Cologne in Germany!
    Last edited by OlliL; Jul 17th, 2013, 04:13 AM.
Working...
X