cdmlib-ehcache : removed disk based cache manager since the hb config is now cached...
authorCherian Mathew <c.mathew@bgbm.org>
Wed, 27 May 2015 15:54:53 +0000 (17:54 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Wed, 27 May 2015 15:54:53 +0000 (17:54 +0200)
CdmApplicationRemoteController, CdmModelCacher, CdmRemoteCacheManager, CdmModelGetMethodCacherTest : running the hibernate config load in separate thread
CdmTransientEntityCacher, EntityCacherDebugResult, CdmStore, SessionsViewPart: refactoring
httpInvokerServiceClients.xml : removed lazy loading of beans

13 files changed:
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmModelCacher.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmRemoteCacheManager.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmTransientEntityCacher.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/EntityCacherDebugResult.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/util/Serializer.java
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/cdmlib-ehcache.xml [deleted file]
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientCdmRepository.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/sessions/SessionsViewPart.java
eu.etaxonomy.taxeditor.test/src/main/resources/cdmlib-ehcache.xml [deleted file]
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/cdm/api/cache/CdmModelGetMethodCacherTest.java

index d0681e20c296d8da69e6f39a9c0cf49d45aa15d8..e9d9a8f6776e5d35bf2d31262c6aaef7e2a0a2ce 100644 (file)
@@ -25,7 +25,7 @@ import org.springframework.core.io.Resource;
 
 import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
 import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor;
-import eu.etaxonomy.taxeditor.remoting.cache.CdmModelCacher;
+import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager;
 import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
 
@@ -145,7 +145,7 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
 
         GenericApplicationContext applicationContext =  new GenericApplicationContext();
 
-        int nTasks = 5;
+        int nTasks = 4;
 
         progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
 
@@ -190,16 +190,14 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
     @Override
     protected void init(){
         progressMonitor.subTask("Loading configuration ...");
+        // initialising the cdm model cache
+        CdmRemoteCacheManager.getInstance();
+        // retrieving the application configuration
         configuration = (ICdmApplicationConfiguration)applicationContext.getBean("cdmApplicationRemoteConfiguration");
         AbstractLazyInitializer.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
         AbstractPersistentCollection.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
         progressMonitor.worked(1);
 
-        progressMonitor.subTask("Loading CDM config cache ...");
-        CdmModelCacher cmdmc = new CdmModelCacher();
-        cmdmc.cacheGetterFields();
-        progressMonitor.worked(1);
-
         progressMonitor.done();
     }
 
index 5235fe7209b114775977ea9abc002261dd97c457..02ec4b9047b0994d726056fc53dfb939e7f24e23 100644 (file)
@@ -21,16 +21,22 @@ public class CdmModelCacher {
 
        private static final Logger logger = Logger.getLogger(CdmModelCacher.class);
 
+       public static String HB_CONFIG_FILE_PATH= "/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml";
+
        private final List<CdmModelFieldPropertyFromClass> cmgmfcList = new ArrayList<CdmModelFieldPropertyFromClass>();
 
 
-       public void cacheGetterFields() {
+       public static Configuration buildConfiguration() {
+           Configuration configuration = new Configuration().configure(HB_CONFIG_FILE_PATH);
+        configuration.buildMappings();
+        return configuration;
+       }
+
+       public void cacheGetterFields(Cache cache) {
 
-               Configuration configuration = new Configuration().configure("/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml");
-               configuration.buildMappings();
+           Configuration configuration = buildConfiguration();
                Iterator<PersistentClass> classMappingIterator =   configuration.getClassMappings();
 
-               Cache cache = CdmRemoteCacheManager.getInstance().getCdmModelGetMethodsCache();
                cache.removeAll();
 
                while(classMappingIterator.hasNext()) {
@@ -42,9 +48,8 @@ public class CdmModelCacher {
                        logger.info("Adding class : " + mappedClassName + " to cache");
                        addGetters(persistentClass, cmgmfc);
                        cache.put(new Element(mappedClassName, cmgmfc));
-
                }
-               //cache.flush();
+
        }
 
        private void addGetters(PersistentClass persistentClass, CdmModelFieldPropertyFromClass cmgmfc) {
@@ -68,7 +73,7 @@ public class CdmModelCacher {
 
        public void checkGetterMethods() {
 
-               Configuration configuration = new Configuration().configure("/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml");
+               Configuration configuration = new Configuration().configure(HB_CONFIG_FILE_PATH);
                configuration.buildMappings();
                Iterator<PersistentClass> classMappingIterator =   configuration.getClassMappings();
 
@@ -113,7 +118,7 @@ public class CdmModelCacher {
 
        public List<CdmModelFieldPropertyFromClass> getCdmModelGetMethodFromClassList() {
                cmgmfcList.clear();
-               Configuration configuration = new Configuration().configure("/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml");
+               Configuration configuration = new Configuration().configure(HB_CONFIG_FILE_PATH);
                configuration.buildMappings();
                Iterator<PersistentClass> classMappingIterator =   configuration.getClassMappings();
 
index b8998c221d14378179e14a0c055d6ffe31b4411a..38612cc9152f0f5db790597c6fda8889155a0ede 100644 (file)
 package eu.etaxonomy.taxeditor.remoting.cache;
 
-import java.io.InputStream;
-import java.util.HashSet;
-import java.util.Set;
-
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheException;
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.config.CacheConfiguration;
 import net.sf.ehcache.config.SizeOfPolicyConfiguration;
 
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
+import org.apache.log4j.Logger;
 
 
 public class CdmRemoteCacheManager {
 
-       private CacheManager cdmlibModelCacheManager;
+    private static final Logger logger = Logger.getLogger(CdmRemoteCacheManager.class);
 
-       private static CdmRemoteCacheManager cdmRemoteCacheManager = null;
 
-       private final Set<CdmTransientEntityCacher> transientEntityCachers = new HashSet<CdmTransientEntityCacher>();
+    private Cache cdmlibModelCache;
 
-    public static final Resource CDMLIB_CACHE_MANAGER_CONFIG_RESOURCE =
-            new ClassPathResource("cdmlib-ehcache.xml");
+    private static CdmRemoteCacheManager cdmRemoteCacheManager = null;
 
-    public static final String CDM_MODEL_CACHE_MGR_NAME = "cdmlibModelCacheManager";
     public static final String CDM_MODEL_CACHE_NAME = "cdmModelGetMethodsCache";
 
+    private static Thread initThread;
+
+    private static boolean cacheInitialised = false;
 
     public enum CdmCacheManagerType {
-       CDMLIB_MODEL,
-       DEFAULT
+        CDMLIB_MODEL,
+        DEFAULT
     }
 
     public static CdmRemoteCacheManager getInstance(){
-       if(cdmRemoteCacheManager == null) {
-               cdmRemoteCacheManager = new CdmRemoteCacheManager();
-       }
-       return cdmRemoteCacheManager;
+
+        if(cdmRemoteCacheManager == null) {
+            cdmRemoteCacheManager = new CdmRemoteCacheManager();
+        }
+        return cdmRemoteCacheManager;
     }
     private CdmRemoteCacheManager() {
 
 
-       try {
-               // NOTE:Programmatically creating the cache manager may solve the problem of
-               //      recreating data written to disk on startup
-               //      see https://stackoverflow.com/questions/1729605/ehcache-persist-to-disk-issues
-               //String cacheFilePath = CDMLIB_CACHE_MANAGER_CONFIG_RESOURCE.getFile().getAbsolutePath();
-               InputStream in = this.getClass().getClassLoader().getResourceAsStream("cdmlib-ehcache.xml");
+        try {
+            // NOTE:Programmatically creating the cache manager may solve the problem of
+            //      recreating data written to disk on startup
+            //      see https://stackoverflow.com/questions/1729605/ehcache-persist-to-disk-issues
+            //String cacheFilePath = CDMLIB_CACHE_MANAGER_CONFIG_RESOURCE.getFile().getAbsolutePath();
+            //InputStream in = this.getClass().getClassLoader().getResourceAsStream("cdmlib-ehcache.xml");
 
             SizeOfPolicyConfiguration sizeOfConfig = new SizeOfPolicyConfiguration();
             sizeOfConfig.setMaxDepth(1000);
             sizeOfConfig.setMaxDepthExceededBehavior("abort");
 
-               CacheConfiguration modelcc = new CacheConfiguration(CDM_MODEL_CACHE_NAME, 0)
+            CacheConfiguration modelcc = new CacheConfiguration(CDM_MODEL_CACHE_NAME, 0)
             .eternal(true)
             .statistics(true)
             .sizeOfPolicy(sizeOfConfig)
             .overflowToOffHeap(false);
 
-               Cache modelCache = new Cache(modelcc);
+            cdmlibModelCache = new Cache(modelcc);
 
-                       cdmlibModelCacheManager = CacheManager.create(CDM_MODEL_CACHE_MGR_NAME);
-                       cdmlibModelCacheManager.addCache(modelCache);
+            CacheManager.create().addCache(cdmlibModelCache);
 
-               } catch (CacheException e) {
-                       throw new CdmClientCacheException(e);
-               }
+            initCache(cdmlibModelCache);
+
+        } catch (CacheException e) {
+            throw new CdmClientCacheException(e);
+        }
 
     }
 
-       public Cache getCdmModelGetMethodsCache(){
-               return cdmlibModelCacheManager.getCache(CDM_MODEL_CACHE_NAME);
-       }
-
-       public CacheManager getCdmModelGetMethodsCacheManager() {
-           return cdmlibModelCacheManager;
-       }
-
-       public CacheManager getDefaultCacheManager() {
-           return CacheManager.create();
-       }
-
-       public void shutdown(CdmCacheManagerType ccmt) {
-               CacheManager cm;
-               switch(ccmt) {
-               case CDMLIB_MODEL:
-                       cdmlibModelCacheManager.shutdown();
-                       break;
-               case DEFAULT:
-                       cm = CacheManager.create();
-                       cm.shutdown();
-                       break;
-               default:
-                       //do nothing
-               }
-       }
+    private void initCache(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(){
+        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;
+    }
+
+    public static void removeEntityCaches() {
+        CacheManager cm = CacheManager.create();
+        String[] cacheNames = CacheManager.create().getCacheNames();
+        for(String cacheName : cacheNames) {
+            if(!cacheName.equals(CDM_MODEL_CACHE_NAME)) {
+                cm.removeCache(cacheName);
+            }
+        }
+    }
 
 
 
index 52f18ca40f9e47d7372224998b33ffe5ca6258bf..9239fcdce48ce47e61be4c54d7792f129adaee8c 100644 (file)
@@ -15,6 +15,7 @@ import java.util.List;
 import java.util.Map;
 
 import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
 import net.sf.ehcache.config.CacheConfiguration;
 import net.sf.ehcache.config.SizeOfPolicyConfiguration;
@@ -63,7 +64,7 @@ public class CdmTransientEntityCacher implements ICdmCacher {
 
         cache = new Cache(getEntityCacheConfiguration(cacheId));
 
-        CdmRemoteCacheManager.getInstance().getDefaultCacheManager().addCache(cache);
+        CacheManager.create().addCache(cache);
 
         this.cdmEntitySessionManager = cdmEntitySessionManager;
 
@@ -111,7 +112,7 @@ public class CdmTransientEntityCacher implements ICdmCacher {
      * @return
      */
     private Cache getCache() {
-        return  CdmRemoteCacheManager.getInstance().getDefaultCacheManager().getCache(cacheId);
+        return  CacheManager.create().getCache(cacheId);
     }
 
     public <T extends Object> T load(T obj, boolean update) {
index 436711dbb88a03b3f5f79139e2aa2422bfdc1e46..e88e09b28461fb93c9617892080769f9250ba94d 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
 import java.util.Map;
 
 import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
 
 import org.apache.log4j.Logger;
@@ -183,7 +184,7 @@ public class EntityCacherDebugResult {
     }
 
     private String getCachesContainingEntity(CdmBase cdmEntity) {
-        Cache defaultCache = CdmRemoteCacheManager.getInstance().getDefaultCacheManager().getCache(CdmCacher.DEFAULT_CACHE_NAME);
+        Cache defaultCache = CacheManager.create().getCache(CdmCacher.DEFAULT_CACHE_NAME);
         String caches = "";
         Element dce = defaultCache.get(cdmEntity.getUuid());
         if(dce != null && dce.getObjectValue() == cdmEntity) {
index 5274ee0ba7fe81919f7b5931a50941d9b5b41b8a..04e998e3110f2fd7f05bcbdd584735876e2de39c 100644 (file)
@@ -9,20 +9,64 @@
 */
 package eu.etaxonomy.taxeditor.util;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import org.apache.log4j.Logger;
 import org.hibernate.cfg.Configuration;
 
+import eu.etaxonomy.taxeditor.remoting.cache.CdmModelCacher;
+
 /**
  * @author cmathew
  * @date 27 May 2015
  *
  */
 public class Serializer {
+    private static final Logger logger = Logger.getLogger(Serializer.class);
+
+
+    public static String HB_CONFIG_SER_FILE_NAME = "hibernate.cfg.ser";
+
+    public static boolean checkDir(String dirString) {
+        if(dirString == null || dirString.isEmpty()) {
+            logger.warn("Directory not set or set to empty string");
+            return false;
+        }
+
+        File dir = new File(dirString);
+
+        if(!dir.exists()) {
+            logger.warn("Directory does not exist");
+            return false;
+        }
+
+        return true;
+
+    }
+    public static void serializeHbConfig() {
+
+        Configuration configuration = CdmModelCacher.buildConfiguration();
+        String hbConfigDir = System.getProperty("hb.config.dir");
+        if(checkDir(hbConfigDir)) {
+            try {
+               FileOutputStream fileOut = new FileOutputStream(hbConfigDir + File.separator + HB_CONFIG_SER_FILE_NAME);
+               ObjectOutputStream out = new ObjectOutputStream(fileOut);
+               out.writeObject(configuration);
+               out.close();
+               fileOut.close();
+               logger.info("Serialized configuration object");
+            } catch(IOException i) {
+                i.printStackTrace();
+            }
+        }
+    }
 
-    String HB_CONFIG_PATH= "/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml";
+    public static void main(String[] args) {
+        serializeHbConfig();
 
-    public static void serializeHbConfig(String serializedFilePath) {
-        Configuration configuration = new Configuration().configure("/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml");
-        configuration.buildMappings();
     }
 
 }
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/cdmlib-ehcache.xml b/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/cdmlib-ehcache.xml
deleted file mode 100644 (file)
index 36e1fe0..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<ehcache name="cdmlibModelCacheManager">
-       <diskStore path="ehcache.disk.store.dir/cdmlib" />
-       <cache name="cdmModelGetMethodsCache" maxElementsInMemory="1" maxElementsOnDisk="0" eternal="true"
-               overflowToDisk="true" diskPersistent="true" memoryStoreEvictionPolicy="LRU" statistics="true">
-        <sizeOfPolicy maxDepth="1000" maxDepthExceededBehavior="abort"/>         
-       </cache>
-</ehcache>
\ No newline at end of file
index 2d7e7c5d8399ba6c3b660b63a3281024600e67cd..4ec058513280558621d6963b6456ed5d96092c2a 100644 (file)
@@ -4,11 +4,10 @@
   xmlns:tx="http://www.springframework.org/schema/tx"\r
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd\r
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd\r
-    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"\r
-    default-lazy-init="true">\r
+    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">\r
 \r
 \r
-  <bean id="agentService" lazy-init="true"\r
+  <bean id="agentService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/agent.service</value>\r
@@ -22,7 +21,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="annotationService" lazy-init="true"\r
+  <bean id="annotationService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/annotation.service</value>\r
@@ -36,7 +35,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="auditeventService" lazy-init="true"\r
+  <bean id="auditeventService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/auditevent.service</value>\r
@@ -50,7 +49,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="classificationService" lazy-init="true"\r
+  <bean id="classificationService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/classification.service</value>\r
@@ -64,7 +63,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="collectionService" lazy-init="true"\r
+  <bean id="collectionService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/collection.service</value>\r
@@ -78,7 +77,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="commonService" lazy-init="true"\r
+  <bean id="commonService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/common.service</value>\r
@@ -92,7 +91,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="descriptionService" lazy-init="true"\r
+  <bean id="descriptionService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/description.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="editGeoService" lazy-init="true"\r
+  <bean id="editGeoService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/editgeo.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="featureNodeService" lazy-init="true"\r
+  <bean id="featureNodeService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/featurenode.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="featureTreeService" lazy-init="true"\r
+  <bean id="featureTreeService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/featuretree.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="groupService" lazy-init="true"\r
+  <bean id="groupService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/group.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="identificationKeyService" lazy-init="true"\r
+  <bean id="identificationKeyService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/identificationkey.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="locationService" lazy-init="true"\r
+  <bean id="locationService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/location.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="markerService" lazy-init="true"\r
+  <bean id="markerService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/marker.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="mediaService" lazy-init="true"\r
+  <bean id="mediaService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/media.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="nameService" lazy-init="true"\r
+  <bean id="nameService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/name.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="occurrenceService" lazy-init="true"\r
+  <bean id="occurrenceService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/occurrence.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="polytomousKeyNodeService" lazy-init="true"\r
+  <bean id="polytomousKeyNodeService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/polytomouskeynode.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="polytomousKeyService" lazy-init="true"\r
+  <bean id="polytomousKeyService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/polytomouskey.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="referenceService" lazy-init="true"\r
+  <bean id="referenceService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/reference.service</value>\r
     </property> <property name="serviceInterface"> <value>eu.etaxonomy.cdm.api.service.IService</value> \r
     </property> </bean> -->\r
 \r
-  <bean id="taxonNodeService" lazy-init="true"\r
+  <bean id="taxonNodeService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/taxonnode.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="taxonService" lazy-init="true"\r
+  <bean id="taxonService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/taxon.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="termService" lazy-init="true"\r
+  <bean id="termService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/term.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="userService" lazy-init="true"\r
+  <bean id="userService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting-public/user.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="vocabularyService" lazy-init="true"\r
+  <bean id="vocabularyService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/vocabulary.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="workingSetService" lazy-init="true"\r
+  <bean id="workingSetService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/workingset.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="grantedAuthorityService" lazy-init="true"\r
+  <bean id="grantedAuthorityService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/grantedauthority.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="databaseService" lazy-init="true"\r
+  <bean id="databaseService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting-public/database.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="lsidAuthorityService" lazy-init="true"\r
+  <bean id="lsidAuthorityService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/lsidauthoruty.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="lsidMetadataService" lazy-init="true"\r
+  <bean id="lsidMetadataService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/lsidmetadata.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="lsiDataService" lazy-init="true"\r
+  <bean id="lsiDataService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/lsiddata.service</value>\r
 <!--     </property> -->\r
 <!--   </bean> -->\r
 \r
-  <bean id="primerService" lazy-init="true"\r
+  <bean id="primerService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/primer.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="amplificationService" lazy-init="true"\r
+  <bean id="amplificationService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/amplification.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="sequenceService" lazy-init="true"\r
+  <bean id="sequenceService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/sequence.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="entityValidationService" lazy-init="true"\r
+  <bean id="entityValidationService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/entityvalidation.service</value>\r
     </property>\r
   </bean>\r
 \r
-  <bean id="entityConstraintViolationService" lazy-init="true"\r
+  <bean id="entityConstraintViolationService" \r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/entityconstraintviolation.service</value>\r
index 4a8da2c4c4c1e433dde3f2880f087fae223107f9..caa6991897609acb5672a25d1935bddccf132a7b 100644 (file)
@@ -11,7 +11,7 @@ package eu.etaxonomy.taxeditor.editor.view.dataimport.transientServices;
 
 import java.util.Collection;
 
-import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.ProviderManager;
 import org.springframework.transaction.PlatformTransactionManager;
 import org.springframework.transaction.TransactionStatus;
 
@@ -115,7 +115,7 @@ public class TransientCdmRepository implements ICdmApplicationConfiguration {
      * @see eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration#getAuthenticationManager()
      */
     @Override
-    public AuthenticationManager getAuthenticationManager() {
+    public ProviderManager getAuthenticationManager() {
         return defaultApplicationConfiguration.getAuthenticationManager();
     }
 
index db380c7f5308a0d061d12c1c072518601a7093cc..61b30da6c81449801ca4a77a66b32004625f0e6d 100644 (file)
@@ -153,8 +153,8 @@ public class CdmStore {
                        final DbSchemaValidation dbSchemaValidation,
                        final Resource applicationContextBean) {
            if(isActive()) {
-               // before we connect we clear the caches and the sessions
-               CdmRemoteCacheManager.getInstance().getDefaultCacheManager().removalAll();
+               // before we connect we clear the entity caches and the sessions
+               CdmRemoteCacheManager.removeEntityCaches();
                if(getCurrentSessionManager() != null) {
                    getCurrentSessionManager().disposeAll();
                }
index 406e977de0d172ac4206d9c8f96078cdfb98a7d5..3db7c9ce8a29fb00884047a9bbec0d4287b35401 100644 (file)
@@ -13,6 +13,7 @@ import java.text.DecimalFormat;
 import java.util.Collection;
 
 import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.statistics.LiveCacheStatistics;
 
 import org.eclipse.jface.action.IMenuManager;
@@ -277,10 +278,10 @@ public class SessionsViewPart extends ViewPart implements ICdmEntitySessionManag
         }
 
         CdmRemoteCacheManager instance = CdmRemoteCacheManager.getInstance();
-        int cdmEnityCacheSize = instance.getDefaultCacheManager().getCacheNames().length;
+        int cdmEnityCacheSize = CacheManager.create().getCacheNames().length;
         txtNoOfCaches.setText(String.valueOf(cdmEnityCacheSize));
 
-        Cache defaultCache = instance.getDefaultCacheManager().getCache(CdmCacher.DEFAULT_CACHE_NAME);
+        Cache defaultCache = CacheManager.create().getCache(CdmCacher.DEFAULT_CACHE_NAME);
         txtDefaultInMemory.setText("");
         txtDefaultOnDisk.setText("");
         if(defaultCache != null) {
diff --git a/eu.etaxonomy.taxeditor.test/src/main/resources/cdmlib-ehcache.xml b/eu.etaxonomy.taxeditor.test/src/main/resources/cdmlib-ehcache.xml
deleted file mode 100644 (file)
index 7ab604c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<ehcache name="cdmlibModelCacheManager">
-       <diskStore path="ehcache.disk.store.dir/cdmlib" />
-       <cache name="cdmModelGetMethodsCache" maxElementsInMemory="0" maxElementsOnDisk="0" eternal="true"
-               overflowToDisk="true" diskPersistent="true" memoryStoreEvictionPolicy="LRU">
-       </cache>
-</ehcache>
\ No newline at end of file
index 36b790c9e1702a59c4fe99502e2dd299df997653..c0dd776f28d32d2d8f7e25c95457d882d536024e 100644 (file)
@@ -1,66 +1,45 @@
 package eu.etaxonomy.cdm.api.cache;
 
-import java.io.IOException;
 import java.util.List;
 
 import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
 
-import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.junit.Assert;
 import org.junit.Test;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
 
-import eu.etaxonomy.taxeditor.remoting.cache.CdmClientCacheException;
 import eu.etaxonomy.taxeditor.remoting.cache.CdmModelCacher;
 import eu.etaxonomy.taxeditor.remoting.cache.CdmModelFieldPropertyFromClass;
 import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager;
-import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager.CdmCacheManagerType;
 
 
 public class CdmModelGetMethodCacherTest {
 
        private static final Logger logger = Logger.getLogger(CdmModelGetMethodCacherTest.class);
 
-    public static final Resource CDMLIB_DISK_STORE_RESOURCE =
-            new ClassPathResource("/eu/etaxonomy/cache");
-    
-    
 
        @Test
        public void cacheGettersTest() {
-               
-               Logger.getRootLogger().setLevel(Level.INFO);
-               try {
-                       System.setProperty("ehcache.disk.store.dir", CDMLIB_DISK_STORE_RESOURCE.getFile().getAbsolutePath());
-               } catch (IOException e) {
-                       throw new CdmClientCacheException(e);
-               }               
+
                CdmModelCacher cmdmc = new CdmModelCacher();
-               
-               //cmdmc.checkGetterMethods();
-               
-               cmdmc.cacheGetterFields();
 
-                                               
                Cache cdmlibCache = CdmRemoteCacheManager.getInstance().getCdmModelGetMethodsCache();
                List<CdmModelFieldPropertyFromClass> cmgmfcList = cmdmc.getCdmModelGetMethodFromClassList();
-               
+
                List<Object> keys = cdmlibCache.getKeys();
                Assert.assertEquals(cmgmfcList.size(), keys.size());
-                               
+
                for(CdmModelFieldPropertyFromClass cmgmfc: cmgmfcList) {
                        String className = cmgmfc.getClassName();
                        Assert.assertTrue(keys.contains(className));
                        logger.info("Class Name : " + className + " has been cached");
                }
                cdmlibCache.removeAll();
-               cdmlibCache.flush();
-               CdmRemoteCacheManager.getInstance().shutdown(CdmCacheManagerType.CDMLIB_MODEL);
+               CacheManager.create().shutdown();
        }
 
-       
-        
+
+
 
 }