import net.sf.ehcache.config.CacheConfiguration;
import net.sf.ehcache.config.SizeOfPolicyConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.common.TermBase;
import eu.etaxonomy.taxeditor.remoting.cache.CacheLoader;
import eu.etaxonomy.taxeditor.remoting.cache.CdmEntityCacheKey;
import eu.etaxonomy.taxeditor.remoting.cache.CdmTransientEntityCacher;
/**
* Class which uses CDM services to cache cdm entities
*
- * FIXME: Currently only handles terms entities. It would be
+ * FIXME: Currently only handles term entities. It would be
* interesting to have a generic method which finds the
* correct service to load / cache the entity.
*
@Component
public class CdmServiceCacher extends CdmCacher implements ICdmEntitySessionManagerObserver {
- @Autowired
- ITermService termService;
private ICdmEntitySessionManager cdmEntitySessionManager;
DefinedTermBase.setCacher(this);
CdmTransientEntityCacher.setDefaultCacher(this);
TermServiceRequestExecutor.setDefaultCacher(this);
+
cacheLoader = new CacheLoader(this);
}
@Override
protected CdmBase findByUuid(UUID uuid) {
- CdmBase term = termService.findWithoutFlush(uuid);
+ CdmBase term = CdmApplicationState.getCurrentAppConfig().getTermService().findWithoutFlush(uuid);
return load(term);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.model.ICdmCacher#isCachable(eu.etaxonomy.cdm.model.common.CdmBase)
- */
@Override
public boolean isCachable(CdmBase cdmEntity) {
- if(cdmEntity != null && cdmEntity instanceof DefinedTermBase) {
+ // if(cdmEntity != null && cdmEntity instanceof DefinedTermBase) {
+ if(cdmEntity != null && cdmEntity instanceof TermBase) {
return true;
}
return false;
CdmBase cachedCdmEntity = getFromCache(cdmEntity.getUuid());
if(isCachable(cdmEntity) && cachedCdmEntity == null) {
- cachedCdmEntity = cacheLoader.load(cdmEntity, true, true);
+ cachedCdmEntity = cacheLoader.load(cdmEntity, false, true);
}
return cachedCdmEntity;
}