Revision 506d9934
Added by Andreas Kohlbecker about 7 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/cache/CdmServiceCacher.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.cdm.api.cache; |
2 | 2 |
|
3 |
import java.io.File; |
|
3 | 4 |
import java.util.UUID; |
4 | 5 |
|
5 | 6 |
import org.springframework.stereotype.Component; |
6 | 7 |
|
7 | 8 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
9 |
import eu.etaxonomy.cdm.api.config.EhCacheConfiguration; |
|
10 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
8 | 11 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
9 | 12 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
10 | 13 |
import eu.etaxonomy.cdm.model.common.TermBase; |
... | ... | |
17 | 20 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager; |
18 | 21 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManagerObserver; |
19 | 22 |
import net.sf.ehcache.config.CacheConfiguration; |
23 |
import net.sf.ehcache.config.DiskStoreConfiguration; |
|
20 | 24 |
import net.sf.ehcache.config.SizeOfPolicyConfiguration; |
21 | 25 |
|
22 | 26 |
/** |
... | ... | |
30 | 34 |
* |
31 | 35 |
* @param <T> |
32 | 36 |
*/ |
33 |
@Component |
|
37 |
@Component //FIXME This indicates that the CdmServiceCacher is initialized as Spring Component but it seems only to be instantiated directly
|
|
34 | 38 |
public class CdmServiceCacher extends CdmCacher implements ICdmEntitySessionManagerObserver { |
35 | 39 |
|
36 | 40 |
|
37 |
|
|
38 | 41 |
private ICdmEntitySessionManager cdmEntitySessionManager; |
39 | 42 |
|
40 | 43 |
private CdmTransientEntityCacher cdmTransientEntityCacher; |
... | ... | |
43 | 46 |
|
44 | 47 |
@Override |
45 | 48 |
protected void setup() { |
49 |
|
|
50 |
setUpCacheManager(); |
|
51 |
|
|
46 | 52 |
DefinedTermBase.setCacher(this); |
47 | 53 |
CdmTransientEntityCacher.setDefaultCacher(this); |
48 | 54 |
TermServiceRequestExecutor.setDefaultCacher(this); |
49 | 55 |
|
50 | 56 |
cacheLoader = new CacheLoader(this); |
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
/** |
|
62 |
* |
|
63 |
*/ |
|
64 |
private void setUpCacheManager() { |
|
65 |
|
|
66 |
EhCacheConfiguration cacheConfig = new EhCacheConfiguration(); |
|
67 |
|
|
68 |
DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration(); |
|
69 |
File ehcacheFolder = CdmUtils.getCdmSubDir("taxeditor-ehcache"); |
|
70 |
// FIXME use subfolder per taxeditor version to allow running multiple installations in parallel |
|
71 |
// String taxEditorVersion = ..; |
|
72 |
// File ehcacheFolder = new File(ehcacheFolder, taxEditorVersion); |
|
73 |
diskStoreConfiguration.setPath(ehcacheFolder.getAbsolutePath()); |
|
74 |
|
|
75 |
cacheConfig.setDiskStoreConfiguration(diskStoreConfiguration); |
|
76 |
addCacheManager(cacheConfig.cacheManager()); |
|
77 |
|
|
51 | 78 |
} |
52 | 79 |
|
53 | 80 |
|
Also available in: Unified diff
fix #2939 removing EhCacheConfig from application contexts and configuring the CacheManager explicitely