1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.opt.config;
|
10
|
|
11
|
import java.io.File;
|
12
|
|
13
|
import org.apache.logging.log4j.LogManager;
|
14
|
import org.apache.logging.log4j.Logger;
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
import org.springframework.context.annotation.Bean;
|
17
|
import org.springframework.context.annotation.Configuration;
|
18
|
|
19
|
import eu.etaxonomy.cdm.config.ConfigFileUtil;
|
20
|
import net.sf.ehcache.config.DiskStoreConfiguration;
|
21
|
|
22
|
/**
|
23
|
* @author a.kohlbecker
|
24
|
* @since Feb 1, 2017
|
25
|
*/
|
26
|
@Configuration
|
27
|
public class EhCacheDiskStoreConfiguration {
|
28
|
|
29
|
public static final Logger logger = LogManager.getLogger(EhCacheDiskStoreConfiguration.class);
|
30
|
|
31
|
@Autowired
|
32
|
private DataSourceProperties dataSourceProperties = null;
|
33
|
|
34
|
@Autowired
|
35
|
private ConfigFileUtil configFileUtil;
|
36
|
|
37
|
@Bean
|
38
|
public DiskStoreConfiguration diskStoreConfiguration(){
|
39
|
|
40
|
DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
|
41
|
File ehcacheFolder = configFileUtil.getCdmHomeSubDir("ehcache");
|
42
|
String instanceName = dataSourceProperties.getCurrentDataSourceId();
|
43
|
File instanceCacheFolder = new File(ehcacheFolder, instanceName);
|
44
|
logger.debug("Setting ehcache diskstore location to " + instanceCacheFolder.getAbsolutePath());
|
45
|
diskStoreConfiguration.setPath(instanceCacheFolder.getAbsolutePath());
|
46
|
|
47
|
return diskStoreConfiguration;
|
48
|
}
|
49
|
|
50
|
}
|