From 6859bfb464bbe110948374cbe1d76895aa953cd9 Mon Sep 17 00:00:00 2001 From: Tamas Cserhati Date: Thu, 29 Feb 2024 14:40:25 +0100 Subject: [PATCH] #42 applicatinoconfiguration null fix --- .../document/service/cache/TemplateCache.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/dookug-document/dookug-document-service/src/main/java/hu/icellmobilsoft/dookug/document/service/cache/TemplateCache.java b/dookug-document/dookug-document-service/src/main/java/hu/icellmobilsoft/dookug/document/service/cache/TemplateCache.java index b63c0d2a..482414bb 100644 --- a/dookug-document/dookug-document-service/src/main/java/hu/icellmobilsoft/dookug/document/service/cache/TemplateCache.java +++ b/dookug-document/dookug-document-service/src/main/java/hu/icellmobilsoft/dookug/document/service/cache/TemplateCache.java @@ -20,8 +20,6 @@ package hu.icellmobilsoft.dookug.document.service.cache; import java.security.InvalidParameterException; -import java.time.Duration; -import java.util.Optional; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -30,11 +28,9 @@ import org.eclipse.microprofile.config.ConfigProvider; import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; import hu.icellmobilsoft.coffee.cdi.logger.AppLogger; import hu.icellmobilsoft.coffee.cdi.logger.ThisLogger; -import hu.icellmobilsoft.coffee.configuration.ApplicationConfiguration; import hu.icellmobilsoft.dookug.api.dto.constants.ConfigKeys; import hu.icellmobilsoft.dookug.common.system.rest.cache.AbstractCache; import hu.icellmobilsoft.dookug.document.service.cache.dto.TemplateCacheItem; @@ -54,9 +50,6 @@ public class TemplateCache extends AbstractCache { private final Cache cache = createCacheBuilder().build(); - @Inject - private ApplicationConfiguration applicationConfiguration; - /** * Add a new {@link TemplateCacheItem} to the Map * @@ -100,18 +93,18 @@ protected String getCacheName() { @Override protected long getTtl() { - return applicationConfiguration.getOptionalValue(ConfigKeys.Cache.Template.TTL, Long.class) + return ConfigProvider.getConfig().getOptionalValue(ConfigKeys.Cache.Template.TTL, Long.class) .orElse(Long.parseLong(ConfigKeys.Cache.Template.Defaults.TTL_IN_MINUTES)); } @Override protected boolean isStatisticsEnabled() { - return applicationConfiguration.getOptionalValue(ConfigKeys.Cache.Template.ENABLESTATISTIC, Boolean.class).orElse(false); + return ConfigProvider.getConfig().getOptionalValue(ConfigKeys.Cache.Template.ENABLESTATISTIC, Boolean.class).orElse(false); } @Override public boolean isCacheEnabled() { - return applicationConfiguration.getOptionalValue(ConfigKeys.Cache.Template.ENABLED, Boolean.class).orElse(true); + return ConfigProvider.getConfig().getOptionalValue(ConfigKeys.Cache.Template.ENABLED, Boolean.class).orElse(true); } }