FINERACT-1022 - Update to org.ehcache

This commit is contained in:
xurror
2020-06-13 14:21:45 +02:00
committed by Michael Vorburger ⛑️
parent 17cb620ec0
commit ca97a37544
11 changed files with 35 additions and 21 deletions
@@ -30,7 +30,7 @@ import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.cache.jcache.JCacheCacheManager;
import org.springframework.cache.support.NoOpCacheManager;
import org.springframework.stereotype.Component;
@@ -45,13 +45,13 @@ import org.springframework.stereotype.Component;
@Component(value = "runtimeDelegatingCacheManager")
public class RuntimeDelegatingCacheManager implements CacheManager {
private final EhCacheCacheManager ehcacheCacheManager;
private final JCacheCacheManager jcacheCacheManager;
private final CacheManager noOpCacheManager = new NoOpCacheManager();
private CacheManager currentCacheManager;
@Autowired
public RuntimeDelegatingCacheManager(final EhCacheCacheManager ehcacheCacheManager) {
this.ehcacheCacheManager = ehcacheCacheManager;
public RuntimeDelegatingCacheManager(final JCacheCacheManager jcacheCacheManager) {
this.jcacheCacheManager = jcacheCacheManager;
this.currentCacheManager = this.noOpCacheManager;
}
@@ -68,7 +68,7 @@ public class RuntimeDelegatingCacheManager implements CacheManager {
public Collection<CacheData> retrieveAll() {
final boolean noCacheEnabled = this.currentCacheManager instanceof NoOpCacheManager;
final boolean ehcacheEnabled = this.currentCacheManager instanceof EhCacheCacheManager;
final boolean ehcacheEnabled = this.currentCacheManager instanceof JCacheCacheManager;
// final boolean distributedCacheEnabled = false;
@@ -107,7 +107,7 @@ public class RuntimeDelegatingCacheManager implements CacheManager {
changes.put(CacheApiConstants.cacheTypeParameter, toCacheType.getValue());
clearEhCache();
}
this.currentCacheManager = this.ehcacheCacheManager;
this.currentCacheManager = this.jcacheCacheManager;
break;
case MULTI_NODE:
if (!distributedCacheEnabled) {
@@ -120,6 +120,10 @@ public class RuntimeDelegatingCacheManager implements CacheManager {
}
private void clearEhCache() {
this.ehcacheCacheManager.getCacheManager().clearAll();
javax.cache.CacheManager cacheManager = this.jcacheCacheManager.getCacheManager();
Iterable<String> cacheNames = cacheManager.getCacheNames();
for (String cacheName: cacheNames) {
cacheManager.getCache(cacheName).clear();
}
}
}
@@ -18,10 +18,10 @@
*/
package org.apache.fineract.organisation.monetary.domain;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.MathContext;
import java.math.RoundingMode;
import javax.annotation.PostConstruct;
import net.sf.ehcache.util.FindBugsSuppressWarnings;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -40,7 +40,7 @@ public class MoneyHelper {
@PostConstruct
// This is a hack, but fixing this is not trivial, because some @Entity domain classes use this helper
@FindBugsSuppressWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void someFunction () {
staticConfigurationDomainService = configurationDomainService;
}
@@ -18,13 +18,13 @@
*/
package org.apache.fineract.portfolio.loanproduct.data;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import net.sf.ehcache.util.FindBugsSuppressWarnings;
import org.apache.fineract.accounting.common.AccountingEnumerations;
import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
@@ -1160,12 +1160,12 @@ public class LoanProductData implements Serializable {
return null;
}
@FindBugsSuppressWarnings("NP_BOOLEAN_RETURN_NULL")
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
public Boolean isCompoundingToBePostedAsTransaction() {
return isInterestRecalculationEnabled() ? this.interestRecalculationData.isCompoundingToBePostedAsTransaction() : null;
}
@FindBugsSuppressWarnings("NP_BOOLEAN_RETURN_NULL")
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
public Boolean allowCompoundingOnEod() {
return isInterestRecalculationEnabled() ? this.interestRecalculationData.allowCompoundingOnEod() : null;
}