package eu.etaxonomy.taxeditor.remoting.cache;
+import java.io.IOException;
+import java.net.URISyntaxException;
+
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheException;
import net.sf.ehcache.CacheManager;
cdmlibModelCache = new Cache(modelcc);
CacheManager.create().addCache(cdmlibModelCache);
- initCdmModelCache(cdmlibModelCache);
+ CdmModelCacher cmdmc = new CdmModelCacher();
+ cmdmc.cacheGetterFields(cdmlibModelCache);
} catch (CacheException e) {
throw new CdmClientCacheException(e);
+ } catch (ClassNotFoundException e) {
+ throw new CdmClientCacheException(e);
+ } catch (IOException e) {
+ throw new CdmClientCacheException(e);
+ } catch (URISyntaxException e) {
+ throw new CdmClientCacheException(e);
}
}
- private void initCdmModelCache(final Cache cache) {
-
- initThread = new Thread() {
- @Override
- public void run(){
- synchronized (cdmlibModelCache) {
- CdmModelCacher cmdmc = new CdmModelCacher();
- cmdmc.cacheGetterFields(cache);
- cacheInitialised = true;
- logger.info("Initialisation of CDM getter fields complete");
- cdmlibModelCache.notify();
- }
- }
-
- };
- initThread.start();
- }
public Cache getCdmModelGetMethodsCache(){
- //Note : Even though we synchronize this method, the cache can be simply
- // retrieved using CacheManager.create().getCache(CDM_MODEL_CACHE_NAME)
- // in which case the cache may not be fully initialised
- synchronized (cdmlibModelCache) {
- while(!cacheInitialised) {
- try {
- logger.info("Waiting for initialisation of CDM getter fields to complete ...");
- cdmlibModelCache.wait();
- } catch (InterruptedException e) {}
- }
- }
- logger.info("CDM getter fields cache initialised");
return cdmlibModelCache;
}
}
}
}
-
-
-
}