This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new ca97a37  FINERACT-1022 - Update to org.ehcache
ca97a37 is described below

commit ca97a3754454cc13891a91a060be51df6c798139
Author: xurror <[email protected]>
AuthorDate: Sat Jun 13 08:56:39 2020 +0100

    FINERACT-1022 - Update to org.ehcache
---
 fineract-provider/build.gradle                         |  3 ++-
 fineract-provider/dependencies.gradle                  |  7 ++++++-
 .../properties/basicauth/application.properties        |  1 +
 .../basicauth/twofactor/application.properties         |  1 +
 .../properties/oauth/application.properties            |  3 ++-
 .../properties/oauth/twofactor/application.properties  |  1 +
 .../cache/service/RuntimeDelegatingCacheManager.java   | 18 +++++++++++-------
 .../organisation/monetary/domain/MoneyHelper.java      |  4 ++--
 .../portfolio/loanproduct/data/LoanProductData.java    |  6 +++---
 .../src/main/resources/META-INF/spring/cache.xml       |  5 ++---
 .../src/main/resources/META-INF/spring/ehcache.xml     |  7 ++++---
 11 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle
index b5b064f..14664b5 100644
--- a/fineract-provider/build.gradle
+++ b/fineract-provider/build.gradle
@@ -94,7 +94,7 @@ dependencyManagement {
         dependency 'org.flywaydb:flyway-core:6.4.4'
         dependency 'org.quartz-scheduler:quartz:2.3.2'
         dependency 'com.amazonaws:aws-java-sdk-s3:1.11.800'
-        dependency 'net.sf.ehcache:ehcache:2.10.6' // TODO FINERACT-1018
+        dependency 'org.ehcache:ehcache:3.8.1'
         dependency 'com.github.spullara.mustache.java:compiler:0.9.6'
         dependency 'com.jayway.jsonpath:json-path:2.4.0'
         dependency 'org.apache.tika:tika-core:1.24.1'
@@ -110,6 +110,7 @@ dependencyManagement {
         dependency 'io.github.classgraph:classgraph:4.8.85'
         dependency 'org.awaitility:awaitility:4.0.3'
         dependency 'com.github.spotbugs:spotbugs-annotations:4.0.4'
+        dependency 'javax.cache:cache-api:1.1.1'
 
         dependency ('org.dom4j:dom4j:2.1.3') {
             exclude 'relaxngDatatype:relaxngDatatype' // already in 
com.sun.xml.bind:jaxb-osgi:2.3.0.1
diff --git a/fineract-provider/dependencies.gradle 
b/fineract-provider/dependencies.gradle
index 1de39f9..81ae52b 100644
--- a/fineract-provider/dependencies.gradle
+++ b/fineract-provider/dependencies.gradle
@@ -33,6 +33,7 @@ dependencies {
 
             'org.springframework.boot:spring-boot-starter-web',
             'org.springframework.boot:spring-boot-starter-security',
+            'org.springframework.boot:spring-boot-starter-cache',
 
             'org.springframework:spring-jms',
             'org.springframework:spring-context-support',
@@ -65,7 +66,6 @@ dependencies {
             'org.drizzle.jdbc:drizzle-jdbc',
             'org.flywaydb:flyway-core',
 
-            'net.sf.ehcache:ehcache',
             'com.github.librepdf:openpdf',
             'com.github.spullara.mustache.java:compiler',
             'com.jayway.jsonpath:json-path',
@@ -74,6 +74,8 @@ dependencies {
              'jakarta.xml.bind:jakarta.xml.bind-api',
              'org.dom4j:dom4j',
 
+             'javax.cache:cache-api',
+
              'com.github.spotbugs:spotbugs-annotations',
     )
     implementation ('io.swagger:swagger-jersey-jaxrs') {
@@ -98,6 +100,9 @@ dependencies {
     implementation ('org.mnode.ical4j:ical4j') {
                exclude group: 'commons-logging'
     }
+    implementation ('org.ehcache:ehcache') {
+        exclude group: 'org.glassfish.jaxb', module: 'jaxb-runtime'
+    }
 
        // runtimeOnly dependencies are things that Fineract code has no direct 
compile time dependency on, but which must be present at run-time
        runtimeOnly(
diff --git a/fineract-provider/properties/basicauth/application.properties 
b/fineract-provider/properties/basicauth/application.properties
index 64e5421..406e6b7 100644
--- a/fineract-provider/properties/basicauth/application.properties
+++ b/fineract-provider/properties/basicauth/application.properties
@@ -25,3 +25,4 @@ management.info.git.mode=FULL
 
 # FINERACT-914
 server.forward-headers-strategy=framework
+spring.cache.jcache.config=classpath:/META-INF/spring/ehcache.xml
diff --git 
a/fineract-provider/properties/basicauth/twofactor/application.properties 
b/fineract-provider/properties/basicauth/twofactor/application.properties
index a9b13cc..43cb20b 100644
--- a/fineract-provider/properties/basicauth/twofactor/application.properties
+++ b/fineract-provider/properties/basicauth/twofactor/application.properties
@@ -26,3 +26,4 @@ management.info.git.mode=FULL
 
 # FINERACT-914
 server.forward-headers-strategy=framework
+spring.cache.jcache.config=classpath:/META-INF/spring/ehcache.xml
diff --git a/fineract-provider/properties/oauth/application.properties 
b/fineract-provider/properties/oauth/application.properties
index 0241941..881ad0e 100644
--- a/fineract-provider/properties/oauth/application.properties
+++ b/fineract-provider/properties/oauth/application.properties
@@ -25,4 +25,5 @@ management.health.jms.enabled=false
 management.info.git.mode=FULL
 
 # FINERACT-914
-server.forward-headers-strategy=framework
\ No newline at end of file
+server.forward-headers-strategy=framework
+spring.cache.jcache.config=classpath:/META-INF/spring/ehcache.xml
\ No newline at end of file
diff --git 
a/fineract-provider/properties/oauth/twofactor/application.properties 
b/fineract-provider/properties/oauth/twofactor/application.properties
index 562fbd3..4e4ecd3 100644
--- a/fineract-provider/properties/oauth/twofactor/application.properties
+++ b/fineract-provider/properties/oauth/twofactor/application.properties
@@ -26,3 +26,4 @@ management.info.git.mode=FULL
 
 # FINERACT-914
 server.forward-headers-strategy=framework
+spring.cache.jcache.config=classpath:/META-INF/spring/ehcache.xml
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/cache/service/RuntimeDelegatingCacheManager.java
 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/cache/service/RuntimeDelegatingCacheManager.java
index 4246807..db93094 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/cache/service/RuntimeDelegatingCacheManager.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/cache/service/RuntimeDelegatingCacheManager.java
@@ -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();
+        }
     }
 }
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/domain/MoneyHelper.java
 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/domain/MoneyHelper.java
index ca2fc38..b6bfbe2 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/domain/MoneyHelper.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/domain/MoneyHelper.java
@@ -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;
     }
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductData.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductData.java
index 677c3ca..9be3f17 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductData.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductData.java
@@ -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;
     }
diff --git a/fineract-provider/src/main/resources/META-INF/spring/cache.xml 
b/fineract-provider/src/main/resources/META-INF/spring/cache.xml
index 1526df7..891ada5 100644
--- a/fineract-provider/src/main/resources/META-INF/spring/cache.xml
+++ b/fineract-provider/src/main/resources/META-INF/spring/cache.xml
@@ -30,11 +30,10 @@
                http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd
                http://www.springframework.org/schema/cache 
http://www.springframework.org/schema/cache/spring-cache.xsd";>
 
-       <bean id="ehcacheManager" 
class="org.springframework.cache.ehcache.EhCacheCacheManager"
+       <bean id="ehcacheManager" 
class="org.springframework.cache.jcache.JCacheCacheManager"
                p:cacheManager-ref="ehcacheInstance" />
 
        <bean id="ehcacheInstance"
-               
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
-               p:configLocation="classpath:/META-INF/spring/ehcache.xml" 
p:shared="true" />
+               
class="org.springframework.cache.jcache.JCacheManagerFactoryBean"/>
 
 </beans>
\ No newline at end of file
diff --git a/fineract-provider/src/main/resources/META-INF/spring/ehcache.xml 
b/fineract-provider/src/main/resources/META-INF/spring/ehcache.xml
index b5a442d..40f13b4 100644
--- a/fineract-provider/src/main/resources/META-INF/spring/ehcache.xml
+++ b/fineract-provider/src/main/resources/META-INF/spring/ehcache.xml
@@ -21,8 +21,9 @@
 -->
 
 
-<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-       xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd";>
+<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
xmlns='http://www.ehcache.org/v3'
+               xsi:schemaLocation="http://www.ehcache.org/v3 
http://www.ehcache.org/schema/ehcache-core-3.7.xsd";>
+
        <defaultCache eternal="true" maxEntriesLocalHeap="100"
                overflowToDisk="false" />
 
@@ -52,4 +53,4 @@
                   overflowToDisk="false" timeToIdleSeconds="7200" />
        <cache name="tfConfig" maxEntriesLocalHeap="10000" eternal="true"
                   overflowToDisk="false" />
-</ehcache>
\ No newline at end of file
+</config>
\ No newline at end of file

Reply via email to