Project

General

Profile

Download (1.5 KB) Statistics
| Branch: | Tag: | Revision:
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.log4j.Logger;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.context.annotation.Bean;
16
import org.springframework.context.annotation.Configuration;
17

    
18
import eu.etaxonomy.cdm.common.ConfigFileUtil;
19
import net.sf.ehcache.config.DiskStoreConfiguration;
20

    
21
/**
22
 * @author a.kohlbecker
23
 * @since Feb 1, 2017
24
 *
25
 */
26
@Configuration
27
public class EhCacheDiskStoreConfiguration {
28

    
29
    public static final Logger logger = Logger.getLogger(EhCacheDiskStoreConfiguration.class);
30

    
31
    @Autowired
32
    private DataSourceProperties dataSourceProperties = null;
33

    
34
    @Bean
35
    public DiskStoreConfiguration diskStoreConfiguration(){
36

    
37
        DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
38
        File ehcacheFolder = ConfigFileUtil.getCdmHomeSubDir("ehcache");
39
        String instanceName = dataSourceProperties.getCurrentDataSourceId();
40
        File instanceCacheFolder = new File(ehcacheFolder, instanceName);
41
        logger.debug("Setting ehcache diskstore location to " + instanceCacheFolder.getAbsolutePath());
42
        diskStoreConfiguration.setPath(instanceCacheFolder.getAbsolutePath());
43

    
44
        return diskStoreConfiguration;
45
    }
46

    
47
}
(3-3/5)