You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gg...@apache.org on 2018/06/11 10:03:54 UTC
[camel] branch camel-2.21.x updated: [CAMEL-12570] Upgrade to
blueprint.core 1.10.0, blueprint.cm 1.3.0, aries.proxy 1.1.1
This is an automated email from the ASF dual-hosted git repository.
ggrzybek pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.21.x by this push:
new 898e86d [CAMEL-12570] Upgrade to blueprint.core 1.10.0, blueprint.cm 1.3.0, aries.proxy 1.1.1
898e86d is described below
commit 898e86dae59013363324fd6779aded8bd4a60173
Author: Grzegorz Grzybek <gr...@gmail.com>
AuthorDate: Mon Jun 11 11:45:17 2018 +0200
[CAMEL-12570] Upgrade to blueprint.core 1.10.0, blueprint.cm 1.3.0, aries.proxy 1.1.1
(cherry picked from commit dfe81111eeaa55a4ea2b792b9541706a06d67bbd)
---
.../camel/blueprint/BlueprintPropertiesParser.java | 84 +++++++++++++++++++---
components/camel-test-blueprint/pom.xml | 7 +-
parent/pom.xml | 8 +--
3 files changed, 80 insertions(+), 19 deletions(-)
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 d16762a..e3b17b5 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
@@ -26,7 +26,9 @@ import java.util.Set;
import org.apache.aries.blueprint.ExtendedBeanMetadata;
import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder;
+import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholderExt;
import org.apache.aries.blueprint.ext.PropertyPlaceholder;
+import org.apache.aries.blueprint.ext.PropertyPlaceholderExt;
import org.apache.camel.component.properties.DefaultPropertiesParser;
import org.apache.camel.component.properties.PropertiesComponent;
import org.apache.camel.component.properties.PropertiesParser;
@@ -47,8 +49,9 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser {
private final PropertiesComponent propertiesComponent;
private final BlueprintContainer container;
private final PropertiesParser delegate;
- private final Set<AbstractPropertyPlaceholder> placeholders = new LinkedHashSet<AbstractPropertyPlaceholder>();
+ private final Set<PropertyPlaceholderWrapper> placeholders = new LinkedHashSet<PropertyPlaceholderWrapper>();
private Method method;
+ private Method oldMethod;
public BlueprintPropertiesParser(PropertiesComponent propertiesComponent, BlueprintContainer container, PropertiesParser delegate) {
super(propertiesComponent);
@@ -71,7 +74,8 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser {
ComponentMetadata meta = container.getComponentMetadata(id);
if (meta instanceof ExtendedBeanMetadata) {
Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
- if (clazz != null && AbstractPropertyPlaceholder.class.isAssignableFrom(clazz)) {
+ if (clazz != null && (AbstractPropertyPlaceholder.class.isAssignableFrom(clazz)
+ || AbstractPropertyPlaceholderExt.class.isAssignableFrom(clazz))) {
ids.add(id);
}
}
@@ -88,15 +92,16 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser {
public void addPropertyPlaceholder(String id) {
Object component = container.getComponentInstance(id);
- if (component instanceof AbstractPropertyPlaceholder) {
- AbstractPropertyPlaceholder placeholder = (AbstractPropertyPlaceholder) component;
- placeholders.add(placeholder);
+ // new API
+ if (component instanceof AbstractPropertyPlaceholderExt) {
+ AbstractPropertyPlaceholderExt placeholder = (AbstractPropertyPlaceholderExt) component;
+ placeholders.add(new AbstractPropertyPlaceholderExtWrapper(placeholder));
log.debug("Adding Blueprint PropertyPlaceholder: {}", id);
if (method == null) {
try {
- method = AbstractPropertyPlaceholder.class.getDeclaredMethod("retrieveValue", String.class);
+ method = AbstractPropertyPlaceholderExt.class.getDeclaredMethod("retrieveValue", String.class);
method.setAccessible(true);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Cannot add blueprint property placeholder: " + id
@@ -104,6 +109,24 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser {
}
}
}
+
+ // old, deprecated API
+ if (component instanceof AbstractPropertyPlaceholder) {
+ AbstractPropertyPlaceholder placeholder = (AbstractPropertyPlaceholder) component;
+ placeholders.add(new AbstractPropertyPlaceholderWrapper(placeholder));
+
+ log.debug("Adding Blueprint PropertyPlaceholder: {}", id);
+
+ if (oldMethod == null) {
+ try {
+ oldMethod = AbstractPropertyPlaceholder.class.getDeclaredMethod("retrieveValue", String.class);
+ oldMethod.setAccessible(true);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalStateException("Cannot add blueprint property placeholder: " + id
+ + " as the method retrieveValue is not accessible", e);
+ }
+ }
+ }
}
@Override
@@ -122,12 +145,15 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser {
// lookup key in blueprint and return its value
if (answer == null && key != null) {
- for (AbstractPropertyPlaceholder placeholder : placeholders) {
+ for (PropertyPlaceholderWrapper placeholder : placeholders) {
boolean isDefault = false;
if (placeholders.size() > 1) {
// okay we have multiple placeholders and we want to return the answer that
// is not the default placeholder if there is multiple keys
- if (placeholder instanceof PropertyPlaceholder) {
+ if (placeholder instanceof PropertyPlaceholderExt) {
+ Map map = ((PropertyPlaceholderExt) placeholder).getDefaultProperties();
+ isDefault = map != null && map.containsKey(key);
+ } else if (placeholder instanceof PropertyPlaceholder) {
Map map = ((PropertyPlaceholder) placeholder).getDefaultProperties();
isDefault = map != null && map.containsKey(key);
}
@@ -135,7 +161,7 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser {
}
try {
- String candidate = (String) ObjectHelper.invokeMethod(method, placeholder, key);
+ String candidate = placeholder.retrieveValue(key);
if (candidate != null) {
if (answer == null || !isDefault) {
@@ -164,4 +190,44 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser {
return answer;
}
+ private interface PropertyPlaceholderWrapper {
+
+ /**
+ * Retrieves the String value (or {@code null}) from underlying placeholder
+ * @param key
+ * @return
+ */
+ String retrieveValue(String key);
+ }
+
+ private class AbstractPropertyPlaceholderExtWrapper implements PropertyPlaceholderWrapper {
+
+ private AbstractPropertyPlaceholderExt delegate;
+
+ public AbstractPropertyPlaceholderExtWrapper(AbstractPropertyPlaceholderExt delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public String retrieveValue(String key) {
+ Object v = ObjectHelper.invokeMethod(method, delegate, key);
+ return v == null ? null : v.toString();
+ }
+ }
+
+ private class AbstractPropertyPlaceholderWrapper implements PropertyPlaceholderWrapper {
+
+ private AbstractPropertyPlaceholder delegate;
+
+ public AbstractPropertyPlaceholderWrapper(AbstractPropertyPlaceholder delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public String retrieveValue(String key) {
+ Object v = ObjectHelper.invokeMethod(oldMethod, delegate, key);
+ return v == null ? null : v.toString();
+ }
+ }
+
}
diff --git a/components/camel-test-blueprint/pom.xml b/components/camel-test-blueprint/pom.xml
index c3d02eb..60c03c4 100644
--- a/components/camel-test-blueprint/pom.xml
+++ b/components/camel-test-blueprint/pom.xml
@@ -66,15 +66,10 @@
with felix-connect, and you may get a weird error if wrong order -->
<dependency>
<groupId>org.apache.aries.proxy</groupId>
- <artifactId>org.apache.aries.proxy.api</artifactId>
+ <artifactId>org.apache.aries.proxy</artifactId>
<version>${aries-blueprint-proxy-version}</version>
</dependency>
<dependency>
- <groupId>org.apache.aries.proxy</groupId>
- <artifactId>org.apache.aries.proxy.impl</artifactId>
- <version>${aries-blueprint-proxy-impl-version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint.api</artifactId>
</dependency>
diff --git a/parent/pom.xml b/parent/pom.xml
index 8bb5b75..4b698f5 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -53,10 +53,10 @@
<apache-gora-version>0.8</apache-gora-version>
<apache-mime4j-version>0.7.2</apache-mime4j-version>
<aries-blueprint-api-version>1.0.1</aries-blueprint-api-version>
- <aries-blueprint-cm-version>1.0.6</aries-blueprint-cm-version>
- <aries-blueprint-core-version>1.4.4</aries-blueprint-core-version>
- <aries-blueprint-proxy-version>1.0.1</aries-blueprint-proxy-version>
- <aries-blueprint-proxy-impl-version>1.0.4</aries-blueprint-proxy-impl-version>
+ <aries-blueprint-cm-version>1.3.0</aries-blueprint-cm-version>
+ <aries-blueprint-core-version>1.10.0</aries-blueprint-core-version>
+ <aries-blueprint-proxy-version>1.1.1</aries-blueprint-proxy-version>
+ <aries-blueprint-proxy-impl-version>1.1.1</aries-blueprint-proxy-impl-version>
<aries-spifly-version>1.0.8</aries-spifly-version>
<aries-util-version>1.1.3</aries-util-version>
<arquillian-container-se-managed-version>1.0.0.Final</arquillian-container-se-managed-version>
--
To stop receiving notification emails like this one, please contact
ggrzybek@apache.org.