package eu.etaxonomy.taxeditor.remoting.cache;
import java.lang.reflect.Field;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import net.sf.ehcache.Cache;
import net.sf.ehcache.Element;
}
@SuppressWarnings("unchecked")
- private <T extends Object> T loadRecursive(T obj, Set<Object> alreadyVisitedEntities, boolean update) {
+ private <T extends Object> T loadRecursive(T obj, List<Object> alreadyVisitedEntities, boolean update) {
if(obj == null) {
return null;
}
if(isRecursiveEnabled && recursive) {
logger.info("---- starting recursive load for cdm entity map");
- Set<Object> alreadyVisitedEntities = new HashSet<Object>();
+ List<Object> alreadyVisitedEntities = new ArrayList<Object>();
Map<T,T> cachedMap = load(map, alreadyVisitedEntities, update);
alreadyVisitedEntities.clear();
logger.info("---- ending recursive load for cdm entity map \n");
}
- private <T extends Object> Map<T,T> load(Map<T,T> map, Set<Object> alreadyVisitedEntities, boolean update){
+ private <T extends Object> Map<T,T> load(Map<T,T> map, List<Object> alreadyVisitedEntities, boolean update){
//map = (Map<T,T>)deproxy(map);
if(map == null || map.isEmpty()) {
Collection<T> loadedCollection;
if(isRecursiveEnabled && recursive) {
logger.info("---- starting recursive load for cdm entity collection");
- Set<Object> alreadyVisitedEntities = new HashSet<Object>();
+ List<Object> alreadyVisitedEntities = new ArrayList<Object>();
Collection<T> cachedCollection = load(collection, alreadyVisitedEntities, update);
alreadyVisitedEntities.clear();
logger.info("---- ending recursive load for cdm entity collection \n");
}
@SuppressWarnings("unchecked")
- private <T extends Object> Collection<T> load(Collection<T> collection, Set<Object> alreadyVisitedEntities, boolean update) {
+ private <T extends Object> Collection<T> load(Collection<T> collection, List<Object> alreadyVisitedEntities, boolean update) {
CdmBase loadedCdmBase;
if(isRecursiveEnabled && recursive) {
logger.info("---- starting recursive load for cdm entity " + cdmEntity.getClass().getName() + " with id " + cdmEntity.getId());
- Set<Object> alreadyVisitedEntities = new HashSet<Object>();
+ List<Object> alreadyVisitedEntities = new ArrayList<Object>();
CdmBase cb = loadRecursive(cdmEntity, alreadyVisitedEntities, update);
alreadyVisitedEntities.clear();
logger.info("---- ending recursive load for cdm entity " + cdmEntity.getClass().getName() + " with id " + cdmEntity.getId() + "\n");
protected CdmBase load(CdmBase cdmEntity) {
logger.info("loading object of type " + cdmEntity.getClass().getName() + " with id " + cdmEntity.getId());
-
- cdmEntity = (CdmBase)ProxyUtils.deproxy(cdmEntity);
-
- cdmCacher.put(cdmEntity);
-
+ cdmCacher.put((CdmBase)ProxyUtils.deproxy(cdmEntity));
return cdmCacher.getFromCache(cdmEntity);
-
}
- private CdmBase loadRecursive(CdmBase cdmEntity, Set<Object> alreadyVisitedEntities, boolean update) {
+ private CdmBase loadRecursive(CdmBase cdmEntity, List<Object> alreadyVisitedEntities, boolean update) {
CdmBase cachedCdmEntity = load(cdmEntity);
CdmBase cdmEntityInSubGraph = getCdmBaseTypeFieldValue(cdmEntity, cachedCdmEntity, field, alreadyVisitedEntities, update);
if(cdmEntityInSubGraph != null) {
//checkForIdenticalCdmEntity(alreadyVisitedEntities, cdmEntityInSubGraph);
- if(!alreadyVisitedEntities.contains(cdmEntityInSubGraph)) {
+ if(!checkForIdenticalCdmEntity(alreadyVisitedEntities, cdmEntityInSubGraph)) {
logger.info("recursive loading object of type " + cdmEntityInSubGraph.getClass().getName() + " with id " + cdmEntityInSubGraph.getId());
loadRecursive(cdmEntityInSubGraph, alreadyVisitedEntities, update);
} else {
private CdmBase getCdmBaseTypeFieldValue(CdmBase cdmEntity,
CdmBase cachedCdmEntity,
String fieldName,
- Set<Object> alreadyVisitedEntities,
+ List<Object> alreadyVisitedEntities,
boolean update) {
// this method attempts to make sure that for any two objects found in
if(update) {
// if we are in update mode we have to make the field of the cached entity
// up-to-date by setting it to the value of the cdm entity being loaded
- // NOTE : two exceptions to this are found below
+ // NOTE : the filed is overridden in the case of two exceptions
+ // found below
field.set(cachedCdmEntity, o);
}
return null;
}
}
- } else if(o instanceof Map && !alreadyVisitedEntities.contains(o)) {
+ } else if(o instanceof Map && !checkForIdenticalCdmEntity(alreadyVisitedEntities, o)) {
loadRecursive((Map)o, alreadyVisitedEntities, update);
- } else if(o instanceof Collection && !alreadyVisitedEntities.contains(o)) {
+ } else if(o instanceof Collection && !checkForIdenticalCdmEntity(alreadyVisitedEntities, o)) {
loadRecursive((Collection)o, alreadyVisitedEntities, update);
}
}
}
}
- private boolean checkForIdenticalCdmEntity(Set<CdmBase> cbSet, CdmBase cbToCompare) {
- if(cbToCompare != null) {
- for(CdmBase cb : cbSet) {
-
- if(cb == cbToCompare) {
+ private boolean checkForIdenticalCdmEntity(List<Object> objList, Object objToCompare) {
+ if(objToCompare != null) {
+ for(Object obj : objList) {
+ if(obj == objToCompare) {
return true;
- } else {
- if(cb.equals(cbToCompare)) {
- logger.info("equal but non identical object found of type " + cbToCompare.getUserFriendlyTypeName() + " with id " + cbToCompare.getId());
- }
}
}
}
<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
+<beans default-lazy-init="true" 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/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">\r
\r
\r
- <bean id="agentService"\r
+ <bean id="agentService" \r
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
<property name="serviceUrl">\r
<value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/agent.service</value>\r
</property>\r
</bean>\r
\r
- <bean id="entityValidationResultService"\r
+ <bean id="entityValidationService"\r
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">\r
<property name="serviceUrl">\r
- <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/entityvalidationresult.service</value>\r
+ <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/entityvalidation.service</value>\r
</property>\r
<property name="serviceInterface">\r
- <value>eu.etaxonomy.cdm.api.service.IEntityValidationResultService\r
+ <value>eu.etaxonomy.cdm.api.service.IEntityValidationService\r
</value>\r
</property>\r
<property name="httpInvokerRequestExecutor">\r
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
-
-
- <!-- Default application context and term initializer -->
- <import resource="classpath:/eu/etaxonomy/cdm/defaultApplicationContext.xml"/>
+
+
+ <!-- Default application context and term initializer -->
+ <import resource="classpath:/eu/etaxonomy/cdm/defaultApplicationContext.xml" />
<bean id="persistentTermInitializer" class="eu.etaxonomy.cdm.database.PersistentTermInitializer">
<property name="omit" value="false" />
</bean>
-
- <import resource="classpath:/eu/etaxonomy/cdm/remote.xml"/>
- <import resource="classpath:eu/etaxonomy/cdm/remote/json/jsonConfigurations.xml"/>
-
- <context:component-scan base-package="eu/etaxonomy/cdm/ext"/>
-
+
+ <context:component-scan base-package="eu/etaxonomy/taxeditor/session" />
+ <import resource="classpath:/eu/etaxonomy/cdm/remote.xml" />
+ <import resource="classpath:eu/etaxonomy/cdm/remote/json/jsonConfigurations.xml" />
+
+ <context:component-scan base-package="eu/etaxonomy/cdm/ext" />
+
<context:component-scan base-package="eu/etaxonomy/cdm/remote">
- <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.remote\.config\.DataSourceConfigurer" />
- <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.remote\.config\.LoggingConfigurer" />
- <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.remote\.view\.PatternViewResolver" />
- <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.remote\.vaadin\..*" />
- <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.remote\.controller\..*Portal.*" />
+ <context:exclude-filter type="regex"
+ expression="eu\.etaxonomy\.cdm\.remote\.config\.DataSourceConfigurer" />
+ <context:exclude-filter type="regex"
+ expression="eu\.etaxonomy\.cdm\.remote\.config\.LoggingConfigurer" />
+ <context:exclude-filter type="regex"
+ expression="eu\.etaxonomy\.cdm\.remote\.view\.PatternViewResolver" />
+ <context:exclude-filter type="regex"
+ expression="eu\.etaxonomy\.cdm\.remote\.vaadin\..*" />
+ <context:exclude-filter type="regex"
+ expression="eu\.etaxonomy\.cdm\.remote\.controller\..*Portal.*" />
</context:component-scan>
-
+
<context:component-scan base-package="eu/etaxonomy/taxeditor/remoting/session/mock" />
</beans>