- corrected recursive autowiring
authorCherian Mathew <c.mathew@bgbm.org>
Tue, 26 May 2015 16:18:12 +0000 (18:18 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Tue, 26 May 2015 16:18:12 +0000 (18:18 +0200)
- changed application context loading to be more performant

13 files changed:
eu.etaxonomy.taxeditor.cdmlib/.classpath
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
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
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredListableBeanFactory.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/cache/CdmServiceCacher.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/session/CdmEntitySession.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionManager.java
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_services_security.xml
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/CdmApplicationRemoteControllerTest.java [new file with mode: 0644]

index ac54ad8a89971cad6b2049d64b48addf971073c1..433df8079081a19e3884964b1227708b87885a87 100644 (file)
        <classpathentry exported="true" kind="lib" path="lib/org.osgi.core-1.0.0.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/org.springframework.aop-3.2.2.RELEASE.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/org.springframework.aspects-3.2.2.RELEASE.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/org.springframework.beans-3.2.2.RELEASE.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/org.springframework.context-3.2.2.RELEASE.jar"/>
+       <classpathentry exported="true" kind="lib" path="lib/org.springframework.beans-3.2.2.RELEASE.jar" sourcepath="/home/cmathew/.m2/repository/org/springframework/org.springframework.beans/3.2.2.RELEASE/org.springframework.beans-3.2.2.RELEASE-sources.jar"/>
+       <classpathentry exported="true" kind="lib" path="lib/org.springframework.context-3.2.2.RELEASE.jar" sourcepath="/home/cmathew/.m2/repository/org/springframework/org.springframework.context/3.2.2.RELEASE/org.springframework.context-3.2.2.RELEASE-sources.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/org.springframework.core-3.2.2.RELEASE.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/org.springframework.expression-3.2.2.RELEASE.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/org.springframework.jdbc-3.2.2.RELEASE.jar" sourcepath="lib/org.springframework.jdbc-3.2.2.RELEASE-sources.jar"/>
index 20fcb506b7d9f93c4b9ff49e147cd896659f5ea1..321df5830bebf250095250ba5697d18364bd3026 100644 (file)
@@ -13,14 +13,55 @@ import javax.sql.DataSource;
 \r
 import org.apache.log4j.Logger;\r
 import org.hibernate.SessionFactory;\r
+import org.springframework.beans.BeansException;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.context.ApplicationContext;\r
+import org.springframework.context.ApplicationContextAware;\r
+import org.springframework.orm.hibernate4.HibernateTransactionManager;\r
+import org.springframework.security.authentication.ProviderManager;\r
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;\r
+import org.springframework.security.core.Authentication;\r
+import org.springframework.security.core.context.SecurityContext;\r
+import org.springframework.security.core.context.SecurityContextHolder;\r
 import org.springframework.stereotype.Component;\r
 import org.springframework.transaction.PlatformTransactionManager;\r
 import org.springframework.transaction.TransactionStatus;\r
 \r
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;\r
 import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;\r
+import eu.etaxonomy.cdm.api.service.IAgentService;\r
+import eu.etaxonomy.cdm.api.service.IClassificationService;\r
+import eu.etaxonomy.cdm.api.service.ICollectionService;\r
+import eu.etaxonomy.cdm.api.service.ICommonService;\r
+import eu.etaxonomy.cdm.api.service.IDatabaseService;\r
+import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
+import eu.etaxonomy.cdm.api.service.IEntityConstraintViolationService;\r
+import eu.etaxonomy.cdm.api.service.IEntityValidationService;\r
+import eu.etaxonomy.cdm.api.service.IFeatureNodeService;\r
+import eu.etaxonomy.cdm.api.service.IFeatureTreeService;\r
+import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;\r
+import eu.etaxonomy.cdm.api.service.IGroupService;\r
+import eu.etaxonomy.cdm.api.service.IIdentificationKeyService;\r
+import eu.etaxonomy.cdm.api.service.ILocationService;\r
+import eu.etaxonomy.cdm.api.service.IMediaService;\r
+import eu.etaxonomy.cdm.api.service.INameService;\r
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;\r
+import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;\r
+import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;\r
+import eu.etaxonomy.cdm.api.service.IReferenceService;\r
+import eu.etaxonomy.cdm.api.service.IService;\r
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;\r
+import eu.etaxonomy.cdm.api.service.ITaxonService;\r
+import eu.etaxonomy.cdm.api.service.ITermService;\r
+import eu.etaxonomy.cdm.api.service.IUserService;\r
+import eu.etaxonomy.cdm.api.service.IVocabularyService;\r
+import eu.etaxonomy.cdm.api.service.IWorkingSetService;\r
+import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;\r
+import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;\r
+import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;\r
 import eu.etaxonomy.cdm.ext.geo.IEditGeoService;\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\r
+import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;\r
 import eu.etaxonomy.taxeditor.service.ICachedCommonService;\r
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;\r
 \r
@@ -31,22 +72,116 @@ import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
  *\r
  */\r
 @Component\r
-public class CdmApplicationRemoteConfiguration extends CdmApplicationDefaultConfiguration {\r
+public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfiguration, ApplicationContextAware  {\r
 \r
     @SuppressWarnings("unused")\r
     private static final Logger logger = Logger.getLogger(CdmApplicationRemoteConfiguration.class);\r
 \r
+    protected ApplicationContext applicationContext;\r
+\r
+    @Autowired\r
+    //@Qualifier("nameService")\r
+    private INameService nameService;\r
+    @Autowired\r
+    //@Qualifier("taxonService")\r
+    private ITaxonService taxonService;\r
+    @Autowired\r
+    //@Qualifier("classificationService")\r
+    private IClassificationService classificationService;\r
+    @Autowired\r
+    //@Qualifier("referenceService")\r
+    private IReferenceService referenceService;\r
+    @Autowired\r
+    //@Qualifier("agentService")\r
+    private IAgentService agentService;\r
+    @Autowired\r
+    //@Qualifier("databaseService")\r
+    private IDatabaseService databaseService;\r
+    @Autowired\r
+    //@Qualifier("termService")\r
+    private ITermService termService;\r
+    //@Autowired\r
+    private HibernateTransactionManager transactionManager;\r
+    @Autowired\r
+    //@Qualifier("descriptionService")\r
+    private IDescriptionService descriptionService;\r
+    @Autowired\r
+    //@Qualifier("occurrenceService")\r
+    private IOccurrenceService occurrenceService;\r
+    @Autowired\r
+    //@Qualifier("primerService")\r
+    private IPrimerService primerService;\r
+    @Autowired\r
+    //@Qualifier("amplificationService")\r
+    private IAmplificationService amplificationService;\r
+    @Autowired\r
+    //@Qualifier("sequenceService")\r
+    private ISequenceService sequenceService;\r
+    @Autowired\r
+    //@Qualifier("mediaService")\r
+    private IMediaService mediaService;\r
+    @Autowired\r
+    //@Qualifier("commonService")\r
+    private ICommonService commonService;\r
+    @Autowired\r
+    private ILocationService locationService;\r
+    //@Autowired\r
+    private SessionFactory sessionFactory;\r
+    //@Autowired\r
+    private DataSource dataSource;\r
+    @Autowired\r
+    private ProviderManager authenticationManager;\r
+    @Autowired\r
+    private IUserService userService;\r
+    @Autowired\r
+    private IGrantedAuthorityService grantedAuthorityService;\r
+    @Autowired\r
+    private IGroupService groupService;\r
+    @Autowired\r
+    private ICollectionService collectionService;\r
+    @Autowired\r
+    private IFeatureTreeService featureTreeService;\r
+    @Autowired\r
+    private IFeatureNodeService featureNodeService;\r
+    @Autowired\r
+    private IVocabularyService vocabularyService;\r
     @Autowired\r
-    IEditGeoService editGeoService;\r
+    private ITaxonNodeService taxonNodeService;\r
+    @Autowired\r
+    private IIdentificationKeyService identificationKeyService;\r
+    @Autowired\r
+    private IPolytomousKeyService polytomousKeyService;\r
+    @Autowired\r
+    private IPolytomousKeyNodeService polytomousKeyNodeService;\r
+    @Autowired\r
+    private IEntityValidationService entityValidationService;\r
+    @Autowired\r
+    private IEntityConstraintViolationService entityConstraintViolationService;\r
+    @Autowired\r
+    private ICdmPermissionEvaluator permissionEvaluator;\r
 \r
+\r
+\r
+    @Autowired\r
+    private IEditGeoService editGeoService;\r
     @Autowired\r
     private ICachedCommonService cachedCommonService;\r
 \r
+    @Autowired\r
+    private IWorkingSetService workingSetService;\r
 \r
     @Autowired\r
     protected ICdmEntitySessionManager cdmEntitySessionManager;\r
 \r
-    public CdmApplicationRemoteConfiguration() {\r
+    private IService<CdmBase> mainService;\r
+\r
+    public CdmApplicationRemoteConfiguration() {}\r
+\r
+    // ****************************** APPLICATION CONTEXT *************************************************/\r
+\r
+    @Override\r
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException{\r
+        this.applicationContext = applicationContext;\r
     }\r
 \r
     /* (non-Javadoc)\r
@@ -58,77 +193,230 @@ public class CdmApplicationRemoteConfiguration extends CdmApplicationDefaultConf
     }\r
 \r
 \r
-    /* (non-Javadoc)\r
-     * @see eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration#startTransaction()\r
+\r
+    /**\r
+     * @return\r
+     */\r
+    public IEditGeoService getEditGeoService() {\r
+        return this.editGeoService;\r
+    }\r
+\r
+    /**\r
+     * @return\r
      */\r
+    public ICachedCommonService getCachedCommonService(){\r
+        return this.cachedCommonService;\r
+    }\r
+\r
+\r
+    public ICdmEntitySessionManager getCdmEntitySessionManager() {\r
+        return this.cdmEntitySessionManager;\r
+    }\r
+\r
+\r
+\r
+\r
+\r
+\r
+ // ****************************** GETTER *************************************************/\r
+\r
     @Override\r
-    public TransactionStatus startTransaction() throws UnsupportedOperationException {\r
-        throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");\r
+    public final Object getBean(String name){\r
+        return this.applicationContext.getBean(name);\r
     }\r
 \r
+    @Override\r
+    public IAgentService getAgentService(){\r
+        return this.agentService;\r
+    }\r
 \r
-    /* (non-Javadoc)\r
-     * @see eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration#startTransaction()\r
-     */\r
     @Override\r
-    public TransactionStatus startTransaction(Boolean readOnly) throws UnsupportedOperationException {\r
-        throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");\r
+    public IDatabaseService getDatabaseService(){\r
+        return this.databaseService;\r
     }\r
 \r
+    @Override\r
+    public INameService getNameService(){\r
+        return this.nameService;\r
+    }\r
 \r
-    /* (non-Javadoc)\r
-     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#commitTransaction(org.springframework.transaction.TransactionStatus)\r
-     */\r
     @Override\r
-    public void commitTransaction(TransactionStatus txStatus) throws UnsupportedOperationException {\r
-        throw new UnsupportedOperationException("commitTransaction is not implemented for CdmApplicationRemoteConfiguration");\r
+    public IReferenceService getReferenceService(){\r
+        return this.referenceService;\r
+    }\r
+\r
+    @Override\r
+    public ITaxonService getTaxonService(){\r
+        return this.taxonService;\r
+    }\r
+\r
+    @Override\r
+    public IClassificationService getClassificationService(){\r
+        return this.classificationService;\r
+    }\r
+\r
+    @Override\r
+    public ITaxonNodeService getTaxonNodeService(){\r
+        return this.taxonNodeService;\r
+    }\r
+\r
+    @Override\r
+    public IDescriptionService getDescriptionService(){\r
+        return this.descriptionService;\r
+    }\r
+\r
+    @Override\r
+    public IOccurrenceService getOccurrenceService(){\r
+        return this.occurrenceService;\r
     }\r
 \r
-    /* (non-Javadoc)\r
-     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#NewConversation()\r
-     */\r
+    @Override\r
+    public IPrimerService getPrimerService(){\r
+        return this.primerService;\r
+    }\r
+\r
+    @Override\r
+    public IAmplificationService getAmplificationService(){\r
+        return this.amplificationService;\r
+    }\r
+\r
+    @Override\r
+    public ISequenceService getSequenceService(){\r
+        return this.sequenceService;\r
+    }\r
+\r
+    @Override\r
+    public IMediaService getMediaService(){\r
+        return this.mediaService;\r
+    }\r
+\r
+    @Override\r
+    public ITermService getTermService(){\r
+        return this.termService;\r
+    }\r
+\r
+    @Override\r
+    public ICommonService getCommonService(){\r
+        return this.commonService;\r
+    }\r
+\r
+    @Override\r
+    public ILocationService getLocationService(){\r
+        return this.locationService;\r
+    }\r
+\r
+    @Override\r
+    public IUserService getUserService(){\r
+        return this.userService;\r
+    }\r
+\r
+    @Override\r
+    public IGrantedAuthorityService getGrantedAuthorityService(){\r
+        return this.grantedAuthorityService;\r
+    }\r
+\r
+    @Override\r
+    public IService<CdmBase> getMainService(){\r
+        return this.mainService;\r
+    }\r
+\r
+\r
+    @Override\r
+    public ProviderManager getAuthenticationManager(){\r
+        return this.authenticationManager;\r
+    }\r
+\r
+\r
     @Override\r
     public ConversationHolder NewConversation() {\r
         return new ConversationHolderMock();\r
     }\r
 \r
-    /**\r
-     * @return\r
-     */\r
-    public IEditGeoService getEditGeoService() {\r
-        return this.editGeoService;\r
+    @Override\r
+    public ICollectionService getCollectionService(){\r
+        return collectionService;\r
     }\r
 \r
-    /**\r
-     * @return\r
-     */\r
-    public ICachedCommonService getCachedCommonService(){\r
-        return this.cachedCommonService;\r
+    @Override\r
+    public IFeatureTreeService getFeatureTreeService(){\r
+        return featureTreeService;\r
     }\r
 \r
+    @Override\r
+    public IFeatureNodeService getFeatureNodeService(){\r
+        return featureNodeService;\r
+    }\r
 \r
-    public ICdmEntitySessionManager getCdmEntitySessionManager() {\r
-        return this.cdmEntitySessionManager;\r
+    @Override\r
+    public IVocabularyService getVocabularyService(){\r
+        return vocabularyService;\r
     }\r
 \r
-    /* (non-Javadoc)\r
-     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setDataSource(javax.sql.DataSource)\r
-     */\r
     @Override\r
-    public void setDataSource(DataSource dataSource) {\r
+    public IIdentificationKeyService getIdentificationKeyService(){\r
+        return identificationKeyService;\r
     }\r
 \r
-    /* (non-Javadoc)\r
-     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setTransactionManager(org.springframework.transaction.PlatformTransactionManager)\r
-     */\r
     @Override\r
-    public void setTransactionManager(PlatformTransactionManager transactionManager) {\r
+    public IPolytomousKeyService getPolytomousKeyService(){\r
+        return polytomousKeyService;\r
+    }\r
+\r
+\r
+    @Override\r
+    public IPolytomousKeyNodeService getPolytomousKeyNodeService(){\r
+        return polytomousKeyNodeService;\r
+    }\r
+\r
+    @Override\r
+    public IWorkingSetService getWorkingSetService(){\r
+        return workingSetService;\r
+    }\r
+\r
+    @Override\r
+    public IGroupService getGroupService(){\r
+        return groupService;\r
+    }\r
+\r
+\r
+    @Override\r
+    public IEntityValidationService getEntityValidationService(){\r
+        return entityValidationService;\r
+    }\r
+\r
+\r
+    @Override\r
+    public IEntityConstraintViolationService getEntityConstraintViolationService(){\r
+        return entityConstraintViolationService;\r
+    }\r
+\r
+    @Override\r
+    public ICdmPermissionEvaluator getPermissionEvaluator(){\r
+        return permissionEvaluator;\r
+    }\r
+\r
+\r
+    @Override\r
+    public TransactionStatus startTransaction() throws UnsupportedOperationException {\r
+        throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");\r
+    }\r
+\r
+    @Override\r
+    public TransactionStatus startTransaction(Boolean readOnly) throws UnsupportedOperationException {\r
+        throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");\r
+    }\r
+\r
+\r
+    @Override\r
+    public void commitTransaction(TransactionStatus txStatus) throws UnsupportedOperationException {\r
+        throw new UnsupportedOperationException("commitTransaction is not implemented for CdmApplicationRemoteConfiguration");\r
     }\r
 \r
-    /* (non-Javadoc)\r
-     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setSessionFactory(org.hibernate.SessionFactory)\r
-     */\r
     @Override\r
-    public void setSessionFactory(SessionFactory sessionFactory) {\r
+    public void authenticate(String username, String password){\r
+        UsernamePasswordAuthenticationToken tokenForUser = new UsernamePasswordAuthenticationToken(username, password);\r
+        Authentication authentication = this.getAuthenticationManager().authenticate(tokenForUser);\r
+        SecurityContext context = SecurityContextHolder.getContext();\r
+        context.setAuthentication(authentication);\r
     }\r
 }\r
index f3abb5b7d84711f442550c5ba6594c3ad751b676..7254c2de1537825e084e03b95b73f65c1349966c 100644 (file)
@@ -1,11 +1,11 @@
 /**
-* Copyright (C) 2014 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) 2014 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.cdm.api.application;
@@ -16,23 +16,17 @@ import java.util.Properties;
 import org.apache.log4j.Logger;
 import org.hibernate.collection.internal.AbstractPersistentCollection;
 import org.hibernate.proxy.AbstractLazyInitializer;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.ApplicationListener;
+import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 
-import eu.etaxonomy.cdm.api.application.CdmApplicationController;
-import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
-import eu.etaxonomy.cdm.api.application.RemotingMonitoredGenericApplicationContext;
 import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
 import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor;
-import eu.etaxonomy.cdm.common.monitor.SubProgressMonitor;
 import eu.etaxonomy.taxeditor.remoting.cache.CdmModelCacher;
 import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
-import eu.etaxonomy.taxeditor.session.CdmEntitySessionManager;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
 
 /**
@@ -47,13 +41,13 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
 
     private static final Logger logger = Logger.getLogger(CdmApplicationRemoteController.class);
 
-       
+
     public static final Resource DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE =
-               new ClassPathResource("/eu/etaxonomy/cdm/remotingApplicationContext.xml");
+            new ClassPathResource("/eu/etaxonomy/cdm/remotingApplicationContext.xml");
     private final Resource applicationContextResource;
     private final IProgressMonitor progressMonitor;
 
-    
+
     /**
      * Creates new instance of CdmApplicationRemoteController
      *
@@ -65,15 +59,15 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
      * @return
      */
     public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource,
-                       ICdmRemoteSource remoteSource,
-                       boolean omitTermLoading,
-                       IProgressMonitor progressMonitor,
-                       List<ApplicationListener> listeners) {
-       return new CdmApplicationRemoteController(applicationContextResource,
-                       remoteSource,
-                       omitTermLoading,
-                       progressMonitor,
-                               listeners);
+            ICdmRemoteSource remoteSource,
+            boolean omitTermLoading,
+            IProgressMonitor progressMonitor,
+            List<ApplicationListener> listeners) {
+        return new CdmApplicationRemoteController(applicationContextResource,
+                remoteSource,
+                omitTermLoading,
+                progressMonitor,
+                listeners);
 
     }
     /**
@@ -87,40 +81,40 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
      * @return
      */
     public static CdmApplicationRemoteController NewInstance(ICdmRemoteSource remoteSource,
-                       boolean omitTermLoading,
-                       IProgressMonitor progressMonitor,
-                       List<ApplicationListener> listeners) {
+            boolean omitTermLoading,
+            IProgressMonitor progressMonitor,
+            List<ApplicationListener> listeners) {
 
-       return new CdmApplicationRemoteController(DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE,
-                       remoteSource,
-                       omitTermLoading,
-                       progressMonitor,
-                               listeners);
+        return new CdmApplicationRemoteController(DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE,
+                remoteSource,
+                omitTermLoading,
+                progressMonitor,
+                listeners);
 
     }
 
-       /**
-        * Constructs CdmApplicationRemoteController
-        *
-        * @param applicationContextResource
-        * @param remoteSource
-        * @param omitTermLoading
-        * @param progressMonitor
-        * @param listeners
-        */
-       private CdmApplicationRemoteController(Resource applicationContextResource,
-                               ICdmRemoteSource remoteSource,
-                               boolean omitTermLoading,
-                               IProgressMonitor progressMonitor,
-                               List<ApplicationListener> listeners){
-               logger.info("Start CdmApplicationRemoteController with remote source: " + remoteSource.getName());
+    /**
+     * Constructs CdmApplicationRemoteController
+     *
+     * @param applicationContextResource
+     * @param remoteSource
+     * @param omitTermLoading
+     * @param progressMonitor
+     * @param listeners
+     */
+    private CdmApplicationRemoteController(Resource applicationContextResource,
+            ICdmRemoteSource remoteSource,
+            boolean omitTermLoading,
+            IProgressMonitor progressMonitor,
+            List<ApplicationListener> listeners){
+        logger.info("Start CdmApplicationRemoteController with remote source: " + remoteSource.getName());
         this.applicationContextResource =
-                       applicationContextResource != null ? applicationContextResource : DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE;
+                applicationContextResource != null ? applicationContextResource : DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE;
         this.progressMonitor = progressMonitor != null ? progressMonitor : new NullProgressMonitor();
 
         setNewRemoteSource(remoteSource, omitTermLoading, listeners);
 
-       }
+    }
 
 
 
@@ -134,18 +128,15 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
      * @return
      */
     protected boolean setNewRemoteSource(ICdmRemoteSource remoteSource,
-               boolean omitTermLoading,
-               List<ApplicationListener> listeners){
+            boolean omitTermLoading,
+            List<ApplicationListener> listeners){
 
         logger.info("Connecting to '" + remoteSource.getName() + "'");
 
-        RemotingMonitoredGenericApplicationContext applicationContext =  new RemotingMonitoredGenericApplicationContext();
-        int refreshTasks = 45;
-        int nTasks = 5 + refreshTasks;
+        GenericApplicationContext applicationContext
+            = generateApplicationContext(applicationContextResource, listeners, progressMonitor, false);
 
-        progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
 
-        progressMonitor.subTask("Registering remote source.");
         PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
         Properties properties = new Properties();
         properties.setProperty("remoteServer", remoteSource.getServer());
@@ -153,39 +144,46 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
         properties.setProperty("remoteContext", remoteSource.getContextPath());
         pspc.setProperties(properties);
         applicationContext.addBeanFactoryPostProcessor(pspc);
+        //progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
+        applicationContext.refresh();
+        applicationContext.start();
+
+
+        progressMonitor.subTask("Cleaning up.");
+        setApplicationContext(applicationContext);
+        progressMonitor.worked(1);
+
+        progressMonitor.done();
+        return true;
+    }
+
+    public static GenericApplicationContext generateApplicationContext(Resource applicationContextResource,
+            List<ApplicationListener> listeners,
+            IProgressMonitor progressMonitor,
+            boolean validateXml) {
+        RemotingMonitoredGenericApplicationContext applicationContext =  new RemotingMonitoredGenericApplicationContext();
+        int refreshTasks = 45;
+        int nTasks = 5 + refreshTasks;
+
+        progressMonitor.subTask("Registering remote source.");
         applicationContext.getEnvironment().setActiveProfiles("remoting");
         progressMonitor.worked(1);
 
         XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext);
-        //xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
+        if(!validateXml) {
+            xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
+        }
         progressMonitor.subTask("Registering resources.");
         xmlReader.loadBeanDefinitions(applicationContextResource);
         progressMonitor.worked(1);
 
-        //omitTerms
-        if (omitTermLoading == true){
-            String initializerName = "persistentTermInitializer";
-            BeanDefinition beanDef = applicationContext.getBeanDefinition(initializerName);
-            MutablePropertyValues values = beanDef.getPropertyValues();
-            values.addPropertyValue("omit", omitTermLoading);
-        }
-
         if (listeners != null){
             for(ApplicationListener listener : listeners){
                 applicationContext.addApplicationListener(listener);
             }
         }
 
-
-        applicationContext.refresh(new SubProgressMonitor(progressMonitor, refreshTasks));
-        applicationContext.start();
-
-        progressMonitor.subTask("Cleaning up.");
-        setApplicationContext(applicationContext);
-        progressMonitor.worked(1);
-
-        progressMonitor.done();
-        return true;
+        return applicationContext;
     }
 
     /* (non-Javadoc)
@@ -194,15 +192,15 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
     @Override
     protected void init(){
         configuration = (ICdmApplicationConfiguration)applicationContext.getBean("cdmApplicationRemoteConfiguration");
-               AbstractLazyInitializer.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
-               AbstractPersistentCollection.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
-               
-               CdmModelCacher cmdmc = new CdmModelCacher();
-               cmdmc.cacheGetterFields();
+        AbstractLazyInitializer.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
+        AbstractPersistentCollection.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
+
+        CdmModelCacher cmdmc = new CdmModelCacher();
+        cmdmc.cacheGetterFields();
 
     }
 
     public ICdmEntitySessionManager getCdmEntitySessionManager() {
-       return ((CdmApplicationRemoteConfiguration)configuration).getCdmEntitySessionManager();
+        return ((CdmApplicationRemoteConfiguration)configuration).getCdmEntitySessionManager();
     }
 }
index 6ad7ad4189f53e5b94c3da17450f2223fd1bfc20..be7b3b2157341d1b5198403dced25b11c5aa206a 100644 (file)
@@ -9,32 +9,28 @@
 */\r
 package eu.etaxonomy.cdm.api.application;\r
 \r
-import java.util.concurrent.CancellationException;\r
+import java.io.Serializable;\r
 \r
 import org.apache.log4j.Logger;\r
-import org.springframework.beans.BeansException;\r
 import org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver;\r
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;\r
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;\r
 import org.springframework.context.support.GenericApplicationContext;\r
 import org.springframework.core.LocalVariableTableParameterNameDiscoverer;\r
 \r
-import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;\r
-import eu.etaxonomy.cdm.common.monitor.SubProgressMonitor;\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{\r
+public class RemotingMonitoredGenericApplicationContext extends GenericApplicationContext implements Serializable {\r
     @SuppressWarnings("unused")\r
-    private static final Logger logger = Logger.getLogger(CdmApplicationController.class);\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
+   // private IProgressMonitor currentMonitor;\r
 \r
 \r
 \r
@@ -42,98 +38,111 @@ public class RemotingMonitoredGenericApplicationContext extends GenericApplicati
      * 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(new RemotingMonitoredListableBeanFactory());\r
+//      MonitoredListableBeanFactory beanFactory =\r
+        super();\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
+        ((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
-    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
+//    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
-    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
-    }\r
-\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.springframework.context.support.AbstractApplicationContext#refresh()\r
-     */\r
-    public void refresh(IProgressMonitor monitor) 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
+//    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
index 4e03ea4d8eb34722cecbeb385fa624023cc264ab..ba85fb5ea99cc2ccf22238542494b94bd3c7d1d0 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$\r
 /**\r
 * Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
 * http://www.e-taxonomy.eu\r
-* \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
@@ -30,21 +30,21 @@ import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
 public class RemotingMonitoredListableBeanFactory extends DefaultListableBeanFactory {\r
        @SuppressWarnings("unused")\r
        private static final Logger logger = Logger.getLogger(RemotingMonitoredListableBeanFactory.class);\r
-       \r
+\r
        private boolean isInitializingBeans = false;\r
        private IProgressMonitor currentMonitor;\r
-       \r
+\r
        private static List<String> beansToMonitor = Arrays.asList("sessionFactory","defaultBeanInitializer","persistentTermInitializer");\r
-       private Set<String> alreadyMonitoredBeans = new HashSet<String>();\r
+       private final Set<String> alreadyMonitoredBeans = new HashSet<String>();\r
 \r
        public RemotingMonitoredListableBeanFactory(){\r
        }\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
 //             }\r
 ////           String message = "Handle bean '%s'";\r
 ////           message = String.format(message, beanName);\r
@@ -54,8 +54,9 @@ public class RemotingMonitoredListableBeanFactory extends DefaultListableBeanFac
 ////           registeredBeanNames.add(beanName);\r
 //             return result;\r
 //     }\r
-       \r
-       public void preInstantiateSingletons() throws BeansException {\r
+\r
+       @Override\r
+    public void preInstantiateSingletons() throws BeansException {\r
                isInitializingBeans = true;\r
                checkMonitorCancelled(currentMonitor);\r
                int countBeans = 0;\r
@@ -86,8 +87,9 @@ public class RemotingMonitoredListableBeanFactory extends DefaultListableBeanFac
 //             }\r
 //             return result;\r
 //     }\r
-       \r
-       protected Object createBean(final String name, final RootBeanDefinition mbd, final Object[] args){\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
@@ -111,18 +113,18 @@ public class RemotingMonitoredListableBeanFactory extends DefaultListableBeanFac
                return result;\r
        }\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
+\r
        private void checkMonitorCancelled(IProgressMonitor monitor) {\r
                if (monitor != null && monitor.isCanceled()){\r
                        throw new CancellationException();\r
-               }       \r
+               }\r
        }\r
-               \r
+\r
 }\r
index 96c94964cc2fb0698048ac580b0051a8d103a068..e7dc0e7d5abeb5a8e492cbe457f23ea35ac5ec63 100644 (file)
@@ -16,8 +16,9 @@ import eu.etaxonomy.taxeditor.remoting.cache.CdmEntityCacheKey;
 import eu.etaxonomy.taxeditor.remoting.cache.CdmTransientEntityCacher;
 import eu.etaxonomy.taxeditor.service.TermServiceRequestExecutor;
 import eu.etaxonomy.taxeditor.session.CdmEntitySession;
-import eu.etaxonomy.taxeditor.session.CdmEntitySessionManager;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManagerObserver;
 
 /**
  * Class which uses CDM services to cache cdm entities
@@ -31,13 +32,13 @@ import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
  * @param <T>
  */
 @Component
-public class CdmServiceCacher extends CdmCacher {
+public class CdmServiceCacher extends CdmCacher  implements ICdmEntitySessionManagerObserver {
 
     @Autowired
     ITermService termService;
 
-    @Autowired
-    private CdmEntitySessionManager cdmEntitySessionManager;
+
+    private ICdmEntitySessionManager cdmEntitySessionManager;
 
     private CdmTransientEntityCacher cdmTransientEntityCacher;
 
@@ -85,12 +86,20 @@ public class CdmServiceCacher extends CdmCacher {
         return false;
     }
 
-    public void setActiveSession(ICdmEntitySession cdmEntitySession) {
+
+    public void setCdmEntitySessionManager(ICdmEntitySessionManager cdmEntitySessionManager) {
+        this.cdmEntitySessionManager = cdmEntitySessionManager;
+        if(cdmEntitySessionManager != null) {
+            cdmEntitySessionManager.addSessionObserver(this);
+        }
+    }
+
+    public CdmTransientEntityCacher getCurrentCacher() {
+        ICdmEntitySession cdmEntitySession = cdmEntitySessionManager.getActiveSession();
         if(cdmEntitySession != null && cdmEntitySession instanceof CdmEntitySession) {
-            this.cdmTransientEntityCacher = ((CdmEntitySession) cdmEntitySession).getCacher();
-        } else {
-            this.cdmTransientEntityCacher = null;
+            return ((CdmEntitySession) cdmEntitySession).getCacher();
         }
+        return null;
     }
 
     @Override
@@ -122,5 +131,18 @@ public class CdmServiceCacher extends CdmCacher {
         return cachedCdmEntity;
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionManagerObserver#changed()
+     */
+    @Override
+    public void changed() {
+        ICdmEntitySession cdmEntitySession = cdmEntitySessionManager.getActiveSession();
+        if(cdmEntitySession != null && cdmEntitySession instanceof CdmEntitySession) {
+            this.cdmTransientEntityCacher = ((CdmEntitySession) cdmEntitySession).getCacher();
+        } else {
+            this.cdmTransientEntityCacher = null;
+        }
+    }
+
 
 }
index 2f3d49be67f88b091110c61fd1419fd109fbf0dc..355fb0d669f9ef178c0287827ecb8afced1baedb 100644 (file)
@@ -74,9 +74,8 @@ public class CdmModelCacher {
                        String mappedClassName = mappedClass.getName();
 
                        CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName);
-                       addGetters(persistentClass, cmgmfc);
                        logger.info("Adding class : " + mappedClassName + " to cache");
-
+                       addGetters(persistentClass, cmgmfc);
                        cache.put(new Element(mappedClassName, cmgmfc));
 
                }
index e3f6b7b4229135df5e18d8fbba05193298d17ba1..e5a50fed30adcaa9f72b3fb8f8c37886cd09d854 100644 (file)
@@ -191,7 +191,7 @@ public class CdmEntitySession implements ICdmEntitySession  {
     public void bind() {
         logger.info("Binding session with owner " + sessionOwner.toString());
         cdmEntitySessionManager.bind(sessionOwner);
-        cdmEntitySessionManager.notifyObservers();
+
     }
 
     /* (non-Javadoc)
index 5e43249ff621356484ed7ac3d361c5c6c1806a56..538f4df32f99947c3b1d12fc5dad1d23214fdd35 100644 (file)
@@ -18,10 +18,8 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import eu.etaxonomy.cdm.api.cache.CdmServiceCacher;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
 
@@ -41,8 +39,7 @@ public class CdmEntitySessionManager implements ICdmEntitySessionManager {
 
     private ICdmEntitySession activeSession;
 
-    @Autowired
-    private CdmServiceCacher cdmServiceCacher;
+
 
     @Override
     public ICdmEntitySession newSession(ICdmEntitySessionEnabled sessionOwner, boolean setAsActive) {
@@ -68,7 +65,7 @@ public class CdmEntitySessionManager implements ICdmEntitySessionManager {
 
     private void setActiveSession(ICdmEntitySession activeSession) {
         this.activeSession = activeSession;
-        cdmServiceCacher.setActiveSession(activeSession);
+        notifyObservers();
     }
 
 
index a2b0a513e8e7ff2215c0466a4e6ff66af957d72c..0927154eacb0ac1e31fd48138f291aacac2743fe 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
-<beans default-lazy-init="true" xmlns="http://www.springframework.org/schema/beans"\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"\r
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
     </property>\r
   </bean>\r
 \r
-  <bean id="providerManager"\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
index 2556cbdc09f1812a5d89c64c7efc855f4343c3cb..47f6b6e3be7373f9404e82b981916ccdfd6de8a3 100644 (file)
 <?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:tx="http://www.springframework.org/schema/tx"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+  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
+  <!-- <bean id="remoteTermInitializer" class="eu.etaxonomy.cdm.remote.service.RemoteTermInitializer"/> -->\r
 \r
-       <context:annotation-config />\r
+  <context:annotation-config />\r
 \r
-       <import resource="classpath:/eu/etaxonomy/cdm/httpInvokerServiceClients.xml" />\r
+  <import resource="classpath:/eu/etaxonomy/cdm/httpInvokerServiceClients.xml" />\r
 \r
-       <context:component-scan base-package="eu/etaxonomy/taxeditor/session" />\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
+  <!-- <context:component-scan base-package="eu/etaxonomy/taxeditor/session" \r
+    /> -->\r
+  <bean id="cdmEntitySessionManager"  class="eu.etaxonomy.taxeditor.session.CdmEntitySessionManager" />\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="cdmApplicationRemoteConfiguration" \r
+    class="eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration" />\r
 \r
-       <context:component-scan base-package="eu.etaxonomy.taxeditor.service"/>\r
-
-       \r
-       <!-- EditGeoService was moved to ext. Therefore it will not be found by \r
-               the default component scan. We added it here because the Editor needs it. \r
-               However, this is only a temporary solution. In the future we want to pass \r
-               in an application context with the editor. -->\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
+    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
+    \r
+    <property name="decisionVoters">\r
+      <list>\r
+        <bean\r
+          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.GrantAlwaysVoter" />\r
+        <bean\r
+          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonNodeVoter" />\r
+        <bean\r
+          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonBaseVoter" />\r
+        <bean\r
+          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionBaseVoter" />\r
+        <bean\r
+          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionElementVoter" />\r
+      </list>\r
+    </property>\r
+  </bean>\r
+\r
+  <!-- CdmPermissionEvaluator.hasPermissions() evaluates the CdmPermissions \r
+    like TAXONNODE.UPDATE{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7} -->\r
+  <bean id="cdmPermissionEvaluator"\r
+    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() \r
+    if the currently authenticated principal or token has sufficient permissions \r
+    on the entity to be persisted -->\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
+\r
+<!--   <bean id="saltSource" -->\r
+<!--     class="org.springframework.security.authentication.dao.ReflectionSaltSource"> -->\r
+<!--     <property name="userPropertyToUse" value="getUsername" /> -->\r
+<!--   </bean> -->\r
+\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
 \r
 \r
-       <!-- <bean id="conversationHolder" class="eu.etaxonomy.cdm.api.conversation.ConversationHolder" \r
-               scope="prototype"/> -->\r
 \r
-       <!-- TODO move to io -->\r
-       <!-- <context:component-scan base-package="eu/etaxonomy/cdm/io"> <context:exclude-filter \r
-               type="regex" expression="eu\.etaxonomy\.cdm\.io\.berlinModel.*" /> </context:component-scan> -->\r
-       <!-- enable the configuration of transactional behavior based on annotations -->\r
-       <!-- <tx:annotation-driven transaction-manager="transactionManager"/> -->\r
 \r
 </beans>\r
index 6a09db4224f26d578657cbd6149a63506102748b..ed23499425c8730616f4ba3508d4759325335df2 100644 (file)
           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
+<!--     <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
+<!--     <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
 \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
+<!--     <bean id="runAsManager" -->\r
+<!--         class="org.springframework.security.access.intercept.RunAsManagerImpl"> -->\r
+<!--       <property name="key" value="TtlCx3pgKC4l"/> -->\r
+<!--     </bean> -->\r
 \r
 \r
 </beans>\r
diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/CdmApplicationRemoteControllerTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/CdmApplicationRemoteControllerTest.java
new file mode 100644 (file)
index 0000000..aa13093
--- /dev/null
@@ -0,0 +1,22 @@
+// $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.application;
+
+/**
+ * @author cmathew
+ * @date 26 May 2015
+ *
+ */
+public class CdmApplicationRemoteControllerTest {
+
+
+
+
+}