1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.mylasta.direction;
17
18 import java.util.concurrent.ExecutionException;
19
20 import org.codelibs.fess.Constants;
21 import org.dbflute.helper.jprop.ObjectiveProperties;
22 import org.lastaflute.core.direction.PropertyFilter;
23
24 import com.google.common.cache.Cache;
25 import com.google.common.cache.CacheBuilder;
26
27 public class FessConfigImpl extends FessConfig.SimpleImpl {
28
29 private static final long serialVersionUID = 1L;
30
31 @Override
32 protected ObjectiveProperties newObjectiveProperties(final String resourcePath, final PropertyFilter propertyFilter) {
33 return new ObjectiveProperties(resourcePath) {
34 Cache<String, String> cache = CacheBuilder.newBuilder().build();
35
36 @Override
37 public String get(final String propertyKey) {
38 final String plainValue = getFromCache(propertyKey);
39 final String filteredValue = propertyFilter.filter(propertyKey, plainValue);
40 verifyPropertyValue(propertyKey, filteredValue);
41 return filterPropertyAsDefault(filteredValue);
42 }
43
44 private String getFromCache(final String propertyKey) {
45 try {
46 return cache.get(propertyKey,
47 () -> System.getProperty(Constants.FESS_CONFIG_PREFIX + propertyKey, super.get(propertyKey)));
48 } catch (final ExecutionException e) {
49 return super.get(propertyKey);
50 }
51 }
52 };
53 }
54 }