Project

General

Profile

« Previous | Next » 

Revision 703e8efc

Added by Cherian Mathew about 9 years ago

CdmRemoteCacheManager : added cache getter methods
CdmTransientEntityCacher, CdmEntitySession, CdmEntitySessionManager, ICdmEntitySession, ICdmEntitySessionManager, ICdmEntitySessionManagerObserver, MockCdmEntitySession, MockCdmEntitySessionManager , eu.etaxonomy.taxeditor.cdmlib/src/main/resources/cdmlib-ehcache.xml : added statistics config , getter method for live stats and observer to update when sessions are bound and disposed
eu.etaxonomy.taxeditor.store/plugin.xml, SessionsViewPart : added new sessions debug view
MatchStrategyConfigurator : moved to cdmlib
ParseHandler, AbstractMatchingPreferences, NonViralNameMatchingPreference, ReferenceMatchingPreference, TeamOrPersonMatchingPreference : refactored after removal of MatchStrategyConfigurator replaced by enum MatchStrategy

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmRemoteCacheManager.java
1 1
package eu.etaxonomy.taxeditor.remoting.cache;
2 2

  
3 3
import java.io.File;
4
import java.io.IOException;
5 4
import java.io.InputStream;
6 5

  
7 6
import net.sf.ehcache.Cache;
......
10 9

  
11 10
import org.springframework.core.io.ClassPathResource;
12 11
import org.springframework.core.io.Resource;
13
import org.springframework.stereotype.Component;
14 12

  
15 13
import eu.etaxonomy.cdm.common.CdmUtils;
16 14

  
17 15

  
18
public class CdmRemoteCacheManager {	
19
	
16
public class CdmRemoteCacheManager {
17

  
20 18
	private CacheManager cdmlibModelCacheManager;
21
	
19

  
22 20
	private static CdmRemoteCacheManager cdmRemoteCacheManager = null;
23
	
21

  
24 22
    public static final Resource CDMLIB_CACHE_MANAGER_CONFIG_RESOURCE =
25 23
            new ClassPathResource("cdmlib-ehcache.xml");
26
    
27
	
24

  
25
    public static final String CDM_MODEL_CACHE_NAME = "cdmModelGetMethodsCache";
26

  
27

  
28 28
    public enum CdmCacheManagerType {
29 29
    	CDMLIB_MODEL,
30 30
    	DEFAULT
31 31
    }
32 32

  
33 33
    public static CdmRemoteCacheManager getInstance(){
34
    	if(cdmRemoteCacheManager == null) {    		
35
    		cdmRemoteCacheManager = new CdmRemoteCacheManager();  		
34
    	if(cdmRemoteCacheManager == null) {
35
    		cdmRemoteCacheManager = new CdmRemoteCacheManager();
36 36
    	}
37 37
    	return cdmRemoteCacheManager;
38 38
    }
39 39
    private CdmRemoteCacheManager() {
40
    	
41
    	System.setProperty("ehcache.disk.store.dir", CdmUtils.getCdmHomeDir().getAbsolutePath() + File.separator + "cdmlib-model");    			
40

  
41
    	System.setProperty("ehcache.disk.store.dir", CdmUtils.getCdmHomeDir().getAbsolutePath() + File.separator + "cdmlib-model");
42 42
    	try {
43
    		// NOTE:Programmatically creating the cache manager may solve the problem of 
43
    		// NOTE:Programmatically creating the cache manager may solve the problem of
44 44
    		//      recreating data written to disk on startup
45 45
    		//      see https://stackoverflow.com/questions/1729605/ehcache-persist-to-disk-issues
46 46
    		//String cacheFilePath = CDMLIB_CACHE_MANAGER_CONFIG_RESOURCE.getFile().getAbsolutePath();
47 47
    		InputStream in = this.getClass().getClassLoader().getResourceAsStream("cdmlib-ehcache.xml");
48 48
			cdmlibModelCacheManager = new CacheManager(in);
49
			
49

  
50 50
		} catch (CacheException e) {
51 51
			throw new CdmClientCacheException(e);
52 52
		}
......
54 54
//			throw new CdmClientCacheException(e);
55 55
//		}
56 56
    }
57
    
57

  
58 58
	public Cache getCdmModelGetMethodsCache(){
59
		return cdmlibModelCacheManager.getCache("cdmModelGetMethodsCache");
59
		return cdmlibModelCacheManager.getCache(CDM_MODEL_CACHE_NAME);
60
	}
61

  
62
	public CacheManager getCdmModelGetMethodsCacheManager() {
63
	    return cdmlibModelCacheManager;
64
	}
65

  
66
	public CacheManager getDefaultCacheManager() {
67
	    return CacheManager.create();
60 68
	}
61
	
69

  
62 70
	public void shutdown(CdmCacheManagerType ccmt) {
63 71
		CacheManager cm;
64
		switch(ccmt) {		
65
		case CDMLIB_MODEL:			
72
		switch(ccmt) {
73
		case CDMLIB_MODEL:
66 74
			cdmlibModelCacheManager.shutdown();
67 75
			break;
68 76
		case DEFAULT:
......
71 79
			break;
72 80
		default:
73 81
			//do nothing
74
		}		
82
		}
75 83
	}
76
	
84

  
77 85
	public static void checkCacheProperties() {
78 86
		String pathToCache = System.getProperty("ehcache.disk.store.dir");
79 87
		if(pathToCache == null || pathToCache.isEmpty()) {

Also available in: Unified diff