Repository: camel Updated Branches: refs/heads/master ea257b0b4 -> 726bbdca9
Revert "CAMEL-10352: Optionally delegate to Aries PropertyEvaluator services in BlueprintPropertiesParser" This reverts commit faec0ea813b0004926121060023f30b61fc2b43e. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/726bbdca Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/726bbdca Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/726bbdca Branch: refs/heads/master Commit: 726bbdca9fdff3053680d6e253b98a0ad44aaa49 Parents: ea257b0 Author: lburgazzoli <lburgazz...@gmail.com> Authored: Mon Oct 17 11:35:17 2016 +0200 Committer: lburgazzoli <lburgazz...@gmail.com> Committed: Mon Oct 17 11:47:04 2016 +0200 ---------------------------------------------------------------------- .../component/properties/DefaultPropertiesParser.java | 14 +++++--------- .../camel/blueprint/BlueprintPropertiesParser.java | 11 ++++++----- 2 files changed, 11 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/726bbdca/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java b/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java index 54037bf..3ab0f73 100644 --- a/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java +++ b/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java @@ -20,6 +20,8 @@ import java.util.HashSet; import java.util.Properties; import java.util.Set; +import static java.lang.String.format; + import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -137,7 +139,7 @@ public class DefaultPropertiesParser implements AugmentedPropertyNameAwareProper // If not found, ensure that there is no valid prefix token in the string if (suffix == -1) { if (getMatchingPrefixIndex(input, input.length()) != -1) { - throw new IllegalArgumentException(String.format("Missing %s from the text: %s", suffixToken, input)); + throw new IllegalArgumentException(format("Missing %s from the text: %s", suffixToken, input)); } return null; } @@ -145,7 +147,7 @@ public class DefaultPropertiesParser implements AugmentedPropertyNameAwareProper // Find the index of the prefix token that matches the suffix token int prefix = getMatchingPrefixIndex(input, suffix); if (prefix == -1) { - throw new IllegalArgumentException(String.format("Missing %s from the text: %s", prefixToken, input)); + throw new IllegalArgumentException(format("Missing %s from the text: %s", prefixToken, input)); } String key = input.substring(prefix + prefixToken.length(), suffix); @@ -231,12 +233,6 @@ public class DefaultPropertiesParser implements AugmentedPropertyNameAwareProper } } - // first try to resolve the key as it is - String value = parseProperty(key, null, properties); - if (value != null) { - return value; - } - // they key may have a get or else expression String defaultValue = null; if (key.contains(GET_OR_ELSE_TOKEN)) { @@ -247,7 +243,7 @@ public class DefaultPropertiesParser implements AugmentedPropertyNameAwareProper String augmentedKey = getAugmentedKey(key); boolean shouldFallback = fallbackToUnaugmentedProperty && !key.equals(augmentedKey); - value = doGetPropertyValue(augmentedKey); + String value = doGetPropertyValue(augmentedKey); if (value == null && shouldFallback) { log.debug("Property with key [{}] not found, attempting with unaugmented key: {}", augmentedKey, key); value = doGetPropertyValue(key); http://git-wip-us.apache.org/repos/asf/camel/blob/726bbdca/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java ---------------------------------------------------------------------- diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java index 3249e48..c04e31e 100644 --- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java +++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java @@ -96,7 +96,7 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser { if (method == null) { try { - method = AbstractPropertyPlaceholder.class.getDeclaredMethod("retrieveValue", String.class); + method = AbstractPropertyPlaceholder.class.getDeclaredMethod("getProperty", String.class); method.setAccessible(true); } catch (NoSuchMethodException e) { throw new IllegalStateException("Cannot add blueprint property placeholder: " + id @@ -133,10 +133,10 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser { } log.trace("Blueprint property key: {} is part of default properties: {}", key, isDefault); } - + try { String candidate = (String) ObjectHelper.invokeMethod(method, placeholder, key); - + if (candidate != null) { if (answer == null || !isDefault) { log.trace("Blueprint parsed candidate property key: {} as value: {}", key, answer); @@ -145,11 +145,11 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser { } } catch (Exception ex) { // Here we just catch the exception and try to use other candidate - } + } } log.debug("Blueprint parsed property key: {} as value: {}", key, answer); } - + // if there is a delegate then let it parse the current answer as it may be jasypt which // need to decrypt values if (delegate != null) { @@ -163,4 +163,5 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser { log.trace("Returning parsed property key: {} as value: {}", key, answer); return answer; } + }