refactor(gateway-vertx) Use common apiman StrSubstitutor in config.
MODIFY
common/util/src/main/java/io/apiman/common/util/ApimanStrLookup.java
common/util/src/main/java/io/apiman/common/util/ApimanStrLookup.java
@@ -23,11 +23,8 @@ import org.apache.commons.lang3.text.StrLookup;
*
* @author eric.wittmann@redhat.com
*/
-public class ApimanStrLookup extends StrLookup {
+public class ApimanStrLookup extends StrLookup<String> {
- /**
- * @see org.apache.commons.lang.text.StrLookup#lookup(java.lang.String)
- */
@Override
public String lookup(String key) {
String replacement = System.getProperty(key);

MODIFY
gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/common/config/VertxEngineConfig.java
gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/common/config/VertxEngineConfig.java
package io.apiman.gateway.platforms.vertx3.common.config;
import io.apiman.common.logging.IDelegateFactory;
+import io.apiman.common.util.ApimanStrLookup;
import io.apiman.common.util.SimpleStringUtils;
import io.apiman.common.util.crypt.IDataEncrypter;
import io.apiman.gateway.engine.EngineConfigTuple;
@@ -50,7 +51,6 @@ import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.text.StrLookup;
import org.apache.commons.lang3.text.StrSubstitutor;
@@ -414,20 +414,9 @@ public class VertxEngineConfig implements IEngineConfig {
private void substituteValues(Map<String, String> map) {
map.entrySet().stream()
- .forEach(pair -> map.put(pair.getKey(), substitutor.replace(pair.getValue())));
+ .forEach(pair -> map.put(pair.getKey(), SUBSTITUTOR.replace(pair.getValue())));
}
- private static final StrSubstitutor substitutor = new StrSubstitutor(new StrLookup<String>() {
-
- @Override
- public String lookup(String key) {
- if (System.getenv().containsKey(key)) {
- return System.getenv(key);
- } else if (System.getProperties().containsKey(key)) {
- return System.getProperty(key);
- }
- return null;
- }
- });
+ private static final StrSubstitutor SUBSTITUTOR = new StrSubstitutor(new ApimanStrLookup());
}

refactor(gateway-vertx) Use common apiman StrSubstitutor in config.