diff --git a/cache-manager/src/main/java/com/networknt/cache/CacheManager.java b/cache-manager/src/main/java/com/networknt/cache/CacheManager.java index 533599d812..033d7231fb 100644 --- a/cache-manager/src/main/java/com/networknt/cache/CacheManager.java +++ b/cache-manager/src/main/java/com/networknt/cache/CacheManager.java @@ -5,23 +5,28 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.TimeUnit; +import java.util.List; public interface CacheManager { Logger logger = LoggerFactory.getLogger(CacheManager.class); static CacheManager getInstance() { - CacheManager cacheManager = SingletonServiceFactory.getBean(CacheManager.class); - if (cacheManager == null) { - logger.warn("No cache manager configured in service.yml; default to CaffeineCacheManager"); - cacheManager = new CaffeineCacheManager(); - for(CacheItem cacheItem: CacheConfig.load().getCaches()) { - cacheManager.addCache(cacheItem.getCacheName(), cacheItem.getMaxSize(), cacheItem.getExpiryInMinutes()); + List caches = CacheConfig.load().getCaches(); + if(caches != null && caches.size() > 0) { + CacheManager cacheManager = SingletonServiceFactory.getBean(CacheManager.class); + if (cacheManager == null) { + logger.warn("No cache manager configured in service.yml; default to CaffeineCacheManager"); + cacheManager = new CaffeineCacheManager(); + for(CacheItem cacheItem: CacheConfig.load().getCaches()) { + cacheManager.addCache(cacheItem.getCacheName(), cacheItem.getMaxSize(), cacheItem.getExpiryInMinutes()); + } + SingletonServiceFactory.setBean(CacheManager.class.getName(), cacheManager); } - SingletonServiceFactory.setBean(CacheManager.class.getName(), cacheManager); + return cacheManager; + } else { + return null; } - return cacheManager; - } + void addCache(String cacheName, long maxSize, long expiryInMinutes); Cache getCache(String cacheName); void removeCache(String cacheName); diff --git a/db-provider/src/main/java/com/networknt/db/provider/DbProviderImpl.java b/db-provider/src/main/java/com/networknt/db/provider/DbProviderImpl.java index 61b704f861..2348c596e9 100644 --- a/db-provider/src/main/java/com/networknt/db/provider/DbProviderImpl.java +++ b/db-provider/src/main/java/com/networknt/db/provider/DbProviderImpl.java @@ -11,6 +11,10 @@ * @author Steve Hu */ public class DbProviderImpl implements DbProvider { + public static final String SQL_EXCEPTION = "ERR10017"; + public static final String GENERIC_EXCEPTION = "ERR10014"; + public static final String OBJECT_NOT_FOUND = "ERR11637"; + private static final Logger logger = LoggerFactory.getLogger(DbProviderImpl.class);