From 84546c78449a2b7412b614d3f4e3b33a91361a91 Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya <shinsuke@apache.org> Date: Tue, 7 Jan 2020 07:12:46 +0900 Subject: [PATCH] fix #2358 add fess.confing. --- .../fess/mylasta/direction/FessConfig.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index 0f51a96e0..5fd928da8 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -15,8 +15,15 @@ */ package org.codelibs.fess.mylasta.direction; +import java.util.concurrent.ExecutionException; + +import org.dbflute.helper.jprop.ObjectiveProperties; +import org.lastaflute.core.direction.PropertyFilter; import org.lastaflute.core.direction.exception.ConfigPropertyNotFoundException; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; + /** * @author FreeGen */ @@ -6438,6 +6445,31 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The serial version UID for object serialization. (Default) */ private static final long serialVersionUID = 1L; + private static final String FESS_CONFIG = "fess.config."; + + @Override + protected ObjectiveProperties newObjectiveProperties(String resourcePath, PropertyFilter propertyFilter) { + return new ObjectiveProperties(resourcePath) { // for e.g. checking existence and filtering value + Cache<String, String> cache = CacheBuilder.newBuilder().build(); + + @Override + public String get(String propertyKey) { + final String plainValue = getFromCache(propertyKey); + final String filteredValue = propertyFilter.filter(propertyKey, plainValue); + verifyPropertyValue(propertyKey, filteredValue); // null checked + return filterPropertyAsDefault(filteredValue); // not null here + } + + private String getFromCache(String propertyKey) { + try { + return cache.get(propertyKey, () -> System.getProperty(FESS_CONFIG + propertyKey, super.get(propertyKey))); + } catch (ExecutionException e) { + return super.get(propertyKey); + } + } + }; + } + public String getDomainTitle() { return get(FessConfig.DOMAIN_TITLE); } -- GitLab