Repository: camel
Updated Branches:
  refs/heads/master e73815d14 -> 50081740d


CAMEL-10352: Optionally delegate to Aries PropertyEvaluator services in 
BlueprintPropertiesParser


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/50081740
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/50081740
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/50081740

Branch: refs/heads/master
Commit: 50081740d19a2081910b33ead3d3c65f9ecf1ab9
Parents: e73815d
Author: lburgazzoli <lburgazz...@gmail.com>
Authored: Thu Oct 13 14:04:20 2016 +0200
Committer: lburgazzoli <lburgazz...@gmail.com>
Committed: Fri Oct 14 16:11:25 2016 +0200

----------------------------------------------------------------------
 .../component/properties/DefaultPropertiesParser.java | 14 +++++++++-----
 .../camel/blueprint/BlueprintPropertiesParser.java    | 11 +++++------
 2 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/50081740/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 3ab0f73..54037bf 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,8 +20,6 @@ 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;
@@ -139,7 +137,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(format("Missing %s from 
the text: %s", suffixToken, input));
+                    throw new IllegalArgumentException(String.format("Missing 
%s from the text: %s", suffixToken, input));
                 }
                 return null;
             }
@@ -147,7 +145,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(format("Missing %s from the 
text: %s", prefixToken, input));
+                throw new IllegalArgumentException(String.format("Missing %s 
from the text: %s", prefixToken, input));
             }
 
             String key = input.substring(prefix + prefixToken.length(), 
suffix);
@@ -233,6 +231,12 @@ 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)) {
@@ -243,7 +247,7 @@ public class DefaultPropertiesParser implements 
AugmentedPropertyNameAwareProper
             String augmentedKey = getAugmentedKey(key);
             boolean shouldFallback = fallbackToUnaugmentedProperty && 
!key.equals(augmentedKey);
 
-            String value = doGetPropertyValue(augmentedKey);
+            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/50081740/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 c04e31e..3249e48 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("getProperty", 
String.class);
+                    method = 
AbstractPropertyPlaceholder.class.getDeclaredMethod("retrieveValue", 
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,5 +163,4 @@ public class BlueprintPropertiesParser extends 
DefaultPropertiesParser {
         log.trace("Returning parsed property key: {} as value: {}", key, 
answer);
         return answer;
     }
-
 }

Reply via email to