CdmApplicationRemoteController : refactoring code to simplify application context...
authorCherian Mathew <c.mathew@bgbm.org>
Wed, 27 May 2015 12:07:33 +0000 (14:07 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Wed, 27 May 2015 12:07:33 +0000 (14:07 +0200)
CdmModelCacher : removed unused method
CdmRemoteCacheManager : moved cache from disk to memory
httpInvokerServiceClients : lazy initializing all service beans
remotingApplicationContext : merged imported bean definition files into this one
CdmApplicationRemoteControllerTest : test for application controller
RemotingMonitoredGenericApplicationContext, RemotingMonitoredListableBeanFactory : removed since specific monitoring is not required in remoting
remoting_persistence_security.xml, remoting_services_security.xml : merged into remotingApplicationContext

15 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/cdm/api/application/RemotingMonitoredGenericApplicationContext.java [deleted file]
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredListableBeanFactory.java [deleted file]
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/util/Serializer.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remotingApplicationContext.xml
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_persistence_security.xml [deleted file]
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_services_security.xml [deleted file]
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/store/CdmStoreConnector.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/CdmApplicationRemoteControllerTest.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/BaseRemotingTest.java

index 77c994b2efe3cafc5af97d6b9cb7b25096c0c9c8..d0681e20c296d8da69e6f39a9c0cf49d45aa15d8 100644 (file)
@@ -58,18 +58,17 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
      * @param listeners
      * @return
      */
-    public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource,
-            ICdmRemoteSource remoteSource,
-            boolean omitTermLoading,
-            IProgressMonitor progressMonitor,
-            List<ApplicationListener> listeners) {
-        return new CdmApplicationRemoteController(applicationContextResource,
-                remoteSource,
-                omitTermLoading,
-                progressMonitor,
-                listeners);
-
-    }
+//    public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource,
+//            ICdmRemoteSource remoteSource,
+//            IProgressMonitor progressMonitor,
+//            List<ApplicationListener> listeners) {
+//        return new CdmApplicationRemoteController(applicationContextResource,
+//                remoteSource,
+//                false,
+//                progressMonitor,
+//                listeners);
+//
+//    }
     /**
      * Creates new instance of CdmApplicationRemoteController
      *
@@ -81,13 +80,25 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
      * @return
      */
     public static CdmApplicationRemoteController NewInstance(ICdmRemoteSource remoteSource,
-            boolean omitTermLoading,
             IProgressMonitor progressMonitor,
             List<ApplicationListener> listeners) {
 
         return new CdmApplicationRemoteController(DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE,
                 remoteSource,
-                omitTermLoading,
+                false,
+                progressMonitor,
+                listeners);
+
+    }
+
+    public static CdmApplicationRemoteController NewInstance(ICdmRemoteSource remoteSource,
+            boolean validateXml,
+            IProgressMonitor progressMonitor,
+            List<ApplicationListener> listeners) {
+
+        return new CdmApplicationRemoteController(DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE,
+                remoteSource,
+                validateXml,
                 progressMonitor,
                 listeners);
 
@@ -104,15 +115,14 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
      */
     private CdmApplicationRemoteController(Resource applicationContextResource,
             ICdmRemoteSource remoteSource,
-            boolean omitTermLoading,
+            boolean validateXml,
             IProgressMonitor progressMonitor,
             List<ApplicationListener> listeners){
         logger.info("Start CdmApplicationRemoteController with remote source: " + remoteSource.getName());
         this.applicationContextResource =
                 applicationContextResource != null ? applicationContextResource : DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE;
         this.progressMonitor = progressMonitor != null ? progressMonitor : new NullProgressMonitor();
-
-        setNewRemoteSource(remoteSource, omitTermLoading, listeners);
+        setNewRemoteSource(remoteSource, validateXml, listeners);
 
     }
 
@@ -127,43 +137,19 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
      * @param listeners
      * @return
      */
-    protected boolean setNewRemoteSource(ICdmRemoteSource remoteSource,
-            boolean omitTermLoading,
+    public boolean setNewRemoteSource(ICdmRemoteSource remoteSource,
+            boolean validateXml,
             List<ApplicationListener> listeners){
 
         logger.info("Connecting to '" + remoteSource.getName() + "'");
 
-        GenericApplicationContext applicationContext
-            = generateApplicationContext(remoteSource, applicationContextResource, listeners, progressMonitor, false);
-
-
-
-        //progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
-        applicationContext.refresh();
-        applicationContext.start();
-
-
-        progressMonitor.subTask("Cleaning up.");
-        setApplicationContext(applicationContext);
-        progressMonitor.worked(1);
+        GenericApplicationContext applicationContext =  new GenericApplicationContext();
 
-        progressMonitor.done();
-        return true;
-    }
-
-    public static GenericApplicationContext generateApplicationContext(ICdmRemoteSource remoteSource,
-            Resource applicationContextResource,
-            List<ApplicationListener> listeners,
-            IProgressMonitor progressMonitor,
-            boolean validateXml) {
-        RemotingMonitoredGenericApplicationContext applicationContext =  new RemotingMonitoredGenericApplicationContext();
-        int refreshTasks = 45;
-        int nTasks = 5 + refreshTasks;
+        int nTasks = 5;
 
-        progressMonitor.subTask("Registering remote source.");
-        applicationContext.getEnvironment().setActiveProfiles("remoting");
-        progressMonitor.worked(1);
+        progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
 
+        progressMonitor.subTask("Loading context beans ...");
         PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
         Properties properties = new Properties();
         properties.setProperty("remoteServer", remoteSource.getServer());
@@ -171,36 +157,50 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
         properties.setProperty("remoteContext", remoteSource.getContextPath());
         pspc.setProperties(properties);
         applicationContext.addBeanFactoryPostProcessor(pspc);
-
+        applicationContext.getEnvironment().setActiveProfiles("remoting");
         XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext);
         if(!validateXml) {
-            xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
+            xmlReader.setValidating(false);
         }
-        progressMonitor.subTask("Registering resources.");
         xmlReader.loadBeanDefinitions(applicationContextResource);
-        progressMonitor.worked(1);
-
         if (listeners != null){
             for(ApplicationListener listener : listeners){
                 applicationContext.addApplicationListener(listener);
             }
         }
+        progressMonitor.worked(1);
 
-        return applicationContext;
+        progressMonitor.subTask("Refreshing / Starting context ...");
+        applicationContext.refresh();
+        applicationContext.start();
+        progressMonitor.worked(1);
+
+        progressMonitor.subTask("Cleaning up ...");
+        setApplicationContext(applicationContext);
+        progressMonitor.worked(1);
+
+        return true;
     }
 
+
+
     /* (non-Javadoc)
      * @see eu.etaxonomy.cdm.api.application.CdmApplicationController#init()
      */
     @Override
     protected void init(){
+        progressMonitor.subTask("Loading 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();
     }
 
     public ICdmEntitySessionManager getCdmEntitySessionManager() {
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredGenericApplicationContext.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredGenericApplicationContext.java
deleted file mode 100644 (file)
index be7b3b2..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-// $Id$\r
-/**\r
-* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.cdm.api.application;\r
-\r
-import java.io.Serializable;\r
-\r
-import org.apache.log4j.Logger;\r
-import org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver;\r
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;\r
-import org.springframework.context.support.GenericApplicationContext;\r
-import org.springframework.core.LocalVariableTableParameterNameDiscoverer;\r
-\r
-/**\r
- * {@link GenericApplicationContext Generic application context} which allows progress monitoring.\r
- * @author a.mueller\r
- * @date 29.09.2011\r
- *\r
- */\r
-public class RemotingMonitoredGenericApplicationContext extends GenericApplicationContext implements Serializable {\r
-    @SuppressWarnings("unused")\r
-    private static final Logger logger = Logger.getLogger(RemotingMonitoredGenericApplicationContext.class);\r
-\r
-    final int countInvokeBeanFactoryPostProcessors = 10;\r
-    final int countFinishBeanFactoryInitialization = 90;\r
-    private final int countTasks = countInvokeBeanFactoryPostProcessors + countFinishBeanFactoryInitialization;\r
-   // private IProgressMonitor currentMonitor;\r
-\r
-\r
-\r
-    /**\r
-     * Constructor.\r
-     * @param progressMonitor\r
-     */\r
-//    public RemotingMonitoredGenericApplicationContext() {\r
-////           MonitoredListableBeanFactory beanFactory =\r
-//        super(new RemotingMonitoredListableBeanFactory());\r
-//        //taken from empty constructor of GenericApplicationContext\r
-//        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setSerializationId(getId());\r
-//        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());\r
-//        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());\r
-//    }\r
-\r
-    public RemotingMonitoredGenericApplicationContext() {\r
-//      MonitoredListableBeanFactory beanFactory =\r
-        super();\r
-        //taken from empty constructor of GenericApplicationContext\r
-        ((DefaultListableBeanFactory)getBeanFactory()).setSerializationId(getId());\r
-        ((DefaultListableBeanFactory)getBeanFactory()).setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());\r
-        ((DefaultListableBeanFactory)getBeanFactory()).setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());\r
-    }\r
-\r
-\r
-//    public int countTasks(){\r
-//        return countTasks;\r
-//    }\r
-//\r
-//    @Override\r
-//    protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory){\r
-//        String task = "Invoke bean factory post processors";\r
-////        checkMonitorCancelled(currentMonitor);\r
-////        currentMonitor.subTask(task);\r
-//        super.invokeBeanFactoryPostProcessors(beanFactory);\r
-////        currentMonitor.worked(countInvokeBeanFactoryPostProcessors);\r
-////        checkMonitorCancelled(currentMonitor);\r
-//    }\r
-//\r
-//    @Override\r
-//    protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory beanFactory){\r
-////        checkMonitorCancelled(currentMonitor);\r
-//        String task = "Finish bean factory initialization";\r
-////        currentMonitor.subTask(task);\r
-////        IProgressMonitor subMonitor        = new SubProgressMonitor(currentMonitor, countFinishBeanFactoryInitialization);\r
-////        getMyBeanFactory().setCurrentMonitor(subMonitor);\r
-//        super.finishBeanFactoryInitialization(beanFactory);\r
-////        checkMonitorCancelled(currentMonitor);\r
-//\r
-//    }\r
-\r
-//    /**\r
-//     * @param progressMonitor the progressMonitor to set\r
-//     */\r
-//    public void setCurrentMonitor(IProgressMonitor monitor) {\r
-////        this.currentMonitor = monitor;\r
-//    }\r
-//\r
-//    /**\r
-//     *\r
-//     */\r
-//    public IProgressMonitor getCurrentMonitor() {\r
-////        return currentMonitor;\r
-//        return null;\r
-//    }\r
-\r
-\r
-//    /* (non-Javadoc)\r
-//     * @see org.springframework.context.support.AbstractApplicationContext#refresh()\r
-//     */\r
-//    @Override\r
-//    public void refresh() throws BeansException, IllegalStateException {\r
-//        //checkMonitorCancelled(monitor);\r
-//        String message = "Refresh application context. This might take a while ...";\r
-////        currentMonitor = monitor;\r
-//        beginTask(message, countTasks);\r
-//        super.refresh();\r
-//        taskDone();\r
-//        //checkMonitorCancelled(monitor);\r
-//    }\r
-\r
-\r
-    /**\r
-     *\r
-     */\r
-//    private void taskDone() {\r
-////        if (currentMonitor != null){\r
-////            currentMonitor.done();\r
-////        }\r
-//    }\r
-\r
-\r
-//    /**\r
-//     * @param monitor\r
-//     * @param message\r
-//     */\r
-//    private void beginTask(String message, int countTasks) {\r
-////        if (currentMonitor != null){\r
-////            currentMonitor.beginTask(message, countTasks);\r
-////        }\r
-//    }\r
-\r
-\r
-//    private RemotingMonitoredListableBeanFactory getMyBeanFactory(){\r
-//        return (RemotingMonitoredListableBeanFactory)getBeanFactory();\r
-//    }\r
-//\r
-//\r
-//    private void checkMonitorCancelled(IProgressMonitor monitor) {\r
-//        if (monitor != null && monitor.isCanceled()){\r
-//            throw new CancellationException();\r
-//        }\r
-//    }\r
-}\r
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredListableBeanFactory.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredListableBeanFactory.java
deleted file mode 100644 (file)
index ba85fb5..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-// $Id$\r
-/**\r
-* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.cdm.api.application;\r
-\r
-import java.util.Arrays;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-import java.util.concurrent.CancellationException;\r
-\r
-import org.apache.log4j.Logger;\r
-import org.springframework.beans.BeansException;\r
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;\r
-import org.springframework.beans.factory.support.RootBeanDefinition;\r
-\r
-import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;\r
-\r
-/**\r
- * @author a.mueller\r
- * @date 29.09.2011\r
- *\r
- */\r
-public class RemotingMonitoredListableBeanFactory extends DefaultListableBeanFactory {\r
-       @SuppressWarnings("unused")\r
-       private static final Logger logger = Logger.getLogger(RemotingMonitoredListableBeanFactory.class);\r
-\r
-       private boolean isInitializingBeans = false;\r
-       private IProgressMonitor currentMonitor;\r
-\r
-       private static List<String> beansToMonitor = Arrays.asList("sessionFactory","defaultBeanInitializer","persistentTermInitializer");\r
-       private final Set<String> alreadyMonitoredBeans = new HashSet<String>();\r
-\r
-       public RemotingMonitoredListableBeanFactory(){\r
-       }\r
-\r
-//     @Override\r
-//     protected RootBeanDefinition getMergedLocalBeanDefinition(String beanName) throws BeansException {\r
-//             if (registeredBeanNames.contains(beanName)){\r
-//                     return super.getMergedLocalBeanDefinition(beanName);\r
-//\r
-//             }\r
-////           String message = "Handle bean '%s'";\r
-////           message = String.format(message, beanName);\r
-////           currentMonitor.subTask(message);\r
-//             RootBeanDefinition result = super.getMergedLocalBeanDefinition(beanName);\r
-////           currentMonitor.worked(1);\r
-////           registeredBeanNames.add(beanName);\r
-//             return result;\r
-//     }\r
-\r
-       @Override\r
-    public void preInstantiateSingletons() throws BeansException {\r
-               isInitializingBeans = true;\r
-               checkMonitorCancelled(currentMonitor);\r
-               int countBeans = 0;\r
-               for (String beanName : getBeanDefinitionNames()) {\r
-                       RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);\r
-                       if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit() && beansToMonitor.contains(beanName) ){\r
-                               countBeans++;\r
-                       }\r
-               }\r
-               String message = "preinstantiate singletons";\r
-               currentMonitor.beginTask(message, countBeans);\r
-               super.preInstantiateSingletons();\r
-               isInitializingBeans = false;\r
-               currentMonitor.done();\r
-       }\r
-\r
-//     protected <T> T doGetBean(final String name, final Class<T> requiredType, final Object[] args, boolean typeCheckOnly){\r
-//             boolean doMonitor = isInitializingBeans && !monitoredBeanNames.contains(name);\r
-//             if (doMonitor){\r
-//                     String message = "Handle bean '%s'";\r
-//                     message = String.format(message, name);\r
-//                     currentMonitor.subTask(message);\r
-//                     monitoredBeanNames.add(name);\r
-//             }\r
-//             T result = super.doGetBean(name, requiredType, args, typeCheckOnly);\r
-//             if (doMonitor){\r
-//                     currentMonitor.worked(1);\r
-//             }\r
-//             return result;\r
-//     }\r
-\r
-       @Override\r
-    protected Object createBean(final String name, final RootBeanDefinition mbd, final Object[] args){\r
-               boolean doMonitor = isInitializingBeans && beansToMonitor.contains(name) && !alreadyMonitoredBeans.contains(name);\r
-               checkMonitorCancelled(currentMonitor);\r
-               if (doMonitor){\r
-                       String message;\r
-                       if (name.equals("sessionFactory")){\r
-                               message = "Initializing persistence context ...";\r
-                       }else if(name.equals("persistentTermInitializer")){\r
-                               message = "Loading terms ...";\r
-                       }else{\r
-                               message = "Handling '%s'";\r
-                               message = String.format(message, name);\r
-                       }\r
-                       currentMonitor.subTask(message);\r
-                       alreadyMonitoredBeans.add(name);\r
-               }\r
-               Object result = super.createBean(name, mbd, args);\r
-               if (doMonitor){\r
-                       checkMonitorCancelled(currentMonitor);\r
-                       currentMonitor.worked(1);\r
-               }\r
-               return result;\r
-       }\r
-\r
-\r
-       /**\r
-        * @param mainMonitor the mainMonitor to set\r
-        */\r
-       public void setCurrentMonitor(IProgressMonitor monitor) {\r
-               this.currentMonitor = monitor;\r
-       }\r
-\r
-       private void checkMonitorCancelled(IProgressMonitor monitor) {\r
-               if (monitor != null && monitor.isCanceled()){\r
-                       throw new CancellationException();\r
-               }\r
-       }\r
-\r
-}\r
index 355fb0d669f9ef178c0287827ecb8afced1baedb..5235fe7209b114775977ea9abc002261dd97c457 100644 (file)
@@ -23,41 +23,6 @@ public class CdmModelCacher {
 
        private final List<CdmModelFieldPropertyFromClass> cmgmfcList = new ArrayList<CdmModelFieldPropertyFromClass>();
 
-       public void cacheGetters() {
-
-               Configuration configuration = new Configuration().configure("/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml");
-               configuration.buildMappings();
-               Iterator<PersistentClass> classMappingIterator = configuration.getClassMappings();
-
-               Cache cache = CdmRemoteCacheManager.getInstance().getCdmModelGetMethodsCache();
-               cache.removeAll();
-
-               while(classMappingIterator.hasNext()) {
-                       PersistentClass persistentClass = classMappingIterator.next();
-                       Class mappedClass = persistentClass.getMappedClass();
-                       String mappedClassName = mappedClass.getName();
-
-                       CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName);
-                       Iterator propertyIt = persistentClass.getPropertyIterator();
-
-                       logger.info("Adding class : " + mappedClassName + " to cache");
-
-                       while(propertyIt.hasNext())
-                       {
-                               Property property = (Property)propertyIt.next();
-                               Getter getter = property.getGetter(mappedClass);
-                               if(getter != null && getter.getMember() != null) {
-                                       Field field = (Field)getter.getMember();
-                                       String getMethod = getMethodNameFromFieldName(field.getName(), field.getType().getName());
-                                       logger.info(" - getMethod : " + getMethod + " for type " + field.getType().getName());
-                                       cmgmfc.addGetMethods(getMethod);
-                               }
-                       }
-                       cache.put(new Element(mappedClassName, cmgmfc));
-
-               }
-               cache.flush();
-       }
 
        public void cacheGetterFields() {
 
@@ -79,7 +44,7 @@ public class CdmModelCacher {
                        cache.put(new Element(mappedClassName, cmgmfc));
 
                }
-               cache.flush();
+               //cache.flush();
        }
 
        private void addGetters(PersistentClass persistentClass, CdmModelFieldPropertyFromClass cmgmfc) {
index 6a0a63d1d1daf33b01bc7eb10f184aa4acabac4b..b8998c221d14378179e14a0c055d6ffe31b4411a 100644 (file)
@@ -1,6 +1,5 @@
 package eu.etaxonomy.taxeditor.remoting.cache;
 
-import java.io.File;
 import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Set;
@@ -8,12 +7,12 @@ 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 eu.etaxonomy.cdm.common.CdmUtils;
-
 
 public class CdmRemoteCacheManager {
 
@@ -26,6 +25,7 @@ public class CdmRemoteCacheManager {
     public static final Resource CDMLIB_CACHE_MANAGER_CONFIG_RESOURCE =
             new ClassPathResource("cdmlib-ehcache.xml");
 
+    public static final String CDM_MODEL_CACHE_MGR_NAME = "cdmlibModelCacheManager";
     public static final String CDM_MODEL_CACHE_NAME = "cdmModelGetMethodsCache";
 
 
@@ -42,21 +42,33 @@ public class CdmRemoteCacheManager {
     }
     private CdmRemoteCacheManager() {
 
-       System.setProperty("ehcache.disk.store.dir", CdmUtils.getCdmHomeDir().getAbsolutePath() + File.separator + "cdmlib-model");
+
        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");
-                       cdmlibModelCacheManager = new CacheManager(in);
+
+            SizeOfPolicyConfiguration sizeOfConfig = new SizeOfPolicyConfiguration();
+            sizeOfConfig.setMaxDepth(1000);
+            sizeOfConfig.setMaxDepthExceededBehavior("abort");
+
+               CacheConfiguration modelcc = new CacheConfiguration(CDM_MODEL_CACHE_NAME, 0)
+            .eternal(true)
+            .statistics(true)
+            .sizeOfPolicy(sizeOfConfig)
+            .overflowToOffHeap(false);
+
+               Cache modelCache = new Cache(modelcc);
+
+                       cdmlibModelCacheManager = CacheManager.create(CDM_MODEL_CACHE_MGR_NAME);
+                       cdmlibModelCacheManager.addCache(modelCache);
 
                } catch (CacheException e) {
                        throw new CdmClientCacheException(e);
                }
-//             } catch (IOException e) {
-//                     throw new CdmClientCacheException(e);
-//             }
+
     }
 
        public Cache getCdmModelGetMethodsCache(){
@@ -86,12 +98,6 @@ public class CdmRemoteCacheManager {
                }
        }
 
-       public static void checkCacheProperties() {
-               String pathToCache = System.getProperty("ehcache.disk.store.dir");
-               if(pathToCache == null || pathToCache.isEmpty()) {
-                       throw new CdmClientCacheException("'ehcache.disk.store.dir' property is not set");
-               }
-       }
 
 
 }
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/util/Serializer.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/util/Serializer.java
new file mode 100644 (file)
index 0000000..5274ee0
--- /dev/null
@@ -0,0 +1,28 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.util;
+
+import org.hibernate.cfg.Configuration;
+
+/**
+ * @author cmathew
+ * @date 27 May 2015
+ *
+ */
+public class Serializer {
+
+    String HB_CONFIG_PATH= "/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml";
+
+    public static void serializeHbConfig(String serializedFilePath) {
+        Configuration configuration = new Configuration().configure("/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml");
+        configuration.buildMappings();
+    }
+
+}
index 0927154eacb0ac1e31fd48138f291aacac2743fe..2d7e7c5d8399ba6c3b660b63a3281024600e67cd 100644 (file)
@@ -2,12 +2,13 @@
 <beans xmlns="http://www.springframework.org/schema/beans"\r
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"\r
   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-2.5.xsd\r
-    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd\r
-    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">\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
 \r
 \r
-  <bean id="agentService" \r
+  <bean id="agentService" lazy-init="true"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/agent.service</value>\r
@@ -21,7 +22,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="annotationService"\r
+  <bean id="annotationService" lazy-init="true"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/annotation.service</value>\r
@@ -35,7 +36,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="auditeventService"\r
+  <bean id="auditeventService" lazy-init="true"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/auditevent.service</value>\r
@@ -49,7 +50,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="classificationService"\r
+  <bean id="classificationService" lazy-init="true"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/classification.service</value>\r
@@ -63,7 +64,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="collectionService"\r
+  <bean id="collectionService" lazy-init="true"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/collection.service</value>\r
@@ -77,7 +78,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="commonService"\r
+  <bean id="commonService" lazy-init="true"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/common.service</value>\r
@@ -91,7 +92,7 @@
     </property>\r
   </bean>\r
 \r
-  <bean id="descriptionService"\r
+  <bean id="descriptionService" lazy-init="true"\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"\r
+  <bean id="editGeoService" lazy-init="true"\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"\r
+  <bean id="featureNodeService" lazy-init="true"\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"\r
+  <bean id="featureTreeService" lazy-init="true"\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"\r
+  <bean id="groupService" lazy-init="true"\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"\r
+  <bean id="identificationKeyService" lazy-init="true"\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"\r
+  <bean id="locationService" lazy-init="true"\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"\r
+  <bean id="markerService" lazy-init="true"\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"\r
+  <bean id="mediaService" lazy-init="true"\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"\r
+  <bean id="nameService" lazy-init="true"\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"\r
+  <bean id="occurrenceService" lazy-init="true"\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"\r
+  <bean id="polytomousKeyNodeService" lazy-init="true"\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"\r
+  <bean id="polytomousKeyService" lazy-init="true"\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"\r
+  <bean id="referenceService" lazy-init="true"\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"\r
+  <bean id="taxonNodeService" lazy-init="true"\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"\r
+  <bean id="taxonService" lazy-init="true"\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"\r
+  <bean id="termService" lazy-init="true"\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"\r
+  <bean id="userService" lazy-init="true"\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"\r
+  <bean id="vocabularyService" lazy-init="true"\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"\r
+  <bean id="workingSetService" lazy-init="true"\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"\r
+  <bean id="grantedAuthorityService" lazy-init="true"\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"\r
+  <bean id="databaseService" lazy-init="true"\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"\r
+  <bean id="lsidAuthorityService" lazy-init="true"\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"\r
+  <bean id="lsidMetadataService" lazy-init="true"\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"\r
+  <bean id="lsiDataService" lazy-init="true"\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="authenticationManager"\r
-    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
-    <property name="serviceUrl">\r
-      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/authenticationManager.service</value>\r
-    </property>\r
-    <property name="serviceInterface">\r
-      <value>org.springframework.security.authentication.AuthenticationManager\r
-      </value>\r
-    </property>\r
-    <property name="httpInvokerRequestExecutor">\r
-      <bean\r
-        class="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor" />\r
-    </property>\r
-  </bean>\r
+<!--   <bean id="providerManager" -->\r
+<!--     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> -->\r
+<!--     <property name="serviceUrl"> -->\r
+<!--       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/authenticationManager.service</value> -->\r
+<!--     </property> -->\r
+<!--     <property name="serviceInterface"> -->\r
+<!--       <value>org.springframework.security.authentication.AuthenticationManager -->\r
+<!--       </value> -->\r
+<!--     </property> -->\r
+<!--     <property name="httpInvokerRequestExecutor"> -->\r
+<!--       <bean -->\r
+<!--         class="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor" /> -->\r
+<!--     </property> -->\r
+<!--   </bean> -->\r
 \r
-  <bean id="primerService"\r
+  <bean id="primerService" lazy-init="true"\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"\r
+  <bean id="amplificationService" lazy-init="true"\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"\r
+  <bean id="sequenceService" lazy-init="true"\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"\r
+  <bean id="entityValidationService" lazy-init="true"\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"\r
+  <bean id="entityConstraintViolationService" lazy-init="true"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
     <property name="serviceUrl">\r
       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/entityconstraintviolation.service</value>\r
index 47f6b6e3be7373f9404e82b981916ccdfd6de8a3..adccb37c5618567095dc8034dfdd7c196620e0ee 100644 (file)
@@ -2,39 +2,29 @@
 <beans xmlns="http://www.springframework.org/schema/beans"\r
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"\r
   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-2.5.xsd
-    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
-    http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-2.5.xsd">\r
-\r
-\r
-  <!-- <bean id="remoteTermInitializer" class="eu.etaxonomy.cdm.remote.service.RemoteTermInitializer"/> -->\r
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
+    http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.1.xsd">\r
 \r
   <context:annotation-config />\r
 \r
   <import resource="classpath:/eu/etaxonomy/cdm/httpInvokerServiceClients.xml" />\r
 \r
-\r
-\r
-  <!-- <context:component-scan base-package="eu/etaxonomy/taxeditor/session" \r
-    /> -->\r
-  <bean id="cdmEntitySessionManager"  class="eu.etaxonomy.taxeditor.session.CdmEntitySessionManager" />\r
+  <bean id="cdmEntitySessionManager"  \r
+    class="eu.etaxonomy.taxeditor.session.CdmEntitySessionManager" />\r
 \r
   <bean id="cdmApplicationRemoteConfiguration" \r
     class="eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration" />\r
 \r
-  <!-- <import resource="classpath:/eu/etaxonomy/cdm/remoting_services_security.xml" \r
-    /> -->\r
-\r
-<!--   <context:component-scan base-package="eu.etaxonomy.taxeditor.service" /> -->\r
   \r
-  <bean id="cdmServiceRequestExecutor"\r
+  <bean id="cdmServiceRequestExecutor" \r
     class="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor" />\r
     \r
   <bean id="cachedCommonService" \r
     class="eu.etaxonomy.taxeditor.service.CachedCommonServiceImpl" />\r
   \r
   <bean id="accessDecisionManager" \r
-    class="eu.etaxonomy.cdm.persistence.hibernate.permission.UnanimousBasedUnrevokable">\r
+    class="eu.etaxonomy.cdm.persistence.hibernate.permission.UnanimousBasedUnrevokable" >\r
     \r
     <property name="decisionVoters">\r
       <list>\r
@@ -54,7 +44,7 @@
 \r
   <!-- CdmPermissionEvaluator.hasPermissions() evaluates the CdmPermissions \r
     like TAXONNODE.UPDATE{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7} -->\r
-  <bean id="cdmPermissionEvaluator"\r
+  <bean id="cdmPermissionEvaluator" \r
     class="eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionEvaluator">\r
     <property name="accessDecisionManager" ref="accessDecisionManager" />\r
   </bean>\r
   <!-- The CdmSecurityHibernateInterceptor checks onSave() and on flushDirty() \r
     if the currently authenticated principal or token has sufficient permissions \r
     on the entity to be persisted -->\r
-  <bean id="securityHibernateInterceptor"\r
+  <bean id="securityHibernateInterceptor" \r
     class="eu.etaxonomy.cdm.persistence.hibernate.CdmSecurityHibernateInterceptor">\r
     <property name="permissionEvaluator" ref="cdmPermissionEvaluator" />\r
   </bean>\r
 \r
-<!--   <bean id="authenticationManager" -->\r
-<!--     class="org.springframework.security.authentication.ProviderManager"> -->\r
-<!--     <property name="providers"> -->\r
-<!--       <list> -->\r
-<!--         <ref local="daoAuthenticationProvider" /> -->\r
-<!--       </list> -->\r
-<!--     </property> -->\r
-<!--   </bean> -->\r
-\r
-<!--   <bean id="daoAuthenticationProvider" -->\r
-<!--     class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"> -->\r
-<!--     <property name="userDetailsService" ref="userService" /> -->\r
-<!--     <property name="saltSource" ref="saltSource" /> -->\r
-<!--     <property name="passwordEncoder" ref="passwordEncoder" /> -->\r
-<!--   </bean> -->\r
-\r
-<!--   <bean id="passwordEncoder" -->\r
-<!--     class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" /> -->\r
+  <bean id="authenticationManager"\r
+    class="org.springframework.security.authentication.ProviderManager">\r
+    <property name="providers">\r
+      <list>\r
+        <ref local="daoAuthenticationProvider" />\r
+      </list>\r
+    </property>\r
+  </bean>\r
 \r
-<!--   <bean id="saltSource" -->\r
-<!--     class="org.springframework.security.authentication.dao.ReflectionSaltSource"> -->\r
-<!--     <property name="userPropertyToUse" value="getUsername" /> -->\r
-<!--   </bean> -->\r
+  <bean id="daoAuthenticationProvider" \r
+    class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">\r
+    <property name="userDetailsService" ref="userService" />\r
+    <property name="saltSource" ref="saltSource" />\r
+    <property name="passwordEncoder" ref="passwordEncoder" />\r
+  </bean>\r
 \r
+  <bean id="passwordEncoder" \r
+    class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" />\r
 \r
-  <context:component-scan base-package="eu.etaxonomy.cdm.api.cache">\r
-    <!-- FIXME:Remoting Temp workaround to make remoting work -->\r
-    <context:exclude-filter type="regex"\r
-      expression="eu\.etaxonomy\.cdm\.api\.cache\.CdmTermCacher" />\r
-  </context:component-scan>\r
+  <bean id="saltSource" \r
+    class="org.springframework.security.authentication.dao.ReflectionSaltSource">\r
+    <property name="userPropertyToUse" value="getUsername" />\r
+  </bean>\r
 \r
 \r
+  <bean id="cdmServiceCacher" \r
+    class="eu.etaxonomy.cdm.api.cache.CdmServiceCacher" />\r
 \r
 \r
 </beans>\r
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_persistence_security.xml b/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_persistence_security.xml
deleted file mode 100644 (file)
index d70bca5..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"\r
-  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"\r
-  xsi:schemaLocation="http://www.springframework.org/schema/beans\r
-    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd\r
-    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd\r
-    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd\r
-    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd\r
-    ">\r
-\r
-\r
-    <!--\r
-      ============================== SECURITY ==============================\r
-    -->\r
-    <bean id="accessDecisionManager" class="eu.etaxonomy.cdm.persistence.hibernate.permission.UnanimousBasedUnrevokable">\r
-        <property name="decisionVoters">\r
-            <list>\r
-                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.GrantAlwaysVoter" />\r
-                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonNodeVoter" />\r
-                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonBaseVoter" />\r
-                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionBaseVoter" />\r
-                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionElementVoter" />\r
-            </list>\r
-        </property>\r
-    </bean>\r
-\r
-    <!--\r
-        CdmPermissionEvaluator.hasPermissions() evaluates the CdmPermissions like TAXONNODE.UPDATE{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7}\r
-    -->\r
-    <bean id="cdmPermissionEvaluator" class="eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionEvaluator">\r
-        <property name="accessDecisionManager" ref="accessDecisionManager" />\r
-    </bean>\r
-\r
-    <!-- The CdmSecurityHibernateInterceptor checks onSave() and on flushDirty() if the currently authenticated principal or token  has\r
-    sufficient permissions on the entity to be persisted -->\r
-    <bean id="securityHibernateInterceptor" class="eu.etaxonomy.cdm.persistence.hibernate.CdmSecurityHibernateInterceptor">\r
-        <property name="permissionEvaluator" ref="cdmPermissionEvaluator" />\r
-    </bean>\r
-\r
-</beans>\r
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_services_security.xml b/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_services_security.xml
deleted file mode 100644 (file)
index ed23499..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-  xmlns:context="http://www.springframework.org/schema/context"\r
-  xmlns:security="http://www.springframework.org/schema/security"\r
-  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd\r
-    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd\r
-    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd\r
-    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"\r
-    >\r
-\r
-    <import resource="classpath:/eu/etaxonomy/cdm/remoting_persistence_security.xml"/>\r
-    <!--\r
-        ======================================================================\r
-          security specific configuration\r
-        ======================================================================\r
-     -->\r
-<!--     <security:global-method-security pre-post-annotations="enabled" run-as-manager-ref="runAsManager" > -->\r
-<!--         <security:expression-handler ref="expressionHandler" /> -->\r
-<!--     </security:global-method-security> -->\r
-\r
-    <!--\r
-        To use "hasPermission()" in the Spring EL method annotations like @PreAuthorize we explicitly configure the permissionEvaluator\r
-        the cdmPermissionEvaluator is already defined in the persistence security context\r
-    -->\r
-<!--     <bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler"> -->\r
-<!--         <property name="permissionEvaluator" ref="cdmPermissionEvaluator" /> -->\r
-<!--     </bean> -->\r
-\r
-    <bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">\r
-        <property name="providers">\r
-            <list>\r
-                <ref local="daoAuthenticationProvider"/>\r
-            </list>\r
-        </property>\r
-    </bean>\r
-\r
-    <bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">\r
-        <property name="userDetailsService" ref="userService"/>\r
-        <property name="saltSource" ref="saltSource"/>\r
-        <property name="passwordEncoder" ref="passwordEncoder"/>\r
-    </bean>\r
-\r
-    <bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder"/>\r
-\r
-    <bean id="saltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource">\r
-        <property name="userPropertyToUse" value="getUsername"/>\r
-    </bean>\r
-\r
-    <!--\r
-        Run-As Authentication Replacement for system operations\r
-        as e.g. performed by the eu.etaxonomy.cdm.api.application.FirstDataInserter\r
-\r
-        the key must match FirstDataInserter.RUN_AS_KEY\r
-     -->\r
-<!--     <bean id="runAsManager" -->\r
-<!--         class="org.springframework.security.access.intercept.RunAsManagerImpl"> -->\r
-<!--       <property name="key" value="TtlCx3pgKC4l"/> -->\r
-<!--     </bean> -->\r
-\r
-\r
-</beans>\r
index caa6991897609acb5672a25d1935bddccf132a7b..4a8da2c4c4c1e433dde3f2880f087fae223107f9 100644 (file)
@@ -11,7 +11,7 @@ package eu.etaxonomy.taxeditor.editor.view.dataimport.transientServices;
 
 import java.util.Collection;
 
-import org.springframework.security.authentication.ProviderManager;
+import org.springframework.security.authentication.AuthenticationManager;
 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 ProviderManager getAuthenticationManager() {
+    public AuthenticationManager getAuthenticationManager() {
         return defaultApplicationConfiguration.getAuthenticationManager();
     }
 
index 804ab05343b56cea5f63f04735025a1eaab9c421..db380c7f5308a0d061d12c1c072518601a7093cc 100644 (file)
@@ -20,7 +20,7 @@ import org.eclipse.swt.widgets.Display;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 import org.springframework.security.access.PermissionEvaluator;
-import org.springframework.security.authentication.ProviderManager;
+import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContext;
 import org.springframework.security.core.context.SecurityContextHolder;
@@ -82,8 +82,8 @@ public class CdmStore {
        private static SearchManager searchManager = new SearchManager();
 
        private static EditorManager editorManager = new EditorManager();
-       
-       private static UseObjectStore useObjectInitializer = new UseObjectStore(); 
+
+       private static UseObjectStore useObjectInitializer = new UseObjectStore();
 
        private static CdmStoreConnector job;
 
@@ -325,7 +325,7 @@ public class CdmStore {
 
                return service;
        }
-       
+
        /**
         * @see #getService(Class)
         * As ICommonService is not extending IService we need a specific request here
@@ -346,7 +346,7 @@ public class CdmStore {
         *         {@link org.springframework.security.authentication.ProviderManager}
         *         object.
         */
-       public static ProviderManager getAuthenticationManager() {
+       public static AuthenticationManager getAuthenticationManager() {
                return getCurrentApplicationConfiguration().getAuthenticationManager();
        }
 
index f1b5e38ad942d63699da7fbc51c24ca88b6faae3..850f194b2744672a603e68287327db12c1f585ad 100644 (file)
@@ -155,7 +155,6 @@ class CdmStoreConnector extends Job {
                                        subprogressMonitor);
                } else if(cdmSource instanceof ICdmRemoteSource) {
                        return CdmApplicationRemoteController.NewInstance((ICdmRemoteSource)cdmSource,
-                                                       false,
                                                        subprogressMonitor,
                                                        null);
                } else {
index aa13093967becf49e6aa2550f2b45bd364ad7728..7bf2a1da813475e809ddd4f10fe514ee34bc49f8 100644 (file)
@@ -1,22 +1,41 @@
 // $Id$
 /**
-* Copyright (C) 2015 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2015 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 package eu.etaxonomy.taxeditor.application;
 
+import org.junit.Test;
+import org.unitils.UnitilsJUnit4;
+
+import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController;
+import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
+
 /**
  * @author cmathew
  * @date 26 May 2015
  *
  */
-public class CdmApplicationRemoteControllerTest {
-
-
+public class CdmApplicationRemoteControllerTest extends UnitilsJUnit4 {
 
 
+    @Test
+    public void initApplicationControllerTest() {
+        CdmRemoteSource crs = CdmRemoteSource.NewInstance("local-cyprus",
+                "localhost",
+                8080,
+                "",
+                NomenclaturalCode.ICNAFP);
+        // first initialize with validation to make sure the xml is valid
+        CdmApplicationRemoteController.NewInstance(crs,
+                true,
+                new NullProgressMonitor(),
+                null);
+    }
 }
index 2672fdc4a7d3327434569f51ebad1f9b3d783d1f..b0424a824e5e899632f0274f4292784943b8fe77 100644 (file)
@@ -37,8 +37,8 @@ import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
 import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException;
 import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
 import eu.etaxonomy.taxeditor.session.CdmEntitySession;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
 
 
 /**
@@ -114,7 +114,6 @@ public class BaseRemotingTest extends UnitilsJUnit4 {
         cdmRemoteSource = CdmRemoteSource.NewInstance(sourceName, host, port, contextPath, ncode);
         remoteApplicationController =
                 CdmApplicationRemoteController.NewInstance(cdmRemoteSource,
-                        false,
                         null,
                         null);