title: Ehcache and spring bootstrapcacheloader not working
body: <p>I am trying to setup a bootstrapcacheloader which will query the database and populate the cache. Here I am using ehcache integrated with spring. But the problem is that I am not able to get the dependencies wired into my cacheloader implementation. The @Autowired,@Resource,@Configurable none of them seem to work. Quite obviously the cacheloader instantiation is not done by Spring container , but is there a way I can inject a spring created cacheloader instance into the cachemanager and bootstrap it?
  My implementation details below.
  <strong>ehcache.xml</strong></p>
  
  <pre><code>&lt;cache name="MyCache"
         maxElementsInMemory="100000"
         eternal="false" 
         overflowToDisk="false"
         timeToLiveSeconds="500"&gt;
        &lt;!--  &lt;pinning store="localMemory"/&gt; --&gt;
        &lt;bootstrapCacheLoaderFactory class="net.tristargroup.claims.helper.ClaimsCacheLoaderFactory" properties="bootstrapAsynchronously=true"/&gt;
         &lt;cacheEventListenerFactory class="net.tristargroup.claims.helper.TristarCacheEventListenerFactory" listenFor="all"/&gt;
  
  &lt;/cache&gt;
  </code></pre>
  
  <p><strong>Spring Context xml</strong></p>
  
  <pre><code>&lt;cache:annotation-driven/&gt;
  
  &lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"&gt;
      &lt;property name="cacheManager"&gt;&lt;ref local="ehcache"/&gt;&lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" depends-on="cacheLoader"&gt;
      &lt;property name="configLocation" value="classpath:ehcache.xml"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p><strong>Cache loader class</strong></p>
  
  <pre><code> @Configurable
  </code></pre>
  
  <p>public class ClaimsCacheLoaderFactory extends BootstrapCacheLoaderFactory{</p>
  
  <pre><code>@Resource
  CacheManager cacheManager;
      .
      .
      .
      @Override
  public BootstrapCacheLoader createBootstrapCacheLoader(Properties arg0) {
      System.out.println("Create cache loader method . Cache manager is -&gt;"+cacheManager);
      BootstrapCacheLoader cacheLoader = new ClaimsCacheLoader();
      return cacheLoader;
  }
  </code></pre>
  
  <p>The cacheManager instance is always null here even if I specify it as an Autowired attribute.
  The problem is present even in the cache event listeners. 
  Someone please help me on this.</p>