#4932 Remove autowired members, Use serliaised cdm model map
[taxeditor.git] / eu.etaxonomy.taxeditor.cdmlib / src / main / java / eu / etaxonomy / taxeditor / remoting / cache / CdmRemoteCacheManager.java
index 84f88c24fb3c51a19b1d4d70bb0e12aa271b2f2e..a2c4d1c663961a885a222b89d35475889267db9e 100644 (file)
@@ -1,5 +1,8 @@
 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;
@@ -59,45 +62,23 @@ public class CdmRemoteCacheManager {
             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;
     }
 
@@ -110,7 +91,4 @@ public class CdmRemoteCacheManager {
             }
         }
     }
-
-
-
 }