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 0f51a96e075ad2f32859cd6ca89470fd3846ccdf..5fd928da862fabdacdf01b68e6ec58b0f8c7d39a 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); }