Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-8620

create a mechanism to proxy non-spring managed objects for the new cache abstraction apis



    • Last commented by a User:


      We have a usecase where we have services that in certain cases are spring-managed while in other cases are not and instantiated in code.

      For example: We have a service interface like the following:

      interface FooService {
      @Cacheable(value="foos" key="#id")
      Foo getFoo(String id);

      Sometimes the implementation of this interface comes from Spring. Other times this implementation comes from org.apache.cxf.frontend.ClientProxyFactoryBean (or something similar) and is proxied (instantiated) directly in code.

      The problem is, the caching proxies will only be created when the bean is spring managed. We would like the ability to Proxy an instance with a caching proxy on the fly, in code. For example:

      ClientProxyFactoryBean clientFactory...
      CacheManager cacheManager... //lookup the CacheManager

      FooService fs = (FooService) clientFactory.create();
      fs = CachedProxy.createCacheProxy(fs, cacheManager); //creates a Proxy with the caching logic based on the Spring annotations on the interface

      I created something to do just this which I'll attach to the jira. One problem with my implementation is it uses package private Spring classes. It would be nice if the spring provided a mechanism to do this. If nothing else it would be good of some of the Spring caching code was opened up so that it could be accessed from other packages. Please feel free to use any parts of the attached code if you want.

      My code is based on milestone 2. Thanks.




            snicoll St├ęphane Nicoll
            leo.herbie Travis Schneeberger
            Last updater:
            Spring Issuemaster
            2 Vote for this issue
            3 Start watching this issue


              Days since last comment:
              1 year, 20 weeks, 3 days ago