Repository: camel Updated Branches: refs/heads/camel-2.18.x faec0ea81 -> 29ea37a0d
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/29ea37a0 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/29ea37a0 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/29ea37a0 Branch: refs/heads/camel-2.18.x Commit: 29ea37a0d8a2dc7fd6b004539165ffaa07b51d26 Parents: faec0ea Author: lburgazzoli <lburgazz...@gmail.com> Authored: Mon Oct 17 11:13:55 2016 +0200 Committer: lburgazzoli <lburgazz...@gmail.com> Committed: Mon Oct 17 11:13:55 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/29ea37a0/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/29ea37a0/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; } + }