diff --git a/mifosng-provider/build.gradle b/mifosng-provider/build.gradle index eb9617560..015fee436 100644 --- a/mifosng-provider/build.gradle +++ b/mifosng-provider/build.gradle @@ -161,7 +161,10 @@ dependencies { [group: 'org.mnode.ical4j', name: 'ical4j', version: '1.0.4'], [group: 'com.googlecode.flyway', name: 'flyway-maven-plugin', version: '2.1.1'], [group: 'org.quartz-scheduler', name: 'quartz', version: '2.1.7'], - [group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.2.1'] + [group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.2.1'], + + [group: 'com.google.code.simple-spring-memcached', name: 'xmemcached-provider', version: '3.2.0'], + [group: 'com.google.code.simple-spring-memcached', name: 'spring-cache', version: '3.2.0'] ) testCompile 'junit:junit:4.10', diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeData.java index e5d598555..d8c65237d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeData.java @@ -5,10 +5,12 @@ */ package org.mifosplatform.infrastructure.codes.data; +import java.io.Serializable; + /** * Immutable data object representing a code. */ -public class CodeData { +public class CodeData implements Serializable { private final Long id; @SuppressWarnings("unused") diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeValueData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeValueData.java index 6517087e8..0aa3df036 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeValueData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeValueData.java @@ -5,10 +5,12 @@ */ package org.mifosplatform.infrastructure.codes.data; +import java.io.Serializable; + /** * Immutable data object represent code-value data in system. */ -public class CodeValueData { +public class CodeValueData implements Serializable{ private final Long id; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeReadPlatformServiceImpl.java index 187802cf4..6449eb286 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeReadPlatformServiceImpl.java @@ -14,6 +14,7 @@ import org.mifosplatform.infrastructure.codes.exception.CodeNotFoundException; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; @@ -49,6 +50,7 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService { } @Override + @Cacheable(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public Collection retrieveAllCodes() { context.authenticatedUser(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java index f9a6ad304..67f131bfc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java @@ -13,6 +13,7 @@ import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Service; @@ -59,6 +60,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe } @Override + @Cacheable(value = "code_values", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#codeId)") public Collection retrieveAllCodeValues(Long codeId) { context.authenticatedUser(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueWritePlatformServiceJpaRepositoryImpl.java index 49ce4c4f7..d9a8b9a5a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueWritePlatformServiceJpaRepositoryImpl.java @@ -22,6 +22,7 @@ import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -50,6 +51,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue @Transactional @Override + @CacheEvict(value = "code_values", allEntries = true) public CommandProcessingResult createCodeValue(final JsonCommand command) { try { @@ -93,6 +95,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue @Transactional @Override + @CacheEvict(value = "code_values", allEntries = true) public CommandProcessingResult updateCodeValue(final Long codeValueId, final JsonCommand command) { try { @@ -123,6 +126,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue @Transactional @Override + @CacheEvict(value = "code_values", allEntries = true) public CommandProcessingResult deleteCodeValue(final Long codeId, final Long codeValueId) { try { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformServiceJpaRepositoryImpl.java index fe8717f38..28bca315e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformServiceJpaRepositoryImpl.java @@ -20,6 +20,7 @@ import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -43,6 +44,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf @Transactional @Override + @CacheEvict(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult createCode(final JsonCommand command) { try { @@ -62,6 +64,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf @Transactional @Override + @CacheEvict(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult updateCode(final Long codeId, final JsonCommand command) { try { @@ -89,6 +92,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf @Transactional @Override + @CacheEvict(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult deleteCode(final Long codeId) { context.authenticatedUser(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/TenantAwareJpaPlatformUserDetailsService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/TenantAwareJpaPlatformUserDetailsService.java index 294cd8bab..0cb76fde5 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/TenantAwareJpaPlatformUserDetailsService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/TenantAwareJpaPlatformUserDetailsService.java @@ -8,6 +8,7 @@ package org.mifosplatform.infrastructure.security.service; import org.mifosplatform.infrastructure.security.domain.PlatformUser; import org.mifosplatform.infrastructure.security.domain.PlatformUserRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.dao.DataAccessException; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; @@ -24,6 +25,7 @@ public class TenantAwareJpaPlatformUserDetailsService implements PlatformUserDet private PlatformUserRepository platformUserRepository; @Override + @Cacheable(value = "users", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#username)") public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException, DataAccessException { final PlatformUser appUser = this.platformUserRepository.findByUsername(username); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeData.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeData.java index ef4371a45..bbad3825b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeData.java @@ -5,6 +5,7 @@ */ package org.mifosplatform.organisation.office.data; +import java.io.Serializable; import java.util.Collection; import java.util.List; @@ -13,7 +14,7 @@ import org.joda.time.LocalDate; /** * Immutable data object for office data. */ -public class OfficeData { +public class OfficeData implements Serializable { private final Long id; private final String name; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java index c0675c4e4..de21834c5 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java @@ -22,6 +22,7 @@ import org.mifosplatform.organisation.office.data.OfficeTransactionData; import org.mifosplatform.organisation.office.exception.OfficeNotFoundException; import org.mifosplatform.useradministration.domain.AppUser; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; @@ -126,6 +127,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService } @Override + @Cacheable(value = "offices", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())") public Collection retrieveAllOffices() { AppUser currentUser = context.authenticatedUser(); @@ -140,6 +142,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService } @Override + @Cacheable(value = "office_template", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())") public Collection retrieveAllOfficesForDropdown() { final AppUser currentUser = context.authenticatedUser(); @@ -224,4 +227,8 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService return OfficeTransactionData.template(new LocalDate(), parentLookups, currencyOptions); } + + public PlatformSecurityContext getContext() { + return this.context; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java index 111ebcc86..9d9d81fdc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java @@ -28,6 +28,8 @@ import org.mifosplatform.useradministration.domain.AppUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Caching; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -60,6 +62,9 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP @Transactional @Override + @Caching(evict = { + @CacheEvict(value = "offices", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())"), + @CacheEvict(value = "office_template", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())") }) public CommandProcessingResult createOffice(final JsonCommand command) { try { @@ -95,6 +100,9 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP @Transactional @Override + @Caching(evict = { + @CacheEvict(value = "offices", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())"), + @CacheEvict(value = "office_template", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())") }) public CommandProcessingResult updateOffice(final Long officeId, final JsonCommand command) { try { @@ -230,4 +238,8 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP return officeToReturn; } + + public PlatformSecurityContext getContext() { + return this.context; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java index c4f1d8db9..fce174d18 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java @@ -5,6 +5,7 @@ */ package org.mifosplatform.portfolio.charge.data; +import java.io.Serializable; import java.math.BigDecimal; import java.util.Collection; import java.util.List; @@ -16,7 +17,7 @@ import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData; /** * Immutable data object for charge data. */ -public class ChargeData implements Comparable { +public class ChargeData implements Comparable, Serializable { private final Long id; private final String name; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java index 8a20c0a55..b7c106ff4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java @@ -21,6 +21,7 @@ import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.domain.ChargeAppliesTo; import org.mifosplatform.portfolio.charge.exception.ChargeNotFoundException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; @@ -45,6 +46,7 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService } @Override + @Cacheable(value = "charges", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public Collection retrieveAllCharges() { this.context.authenticatedUser(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java index 9f563e2dd..2bd3b6509 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java @@ -26,6 +26,7 @@ import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; @@ -56,6 +57,7 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP @Transactional @Override + @CacheEvict(value = "charges", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult createCharge(final JsonCommand command) { try { this.context.authenticatedUser(); @@ -74,6 +76,7 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP @Transactional @Override + @CacheEvict(value = "charges", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult updateCharge(final Long chargeId, final JsonCommand command) { try { @@ -99,6 +102,7 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP @Transactional @Override + @CacheEvict(value = "charges", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult deleteCharge(final Long chargeId) { this.context.authenticatedUser(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/data/FundData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/data/FundData.java index 2a423f52d..bb7109439 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/data/FundData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/data/FundData.java @@ -5,10 +5,12 @@ */ package org.mifosplatform.portfolio.fund.data; +import java.io.Serializable; + /** * Immutable data object to represent fund data. */ -public class FundData { +public class FundData implements Serializable { @SuppressWarnings("unused") private Long id; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundReadPlatformServiceImpl.java index 4ee3c08a3..4d0f15378 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundReadPlatformServiceImpl.java @@ -14,6 +14,7 @@ import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext import org.mifosplatform.portfolio.fund.data.FundData; import org.mifosplatform.portfolio.fund.exception.FundNotFoundException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; @@ -49,6 +50,7 @@ public class FundReadPlatformServiceImpl implements FundReadPlatformService { } @Override + @Cacheable(value = "funds", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public Collection retrieveAllFunds() { context.authenticatedUser(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java index 84d03cb1b..ab05636f0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java @@ -19,6 +19,7 @@ import org.mifosplatform.portfolio.fund.serialization.FundCommandFromApiJsonDese import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,6 +43,7 @@ public class FundWritePlatformServiceJpaRepositoryImpl implements FundWritePlatf @Transactional @Override + @CacheEvict(value = "fund", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult createFund(final JsonCommand command) { try { @@ -62,6 +64,7 @@ public class FundWritePlatformServiceJpaRepositoryImpl implements FundWritePlatf @Transactional @Override + @CacheEvict(value = "fund", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult updateFund(final Long fundId, final JsonCommand command) { try { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/domain/Role.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/domain/Role.java index d1216ac09..135e23ef4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/domain/Role.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/domain/Role.java @@ -5,6 +5,7 @@ */ package org.mifosplatform.useradministration.domain; +import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; @@ -26,7 +27,7 @@ import org.springframework.data.jpa.domain.AbstractPersistable; @Entity @Table(name = "m_role", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "unq_name")}) -public class Role extends AbstractPersistable { +public class Role extends AbstractPersistable implements Serializable { @Column(name = "name", unique = true, nullable = false, length = 100) private String name; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/AppUserWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/AppUserWritePlatformServiceJpaRepositoryImpl.java index e6e42e333..81c185fce 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/AppUserWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/AppUserWritePlatformServiceJpaRepositoryImpl.java @@ -33,6 +33,7 @@ import org.mifosplatform.useradministration.exception.UserNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -66,6 +67,7 @@ public class AppUserWritePlatformServiceJpaRepositoryImpl implements AppUserWrit @Transactional @Override + @CacheEvict(value = "users", allEntries = true) public CommandProcessingResult createUser(final JsonCommand command) { try { @@ -109,6 +111,7 @@ public class AppUserWritePlatformServiceJpaRepositoryImpl implements AppUserWrit @Transactional @Override + @CacheEvict(value = "users", allEntries = true) public CommandProcessingResult updateUser(final Long userId, final JsonCommand command) { try { @@ -169,6 +172,7 @@ public class AppUserWritePlatformServiceJpaRepositoryImpl implements AppUserWrit @Transactional @Override + @CacheEvict(value = "users", allEntries = true) public CommandProcessingResult deleteUser(final Long userId) { final AppUser user = this.appUserRepository.findOne(userId); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformServiceImpl.java index 71e1769d2..d8671bfba 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformServiceImpl.java @@ -14,6 +14,8 @@ import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.useradministration.data.RoleData; import org.mifosplatform.useradministration.exception.RoleNotFoundException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; @@ -32,6 +34,7 @@ public class RoleReadPlatformServiceImpl implements RoleReadPlatformService { } @Override + @Cacheable(value = "roles", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public Collection retrieveAll() { final String sql = "select " + roleRowMapper.schema() + " order by r.id"; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleWritePlatformServiceJpaRepositoryImpl.java index 39dc3a3e7..a59650323 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleWritePlatformServiceJpaRepositoryImpl.java @@ -25,6 +25,7 @@ import org.mifosplatform.useradministration.serialization.PermissionsCommandFrom import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -52,6 +53,7 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf @Transactional @Override + @CacheEvict(value = "roles", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult createRole(final JsonCommand command) { try { @@ -97,6 +99,7 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf @Transactional @Override + @CacheEvict(value = "roles", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult updateRole(final Long roleId, final JsonCommand command) { try { context.authenticatedUser(); @@ -126,6 +129,7 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf @Transactional @Override + @CacheEvict(value = "roles", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()") public CommandProcessingResult updateRolePermissions(final Long roleId, final JsonCommand command) { context.authenticatedUser(); diff --git a/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml b/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml index cbd124385..c7b519280 100644 --- a/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml +++ b/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml @@ -12,16 +12,20 @@ xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:sec="http://www.springframework.org/schema/security" xmlns:tx="http://www.springframework.org/schema/tx" + xmlns:cache="http://www.springframework.org/schema/cache" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + 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"> + + + + \ No newline at end of file diff --git a/mifosng-provider/src/main/resources/META-INF/spring/memcached.xml b/mifosng-provider/src/main/resources/META-INF/spring/memcached.xml new file mode 100644 index 000000000..c364d6b1c --- /dev/null +++ b/mifosng-provider/src/main/resources/META-INF/spring/memcached.xml @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file