Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For anyone who needs to modify the diskstore path which cannot be set as the ehcache javadoc states that the diskstore parameter is ignored, you could create your own implementation of a EhCacheManagerFactoryBean, which allows you to inject the diskstore path; you basically need to intercept the creation of the CacheManager and modify the configuration passed along using your diskstore property, e.g.:</p> <pre><code>private String diskStorePath; ...getter/setter public void afterPropertiesSet() throws IOException, CacheException { if (this.shared) { // Shared CacheManager singleton at the VM level. if (this.configLocation != null) { this.cacheManager = CacheManager.create(this.createConfig()); } else { this.cacheManager = CacheManager.create(); } } else { // Independent CacheManager instance (the default). if (this.configLocation != null) { this.cacheManager = new CacheManager(this.createConfig()); } else { this.cacheManager = new CacheManager(); } } if (this.cacheManagerName != null) { this.cacheManager.setName(this.cacheManagerName); } } private Configuration createConfig() throws CacheException, IOException { Configuration config = ConfigurationFactory.parseConfiguration(this.configLocation.getInputStream()); DiskStoreConfiguration diskStoreConfiguration = config.getDiskStoreConfiguration(); if (diskStoreConfiguration == null) { DiskStoreConfiguration diskStoreConfigurationParameter = new DiskStoreConfiguration(); diskStoreConfigurationParameter.setPath(getDiskStorePath()); config.addDiskStore(diskStoreConfigurationParameter); } else { diskStoreConfiguration.setPath(getDiskStorePath()); } return config; } </code></pre> <p>The Spring config then looks like this:</p> <pre><code>&lt;bean id="cacheManager" class="com.yourcompany.package.MyEhCacheManagerFactoryBean" depends-on="placeholderConfig"&gt; &lt;property name="diskStorePath" value="${diskstore.path}"/&gt; &lt;property name="configLocation" value="classpath:ehcache.xml" /&gt; &lt;/bean&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload